From 2d2262df9727b962135d39b6f22a1a092dc80175 Mon Sep 17 00:00:00 2001 From: shennetsind Date: Fri, 1 Jun 2012 16:45:45 +0000 Subject: Fixed bugreport:4109 battle ground guardians will now follow nearby allies when no foes are in range. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16208 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/mob.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/map') diff --git a/src/map/mob.c b/src/map/mob.c index e8ec4e0a7..d7e94d0d9 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -1122,6 +1122,22 @@ static int mob_ai_sub_hard_changechase(struct block_list *bl,va_list ap) return 1; } +/*========================================== + * finds nearby bg ally for guardians looking for users to follow. + *------------------------------------------*/ +static int mob_ai_sub_hard_bg_ally(struct block_list *bl,va_list ap) { + struct mob_data *md; + struct block_list **target; + + nullpo_ret(bl); + md=va_arg(ap,struct mob_data *); + target= va_arg(ap,struct block_list**); + + if( status_check_skilluse(&md->bl, bl, 0, 0) && battle_check_target(&md->bl,bl,BCT_ENEMY)<=0 ) { + (*target) = bl; + } + return 1; +} /*========================================== * loot monster item search @@ -1528,6 +1544,18 @@ static bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick) if (!tbl) { //No targets available. if (mode&MD_ANGRY && !md->state.aggressive) md->state.aggressive = 1; //Restore angry state when no targets are available. + + /* bg guardians follow allies when no targets nearby */ + if( md->bg_id && mode&MD_CANATTACK ) { + if( md->ud.walktimer != INVALID_TIMER ) + return true;/* we are already moving */ + map_foreachinrange (mob_ai_sub_hard_bg_ally, &md->bl, view_range, BL_PC, md, &tbl, mode); + if( tbl ) { + if( distance_blxy(&md->bl, tbl->x, tbl->y) <= 3 || unit_walktobl(&md->bl, tbl, 1, 1) ) + return true;/* we're moving or close enough don't unlock the target. */ + } + } + //This handles triggering idle walk/skill. mob_unlocktarget(md, tick); return true; -- cgit v1.2.3-70-g09d2