aboutsummaryrefslogtreecommitdiff
path: root/src/game/Unit.cpp
diff options
context:
space:
mode:
authormegamage <none@none>2009-03-12 14:22:59 -0600
committermegamage <none@none>2009-03-12 14:22:59 -0600
commit16ee4a46c271bd7c234ffa7579f5f90cf2007772 (patch)
tree6d547d8228472fcc97ead5dfcdd8a9aaf8f70233 /src/game/Unit.cpp
parent6e12d3f1b9f40f3f95390245f3fcbb30fbd8657f (diff)
parent1fbfc6da645058a6da3073dafde0e6bca621e31c (diff)
*Merge.
--HG-- branch : trunk
Diffstat (limited to 'src/game/Unit.cpp')
-rw-r--r--src/game/Unit.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 85661e97dbf..a77155ab87a 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -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;
}