From 6b6e90d43d59312421fcf952630810263bad311e Mon Sep 17 00:00:00 2001 From: Kitzunu <24550914+Kitzunu@users.noreply.github.com> Date: Sun, 5 Dec 2021 11:14:15 +0100 Subject: [PATCH] feat(Script/Misc): Implement missing FactoryGameObjectScript (#9388) --- src/server/game/Scripting/ScriptMgr.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/server/game/Scripting/ScriptMgr.h b/src/server/game/Scripting/ScriptMgr.h index f0622cca0..bb68ca822 100644 --- a/src/server/game/Scripting/ScriptMgr.h +++ b/src/server/game/Scripting/ScriptMgr.h @@ -2567,15 +2567,25 @@ class FactoryCreatureScript : public CreatureScript }; #define RegisterCreatureAIWithFactory(ai_name, factory_fn) new FactoryCreatureScript(#ai_name) +// Cannot be used due gob scripts not working like this template class GenericGameObjectScript : public GameObjectScript { public: GenericGameObjectScript(char const* name) : GameObjectScript(name) { } - GameObjectAI* GetAI(GameObject* go) const override { return new AI(go); } + GameObjectAI* GetAI(GameObject* me) const override { return new AI(me); } }; #define RegisterGameObjectAI(ai_name) new GenericGameObjectScript(#ai_name) +// Cannot be used due gob scripts not working like this +template class FactoryGameObjectScript : public GameObjectScript +{ + public: + FactoryGameObjectScript(char const* name) : GameObjectScript(name) {} + GameObjectAI* GetAI(GameObject* me) const override { return AIFactory(me); } +}; +#define RegisterGameObjectAIWithFactory(ai_name, factory_fn) new FactoryGameObjectScript(#ai_name) + #define sScriptMgr ScriptMgr::instance() template