*Assign possessed AI and pet AI to charmed creatures.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-03-12 14:15:44 -06:00
parent ab6e9bd7b4
commit 1fbfc6da64
15 changed files with 118 additions and 259 deletions
+7 -7
View File
@@ -46,7 +46,6 @@
#include "CellImpl.h"
#include "OutdoorPvPMgr.h"
#include "GameEvent.h"
#include "PossessedAI.h"
#include "CreatureGroups.h"
// apply implementation of the singletons
#include "Policies/SingletonImp.h"
@@ -141,7 +140,7 @@ bool AssistDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
}
Creature::Creature() :
Unit(), i_AI(NULL),
Unit(),
lootForPickPocketed(false), lootForBody(false), m_groupLootTimer(0), lootingGroupLeaderGUID(0),
m_lootMoney(0), m_lootRecipient(0),
m_deathTimer(0), m_respawnTime(0), m_respawnDelay(25), m_corpseDelay(60), m_respawnradius(0.0f),
@@ -424,7 +423,7 @@ void Creature::Update(uint32 diff)
setDeathState( JUST_ALIVED );
//Call AI respawn virtual function
i_AI->JustRespawned();
AI()->JustRespawned();
GetMap()->Add(this);
}
@@ -484,6 +483,9 @@ void Creature::Update(uint32 diff)
if(!isAlive())
break;
// if creature is charmed, switch to charmed AI
UpdateCharmAI();
if(!IsInEvadeMode() && IsAIEnabled)
{
// do not allow the AI to be changed during update
@@ -596,11 +598,9 @@ bool Creature::AIM_Initialize(CreatureAI* ai)
return false;
}
CreatureAI * oldAI = i_AI;
i_motionMaster.Initialize();
if(i_AI) delete i_AI;
i_AI = ai ? ai : FactorySelector::selectAI(this);
if (oldAI)
delete oldAI;
i_motionMaster.Initialize();
IsAIEnabled = true;
return true;
}