summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshennetsind <shennetsind@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-06-01 16:45:45 +0000
committershennetsind <shennetsind@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-06-01 16:45:45 +0000
commit2d2262df9727b962135d39b6f22a1a092dc80175 (patch)
treec36af8336dc3793f112fb76f816e926cf389e161
parent271ec71b1ebcd926d343a6ef96139519a0c6eab3 (diff)
downloadhercules-2d2262df9727b962135d39b6f22a1a092dc80175.tar.gz
hercules-2d2262df9727b962135d39b6f22a1a092dc80175.tar.bz2
hercules-2d2262df9727b962135d39b6f22a1a092dc80175.tar.xz
hercules-2d2262df9727b962135d39b6f22a1a092dc80175.zip
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
-rw-r--r--src/map/mob.c28
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;