summaryrefslogtreecommitdiff
path: root/src/map/unit.c
diff options
context:
space:
mode:
authorai4rei <ai4rei@54d463be-8e91-2dee-dedb-b68131a5f0ec>2010-11-23 09:26:00 +0000
committerai4rei <ai4rei@54d463be-8e91-2dee-dedb-b68131a5f0ec>2010-11-23 09:26:00 +0000
commit35467de0fb6dc06a402315ea478495d74080e3c5 (patch)
tree79659d470525996eb45773c0d196df440b35330e /src/map/unit.c
parent89974727211311dc13f3c823ab6f565f8942455b (diff)
downloadhercules-35467de0fb6dc06a402315ea478495d74080e3c5.tar.gz
hercules-35467de0fb6dc06a402315ea478495d74080e3c5.tar.bz2
hercules-35467de0fb6dc06a402315ea478495d74080e3c5.tar.xz
hercules-35467de0fb6dc06a402315ea478495d74080e3c5.zip
* Added script command pushpc, which is required by newer scripts.
- Moved knockback-part of skill_blown into unit_blown, to allow unconditional knockback required by pushpc without copy-pasting code. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14492 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/unit.c')
-rw-r--r--src/map/unit.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/map/unit.c b/src/map/unit.c
index 0c16977c1..f2dcdc921 100644
--- a/src/map/unit.c
+++ b/src/map/unit.c
@@ -566,6 +566,54 @@ uint8 unit_getdir(struct block_list *bl)
return ud->dir;
}
+// Pushes a unit by given amount of cells into given direction. Only
+// map cell restrictions are respected.
+// flag:
+// &1 Do not send position update packets.
+int unit_blown(struct block_list* bl, int dx, int dy, int count, int flag)
+{
+ int nx, ny, ret;
+ struct skill_unit* su = BL_CAST(BL_SKILL, bl);
+
+ ret=path_blownpos(bl->m,bl->x,bl->y,dx,dy,count);
+ nx = ret>>16;
+ ny = ret&0xffff;
+
+ if (!su)
+ unit_stop_walking(bl,0);
+
+ dx = nx - bl->x;
+ dy = ny - bl->y;
+
+ if (!dx && !dy) //Could not knockback.
+ return 0;
+
+ map_foreachinmovearea(clif_outsight, bl, AREA_SIZE, dx, dy, bl->type == BL_PC ? BL_ALL : BL_PC, bl);
+
+ if(su)
+ skill_unit_move_unit_group(su->group,bl->m,dx,dy);
+ else
+ map_moveblock(bl, nx, ny, gettick());
+
+ map_foreachinmovearea(clif_insight, bl, AREA_SIZE, -dx, -dy, bl->type == BL_PC ? BL_ALL : BL_PC, bl);
+
+ if(!(flag&0x1))
+ clif_blown(bl);
+
+ if( bl->type == BL_PC )
+ {
+ TBL_PC *sd = (TBL_PC*)bl;
+ if( sd->touching_id )
+ npc_touchnext_areanpc(sd,false);
+ if( map_getcell(bl->m,bl->x,bl->y,CELL_CHKNPC) )
+ npc_touch_areanpc(sd,bl->m,bl->x,bl->y);
+ else
+ sd->areanpc_id=0;
+ }
+
+ return count; //Return amount of knocked back cells.
+}
+
//Warps a unit/ud to a given map/position.
//In the case of players, pc_setpos is used.
//it respects the no warp flags, so it is safe to call this without doing nowarpto/nowarp checks.