--HG--
branch : trunk
This commit is contained in:
megamage committed 2009-03-12 14:22:59 -06:00
commit 16ee4a46c2
24 files changed
+170 -305

No files matched your search

+31
View File
@@ -47,6 +47,8 @@
#include "CellImpl.h"
#include "Path.h"
#include "CreatureGroups.h"
#include "PetAI.h"
#include "NullCreatureAI.h"
#include "Traveller.h"
#include <math.h>
@@ -76,6 +78,7 @@ static bool procPrepared = InitTriggerAuraData();
Unit::Unit()
: WorldObject(), i_motionMaster(this), m_ThreatManager(this), m_HostilRefManager(this)
, m_IsInNotifyList(false), m_Notified(false), IsAIEnabled(false)
, i_AI(NULL), i_disabledAI(NULL)
{
m_objectType |= TYPEMASK_UNIT;
m_objectTypeId = TYPEID_UNIT;
@@ -11284,10 +11287,38 @@ void Unit::CleanupsBeforeDelete()
RemoveFromWorld();
}
void Unit::UpdateCharmAI()
{
if(GetTypeId() == TYPEID_PLAYER)
return;
if(i_disabledAI) // disabled AI must be primary AI
{
if(!isCharmed())
{
if(i_AI) delete i_AI;
i_AI = i_disabledAI;
i_disabledAI = NULL;
}
}
else
{
if(isCharmed())
{
i_disabledAI = i_AI;
if(isPossessed())
i_AI = new PossessedAI((Creature*)this);
else
i_AI = new PetAI((Creature*)this);
}
}
}
CharmInfo* Unit::InitCharmInfo()
{
if(!m_charmInfo)
m_charmInfo = new CharmInfo(this);
return m_charmInfo;
}