Core/AI: use NullGameObjectAI for gameobjects with ScriptName

- use GameObjectAI with Transports too

--HG--
branch : trunk
This commit is contained in:
Rat
2010-10-25 18:11:52 +02:00
parent b282438198
commit 064b3fd2b3
4 changed files with 14 additions and 4 deletions

View File

@@ -137,7 +137,7 @@ namespace FactorySelector
//future goAI types go here
std::string ainame = (ai_factory == NULL) ? "NullGameObjectAI" : ai_factory->key();
std::string ainame = (ai_factory == NULL || go->GetScriptId()) ? "NullGameObjectAI" : ai_factory->key();
sLog.outStaticDebug("GameObject %u used AI is %s.", go->GetGUIDLow(), ainame.c_str());

View File

@@ -239,9 +239,12 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map *map, uint32 phaseMa
void GameObject::Update(uint32 diff)
{
if(!m_AI)
if(!AI())
{
if (!AIM_Initialize())
sLog.outError("Could not initialize GameObjectAI");
} else
AI()->UpdateAI(diff);
if (IS_MO_TRANSPORT(GetGUID()))
{
@@ -550,7 +553,6 @@ void GameObject::Update(uint32 diff)
break;
}
}
AI()->UpdateAI(diff);
sScriptMgr.OnGameObjectUpdate(this, diff);
}

View File

@@ -752,6 +752,7 @@ class GameObject : public WorldObject, public GridObject<GameObject>
std::string GetAIName() const;
protected:
bool AIM_Initialize();
uint32 m_spellId;
time_t m_respawnTime; // (secs) time of next respawn (or despawn if GO have owner()),
uint32 m_respawnDelayTime; // (secs) if 0 then current GO state no dependent from timer
@@ -779,6 +780,5 @@ class GameObject : public WorldObject, public GridObject<GameObject>
private:
void SwitchDoorOrButton(bool activate, bool alternative = false);
GameObjectAI* m_AI;
bool AIM_Initialize();
};
#endif

View File

@@ -26,6 +26,7 @@
#include "DBCStores.h"
#include "ProgressBar.h"
#include "World.h"
#include "GameObjectAI.h"
void MapManager::LoadTransports()
{
@@ -544,6 +545,13 @@ bool Transport::RemovePassenger(Player* passenger)
void Transport::Update(uint32 p_diff)
{
if(!AI())
{
if (!AIM_Initialize())
sLog.outError("Could not initialize GameObjectAI for Transport");
} else
AI()->UpdateAI(p_diff);
if (m_WayPoints.size() <= 1)
return;