rendered paste bodyIndex: GameObject.cpp
===================================================================
--- GameObject.cpp (revision 5260)
+++ GameObject.cpp (working copy)
@@ -34,8 +34,11 @@
#include "GridNotifiersImpl.h"
#include "CellImpl.h"
#include "InstanceData.h"
+#include "ScriptCalls.h"
-GameObject::GameObject( WorldObject *instantiator ) : WorldObject( instantiator )
+GameObject::GameObject( WorldObject *instantiator ) :
+ WorldObject( instantiator ),
+ i_GameObjectAI( NULL )
{
m_objectType |= TYPE_GAMEOBJECT;
m_objectTypeId = TYPEID_GAMEOBJECT;
@@ -61,7 +64,16 @@
{
Unit* owner = ObjectAccessor::GetUnit(*this,owner_guid);
if(owner)
+ {
+ // Remove AI
+ if( i_GameObjectAI )
+ {
+ delete i_GameObjectAI;
+ i_GameObjectAI = NULL;
+ }
+
owner->RemoveGameObject(this,false);
+ }
else if(GUID_HIPART(owner_guid)!=HIGHGUID_PLAYER)
sLog.outError("Delete GameObject (GUID: %u Entry: %u ) that have references in not found creature %u GO list. Crash possable later.",GetGUIDLow(),GetGOInfo()->id,GUID_LOPART(owner_guid));
}
@@ -149,8 +161,12 @@
return true;
}
-void GameObject::Update(uint32 /*p_time*/)
+void GameObject::Update(uint32 p_time)
{
+ // If there is an AI Script, use it
+ if( i_GameObjectAI )
+ i_GameObjectAI->UpdateAI(p_time);
+
if (GUID_HIPART(GetGUID()) == HIGHGUID_MO_TRANSPORT)
{
//((Transport*)this)->Update(p_time);
@@ -507,6 +523,9 @@
m_respawnTime = 0;
}
+ // Get the new AI script
+ i_GameObjectAI = Script->GetGameObjectAI(this);
+
return true;
}