From d07d90fabc19f13a004ea2f0e164a19d063c908a Mon Sep 17 00:00:00 2001 From: skotlex Date: Sat, 1 Apr 2006 19:07:58 +0000 Subject: - Fixes to the mob_ai routines. Prevent casting rude-attacked skills in situations that shouldn't be considered as so. Fixed mobs failing to chase after enemies when range-attacked out of their view_range. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@5848 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 3 +++ src/map/mob.c | 25 ++++++++++++++++--------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index ecabccba4..5c07eeadd 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -4,6 +4,9 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. 2006/04/01 + * Fixes to the mob_ai routines. Prevent casting rude-attacked skills in + situations that shouldn't be considered as so. Fixed mobs failing to chase + after enemies when attacked from out of their view_range. [Skotlex] * Should not exit when you can't find an NPC file.. [Lance] * Dynamic shops support with script callback. (needs testing) [Lance] * Cleaned up and fixed @where command. [Skotlex] diff --git a/src/map/mob.c b/src/map/mob.c index 4e3cf74cf..1125c3872 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -1084,7 +1084,7 @@ static int mob_ai_sub_hard(struct block_list *bl,va_list ap) int i, j, dx, dy, dist; int mode; int search_size; - int view_range, can_move; + int view_range, can_move, can_walk; md = (struct mob_data*)bl; tick = va_arg(ap, unsigned int); @@ -1107,11 +1107,15 @@ static int mob_ai_sub_hard(struct block_list *bl,va_list ap) return 0; if (md->sc.count && md->sc.data[SC_BLIND].timer != -1) - view_range = 1; + view_range = 3; else view_range = md->db->range2; mode = status_get_mode(&md->bl); - can_move = (mode&MD_CANMOVE) && unit_can_move(&md->bl); + + can_move = (mode&MD_CANMOVE)&&unit_can_move(&md->bl); + //Since can_move is false when you are casting or the damage-delay kicks in, some special considerations + //must be taken to avoid unlocking the target or triggering rude-attacked skills in said cases. [Skotlex] + can_walk = DIFF_TICK(tick, md->ud.canmove_tick) > 0; if (md->target_id) { //Check validity of current target. [Skotlex] @@ -1129,7 +1133,7 @@ static int mob_ai_sub_hard(struct block_list *bl,va_list ap) } // Check for target change. - if (md->attacked_id && mode&MD_CANATTACK) + if (md->attacked_id && mode&MD_CANATTACK && can_walk) { if (md->attacked_id == md->target_id) { @@ -1141,7 +1145,7 @@ static int mob_ai_sub_hard(struct block_list *bl,va_list ap) } else if ((abl= map_id2bl(md->attacked_id)) && (!tbl || mob_can_changetarget(md, abl, mode))) { if (md->bl.m != abl->m || abl->prev == NULL || - (dist = distance_bl(&md->bl, abl)) >= 32 || + (dist = distance_bl(&md->bl, abl)) >= MAX_MINCHASE || battle_check_target(bl, abl, BCT_ENEMY) <= 0 || (battle_config.mob_ai&2 && !status_check_skilluse(bl, abl, 0, 0)) || !mob_can_reach(md, abl, dist+2, MSS_RUSH) || @@ -1162,6 +1166,7 @@ static int mob_ai_sub_hard(struct block_list *bl,va_list ap) } else if (!(battle_config.mob_ai&2) && !status_check_skilluse(bl, abl, 0, 0)) { //Can't attack back, but didn't invoke a rude attacked skill... md->attacked_id = 0; //Simply unlock, shouldn't attempt to run away when in dumb_ai mode. +/* Unneeded. Mobs use the min_chase parameter to chase back enemies once hit. } else if (dist > view_range) { //Out of view range, but can reach //Attempt to follow new target if (!md->target_id && can_move) { // why is it moving to the target when the mob can't see the player? o.o @@ -1169,6 +1174,7 @@ static int mob_ai_sub_hard(struct block_list *bl,va_list ap) dy = abl->y - md->bl.y -1; unit_walktoxy(&md->bl, md->bl.x+dx, md->bl.y+dy, 0); } +*/ } else { //Attackable if (!tbl || dist < md->db->range || !check_distance_bl(&md->bl, tbl, dist) || battle_gettarget(tbl) != md->bl.id) @@ -1241,12 +1247,13 @@ static int mob_ai_sub_hard(struct block_list *bl,va_list ap) { //Run towards the enemy when out of range? if (!can_move) { //Give it up. - mob_unlocktarget(md,tick); + if (can_walk) + mob_unlocktarget(md,tick); return 0; } - dx = tbl->x - md->bl.x -1; - dy = tbl->y - md->bl.y -1; - unit_walktoxy(&md->bl, md->bl.x+dx, md->bl.y+dy, 0); + dx = tbl->x+(tbl->x > md->bl.x?-1:+1); + dy = tbl->y+(tbl->y > md->bl.y?-1:+1); + unit_walktoxy(&md->bl, dx, dy, 0); return 0; } md->state.skillstate = md->state.aggressive?MSS_FOLLOW:MSS_RUSH; -- cgit v1.2.3-70-g09d2