diff --git a/.gitmodules b/.gitmodules
index 8e2b3f1..1bb8b63 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,4 +1,4 @@
[submodule "LuaEngine"]
- path = LuaEngine
+ path = src/LuaEngine
url = https://github.com/azerothcore/Eluna.git
branch = master
diff --git a/CMakeLists.txt b/CMakeLists.txt
deleted file mode 100644
index 54641af..0000000
--- a/CMakeLists.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-CU_SET_PATH("CMAKE_MOD_ELUNA_ENGINE_DIR" "${CMAKE_CURRENT_LIST_DIR}")
-CU_ADD_HOOK(AFTER_LOAD_CMAKE_MODULES "${CMAKE_CURRENT_LIST_DIR}/cmake/after_load_cmake_modules.cmake")
diff --git a/cmake/after_gs_install.cmake b/cmake/after_gs_install.cmake
deleted file mode 100644
index de63c48..0000000
--- a/cmake/after_gs_install.cmake
+++ /dev/null
@@ -1,28 +0,0 @@
-set(PUBLIC_INCLUDES
- ${PUBLIC_INCLUDES}
- ${CMAKE_MOD_ELUNA_ENGINE_DIR}/LuaEngine
- ${CMAKE_MOD_ELUNA_ENGINE_DIR}/lualib
-)
-
-target_include_directories(game-interface
- INTERFACE
- ${PUBLIC_INCLUDES})
-
-add_dependencies(game lualib)
-
-target_link_libraries(game
- PUBLIC
- lualib)
-
-if( WIN32 )
- if (MSVC)
- set(MSVC_CONFIGURATION_NAME $(ConfigurationName)/)
- endif()
- add_custom_command(TARGET game
- POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/bin/${MSVC_CONFIGURATION_NAME}lua_scripts/extensions/"
- COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_MOD_ELUNA_ENGINE_DIR}/LuaEngine/extensions" "${CMAKE_BINARY_DIR}/bin/${MSVC_CONFIGURATION_NAME}lua_scripts/extensions/"
- )
-endif()
-
-install(DIRECTORY "${CMAKE_MOD_ELUNA_ENGINE_DIR}/LuaEngine/extensions" DESTINATION "${CMAKE_INSTALL_PREFIX}/bin/lua_scripts/")
diff --git a/cmake/after_load_cmake_modules.cmake b/cmake/after_load_cmake_modules.cmake
deleted file mode 100644
index eb7b43b..0000000
--- a/cmake/after_load_cmake_modules.cmake
+++ /dev/null
@@ -1,12 +0,0 @@
-add_subdirectory(${CMAKE_MOD_ELUNA_ENGINE_DIR}/lualib)
-
-add_definitions(-DELUNA)
-add_definitions(-DAZEROTHCORE)
-add_definitions(-DWOTLK)
-
-CU_ADD_HOOK(BEFORE_GAME_LIBRARY "${CMAKE_MOD_ELUNA_ENGINE_DIR}/cmake/before_gs_install.cmake")
-CU_ADD_HOOK(AFTER_GAME_LIBRARY "${CMAKE_MOD_ELUNA_ENGINE_DIR}/cmake/after_gs_install.cmake")
-
-AC_ADD_CONFIG_FILE("${CMAKE_MOD_ELUNA_ENGINE_DIR}/conf/mod_LuaEngine.conf.dist")
-
-message("** [Eluna Module] LuaEngine is enable!")
diff --git a/cmake/before_gs_install.cmake b/cmake/before_gs_install.cmake
deleted file mode 100644
index 95b99b0..0000000
--- a/cmake/before_gs_install.cmake
+++ /dev/null
@@ -1,13 +0,0 @@
-file(GLOB_RECURSE method_headers ${CMAKE_MOD_ELUNA_ENGINE_DIR}/LuaEngine/*Methods.h)
-file(GLOB_RECURSE sources_ElunaFile_CPP ${CMAKE_MOD_ELUNA_ENGINE_DIR}/LuaEngine/*.cpp )
-file(GLOB_RECURSE sources_ElunaFile_H ${CMAKE_MOD_ELUNA_ENGINE_DIR}/LuaEngine/*.h)
-
-set(ElunaLuaEngineFiles
- ${ElunaLuaEngineFiles}
- ${sources_ElunaFile_H}
- ${sources_ElunaFile_CPP}
-)
-
-source_group("LuaEngine\\Methods" FILES ${method_headers})
-source_group("LuaEngine\\Header Files" FILES ${sources_ElunaFile_H})
-source_group("LuaEngine\\Source Files" FILES ${sources_ElunaFile_CPP})
diff --git a/src/ElunaLuaEngine_SC.cpp b/src/ElunaLuaEngine_SC.cpp
new file mode 100644
index 0000000..6ab9cfe
--- /dev/null
+++ b/src/ElunaLuaEngine_SC.cpp
@@ -0,0 +1,943 @@
+/*
+ * This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see .
+ */
+
+#include "Chat.h"
+#include "ElunaEventMgr.h"
+#include "Log.h"
+#include "LuaEngine.h"
+#include "Pet.h"
+#include "Player.h"
+#include "ScriptMgr.h"
+#include "ScriptedGossip.h"
+
+class Eluna_AllCreatureScript : public AllCreatureScript
+{
+public:
+ Eluna_AllCreatureScript() : AllCreatureScript("Eluna_AllCreatureScript") { }
+
+ // Creature
+ bool CanCreatureGossipHello(Player* player, Creature* creature) override
+ {
+ if (sEluna->OnGossipHello(player, creature))
+ return true;
+
+ return false;
+ }
+
+ bool CanCreatureGossipSelect(Player* player, Creature* creature, uint32 sender, uint32 action) override
+ {
+ if (sEluna->OnGossipSelect(player, creature, sender, action))
+ return true;
+
+ return false;
+ }
+
+ bool CanCreatureGossipSelectCode(Player* player, Creature* creature, uint32 sender, uint32 action, const char* code) override
+ {
+ if (sEluna->OnGossipSelectCode(player, creature, sender, action, code))
+ return true;
+
+ return false;
+ }
+
+ void OnCreatureAddWorld(Creature* creature) override
+ {
+ sEluna->OnAddToWorld(creature);
+
+ if (creature->IsGuardian() && creature->ToTempSummon() && creature->ToTempSummon()->GetSummonerGUID().IsPlayer())
+ sEluna->OnPetAddedToWorld(creature->ToTempSummon()->GetSummonerUnit()->ToPlayer(), creature);
+ }
+
+ void OnCreatureRemoveWorld(Creature* creature) override
+ {
+ sEluna->OnRemoveFromWorld(creature);
+ }
+
+ bool CanCreatureQuestAccept(Player* player, Creature* creature, Quest const* quest) override
+ {
+ sEluna->OnQuestAccept(player, creature, quest);
+ return false;
+ }
+
+ bool CanCreatureQuestReward(Player* player, Creature* creature, Quest const* quest, uint32 opt) override
+ {
+ if (sEluna->OnQuestReward(player, creature, quest, opt))
+ {
+ ClearGossipMenuFor(player);
+ return true;
+ }
+
+ return false;
+ }
+
+ CreatureAI* GetCreatureAI(Creature* creature) const override
+ {
+ if (CreatureAI* luaAI = sEluna->GetAI(creature))
+ return luaAI;
+
+ return nullptr;
+ }
+};
+
+class Eluna_AllGameObjectScript : public AllGameObjectScript
+{
+public:
+ Eluna_AllGameObjectScript() : AllGameObjectScript("Eluna_AllGameObjectScript") { }
+
+ void OnGameObjectAddWorld(GameObject* go) override
+ {
+ sEluna->OnAddToWorld(go);
+ }
+
+ void OnGameObjectRemoveWorld(GameObject* go) override
+ {
+ sEluna->OnRemoveFromWorld(go);
+ }
+
+ void OnGameObjectUpdate(GameObject* go, uint32 diff) override
+ {
+ sEluna->UpdateAI(go, diff);
+ }
+
+ bool CanGameObjectGossipHello(Player* player, GameObject* go) override
+ {
+ if (sEluna->OnGossipHello(player, go))
+ return true;
+
+ if (sEluna->OnGameObjectUse(player, go))
+ return true;
+
+ return false;
+ }
+
+ void OnGameObjectDamaged(GameObject* go, Player* player) override
+ {
+ sEluna->OnDamaged(go, player);
+ }
+
+ void OnGameObjectDestroyed(GameObject* go, Player* player) override
+ {
+ sEluna->OnDestroyed(go, player);
+ }
+
+ void OnGameObjectLootStateChanged(GameObject* go, uint32 state, Unit* /*unit*/) override
+ {
+ sEluna->OnLootStateChanged(go, state);
+ }
+
+ void OnGameObjectStateChanged(GameObject* go, uint32 state) override
+ {
+ sEluna->OnGameObjectStateChanged(go, state);
+ }
+
+ bool CanGameObjectQuestAccept(Player* player, GameObject* go, Quest const* quest) override
+ {
+ sEluna->OnQuestAccept(player, go, quest);
+ return false;
+ }
+
+ bool CanGameObjectGossipSelect(Player* player, GameObject* go, uint32 sender, uint32 action) override
+ {
+ if (sEluna->OnGossipSelect(player, go, sender, action))
+ return true;
+
+ return false;
+ }
+
+ bool CanGameObjectGossipSelectCode(Player* player, GameObject* go, uint32 sender, uint32 action, const char* code) override
+ {
+ if (sEluna->OnGossipSelectCode(player, go, sender, action, code))
+ return true;
+
+ return false;
+ }
+
+ bool CanGameObjectQuestReward(Player* player, GameObject* go, Quest const* quest, uint32 opt) override
+ {
+ if (sEluna->OnQuestAccept(player, go, quest))
+ return false;
+
+ if (sEluna->OnQuestReward(player, go, quest, opt))
+ return false;
+
+ return true;
+ }
+
+ GameObjectAI* GetGameObjectAI(GameObject* go) const override
+ {
+ sEluna->OnSpawn(go);
+ return nullptr;
+ }
+};
+
+class Eluna_AllItemScript : public AllItemScript
+{
+public:
+ Eluna_AllItemScript() : AllItemScript("Eluna_AllItemScript") { }
+
+ bool CanItemQuestAccept(Player* player, Item* item, Quest const* quest) override
+ {
+ if (sEluna->OnQuestAccept(player, item, quest))
+ return false;
+
+ return true;
+ }
+
+ bool CanItemUse(Player* player, Item* item, SpellCastTargets const& targets) override
+ {
+ if (!sEluna->OnUse(player, item, targets))
+ return true;
+
+ return false;
+ }
+
+ bool CanItemExpire(Player* player, ItemTemplate const* proto) override
+ {
+ if (sEluna->OnExpire(player, proto))
+ return false;
+
+ return true;
+ }
+
+ bool CanItemRemove(Player* player, Item* item) override
+ {
+ if (sEluna->OnRemove(player, item))
+ return false;
+
+ return true;
+ }
+
+ void OnItemGossipSelect(Player* player, Item* item, uint32 sender, uint32 action) override
+ {
+ sEluna->HandleGossipSelectOption(player, item, sender, action, "");
+ }
+
+ void OnItemGossipSelectCode(Player* player, Item* item, uint32 sender, uint32 action, const char* code) override
+ {
+ sEluna->HandleGossipSelectOption(player, item, sender, action, code);
+ }
+};
+
+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);
+ }
+
+ void OnDestroyInstance(MapInstanced* /*mapInstanced*/, Map* map) override
+ {
+ sEluna->FreeInstanceId(map->GetInstanceId());
+ }
+
+ void OnCreateMap(Map* map) override
+ {
+ sEluna->OnCreate(map);
+ }
+
+ void OnDestroyMap(Map* map) override
+ {
+ sEluna->OnDestroy(map);
+ }
+
+ void OnPlayerEnterAll(Map* map, Player* player) override
+ {
+ sEluna->OnPlayerEnter(map, player);
+ }
+
+ void OnPlayerLeaveAll(Map* map, Player* player) override
+ {
+ sEluna->OnPlayerLeave(map, player);
+ }
+
+ void OnMapUpdate(Map* map, uint32 diff) override
+ {
+ sEluna->OnUpdate(map, diff);
+ }
+};
+
+class Eluna_AuctionHouseScript : public AuctionHouseScript
+{
+public:
+ Eluna_AuctionHouseScript() : AuctionHouseScript("Eluna_AuctionHouseScript") { }
+
+ void OnAuctionAdd(AuctionHouseObject* ah, AuctionEntry* entry) override
+ {
+ sEluna->OnAdd(ah, entry);
+ }
+
+ void OnAuctionRemove(AuctionHouseObject* ah, AuctionEntry* entry) override
+ {
+ sEluna->OnRemove(ah, entry);
+ }
+
+ void OnAuctionSuccessful(AuctionHouseObject* ah, AuctionEntry* entry) override
+ {
+ sEluna->OnSuccessful(ah, entry);
+ }
+
+ void OnAuctionExpire(AuctionHouseObject* ah, AuctionEntry* entry) override
+ {
+ sEluna->OnExpire(ah, entry);
+ }
+};
+
+class Eluna_BGScript : public BGScript
+{
+public:
+ Eluna_BGScript() : BGScript("Eluna_BGScript") { }
+
+ void OnBattlegroundStart(Battleground* bg) override
+ {
+ sEluna->OnBGStart(bg, bg->GetBgTypeID(), bg->GetInstanceID());
+ }
+
+ void OnBattlegroundEnd(Battleground* bg, TeamId winnerTeam) override
+ {
+ sEluna->OnBGEnd(bg, bg->GetBgTypeID(), bg->GetInstanceID(), winnerTeam);
+ }
+
+ void OnBattlegroundDestroy(Battleground* bg) override
+ {
+ sEluna->OnBGDestroy(bg, bg->GetBgTypeID(), bg->GetInstanceID());
+ }
+
+ void OnBattlegroundCreate(Battleground* bg) override
+ {
+ sEluna->OnBGCreate(bg, bg->GetBgTypeID(), bg->GetInstanceID());
+ }
+};
+
+class Eluna_CommandSC : public CommandSC
+{
+public:
+ Eluna_CommandSC() : CommandSC("Eluna_CommandSC") { }
+
+ bool CanExecuteCommand(ChatHandler& handler, std::string_view cmdStr) override
+ {
+ if (!sEluna->OnCommand(handler.IsConsole() ? nullptr : handler.GetSession()->GetPlayer(), std::string(cmdStr).c_str()))
+ {
+ return false;
+ }
+
+ return true;
+ }
+};
+
+class Eluna_ElunaScript : public ElunaScript
+{
+public:
+ Eluna_ElunaScript() : ElunaScript("Eluna_ElunaScript") { }
+
+ // Weather
+ void OnWeatherChange(Weather* weather, WeatherState state, float grade) override
+ {
+ sEluna->OnChange(weather, weather->GetZone(), state, grade);
+ }
+
+ // AreaTriger
+ bool CanAreaTrigger(Player* player, AreaTrigger const* trigger) override
+ {
+ if (sEluna->OnAreaTrigger(player, trigger))
+ return false;
+
+ return true;
+ }
+};
+
+class Eluna_GameEventScript : public GameEventScript
+{
+public:
+ Eluna_GameEventScript() : GameEventScript("Eluna_GameEventScript") { }
+
+ void OnEventStart(uint16 eventID)
+ {
+ sEluna->OnGameEventStart(eventID);
+ }
+
+ void OnEventStop(uint16 eventID)
+ {
+ sEluna->OnGameEventStop(eventID);
+ }
+};
+
+class Eluna_GroupScript : public GroupScript
+{
+public:
+ Eluna_GroupScript() : GroupScript("Eluna_GroupScript") { }
+
+ void OnAddMember(Group* group, ObjectGuid guid) override
+ {
+ sEluna->OnAddMember(group, guid);
+ }
+
+ void OnInviteMember(Group* group, ObjectGuid guid) override
+ {
+ sEluna->OnInviteMember(group, guid);
+ }
+
+ void OnRemoveMember(Group* group, ObjectGuid guid, RemoveMethod method, ObjectGuid /* kicker */, const char* /* reason */) override
+ {
+ sEluna->OnRemoveMember(group, guid, method);
+ }
+
+ void OnChangeLeader(Group* group, ObjectGuid newLeaderGuid, ObjectGuid oldLeaderGuid) override
+ {
+ sEluna->OnChangeLeader(group, newLeaderGuid, oldLeaderGuid);
+ }
+
+ void OnDisband(Group* group) override
+ {
+ sEluna->OnDisband(group);
+ }
+};
+
+class Eluna_GuildScript : public GuildScript
+{
+public:
+ Eluna_GuildScript() : GuildScript("Eluna_GuildScript") { }
+
+ void OnAddMember(Guild* guild, Player* player, uint8& plRank) override
+ {
+ sEluna->OnAddMember(guild, player, plRank);
+ }
+
+ void OnRemoveMember(Guild* guild, Player* player, bool isDisbanding, bool /*isKicked*/) override
+ {
+ sEluna->OnRemoveMember(guild, player, isDisbanding);
+ }
+
+ void OnMOTDChanged(Guild* guild, const std::string& newMotd) override
+ {
+ sEluna->OnMOTDChanged(guild, newMotd);
+ }
+
+ void OnInfoChanged(Guild* guild, const std::string& newInfo) override
+ {
+ sEluna->OnInfoChanged(guild, newInfo);
+ }
+
+ void OnCreate(Guild* guild, Player* leader, const std::string& name) override
+ {
+ sEluna->OnCreate(guild, leader, name);
+ }
+
+ void OnDisband(Guild* guild) override
+ {
+ sEluna->OnDisband(guild);
+ }
+
+ void OnMemberWitdrawMoney(Guild* guild, Player* player, uint32& amount, bool isRepair) override
+ {
+ sEluna->OnMemberWitdrawMoney(guild, player, amount, isRepair);
+ }
+
+ void OnMemberDepositMoney(Guild* guild, Player* player, uint32& amount) override
+ {
+ sEluna->OnMemberDepositMoney(guild, player, amount);
+ }
+
+ void OnItemMove(Guild* guild, Player* player, Item* pItem, bool isSrcBank, uint8 srcContainer, uint8 srcSlotId,
+ bool isDestBank, uint8 destContainer, uint8 destSlotId) override
+ {
+ sEluna->OnItemMove(guild, player, pItem, isSrcBank, srcContainer, srcSlotId, isDestBank, destContainer, destSlotId);
+ }
+
+ void OnEvent(Guild* guild, uint8 eventType, ObjectGuid::LowType playerGuid1, ObjectGuid::LowType playerGuid2, uint8 newRank) override
+ {
+ sEluna->OnEvent(guild, eventType, playerGuid1, playerGuid2, newRank);
+ }
+
+ void OnBankEvent(Guild* guild, uint8 eventType, uint8 tabId, ObjectGuid::LowType playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId) override
+ {
+ sEluna->OnBankEvent(guild, eventType, tabId, playerGuid, itemOrMoney, itemStackCount, destTabId);
+ }
+};
+
+class Eluna_LootScript : public LootScript
+{
+public:
+ Eluna_LootScript() : LootScript("Eluna_LootScript") { }
+
+ void OnLootMoney(Player* player, uint32 gold) override
+ {
+ sEluna->OnLootMoney(player, gold);
+ }
+};
+
+class Eluna_MiscScript : public MiscScript
+{
+public:
+ Eluna_MiscScript() : MiscScript("Eluna_MiscScript") { }
+
+ void GetDialogStatus(Player* player, Object* questgiver) override
+ {
+ if (questgiver->GetTypeId() == TYPEID_GAMEOBJECT)
+ sEluna->GetDialogStatus(player, questgiver->ToGameObject());
+ else if (questgiver->GetTypeId() == TYPEID_UNIT)
+ sEluna->GetDialogStatus(player, questgiver->ToCreature());
+ }
+};
+
+class Eluna_PetScript : public PetScript
+{
+public:
+ Eluna_PetScript() : PetScript("Eluna_PetScript") { }
+
+ void OnPetAddToWorld(Pet* pet) override
+ {
+ sEluna->OnPetAddedToWorld(pet->GetOwner(), pet);
+ }
+};
+
+class Eluna_PlayerScript : public PlayerScript
+{
+public:
+ Eluna_PlayerScript() : PlayerScript("Eluna_PlayerScript") { }
+
+ void OnPlayerResurrect(Player* player, float /*restore_percent*/, bool /*applySickness*/) override
+ {
+ sEluna->OnResurrect(player);
+ }
+
+ bool CanPlayerUseChat(Player* player, uint32 type, uint32 lang, std::string& msg) override
+ {
+ if (type != CHAT_MSG_SAY && type != CHAT_MSG_YELL && type != CHAT_MSG_EMOTE)
+ return true;
+
+ if (!sEluna->OnChat(player, type, lang, msg))
+ return false;
+
+ return true;
+ }
+
+ bool CanPlayerUseChat(Player* player, uint32 type, uint32 lang, std::string& msg, Player* target) override
+ {
+ if (!sEluna->OnChat(player, type, lang, msg, target))
+ return false;
+
+ return true;
+ }
+
+ bool CanPlayerUseChat(Player* player, uint32 type, uint32 lang, std::string& msg, Group* group) override
+ {
+ if (!sEluna->OnChat(player, type, lang, msg, group))
+ return false;
+
+ return true;
+ }
+
+ bool CanPlayerUseChat(Player* player, uint32 type, uint32 lang, std::string& msg, Guild* guild) override
+ {
+ if (!sEluna->OnChat(player, type, lang, msg, guild))
+ return false;
+
+ return true;
+ }
+
+ bool CanPlayerUseChat(Player* player, uint32 type, uint32 lang, std::string& msg, Channel* channel) override
+ {
+ if (!sEluna->OnChat(player, type, lang, msg, channel))
+ return false;
+
+ return true;
+ }
+
+ void OnLootItem(Player* player, Item* item, uint32 count, ObjectGuid lootguid) override
+ {
+ sEluna->OnLootItem(player, item, count, lootguid);
+ }
+
+ void OnPlayerLearnTalents(Player* player, uint32 talentId, uint32 talentRank, uint32 spellid) override
+ {
+ sEluna->OnLearnTalents(player, talentId, talentRank, spellid);
+ }
+
+ bool CanUseItem(Player* player, ItemTemplate const* proto, InventoryResult& result) override
+ {
+ result = sEluna->OnCanUseItem(player, proto->ItemId);
+ return result != EQUIP_ERR_OK ? false : true;
+ }
+
+ void OnEquip(Player* player, Item* it, uint8 bag, uint8 slot, bool /*update*/) override
+ {
+ sEluna->OnEquip(player, it, bag, slot);
+ }
+
+ void OnPlayerEnterCombat(Player* player, Unit* enemy) override
+ {
+ sEluna->OnPlayerEnterCombat(player, enemy);
+ }
+
+ void OnPlayerLeaveCombat(Player* player) override
+ {
+ sEluna->OnPlayerLeaveCombat(player);
+ }
+
+ bool CanRepopAtGraveyard(Player* player) override
+ {
+ sEluna->OnRepop(player);
+ return true;
+ }
+
+ void OnQuestAbandon(Player* player, uint32 questId) override
+ {
+ sEluna->OnQuestAbandon(player, questId);
+ }
+
+ void OnMapChanged(Player* player) override
+ {
+ sEluna->OnMapChanged(player);
+ }
+
+ void OnGossipSelect(Player* player, uint32 menu_id, uint32 sender, uint32 action) override
+ {
+ sEluna->HandleGossipSelectOption(player, menu_id, sender, action, "");
+ }
+
+ void OnGossipSelectCode(Player* player, uint32 menu_id, uint32 sender, uint32 action, const char* code) override
+ {
+ sEluna->HandleGossipSelectOption(player, menu_id, sender, action, code);
+ }
+
+ void OnPVPKill(Player* killer, Player* killed) override
+ {
+ sEluna->OnPVPKill(killer, killed);
+ }
+
+ void OnCreatureKill(Player* killer, Creature* killed) override
+ {
+ sEluna->OnCreatureKill(killer, killed);
+ }
+
+ void OnPlayerKilledByCreature(Creature* killer, Player* killed) override
+ {
+ sEluna->OnPlayerKilledByCreature(killer, killed);
+ }
+
+ void OnLevelChanged(Player* player, uint8 oldLevel) override
+ {
+ sEluna->OnLevelChanged(player, oldLevel);
+ }
+
+ void OnFreeTalentPointsChanged(Player* player, uint32 points) override
+ {
+ sEluna->OnFreeTalentPointsChanged(player, points);
+ }
+
+ void OnTalentsReset(Player* player, bool noCost) override
+ {
+ sEluna->OnTalentsReset(player, noCost);
+ }
+
+ void OnMoneyChanged(Player* player, int32& amount) override
+ {
+ sEluna->OnMoneyChanged(player, amount);
+ }
+
+ void OnGiveXP(Player* player, uint32& amount, Unit* victim) override
+ {
+ sEluna->OnGiveXP(player, amount, victim);
+ }
+
+ void OnReputationChange(Player* player, uint32 factionID, int32& standing, bool incremental) override
+ {
+ sEluna->OnReputationChange(player, factionID, standing, incremental);
+ }
+
+ void OnDuelRequest(Player* target, Player* challenger) override
+ {
+ sEluna->OnDuelRequest(target, challenger);
+ }
+
+ void OnDuelStart(Player* player1, Player* player2) override
+ {
+ sEluna->OnDuelStart(player1, player2);
+ }
+
+ void OnDuelEnd(Player* winner, Player* loser, DuelCompleteType type) override
+ {
+ sEluna->OnDuelEnd(winner, loser, type);
+ }
+
+ void OnEmote(Player* player, uint32 emote) override
+ {
+ sEluna->OnEmote(player, emote);
+ }
+
+ void OnTextEmote(Player* player, uint32 textEmote, uint32 emoteNum, ObjectGuid guid) override
+ {
+ sEluna->OnTextEmote(player, textEmote, emoteNum, guid);
+ }
+
+ void OnSpellCast(Player* player, Spell* spell, bool skipCheck) override
+ {
+ sEluna->OnSpellCast(player, spell, skipCheck);
+ }
+
+ void OnLogin(Player* player) override
+ {
+ sEluna->OnLogin(player);
+ }
+
+ void OnLogout(Player* player) override
+ {
+ sEluna->OnLogout(player);
+ }
+
+ void OnCreate(Player* player) override
+ {
+ sEluna->OnCreate(player);
+ }
+
+ void OnSave(Player* player) override
+ {
+ sEluna->OnSave(player);
+ }
+
+ void OnDelete(ObjectGuid guid, uint32 /*accountId*/) override
+ {
+ sEluna->OnDelete(guid.GetCounter());
+ }
+
+ void OnBindToInstance(Player* player, Difficulty difficulty, uint32 mapid, bool permanent) override
+ {
+ sEluna->OnBindToInstance(player, difficulty, mapid, permanent);
+ }
+
+ void OnUpdateZone(Player* player, uint32 newZone, uint32 newArea) override
+ {
+ sEluna->OnUpdateZone(player, newZone, newArea);
+ }
+
+ void OnFirstLogin(Player* player) override
+ {
+ sEluna->OnFirstLogin(player);
+ }
+};
+
+class Eluna_ServerScript : public ServerScript
+{
+public:
+ Eluna_ServerScript() : ServerScript("Eluna_ServerScript") { }
+
+ bool CanPacketSend(WorldSession* session, WorldPacket& packet) override
+ {
+ if (!sEluna->OnPacketSend(session, packet))
+ return false;
+
+ return true;
+ }
+
+ bool CanPacketReceive(WorldSession* session, WorldPacket& packet) override
+ {
+ if (!sEluna->OnPacketReceive(session, packet))
+ return false;
+
+ return true;
+ }
+};
+
+class Eluna_SpellSC : public SpellSC
+{
+public:
+ Eluna_SpellSC() : SpellSC("Eluna_SpellSC") { }
+
+ void OnDummyEffect(WorldObject* caster, uint32 spellID, SpellEffIndex effIndex, GameObject* gameObjTarget) override
+ {
+ sEluna->OnDummyEffect(caster, spellID, effIndex, gameObjTarget);
+ }
+
+ void OnDummyEffect(WorldObject* caster, uint32 spellID, SpellEffIndex effIndex, Creature* creatureTarget) override
+ {
+ sEluna->OnDummyEffect(caster, spellID, effIndex, creatureTarget);
+ }
+
+ void OnDummyEffect(WorldObject* caster, uint32 spellID, SpellEffIndex effIndex, Item* itemTarget) override
+ {
+ sEluna->OnDummyEffect(caster, spellID, effIndex, itemTarget);
+ }
+};
+
+class Eluna_UnitScript : public UnitScript
+{
+public:
+ Eluna_UnitScript() : UnitScript("Eluna_UnitScript") { }
+
+ void OnUnitUpdate(Unit* unit, uint32 diff) override
+ {
+ unit->elunaEvents->Update(diff);
+ }
+};
+
+class Eluna_VehicleScript : public VehicleScript
+{
+public:
+ Eluna_VehicleScript() : VehicleScript("Eluna_VehicleScript") { }
+
+ void OnInstall(Vehicle* veh) override
+ {
+ sEluna->OnInstall(veh);
+ }
+
+ void OnUninstall(Vehicle* veh) override
+ {
+ sEluna->OnUninstall(veh);
+ }
+
+ void OnInstallAccessory(Vehicle* veh, Creature* accessory) override
+ {
+ sEluna->OnInstallAccessory(veh, accessory);
+ }
+
+ void OnAddPassenger(Vehicle* veh, Unit* passenger, int8 seatId) override
+ {
+ sEluna->OnAddPassenger(veh, passenger, seatId);
+ }
+
+ void OnRemovePassenger(Vehicle* veh, Unit* passenger) override
+ {
+ sEluna->OnRemovePassenger(veh, passenger);
+ }
+};
+
+class Eluna_WorldObjectScript : public WorldObjectScript
+{
+public:
+ Eluna_WorldObjectScript() : WorldObjectScript("Eluna_WorldObjectScript") { }
+
+ void OnWorldObjectDestroy(WorldObject* object) override
+ {
+ delete object->elunaEvents;
+ object->elunaEvents = nullptr;
+ }
+
+ void OnWorldObjectCreate(WorldObject* object) override
+ {
+ object->elunaEvents = nullptr;
+ }
+
+ void OnWorldObjectSetMap(WorldObject* object, Map* /*map*/) override
+ {
+ delete object->elunaEvents;
+
+ // On multithread replace this with a pointer to map's Eluna pointer stored in a map
+ object->elunaEvents = new ElunaEventProcessor(&Eluna::GEluna, object);
+ }
+
+ void OnWorldObjectResetMap(WorldObject* object) override
+ {
+ delete object->elunaEvents;
+ object->elunaEvents = nullptr;
+ }
+
+ void OnWorldObjectUpdate(WorldObject* object, uint32 diff) override
+ {
+ object->elunaEvents->Update(diff);
+ }
+};
+
+class Eluna_WorldScript : public WorldScript
+{
+public:
+ Eluna_WorldScript() : WorldScript("Eluna_WorldScript") { }
+
+ void OnOpenStateChange(bool open) override
+ {
+ sEluna->OnOpenStateChange(open);
+ }
+
+ void OnBeforeConfigLoad(bool reload) override
+ {
+ if (!reload)
+ {
+ ///- Initialize Lua Engine
+ LOG_INFO("eluna", "Initialize Eluna Lua Engine...");
+ Eluna::Initialize();
+ }
+
+ sEluna->OnConfigLoad(reload, true);
+ }
+
+ void OnAfterConfigLoad(bool reload) override
+ {
+ sEluna->OnConfigLoad(reload, false);
+ }
+
+ void OnShutdownInitiate(ShutdownExitCode code, ShutdownMask mask) override
+ {
+ sEluna->OnShutdownInitiate(code, mask);
+ }
+
+ void OnShutdownCancel() override
+ {
+ sEluna->OnShutdownCancel();
+ }
+
+ void OnUpdate(uint32 diff) override
+ {
+ sEluna->OnWorldUpdate(diff);
+ }
+
+ void OnStartup() override
+ {
+ sEluna->OnStartup();
+ }
+
+ void OnShutdown() override
+ {
+ sEluna->OnShutdown();
+ Eluna::Uninitialize();
+ }
+
+ void OnBeforeWorldInitialized() override
+ {
+ ///- Run eluna scripts.
+ // in multithread foreach: run scripts
+ sEluna->RunScripts();
+ sEluna->OnConfigLoad(false, false); // Must be done after Eluna is initialized and scripts have run.
+ }
+};
+
+// Group all custom scripts
+void AddSC_ElunaLuaEngine()
+{
+ new Eluna_AllCreatureScript();
+ new Eluna_AllGameObjectScript();
+ new Eluna_AllItemScript();
+ new Eluna_AllMapScript();
+ new Eluna_AuctionHouseScript();
+ new Eluna_BGScript();
+ new Eluna_CommandSC();
+ new Eluna_ElunaScript();
+ new Eluna_GameEventScript();
+ new Eluna_GroupScript();
+ new Eluna_GuildScript();
+ new Eluna_LootScript();
+ new Eluna_MiscScript();
+ new Eluna_PetScript();
+ new Eluna_PlayerScript();
+ new Eluna_ServerScript();
+ new Eluna_SpellSC();
+ new Eluna_UnitScript();
+ new Eluna_VehicleScript();
+ new Eluna_WorldObjectScript();
+ new Eluna_WorldScript();
+}
diff --git a/LuaEngine b/src/LuaEngine
similarity index 100%
rename from LuaEngine
rename to src/LuaEngine
diff --git a/src/eluna_lua_engine_loader.cpp b/src/eluna_lua_engine_loader.cpp
new file mode 100644
index 0000000..12040dc
--- /dev/null
+++ b/src/eluna_lua_engine_loader.cpp
@@ -0,0 +1,25 @@
+/*
+ * This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see .
+ */
+
+// From SC
+void AddSC_ElunaLuaEngine();
+
+// Add all
+void Addmod_eluna_lua_engineScripts()
+{
+ AddSC_ElunaLuaEngine();
+}
diff --git a/lualib/CMakeLists.txt b/src/lualib/CMakeLists.txt
similarity index 100%
rename from lualib/CMakeLists.txt
rename to src/lualib/CMakeLists.txt
diff --git a/lualib/lapi.c b/src/lualib/lapi.c
similarity index 100%
rename from lualib/lapi.c
rename to src/lualib/lapi.c
diff --git a/lualib/lapi.h b/src/lualib/lapi.h
similarity index 100%
rename from lualib/lapi.h
rename to src/lualib/lapi.h
diff --git a/lualib/lauxlib.c b/src/lualib/lauxlib.c
similarity index 100%
rename from lualib/lauxlib.c
rename to src/lualib/lauxlib.c
diff --git a/lualib/lauxlib.h b/src/lualib/lauxlib.h
similarity index 100%
rename from lualib/lauxlib.h
rename to src/lualib/lauxlib.h
diff --git a/lualib/lbaselib.c b/src/lualib/lbaselib.c
similarity index 100%
rename from lualib/lbaselib.c
rename to src/lualib/lbaselib.c
diff --git a/lualib/lbitlib.c b/src/lualib/lbitlib.c
similarity index 100%
rename from lualib/lbitlib.c
rename to src/lualib/lbitlib.c
diff --git a/lualib/lcode.c b/src/lualib/lcode.c
similarity index 100%
rename from lualib/lcode.c
rename to src/lualib/lcode.c
diff --git a/lualib/lcode.h b/src/lualib/lcode.h
similarity index 100%
rename from lualib/lcode.h
rename to src/lualib/lcode.h
diff --git a/lualib/lcorolib.c b/src/lualib/lcorolib.c
similarity index 100%
rename from lualib/lcorolib.c
rename to src/lualib/lcorolib.c
diff --git a/lualib/lctype.c b/src/lualib/lctype.c
similarity index 100%
rename from lualib/lctype.c
rename to src/lualib/lctype.c
diff --git a/lualib/lctype.h b/src/lualib/lctype.h
similarity index 100%
rename from lualib/lctype.h
rename to src/lualib/lctype.h
diff --git a/lualib/ldblib.c b/src/lualib/ldblib.c
similarity index 100%
rename from lualib/ldblib.c
rename to src/lualib/ldblib.c
diff --git a/lualib/ldebug.c b/src/lualib/ldebug.c
similarity index 100%
rename from lualib/ldebug.c
rename to src/lualib/ldebug.c
diff --git a/lualib/ldebug.h b/src/lualib/ldebug.h
similarity index 100%
rename from lualib/ldebug.h
rename to src/lualib/ldebug.h
diff --git a/lualib/ldo.c b/src/lualib/ldo.c
similarity index 100%
rename from lualib/ldo.c
rename to src/lualib/ldo.c
diff --git a/lualib/ldo.h b/src/lualib/ldo.h
similarity index 100%
rename from lualib/ldo.h
rename to src/lualib/ldo.h
diff --git a/lualib/ldump.c b/src/lualib/ldump.c
similarity index 100%
rename from lualib/ldump.c
rename to src/lualib/ldump.c
diff --git a/lualib/lfunc.c b/src/lualib/lfunc.c
similarity index 100%
rename from lualib/lfunc.c
rename to src/lualib/lfunc.c
diff --git a/lualib/lfunc.h b/src/lualib/lfunc.h
similarity index 100%
rename from lualib/lfunc.h
rename to src/lualib/lfunc.h
diff --git a/lualib/lgc.c b/src/lualib/lgc.c
similarity index 100%
rename from lualib/lgc.c
rename to src/lualib/lgc.c
diff --git a/lualib/lgc.h b/src/lualib/lgc.h
similarity index 100%
rename from lualib/lgc.h
rename to src/lualib/lgc.h
diff --git a/lualib/linit.c b/src/lualib/linit.c
similarity index 100%
rename from lualib/linit.c
rename to src/lualib/linit.c
diff --git a/lualib/liolib.c b/src/lualib/liolib.c
similarity index 100%
rename from lualib/liolib.c
rename to src/lualib/liolib.c
diff --git a/lualib/llex.c b/src/lualib/llex.c
similarity index 100%
rename from lualib/llex.c
rename to src/lualib/llex.c
diff --git a/lualib/llex.h b/src/lualib/llex.h
similarity index 100%
rename from lualib/llex.h
rename to src/lualib/llex.h
diff --git a/lualib/llimits.h b/src/lualib/llimits.h
similarity index 100%
rename from lualib/llimits.h
rename to src/lualib/llimits.h
diff --git a/lualib/lmathlib.c b/src/lualib/lmathlib.c
similarity index 100%
rename from lualib/lmathlib.c
rename to src/lualib/lmathlib.c
diff --git a/lualib/lmem.c b/src/lualib/lmem.c
similarity index 100%
rename from lualib/lmem.c
rename to src/lualib/lmem.c
diff --git a/lualib/lmem.h b/src/lualib/lmem.h
similarity index 100%
rename from lualib/lmem.h
rename to src/lualib/lmem.h
diff --git a/lualib/loadlib.c b/src/lualib/loadlib.c
similarity index 100%
rename from lualib/loadlib.c
rename to src/lualib/loadlib.c
diff --git a/lualib/lobject.c b/src/lualib/lobject.c
similarity index 100%
rename from lualib/lobject.c
rename to src/lualib/lobject.c
diff --git a/lualib/lobject.h b/src/lualib/lobject.h
similarity index 100%
rename from lualib/lobject.h
rename to src/lualib/lobject.h
diff --git a/lualib/lopcodes.c b/src/lualib/lopcodes.c
similarity index 100%
rename from lualib/lopcodes.c
rename to src/lualib/lopcodes.c
diff --git a/lualib/lopcodes.h b/src/lualib/lopcodes.h
similarity index 100%
rename from lualib/lopcodes.h
rename to src/lualib/lopcodes.h
diff --git a/lualib/loslib.c b/src/lualib/loslib.c
similarity index 100%
rename from lualib/loslib.c
rename to src/lualib/loslib.c
diff --git a/lualib/lparser.c b/src/lualib/lparser.c
similarity index 100%
rename from lualib/lparser.c
rename to src/lualib/lparser.c
diff --git a/lualib/lparser.h b/src/lualib/lparser.h
similarity index 100%
rename from lualib/lparser.h
rename to src/lualib/lparser.h
diff --git a/lualib/lstate.c b/src/lualib/lstate.c
similarity index 100%
rename from lualib/lstate.c
rename to src/lualib/lstate.c
diff --git a/lualib/lstate.h b/src/lualib/lstate.h
similarity index 100%
rename from lualib/lstate.h
rename to src/lualib/lstate.h
diff --git a/lualib/lstring.c b/src/lualib/lstring.c
similarity index 100%
rename from lualib/lstring.c
rename to src/lualib/lstring.c
diff --git a/lualib/lstring.h b/src/lualib/lstring.h
similarity index 100%
rename from lualib/lstring.h
rename to src/lualib/lstring.h
diff --git a/lualib/lstrlib.c b/src/lualib/lstrlib.c
similarity index 100%
rename from lualib/lstrlib.c
rename to src/lualib/lstrlib.c
diff --git a/lualib/ltable.c b/src/lualib/ltable.c
similarity index 100%
rename from lualib/ltable.c
rename to src/lualib/ltable.c
diff --git a/lualib/ltable.h b/src/lualib/ltable.h
similarity index 100%
rename from lualib/ltable.h
rename to src/lualib/ltable.h
diff --git a/lualib/ltablib.c b/src/lualib/ltablib.c
similarity index 100%
rename from lualib/ltablib.c
rename to src/lualib/ltablib.c
diff --git a/lualib/ltm.c b/src/lualib/ltm.c
similarity index 100%
rename from lualib/ltm.c
rename to src/lualib/ltm.c
diff --git a/lualib/ltm.h b/src/lualib/ltm.h
similarity index 100%
rename from lualib/ltm.h
rename to src/lualib/ltm.h
diff --git a/lualib/lua.c b/src/lualib/lua.c
similarity index 100%
rename from lualib/lua.c
rename to src/lualib/lua.c
diff --git a/lualib/lua.h b/src/lualib/lua.h
similarity index 100%
rename from lualib/lua.h
rename to src/lualib/lua.h
diff --git a/lualib/lua.hpp b/src/lualib/lua.hpp
similarity index 100%
rename from lualib/lua.hpp
rename to src/lualib/lua.hpp
diff --git a/lualib/luac.c b/src/lualib/luac.c
similarity index 100%
rename from lualib/luac.c
rename to src/lualib/luac.c
diff --git a/lualib/luaconf.h b/src/lualib/luaconf.h
similarity index 100%
rename from lualib/luaconf.h
rename to src/lualib/luaconf.h
diff --git a/lualib/lualib.h b/src/lualib/lualib.h
similarity index 100%
rename from lualib/lualib.h
rename to src/lualib/lualib.h
diff --git a/lualib/lundump.c b/src/lualib/lundump.c
similarity index 100%
rename from lualib/lundump.c
rename to src/lualib/lundump.c
diff --git a/lualib/lundump.h b/src/lualib/lundump.h
similarity index 100%
rename from lualib/lundump.h
rename to src/lualib/lundump.h
diff --git a/lualib/lvm.c b/src/lualib/lvm.c
similarity index 100%
rename from lualib/lvm.c
rename to src/lualib/lvm.c
diff --git a/lualib/lvm.h b/src/lualib/lvm.h
similarity index 100%
rename from lualib/lvm.h
rename to src/lualib/lvm.h
diff --git a/lualib/lzio.c b/src/lualib/lzio.c
similarity index 100%
rename from lualib/lzio.c
rename to src/lualib/lzio.c
diff --git a/lualib/lzio.h b/src/lualib/lzio.h
similarity index 100%
rename from lualib/lzio.h
rename to src/lualib/lzio.h