From 8ff8d0f9ee285452ba7820c3fb333eddb042272b Mon Sep 17 00:00:00 2001 From: skotlex Date: Tue, 16 Jan 2007 13:56:17 +0000 Subject: - Added function unit_escape to simplify the run-away code a bit in the mob ai. - Some cleaning on the mob_ai to enable mobs to run away from their current target when they are rude-attacked by them. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@9658 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/unit.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/map/unit.c') 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) { -- cgit v1.2.3-70-g09d2