mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Scripts: Added support for creating custom GameObjectAI classes, similar to how creature scripts work.
This commit is contained in:
@@ -133,6 +133,9 @@ namespace FactorySelector
|
||||
const GameObjectAICreator* ai_factory = NULL;
|
||||
GameObjectAIRegistry& ai_registry(*GameObjectAIRepository::instance());
|
||||
|
||||
if (GameObjectAI* scriptedAI = sScriptMgr->GetGameObjectAI(go))
|
||||
return scriptedAI;
|
||||
|
||||
ai_factory = ai_registry.GetRegistryItem(go->GetAIName());
|
||||
|
||||
//future goAI types go here
|
||||
|
||||
@@ -954,6 +954,14 @@ bool ScriptMgr::OnDummyEffect(Unit* caster, uint32 spellId, SpellEffIndex effInd
|
||||
return tmpscript->OnDummyEffect(caster, spellId, effIndex, target);
|
||||
}
|
||||
|
||||
GameObjectAI* ScriptMgr::GetGameObjectAI(GameObject* go)
|
||||
{
|
||||
ASSERT(go);
|
||||
|
||||
GET_SCRIPT_RET(GameObjectScript, go->GetScriptId(), tmpscript, NULL);
|
||||
tmpscript->GetAI(go);
|
||||
}
|
||||
|
||||
bool ScriptMgr::OnAreaTrigger(Player* player, AreaTriggerEntry const* trigger)
|
||||
{
|
||||
ASSERT(player);
|
||||
|
||||
@@ -39,6 +39,7 @@ class Creature;
|
||||
class CreatureAI;
|
||||
class DynamicObject;
|
||||
class GameObject;
|
||||
class GameObjectAI;
|
||||
class Guild;
|
||||
class GridMap;
|
||||
class Group;
|
||||
@@ -471,6 +472,9 @@ class GameObjectScript : public ScriptObject, public UpdatableScript<GameObject>
|
||||
|
||||
// Called when the game object is damaged (destructible buildings only).
|
||||
virtual void OnDamaged(GameObject* /*go*/, Player* /*player*/) { }
|
||||
|
||||
// Called when a GameObjectAI object is needed for the gameobject.
|
||||
virtual GameObjectAI* GetAI(GameObject* /*go*/) const { return NULL; }
|
||||
};
|
||||
|
||||
class AreaTriggerScript : public ScriptObject
|
||||
@@ -911,6 +915,7 @@ class ScriptMgr
|
||||
void OnGameObjectDestroyed(GameObject* go, Player* player);
|
||||
void OnGameObjectDamaged(GameObject* go, Player* player);
|
||||
void OnGameObjectUpdate(GameObject* go, uint32 diff);
|
||||
GameObjectAI* GetGameObjectAI(GameObject* go);
|
||||
|
||||
public: /* AreaTriggerScript */
|
||||
|
||||
|
||||
@@ -234,7 +234,6 @@ class instance_ulduar : public InstanceMapScript
|
||||
case NPC_ALGALON:
|
||||
AlgalonGUID = creature->GetGUID();
|
||||
break;
|
||||
|
||||
// Hodir's Helper NPCs
|
||||
case NPC_EIVI_NIGHTFEATHER:
|
||||
if (TeamInInstance == HORDE)
|
||||
|
||||
Reference in New Issue
Block a user