From 35467de0fb6dc06a402315ea478495d74080e3c5 Mon Sep 17 00:00:00 2001 From: ai4rei Date: Tue, 23 Nov 2010 09:26:00 +0000 Subject: * 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 --- src/map/unit.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'src/map/unit.c') 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. -- cgit v1.2.3-70-g09d2