[11995] Fix following for guid linked npcs on evade

Thanks to grz3s for pointing

Signed-off-by: Schmoozerd <schmoozerd@scriptdev2.com>
This commit is contained in:
Schmoozerd 2012-06-09 13:50:30 +02:00
parent d41974b38b
commit 41072c5455
2 changed files with 20 additions and 7 deletions

View file

@ -644,16 +644,29 @@ bool CreatureLinkingHolder::TryFollowMaster(Creature* pCreature)
if (!pInfo || !(pInfo->linkingFlag & FLAG_FOLLOW)) if (!pInfo || !(pInfo->linkingFlag & FLAG_FOLLOW))
return false; return false;
BossGuidMapBounds finds = m_masterGuid.equal_range(pInfo->masterId); Creature* pMaster = NULL;
for (BossGuidMap::iterator itr = finds.first; itr != finds.second; ++itr) if (pInfo->mapId != INVALID_MAP_ID) // entry case
{ {
Creature* pMaster = pCreature->GetMap()->GetCreature(itr->second); BossGuidMapBounds finds = m_masterGuid.equal_range(pInfo->masterId);
if (pMaster && pMaster->isAlive() && IsSlaveInRangeOfBoss(pCreature, pMaster, pInfo->searchRange)) for (BossGuidMap::iterator itr = finds.first; itr != finds.second; ++itr)
{ {
SetFollowing(pCreature, pMaster); pMaster = pCreature->GetMap()->GetCreature(itr->second);
return true; if (pMaster && IsSlaveInRangeOfBoss(pCreature, pMaster, pInfo->searchRange))
break;
} }
} }
else // guid case
{
CreatureData const* masterData = sObjectMgr.GetCreatureData(pInfo->masterDBGuid);
CreatureInfo const* cInfo = ObjectMgr::GetCreatureTemplate(masterData->id);
pMaster = pCreature->GetMap()->GetCreature(ObjectGuid(cInfo->GetHighGuid(), cInfo->Entry, pInfo->masterDBGuid));
}
if (pMaster && pMaster->isAlive())
{
SetFollowing(pCreature, pMaster);
return true;
}
return false; return false;
} }

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "11994" #define REVISION_NR "11995"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__