diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/map/mob.c | 28 |
1 files changed, 28 insertions, 0 deletions
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; |