summaryrefslogtreecommitdiff
path: root/src/map/unit.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/unit.c')
-rw-r--r--src/map/unit.c82
1 files changed, 53 insertions, 29 deletions
diff --git a/src/map/unit.c b/src/map/unit.c
index f2dcdc921..05c0bcb16 100644
--- a/src/map/unit.c
+++ b/src/map/unit.c
@@ -572,46 +572,70 @@ uint8 unit_getdir(struct block_list *bl)
// &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);
+ int nx, ny, result;
+ struct map_session_data* sd;
+ struct skill_unit* su = NULL;
- ret=path_blownpos(bl->m,bl->x,bl->y,dx,dy,count);
- nx = ret>>16;
- ny = ret&0xffff;
+ if(count)
+ {
+ sd = BL_CAST(BL_PC, bl);
+ su = BL_CAST(BL_SKILL, bl);
- if (!su)
- unit_stop_walking(bl,0);
+ result = path_blownpos(bl->m, bl->x, bl->y, dx, dy, count);
- dx = nx - bl->x;
- dy = ny - bl->y;
+ nx = result>>16;
+ ny = result&0xffff;
- if (!dx && !dy) //Could not knockback.
- return 0;
+ if(!su)
+ {
+ unit_stop_walking(bl, 0);
+ }
- map_foreachinmovearea(clif_outsight, bl, AREA_SIZE, dx, dy, bl->type == BL_PC ? BL_ALL : BL_PC, bl);
+ dx = nx-bl->x;
+ dy = ny-bl->y;
- if(su)
- skill_unit_move_unit_group(su->group,bl->m,dx,dy);
- else
- map_moveblock(bl, nx, ny, gettick());
+ if(dx || dy)
+ {
+ map_foreachinmovearea(clif_outsight, bl, AREA_SIZE, dx, dy, bl->type == BL_PC ? BL_ALL : BL_PC, bl);
- map_foreachinmovearea(clif_insight, 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());
+ }
- if(!(flag&0x1))
- clif_blown(bl);
+ map_foreachinmovearea(clif_insight, bl, AREA_SIZE, -dx, -dy, bl->type == BL_PC ? BL_ALL : BL_PC, 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);
+ if(!(flag&1))
+ {
+ clif_blown(bl);
+ }
+
+ if(sd)
+ {
+ 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;
+ }
+ }
+ }
else
- sd->areanpc_id=0;
+ {// could not knockback
+ count = 0;
+ }
}
-
- return count; //Return amount of knocked back cells.
+ return count; // return amount of knocked back cells
}
//Warps a unit/ud to a given map/position.