diff options
Diffstat (limited to 'src/map/unit.c')
-rw-r--r-- | src/map/unit.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/map/unit.c b/src/map/unit.c index 8684c0732..a03b24d74 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -413,6 +413,19 @@ int unit_run(struct block_list *bl) return 1; } +//Makes bl attempt to run dist cells away from target. Uses hard-paths. +int unit_escape(struct block_list *bl, struct block_list *target, int dist) +{ + int dir = map_calc_dir(target, bl->x, bl->y); + while (dist > 0 && map_getcell(bl->m, + bl->x + dist*dirx[dir], bl->y + dist*diry[dir], + CELL_CHKNOREACH)) + dist--; + return (dist > 0 && unit_walktoxy(bl, + bl->x + dist*dirx[dir], bl->y + dist*diry[dir], + 0)); +} + //Instant warp function. int unit_movepos(struct block_list *bl,int dst_x,int dst_y, int easy, int checkpath) { |