From d0dbc0c3499a8aef804f94a5ab66810e8629c9d9 Mon Sep 17 00:00:00 2001 From: Ben Carter Date: Sun, 21 Jan 2024 21:12:53 -0500 Subject: [PATCH] Added NPCBot commands --- src/ElunaLuaEngine_SC.cpp | 1 + src/LuaEngine/CreatureMethods.h | 19 +++++++++++++++++++ src/LuaEngine/LuaFunctions.cpp | 8 ++++++++ 3 files changed, 28 insertions(+) diff --git a/src/ElunaLuaEngine_SC.cpp b/src/ElunaLuaEngine_SC.cpp index 803044c..301607b 100644 --- a/src/ElunaLuaEngine_SC.cpp +++ b/src/ElunaLuaEngine_SC.cpp @@ -237,6 +237,7 @@ class Eluna_AllMapScript : public AllMapScript public: Eluna_AllMapScript() : AllMapScript("Eluna_AllMapScript") { } + void OnBeforeCreateInstanceScript(InstanceMap* instanceMap, InstanceScript* instanceData, bool /*load*/, std::string /*data*/, uint32 /*completedEncounterMask*/) override { instanceData = sEluna->GetInstanceData(instanceMap); diff --git a/src/LuaEngine/CreatureMethods.h b/src/LuaEngine/CreatureMethods.h index cb85860..f1041cc 100644 --- a/src/LuaEngine/CreatureMethods.h +++ b/src/LuaEngine/CreatureMethods.h @@ -393,6 +393,25 @@ namespace LuaCreature return 1; } + /** -- NPCBOT Start */ +#if defined(AZEROTHCORE) + int IsNPCBot(lua_State* L, Creature* creature) + { + Eluna::Push(L, creature->IsNPCBot()); + return 1; + } + + int GetBotOwner(lua_State* L, Creature* creature) + { + if(!creature->IsNPCBot()) + return 0; + + Eluna::Push(L, creature->GetBotOwner()); + return 1; + } +#endif + /** -- NPCBot End */ + #if defined(TRINITY) || defined(AZEROTHCORE) /** * Returns `true` if the [Creature] is an invisible trigger, diff --git a/src/LuaEngine/LuaFunctions.cpp b/src/LuaEngine/LuaFunctions.cpp index ebf32d8..12e6e93 100644 --- a/src/LuaEngine/LuaFunctions.cpp +++ b/src/LuaEngine/LuaFunctions.cpp @@ -910,6 +910,14 @@ ElunaRegister CreatureMethods[] = { "MoveWaypoint", &LuaCreature::MoveWaypoint }, { "UpdateEntry", &LuaCreature::UpdateEntry }, + + /** -- NPCBOT Start */ +#if defined(AZEROTHCORE) + { "IsNPCBot", &LuaCreature::IsNPCBot }, + { "GetBotOwner", } +#endif + /** -- NPCBOT End */ + { NULL, NULL } };