summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cmake/macros/ConfigInstall.cmake40
-rw-r--r--src/cmake/macros/ConfigureModules.cmake15
-rw-r--r--src/server/database/CMakeLists.txt3
-rw-r--r--src/server/database/Database/DatabaseLoader.cpp12
-rw-r--r--src/server/database/Database/DatabaseLoader.h5
-rw-r--r--src/server/database/Updater/DBUpdater.cpp4
-rw-r--r--src/server/database/Updater/DBUpdater.h2
-rw-r--r--src/server/database/Updater/UpdateFetcher.cpp21
-rw-r--r--src/server/database/Updater/UpdateFetcher.h9
-rw-r--r--src/server/game/Battlegrounds/Battleground.cpp15
-rw-r--r--src/server/game/Battlegrounds/BattlegroundMgr.cpp9
-rw-r--r--src/server/game/CMakeLists.txt3
-rw-r--r--src/server/game/Chat/Chat.cpp4
-rw-r--r--src/server/game/Chat/ChatCommands/ChatCommand.cpp17
-rw-r--r--src/server/game/Entities/Creature/Creature.cpp15
-rw-r--r--src/server/game/Entities/GameObject/GameObject.cpp41
-rw-r--r--src/server/game/Entities/Object/Object.cpp38
-rw-r--r--src/server/game/Entities/Object/Object.h13
-rw-r--r--src/server/game/Entities/Pet/Pet.cpp10
-rw-r--r--src/server/game/Entities/Player/Player.cpp56
-rw-r--r--src/server/game/Entities/Player/PlayerQuest.cpp20
-rw-r--r--src/server/game/Entities/Player/PlayerStorage.cpp32
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp24
-rw-r--r--src/server/game/Events/GameEventMgr.cpp4
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp6
-rw-r--r--src/server/game/Handlers/CharacterHandler.cpp4
-rw-r--r--src/server/game/Handlers/ChatHandler.cpp112
-rw-r--r--src/server/game/Handlers/LootHandler.cpp15
-rw-r--r--src/server/game/Handlers/MiscHandler.cpp8
-rw-r--r--src/server/game/Handlers/QuestHandler.cpp15
-rw-r--r--src/server/game/Handlers/SpellHandler.cpp4
-rw-r--r--src/server/game/Maps/Map.cpp29
-rw-r--r--src/server/game/Maps/MapInstanced.cpp17
-rw-r--r--src/server/game/Maps/MapInstanced.h2
-rw-r--r--src/server/game/Maps/MapMgr.cpp4
-rw-r--r--src/server/game/Modules/ModuleMgr.cpp42
-rw-r--r--src/server/game/Modules/ModuleMgr.h31
-rw-r--r--src/server/game/Scripting/ScriptMgr.cpp745
-rw-r--r--src/server/game/Scripting/ScriptMgr.h655
-rw-r--r--src/server/game/Server/WorldSession.cpp36
-rw-r--r--src/server/game/Spells/Auras/SpellAuraEffects.cpp11
-rw-r--r--src/server/game/Spells/Spell.cpp9
-rw-r--r--src/server/game/Spells/SpellEffects.cpp19
-rw-r--r--src/server/game/World/World.cpp20
-rw-r--r--src/server/scripts/CMakeLists.txt172
-rw-r--r--src/server/scripts/Commands/cs_server.cpp9
-rw-r--r--src/server/scripts/ScriptLoader.cpp.in.cmake10
-rw-r--r--src/server/shared/DataStores/DBCStore.h2
-rw-r--r--src/server/worldserver/CMakeLists.txt7
-rw-r--r--src/server/worldserver/Main.cpp15
50 files changed, 1402 insertions, 1009 deletions
diff --git a/src/cmake/macros/ConfigInstall.cmake b/src/cmake/macros/ConfigInstall.cmake
index 7d976946ad..8dc97a8e6a 100644
--- a/src/cmake/macros/ConfigInstall.cmake
+++ b/src/cmake/macros/ConfigInstall.cmake
@@ -51,17 +51,17 @@ function(CopyModuleConfig configDir)
if(WIN32)
if("${CMAKE_MAKE_PROGRAM}" MATCHES "MSBuild")
- add_custom_command(TARGET worldserver
+ add_custom_command(TARGET modules
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/bin/$(ConfigurationName)/${postPath}")
- add_custom_command(TARGET worldserver
+ add_custom_command(TARGET modules
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy "${configDir}" "${CMAKE_BINARY_DIR}/bin/$(ConfigurationName)/${postPath}")
elseif(MINGW)
- add_custom_command(TARGET worldserver
+ add_custom_command(TARGET modules
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/bin/${postPath}")
- add_custom_command(TARGET worldserver
+ add_custom_command(TARGET modules
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy "${configDir} ${CMAKE_BINARY_DIR}/bin/${postPath}")
endif()
@@ -74,35 +74,3 @@ function(CopyModuleConfig configDir)
endif()
unset(postPath)
endfunction()
-
-# Stores the absolut path of the given config module in the variable
-function(GetPathToModuleConfig module variable)
- set(${variable} "${CMAKE_SOURCE_DIR}/modules/${module}/conf" PARENT_SCOPE)
-endfunction()
-
-# Creates a list of all configs modules
-# and stores it in the given variable.
-function(CollectModulesConfig)
- file(GLOB LOCALE_MODULE_LIST RELATIVE
- ${CMAKE_SOURCE_DIR}/modules
- ${CMAKE_SOURCE_DIR}/modules/*)
-
- message(STATUS "* Modules config list:")
-
- foreach(CONFIG_MODULE ${LOCALE_MODULE_LIST})
- GetPathToModuleConfig(${CONFIG_MODULE} MODULE_CONFIG_PATH)
-
- file(GLOB MODULE_CONFIG_LIST RELATIVE
- ${MODULE_CONFIG_PATH}
- ${MODULE_CONFIG_PATH}/*.conf.dist)
-
- foreach(configFileName ${MODULE_CONFIG_LIST})
- CopyModuleConfig("${MODULE_CONFIG_PATH}/${configFileName}")
- set(CONFIG_LIST ${CONFIG_LIST}${configFileName},)
- message(STATUS " |- ${configFileName}")
- endforeach()
-
- endforeach()
- message("")
- add_definitions(-DCONFIG_FILE_LIST=$<1:"${CONFIG_LIST}">)
-endfunction()
diff --git a/src/cmake/macros/ConfigureModules.cmake b/src/cmake/macros/ConfigureModules.cmake
index d57e692422..8a21fa1c80 100644
--- a/src/cmake/macros/ConfigureModules.cmake
+++ b/src/cmake/macros/ConfigureModules.cmake
@@ -71,18 +71,3 @@ function(IsDynamicLinkingModulesRequired variable)
endforeach()
set(${variable} ${IS_REQUIRED} PARENT_SCOPE)
endfunction()
-
-# Get list all modules
-function(GetModuleList)
- file(GLOB LOCALE_MODULE_LIST RELATIVE
- ${CMAKE_SOURCE_DIR}/modules
- ${CMAKE_SOURCE_DIR}/modules/*)
-
- foreach(MODULE_DIR ${LOCALE_MODULE_LIST})
- if(IS_DIRECTORY "${CMAKE_SOURCE_DIR}/modules/${MODULE_DIR}")
- set(MODULE_LIST__ ${MODULE_LIST__}${MODULE_DIR},)
- endif()
- endforeach()
-
- add_definitions(-DAC_MODULES_LIST=$<1:"${MODULE_LIST__}">)
-endfunction()
diff --git a/src/server/database/CMakeLists.txt b/src/server/database/CMakeLists.txt
index 1ce7130b47..1173f033ea 100644
--- a/src/server/database/CMakeLists.txt
+++ b/src/server/database/CMakeLists.txt
@@ -54,9 +54,6 @@ target_link_libraries(database
PUBLIC
common)
-# Add support auto update db for modules
-GetModuleList()
-
set_target_properties(database
PROPERTIES
FOLDER
diff --git a/src/server/database/Database/DatabaseLoader.cpp b/src/server/database/Database/DatabaseLoader.cpp
index 7bf2e85a43..41e3bacae5 100644
--- a/src/server/database/Database/DatabaseLoader.cpp
+++ b/src/server/database/Database/DatabaseLoader.cpp
@@ -25,11 +25,11 @@
#include <mysqld_error.h>
#include <thread>
-DatabaseLoader::DatabaseLoader(std::string const& logger, uint32 const defaultUpdateMask)
- : _logger(logger), _autoSetup(sConfigMgr->GetOption<bool>("Updates.AutoSetup", true)),
- _updateFlags(sConfigMgr->GetOption<uint32>("Updates.EnableDatabases", defaultUpdateMask))
-{
-}
+DatabaseLoader::DatabaseLoader(std::string const& logger, uint32 const defaultUpdateMask, std::string_view modulesList)
+ : _logger(logger),
+ _modulesList(modulesList),
+ _autoSetup(sConfigMgr->GetOption<bool>("Updates.AutoSetup", true)),
+ _updateFlags(sConfigMgr->GetOption<uint32>("Updates.EnableDatabases", defaultUpdateMask)) { }
template <class T>
DatabaseLoader& DatabaseLoader::AddDatabase(DatabaseWorkerPool<T>& pool, std::string const& name)
@@ -127,7 +127,7 @@ DatabaseLoader& DatabaseLoader::AddDatabase(DatabaseWorkerPool<T>& pool, std::st
_update.push([this, name, &pool]() -> bool
{
- if (!DBUpdater<T>::Update(pool))
+ if (!DBUpdater<T>::Update(pool, _modulesList))
{
LOG_ERROR(_logger, "Could not update the %s database, see log for details.", name.c_str());
return false;
diff --git a/src/server/database/Database/DatabaseLoader.h b/src/server/database/Database/DatabaseLoader.h
index f889fef78f..44aaca1992 100644
--- a/src/server/database/Database/DatabaseLoader.h
+++ b/src/server/database/Database/DatabaseLoader.h
@@ -32,7 +32,7 @@ class DatabaseWorkerPool;
class AC_DATABASE_API DatabaseLoader
{
public:
- DatabaseLoader(std::string const& logger, uint32 const defaultUpdateMask = 0);
+ DatabaseLoader(std::string const& logger, uint32 const defaultUpdateMask = 0, std::string_view modulesList = {});
// Register a database to the loader (lazy implemented)
template <class T>
@@ -57,7 +57,7 @@ public:
return _updateFlags;
}
-private :
+private:
bool OpenDatabases();
bool PopulateDatabases();
bool UpdateDatabases();
@@ -71,6 +71,7 @@ private :
bool Process(std::queue<Predicate>& queue);
std::string const _logger;
+ std::string_view _modulesList;
bool const _autoSetup;
uint32 const _updateFlags;
diff --git a/src/server/database/Updater/DBUpdater.cpp b/src/server/database/Updater/DBUpdater.cpp
index 2c32c6b864..b2f121de48 100644
--- a/src/server/database/Updater/DBUpdater.cpp
+++ b/src/server/database/Updater/DBUpdater.cpp
@@ -214,7 +214,7 @@ bool DBUpdater<T>::Create(DatabaseWorkerPool<T>& pool)
}
template<class T>
-bool DBUpdater<T>::Update(DatabaseWorkerPool<T>& pool)
+bool DBUpdater<T>::Update(DatabaseWorkerPool<T>& pool, std::string_view modulesList /*= {}*/)
{
if (!DBUpdaterUtil::CheckExecutable())
return false;
@@ -260,7 +260,7 @@ bool DBUpdater<T>::Update(DatabaseWorkerPool<T>& pool)
UpdateFetcher updateFetcher(sourceDirectory, [&](std::string const & query) { DBUpdater<T>::Apply(pool, query); },
[&](Path const & file) { DBUpdater<T>::ApplyFile(pool, file); },
- [&](std::string const & query) -> QueryResult { return DBUpdater<T>::Retrieve(pool, query); }, DBUpdater<T>::GetDBModuleName());
+ [&](std::string const & query) -> QueryResult { return DBUpdater<T>::Retrieve(pool, query); }, DBUpdater<T>::GetDBModuleName(), modulesList);
UpdateResult result;
try
diff --git a/src/server/database/Updater/DBUpdater.h b/src/server/database/Updater/DBUpdater.h
index a086ab4350..62af83df1e 100644
--- a/src/server/database/Updater/DBUpdater.h
+++ b/src/server/database/Updater/DBUpdater.h
@@ -75,7 +75,7 @@ public:
static bool IsEnabled(uint32 const updateMask);
static BaseLocation GetBaseLocationType();
static bool Create(DatabaseWorkerPool<T>& pool);
- static bool Update(DatabaseWorkerPool<T>& pool);
+ static bool Update(DatabaseWorkerPool<T>& pool, std::string_view modulesList = {});
static bool Update(DatabaseWorkerPool<T>& pool, std::vector<std::string> const* setDirectories);
static bool Populate(DatabaseWorkerPool<T>& pool);
diff --git a/src/server/database/Updater/UpdateFetcher.cpp b/src/server/database/Updater/UpdateFetcher.cpp
index 648d739b82..5ca2471801 100644
--- a/src/server/database/Updater/UpdateFetcher.cpp
+++ b/src/server/database/Updater/UpdateFetcher.cpp
@@ -45,6 +45,17 @@ UpdateFetcher::UpdateFetcher(Path const& sourceDirectory,
{
}
+UpdateFetcher::UpdateFetcher(Path const& sourceDirectory,
+ std::function<void(std::string const&)> const& apply,
+ std::function<void(Path const& path)> const& applyFile,
+ std::function<QueryResult(std::string const&)> const& retrieve,
+ std::string const& dbModuleName,
+ std::string_view modulesList /*= {}*/) :
+ _sourceDirectory(std::make_unique<Path>(sourceDirectory)), _apply(apply), _applyFile(applyFile),
+ _retrieve(retrieve), _dbModuleName(dbModuleName), _setDirectories(nullptr), _modulesList(modulesList)
+{
+}
+
UpdateFetcher::~UpdateFetcher()
{
}
@@ -144,8 +155,10 @@ UpdateFetcher::DirectoryStorage UpdateFetcher::ReceiveIncludedDirectories() cons
std::vector<std::string> moduleList;
- auto const& _modulesTokens = Acore::Tokenize(AC_MODULES_LIST, ',', true);
- for (auto const& itr : _modulesTokens) moduleList.emplace_back(itr);
+ for (auto const& itr : Acore::Tokenize(_modulesList, ',', true))
+ {
+ moduleList.emplace_back(itr);
+ }
// data/sql
for (auto const& itr : moduleList)
@@ -154,9 +167,11 @@ UpdateFetcher::DirectoryStorage UpdateFetcher::ReceiveIncludedDirectories() cons
Path const p(path);
if (!is_directory(p))
+ {
continue;
+ }
- DirectoryEntry const entry = {p, AppliedFileEntry::StateConvert("MODULE")};
+ DirectoryEntry const entry = { p, AppliedFileEntry::StateConvert("MODULE") };
directories.push_back(entry);
LOG_TRACE("sql.updates", "Added applied modules file \"%s\" from remote.", p.filename().generic_string().c_str());
diff --git a/src/server/database/Updater/UpdateFetcher.h b/src/server/database/Updater/UpdateFetcher.h
index c2b29936f9..ca9918f484 100644
--- a/src/server/database/Updater/UpdateFetcher.h
+++ b/src/server/database/Updater/UpdateFetcher.h
@@ -48,6 +48,14 @@ public:
std::function<void(std::string const&)> const& apply,
std::function<void(Path const& path)> const& applyFile,
std::function<QueryResult(std::string const&)> const& retrieve, std::string const& dbModuleName, std::vector<std::string> const* setDirectories = nullptr);
+
+ UpdateFetcher(Path const& updateDirectory,
+ std::function<void(std::string const&)> const& apply,
+ std::function<void(Path const& path)> const& applyFile,
+ std::function<QueryResult(std::string const&)> const& retrieve,
+ std::string const& dbModuleName,
+ std::string_view modulesList = {});
+
~UpdateFetcher();
UpdateResult Update(bool const redundancyChecks, bool const allowRehash,
@@ -153,6 +161,7 @@ private:
// modules
std::string const _dbModuleName;
std::vector<std::string> const* _setDirectories;
+ std::string_view _modulesList = {};
};
#endif // UpdateFetcher_h__
diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp
index da05eb391b..ac1e647b21 100644
--- a/src/server/game/Battlegrounds/Battleground.cpp
+++ b/src/server/game/Battlegrounds/Battleground.cpp
@@ -44,9 +44,6 @@
#include "World.h"
#include "WorldPacket.h"
-#ifdef ELUNA
-#include "LuaEngine.h"
-#endif
namespace Acore
{
class BattlegroundChatBuilder
@@ -217,9 +214,7 @@ Battleground::~Battleground()
for (uint32 i = 0; i < size; ++i)
DelObject(i);
-#ifdef ELUNA
- sEluna->OnBGDestroy(this, GetBgTypeID(), GetInstanceID());
-#endif
+ sScriptMgr->OnBattlegroundDestroy(this);
sBattlegroundMgr->RemoveBattleground(GetBgTypeID(), GetInstanceID());
// unload map
@@ -513,10 +508,6 @@ inline void Battleground::_ProcessJoin(uint32 diff)
StartingEventOpenDoors();
-#ifdef ELUNA
- sEluna->OnBGStart(this, GetBgTypeID(), GetInstanceID());
-#endif
-
SendWarningToAll(StartMessageIds[BG_STARTING_EVENT_FOURTH]);
SetStatus(STATUS_IN_PROGRESS);
SetStartDelayTime(StartDelayTimes[BG_STARTING_EVENT_FOURTH]);
@@ -1063,9 +1054,7 @@ void Battleground::EndBattleground(TeamId winnerTeamId)
if (winmsg_id)
SendMessageToAll(winmsg_id, CHAT_MSG_BG_SYSTEM_NEUTRAL);
-#ifdef ELUNA
- sEluna->OnBGEnd(this, GetBgTypeID(), GetInstanceID(), winnerTeamId);
-#endif
+ sScriptMgr->OnBattlegroundEnd(this, winnerTeamId);
}
uint32 Battleground::GetBonusHonorFromKill(uint32 kills) const
diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.cpp b/src/server/game/Battlegrounds/BattlegroundMgr.cpp
index b31cfab92d..63c9bed72d 100644
--- a/src/server/game/Battlegrounds/BattlegroundMgr.cpp
+++ b/src/server/game/Battlegrounds/BattlegroundMgr.cpp
@@ -48,10 +48,6 @@
#include <random>
#include <unordered_map>
-#ifdef ELUNA
-#include "LuaEngine.h"
-#endif
-
/*********************************************************/
/*** BATTLEGROUND MANAGER ***/
/*********************************************************/
@@ -994,9 +990,8 @@ void BattlegroundMgr::AddBattleground(Battleground* bg)
m_BattlegroundTemplates[bg->GetBgTypeID()] = bg;
else
m_Battlegrounds[bg->GetInstanceID()] = bg;
-#ifdef ELUNA
- sEluna->OnBGCreate(bg, bg->GetBgTypeID(), bg->GetInstanceID());
-#endif
+
+ sScriptMgr->OnBattlegroundCreate(bg);
}
void BattlegroundMgr::RemoveBattleground(BattlegroundTypeId bgTypeId, uint32 instanceId)
diff --git a/src/server/game/CMakeLists.txt b/src/server/game/CMakeLists.txt
index 0b39215bc0..3ac1d0d359 100644
--- a/src/server/game/CMakeLists.txt
+++ b/src/server/game/CMakeLists.txt
@@ -42,8 +42,7 @@ target_link_libraries(game-interface
shared)
add_library(game STATIC
- ${PRIVATE_SOURCES}
- ${ElunaLuaEngineFiles})
+ ${PRIVATE_SOURCES})
add_dependencies(game revision.h)
diff --git a/src/server/game/Chat/Chat.cpp b/src/server/game/Chat/Chat.cpp
index cb1d780ae2..a8a1fb9765 100644
--- a/src/server/game/Chat/Chat.cpp
+++ b/src/server/game/Chat/Chat.cpp
@@ -35,10 +35,6 @@
#include "WorldPacket.h"
#include "WorldSession.h"
-#ifdef ELUNA
-#include "LuaEngine.h"
-#endif
-
Player* ChatHandler::GetPlayer() const
{
return m_session ? m_session->GetPlayer() : nullptr;
diff --git a/src/server/game/Chat/ChatCommands/ChatCommand.cpp b/src/server/game/Chat/ChatCommands/ChatCommand.cpp
index bbaced351c..fb80168c0b 100644
--- a/src/server/game/Chat/ChatCommands/ChatCommand.cpp
+++ b/src/server/game/Chat/ChatCommands/ChatCommand.cpp
@@ -27,10 +27,6 @@
#include "Tokenize.h"
#include "WorldSession.h"
-#ifdef ELUNA
-#include "LuaEngine.h"
-#endif
-
using ChatSubCommandMap = std::map<std::string_view, Acore::Impl::ChatCommands::ChatCommandNode, StringCompareLessI_T>;
void Acore::Impl::ChatCommands::ChatCommandNode::LoadFromBuilder(ChatCommandBuilder const& builder)
@@ -334,27 +330,24 @@ namespace Acore::Impl::ChatCommands
if (!handler.IsConsole())
LogCommandUsage(*handler.GetSession(), cmdStr);
}
- else if (!handler.HasSentErrorMessage())
- { /* invocation failed, we should show usage */
-#ifdef ELUNA
- if (!sEluna->OnCommand(handler.IsConsole() ? nullptr : handler.GetSession()->GetPlayer(), std::string(cmdStr).c_str()))
+ else if (!handler.HasSentErrorMessage()) /* invocation failed, we should show usage */
+ {
+ if (!sScriptMgr->CanExecuteCommand(handler, cmdStr))
{
return true;
}
-#endif
cmd->SendCommandHelp(handler);
handler.SetSentErrorMessage(true);
}
+
return true;
}
-#ifdef ELUNA
- if (!sEluna->OnCommand(handler.IsConsole() ? nullptr : handler.GetSession()->GetPlayer(), std::string(cmdStr).c_str()))
+ if (!sScriptMgr->CanExecuteCommand(handler, cmdStr))
{
return true;
}
-#endif
return false;
}
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp
index 1f56a0c181..655df486a4 100644
--- a/src/server/game/Entities/Creature/Creature.cpp
+++ b/src/server/game/Entities/Creature/Creature.cpp
@@ -53,10 +53,6 @@
// there is probably some underlying problem with imports which should properly addressed
#include "GridNotifiersImpl.h"
-#ifdef ELUNA
-#include "LuaEngine.h"
-#endif
-
TrainerSpell const* TrainerSpellData::Find(uint32 spell_id) const
{
TrainerSpellMap::const_iterator itr = spellList.find(spell_id);
@@ -242,12 +238,8 @@ void Creature::AddToWorld()
{
GetZoneScript()->OnCreatureCreate(this);
}
-#ifdef ELUNA
- sEluna->OnAddToWorld(this);
- if (IsGuardian() && ToTempSummon() && ToTempSummon()->GetSummonerGUID().IsPlayer())
- sEluna->OnPetAddedToWorld(ToTempSummon()->GetSummonerUnit()->ToPlayer(), this);
-#endif
+ sScriptMgr->OnCreatureAddWorld(this);
}
}
@@ -255,9 +247,8 @@ void Creature::RemoveFromWorld()
{
if (IsInWorld())
{
-#ifdef ELUNA
- sEluna->OnRemoveFromWorld(this);
-#endif
+ sScriptMgr->OnCreatureRemoveWorld(this);
+
if (GetZoneScript())
GetZoneScript()->OnCreatureRemove(this);
diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp
index 58121cfeb8..a159ebbfd4 100644
--- a/src/server/game/Entities/GameObject/GameObject.cpp
+++ b/src/server/game/Entities/GameObject/GameObject.cpp
@@ -38,10 +38,6 @@
#include <G3D/CoordinateFrame.h>
#include <G3D/Quat.h>
-#ifdef ELUNA
-#include "LuaEngine.h"
-#endif
-
GameObject::GameObject() : WorldObject(false), MovableMapObject(),
m_model(nullptr), m_goValue(), m_AI(nullptr)
{
@@ -161,9 +157,8 @@ void GameObject::AddToWorld()
EnableCollision(GetGoState() == GO_STATE_READY || IsTransport()); // pussywizard: this startOpen is unneeded here, collision depends entirely on GOState
WorldObject::AddToWorld();
-#ifdef ELUNA
- sEluna->OnAddToWorld(this);
-#endif
+
+ sScriptMgr->OnGameObjectAddWorld(this);
}
}
@@ -172,9 +167,8 @@ void GameObject::RemoveFromWorld()
///- Remove the gameobject from the accessor
if (IsInWorld())
{
-#ifdef ELUNA
- sEluna->OnRemoveFromWorld(this);
-#endif
+ sScriptMgr->OnGameObjectRemoveWorld(this);
+
if (m_zoneScript)
m_zoneScript->OnGameObjectRemove(this);
@@ -411,9 +405,6 @@ bool GameObject::Create(ObjectGuid::LowType guidlow, uint32 name_id, Map* map, u
void GameObject::Update(uint32 diff)
{
-#ifdef ELUNA
- sEluna->UpdateAI(this, diff);
-#endif
if (AI())
AI()->UpdateAI(diff);
else if (!AIM_Initialize())
@@ -840,6 +831,7 @@ void GameObject::Update(uint32 diff)
break;
}
}
+
sScriptMgr->OnGameObjectUpdate(this, diff);
}
@@ -1424,10 +1416,6 @@ void GameObject::Use(Unit* user)
if (Player* playerUser = user->ToPlayer())
{
-#ifdef ELUNA
- if (sEluna->OnGossipHello(playerUser, this))
- return;
-#endif
if (sScriptMgr->OnGossipHello(playerUser, this))
return;
@@ -2287,11 +2275,10 @@ void GameObject::SetDestructibleState(GameObjectDestructibleState state, Player*
break;
case GO_DESTRUCTIBLE_DAMAGED:
{
-#ifdef ELUNA
- sEluna->OnDamaged(this, eventInvoker);
-#endif
EventInform(m_goInfo->building.damagedEvent);
+
sScriptMgr->OnGameObjectDamaged(this, eventInvoker);
+
if (BattlegroundMap* bgMap = GetMap()->ToBattlegroundMap())
if (Battleground* bg = bgMap->GetBG())
bg->EventPlayerDamagedGO(eventInvoker, this, m_goInfo->building.damagedEvent);
@@ -2318,11 +2305,10 @@ void GameObject::SetDestructibleState(GameObjectDestructibleState state, Player*
}
case GO_DESTRUCTIBLE_DESTROYED:
{
-#ifdef ELUNA
- sEluna->OnDestroyed(this, eventInvoker);
-#endif
sScriptMgr->OnGameObjectDestroyed(this, eventInvoker);
+
EventInform(m_goInfo->building.destroyedEvent);
+
if (BattlegroundMap* bgMap = GetMap()->ToBattlegroundMap())
{
if (Battleground* bg = bgMap->GetBG())
@@ -2375,9 +2361,7 @@ void GameObject::SetDestructibleState(GameObjectDestructibleState state, Player*
void GameObject::SetLootState(LootState state, Unit* unit)
{
m_lootState = state;
-#ifdef ELUNA
- sEluna->OnLootStateChanged(this, state);
-#endif
+
AI()->OnStateChanged(state, unit);
sScriptMgr->OnGameObjectLootStateChanged(this, state, unit);
// pussywizard: lootState has nothing to do with collision, it depends entirely on GOState. Loot state is for timed close/open door and respawning, which then sets GOState
@@ -2400,10 +2384,9 @@ void GameObject::SetLootState(LootState state, Unit* unit)
void GameObject::SetGoState(GOState state)
{
SetByteValue(GAMEOBJECT_BYTES_1, 0, state);
-#ifdef ELUNA
- sEluna->OnGameObjectStateChanged(this, state);
-#endif
+
sScriptMgr->OnGameObjectStateChanged(this, state);
+
if (m_model)
{
if (!IsInWorld())
diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp
index e01d4f3b0a..5b786dfbf8 100644
--- a/src/server/game/Entities/Object/Object.cpp
+++ b/src/server/game/Entities/Object/Object.cpp
@@ -55,11 +55,6 @@
// there is probably some underlying problem with imports which should properly addressed
#include "GridNotifiersImpl.h"
-#ifdef ELUNA
-#include "ElunaEventMgr.h"
-#include "LuaEngine.h"
-#endif
-
constexpr float VisibilityDistances[AsUnderlyingType(VisibilityDistanceType::Max)] =
{
DEFAULT_VISIBILITY_DISTANCE,
@@ -87,10 +82,7 @@ Object::Object() : m_PackGUID(sizeof(uint64) + 1)
WorldObject::~WorldObject()
{
-#ifdef ELUNA
- delete elunaEvents;
- elunaEvents = nullptr;
-#endif
+ sScriptMgr->OnWorldObjectDestroy(this);
// this may happen because there are many !create/delete
if (IsWorldObject() && m_currMap)
@@ -1106,23 +1098,20 @@ void MovementInfo::OutDebug()
}
WorldObject::WorldObject(bool isWorldObject) : WorldLocation(),
-#ifdef ELUNA
- elunaEvents(nullptr),
-#endif
LastUsedScriptID(0), m_name(""), m_isActive(false), m_visibilityDistanceOverride(false), m_isWorldObject(isWorldObject), m_zoneScript(nullptr),
_zoneId(0), _areaId(0), _floorZ(INVALID_HEIGHT), _outdoors(false), _liquidData(), _updatePositionData(false), m_transport(nullptr),
m_currMap(nullptr), m_InstanceId(0), m_phaseMask(PHASEMASK_NORMAL), m_useCombinedPhases(true), m_notifyflags(0), m_executed_notifies(0)
{
m_serverSideVisibility.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_ALIVE | GHOST_VISIBILITY_GHOST);
m_serverSideVisibilityDetect.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_ALIVE);
+
+ sScriptMgr->OnWorldObjectCreate(this);
}
-#ifdef ELUNA
void WorldObject::Update(uint32 time_diff)
{
- elunaEvents->Update(time_diff);
+ sScriptMgr->OnWorldObjectUpdate(this, time_diff);
}
-#endif
void WorldObject::SetWorldObject(bool on)
{
@@ -2227,22 +2216,23 @@ void WorldObject::SetMap(Map* map)
{
ASSERT(map);
ASSERT(!IsInWorld());
+
if (m_currMap == map) // command add npc: first create, than loadfromdb
+ {
return;
+ }
+
if (m_currMap)
{
LOG_FATAL("entities.object", "WorldObject::SetMap: obj %u new map %u %u, old map %u %u", (uint32)GetTypeId(), map->GetId(), map->GetInstanceId(), m_currMap->GetId(), m_currMap->GetInstanceId());
ABORT();
}
+
m_currMap = map;
m_mapId = map->GetId();
m_InstanceId = map->GetInstanceId();
-#ifdef ELUNA
- delete elunaEvents;
- // On multithread replace this with a pointer to map's Eluna pointer stored in a map
- elunaEvents = new ElunaEventProcessor(&Eluna::GEluna, this);
-#endif
+ sScriptMgr->OnWorldObjectSetMap(this, map);
if (IsWorldObject())
m_currMap->AddWorldObject(this);
@@ -2252,13 +2242,13 @@ void WorldObject::ResetMap()
{
ASSERT(m_currMap);
ASSERT(!IsInWorld());
+
if (IsWorldObject())
+ {
m_currMap->RemoveWorldObject(this);
+ }
-#ifdef ELUNA
- delete elunaEvents;
- elunaEvents = nullptr;
-#endif
+ sScriptMgr->OnWorldObjectResetMap(this);
m_currMap = nullptr;
//maybe not for corpse
diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h
index e43022d168..cdf570a7f9 100644
--- a/src/server/game/Entities/Object/Object.h
+++ b/src/server/game/Entities/Object/Object.h
@@ -33,9 +33,7 @@
#include <sstream>
#include <string>
-#ifdef ELUNA
class ElunaEventProcessor;
-#endif
enum TempSummonType
{
@@ -673,20 +671,13 @@ protected:
public:
~WorldObject() override;
-#ifdef ELUNA
virtual void Update(uint32 /*time_diff*/);
-#else
- virtual void Update(uint32 /*time_diff*/) { };
-#endif
+
void _Create(ObjectGuid::LowType guidlow, HighGuid guidhigh, uint32 phaseMask);
void AddToWorld() override;
void RemoveFromWorld() override;
-#ifdef ELUNA
- ElunaEventProcessor* elunaEvents;
-#endif
-
void GetNearPoint2D(WorldObject const* searcher, float& x, float& y, float distance, float absAngle, Position const* startPos = nullptr) const;
void GetNearPoint2D(float& x, float& y, float distance, float absAngle, Position const* startPos = nullptr) const;
void GetNearPoint(WorldObject const* searcher, float& x, float& y, float& z, float searcher_size, float distance2d, float absAngle, float controlZ = 0, Position const* startPos = nullptr) const;
@@ -899,6 +890,8 @@ public:
[[nodiscard]] bool HasAllowedLooter(ObjectGuid guid) const;
[[nodiscard]] GuidUnorderedSet const& GetAllowedLooters() const;
+ ElunaEventProcessor* elunaEvents;
+
protected:
std::string m_name;
bool m_isActive;
diff --git a/src/server/game/Entities/Pet/Pet.cpp b/src/server/game/Entities/Pet/Pet.cpp
index 2aaa89b833..dc51eea049 100644
--- a/src/server/game/Entities/Pet/Pet.cpp
+++ b/src/server/game/Entities/Pet/Pet.cpp
@@ -35,10 +35,6 @@
#include "WorldPacket.h"
#include "WorldSession.h"
-#ifdef ELUNA
-#include "LuaEngine.h"
-#endif
-
Pet::Pet(Player* owner, PetType type) : Guardian(nullptr, owner ? owner->GetGUID() : ObjectGuid::Empty, true),
m_usedTalentCount(0), m_removed(false), m_owner(owner),
m_happinessTimer(PET_LOSE_HAPPINES_INTERVAL), m_petType(type), m_duration(0),
@@ -98,10 +94,10 @@ void Pet::AddToWorld()
GetCharmInfo()->SetIsReturning(false);
}
-#ifdef ELUNA
if (GetOwnerGUID().IsPlayer())
- sEluna->OnPetAddedToWorld(GetOwner(), this);
-#endif
+ {
+ sScriptMgr->OnPetAddToWorld(this);
+ }
}
void Pet::RemoveFromWorld()
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index f41ab451cf..820e4b3463 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -92,10 +92,6 @@
#include "WorldPacket.h"
#include "WorldSession.h"
-#ifdef ELUNA
-#include "LuaEngine.h"
-#endif
-
enum CharacterFlags
{
CHARACTER_FLAG_NONE = 0x00000000,
@@ -4356,12 +4352,12 @@ void Player::ResurrectPlayer(float restore_percent, bool applySickness)
// update visibility
UpdateObjectVisibility();
-#ifdef ELUNA
- sEluna->OnResurrect(this);
-#endif
+ sScriptMgr->OnPlayerResurrect(this, restore_percent, applySickness);
- if(!applySickness)
+ if (!applySickness)
+ {
return;
+ }
//Characters from level 1-10 are not affected by resurrection sickness.
//Characters from level 11-19 will suffer from one minute of sickness
@@ -8774,11 +8770,12 @@ void Player::StopCastingCharm()
void Player::Say(std::string_view text, Language language, WorldObject const* /*= nullptr*/)
{
std::string _text(text);
- sScriptMgr->OnPlayerChat(this, CHAT_MSG_SAY, language, _text);
-#ifdef ELUNA
- if (!sEluna->OnChat(this, CHAT_MSG_SAY, language, _text))
+ if (!sScriptMgr->CanPlayerUseChat(this, CHAT_MSG_SAY, language, _text))
+ {
return;
-#endif
+ }
+
+ sScriptMgr->OnPlayerChat(this, CHAT_MSG_SAY, language, _text);
WorldPacket data;
ChatHandler::BuildChatPacket(data, CHAT_MSG_SAY, language, this, this, _text);
@@ -8793,11 +8790,13 @@ void Player::Say(uint32 textId, WorldObject const* target /*= nullptr*/)
void Player::Yell(std::string_view text, Language language, WorldObject const* /*= nullptr*/)
{
std::string _text(text);
- sScriptMgr->OnPlayerChat(this, CHAT_MSG_YELL, language, _text);
-#ifdef ELUNA
- if (!sEluna->OnChat(this, CHAT_MSG_YELL, language, _text))
+
+ if (!sScriptMgr->CanPlayerUseChat(this, CHAT_MSG_YELL, language, _text))
+ {
return;
-#endif
+ }
+
+ sScriptMgr->OnPlayerChat(this, CHAT_MSG_YELL, language, _text);
WorldPacket data;
ChatHandler::BuildChatPacket(data, CHAT_MSG_YELL, language, this, this, _text);
@@ -8812,11 +8811,13 @@ void Player::Yell(uint32 textId, WorldObject const* target /*= nullptr*/)
void Player::TextEmote(std::string_view text, WorldObject const* /*= nullptr*/, bool /*= false*/)
{
std::string _text(text);
- sScriptMgr->OnPlayerChat(this, CHAT_MSG_EMOTE, LANG_UNIVERSAL, _text);
-#ifdef ELUNA
- if (!sEluna->OnChat(this, CHAT_MSG_EMOTE, LANG_UNIVERSAL, _text))
+
+ if (!sScriptMgr->CanPlayerUseChat(this, CHAT_MSG_EMOTE, LANG_UNIVERSAL, _text))
+ {
return;
-#endif
+ }
+
+ sScriptMgr->OnPlayerChat(this, CHAT_MSG_EMOTE, LANG_UNIVERSAL, _text);
WorldPacket data;
ChatHandler::BuildChatPacket(data, CHAT_MSG_EMOTE, LANG_UNIVERSAL, this, this, _text);
@@ -8838,13 +8839,13 @@ void Player::Whisper(std::string_view text, Language language, Player* target, b
language = LANG_UNIVERSAL; // whispers should always be readable
std::string _text(text);
- sScriptMgr->OnPlayerChat(this, CHAT_MSG_WHISPER, language, _text, target);
-#ifdef ELUNA
- if (!sEluna->OnChat(this, CHAT_MSG_WHISPER, language, _text, target))
+
+ if (!sScriptMgr->CanPlayerUseChat(this, CHAT_MSG_EMOTE, LANG_UNIVERSAL, _text, target))
{
return;
}
-#endif
+
+ sScriptMgr->OnPlayerChat(this, CHAT_MSG_WHISPER, language, _text, target);
WorldPacket data;
ChatHandler::BuildChatPacket(data, CHAT_MSG_WHISPER, language, this, this, _text);
@@ -12803,9 +12804,6 @@ void Player::StoreLootItem(uint8 lootSlot, Loot* loot)
if (loot->containerGUID)
sLootItemStorage->RemoveStoredLootItem(loot->containerGUID, item->itemid, item->count, loot, item->itemIndex);
-#ifdef ELUNA
- sEluna->OnLootItem(this, newitem, item->count, this->GetLootGUID());
-#endif
sScriptMgr->OnLootItem(this, newitem, item->count, this->GetLootGUID());
}
else
@@ -13235,9 +13233,7 @@ void Player::LearnTalent(uint32 talentId, uint32 talentRank)
m_usedTalentCount += talentPointsChange;
SetFreeTalentPoints(CurTalentPoints - talentPointsChange);
-#ifdef ELUNA
- sEluna->OnLearnTalents(this, talentId, talentRank, spellId);
-#endif
+ sScriptMgr->OnPlayerLearnTalents(this, talentId, talentRank, spellId);
}
void Player::LearnPetTalent(ObjectGuid petGuid, uint32 talentId, uint32 talentRank)
diff --git a/src/server/game/Entities/Player/PlayerQuest.cpp b/src/server/game/Entities/Player/PlayerQuest.cpp
index d243188d5b..2c5ccff187 100644
--- a/src/server/game/Entities/Player/PlayerQuest.cpp
+++ b/src/server/game/Entities/Player/PlayerQuest.cpp
@@ -30,10 +30,6 @@
#include "SpellMgr.h"
#include "WorldSession.h"
-#ifdef ELUNA
-#include "LuaEngine.h"
-#endif
-
/*********************************************************/
/*** QUEST SYSTEM ***/
/*********************************************************/
@@ -429,10 +425,7 @@ void Player::AddQuestAndCheckCompletion(Quest const* quest, Object* questGiver)
switch (questGiver->GetTypeId())
{
case TYPEID_UNIT:
-#ifdef ELUNA
- sEluna->OnQuestAccept(this, questGiver->ToCreature(), quest);
-#endif
- sScriptMgr->OnQuestAccept(this, (questGiver->ToCreature()), quest);
+ sScriptMgr->OnQuestAccept(this, questGiver->ToCreature(), quest);
questGiver->ToCreature()->AI()->sQuestAccept(this, quest);
break;
case TYPEID_ITEM:
@@ -458,9 +451,6 @@ void Player::AddQuestAndCheckCompletion(Quest const* quest, Object* questGiver)
break;
}
case TYPEID_GAMEOBJECT:
-#ifdef ELUNA
- sEluna->OnQuestAccept(this, questGiver->ToGameObject(), quest);
-#endif
sScriptMgr->OnQuestAccept(this, questGiver->ToGameObject(), quest);
questGiver->ToGameObject()->AI()->QuestAccept(this, quest);
break;
@@ -1566,13 +1556,12 @@ QuestGiverStatus Player::GetQuestDialogStatus(Object* questgiver)
QuestRelationBounds qr;
QuestRelationBounds qir;
+ sScriptMgr->GetDialogStatus(this, questgiver);
+
switch (questgiver->GetTypeId())
{
case TYPEID_GAMEOBJECT:
{
-#ifdef ELUNA
- sEluna->GetDialogStatus(this, questgiver->ToGameObject());
-#endif
QuestGiverStatus questStatus = QuestGiverStatus(sScriptMgr->GetDialogStatus(this, questgiver->ToGameObject()));
if (questStatus != DIALOG_STATUS_SCRIPTED_NO_STATUS)
return questStatus;
@@ -1582,9 +1571,6 @@ QuestGiverStatus Player::GetQuestDialogStatus(Object* questgiver)
}
case TYPEID_UNIT:
{
-#ifdef ELUNA
- sEluna->GetDialogStatus(this, questgiver->ToCreature());
-#endif
QuestGiverStatus questStatus = QuestGiverStatus(sScriptMgr->GetDialogStatus(this, questgiver->ToCreature()));
if (questStatus != DIALOG_STATUS_SCRIPTED_NO_STATUS)
return questStatus;
diff --git a/src/server/game/Entities/Player/PlayerStorage.cpp b/src/server/game/Entities/Player/PlayerStorage.cpp
index 13000ab94d..43517b3f83 100644
--- a/src/server/game/Entities/Player/PlayerStorage.cpp
+++ b/src/server/game/Entities/Player/PlayerStorage.cpp
@@ -76,10 +76,6 @@
#include "WorldPacket.h"
#include "WorldSession.h"
-#ifdef ELUNA
-#include "LuaEngine.h"
-#endif
-
/*********************************************************/
/*** STORAGE SYSTEM ***/
/*********************************************************/
@@ -2340,13 +2336,6 @@ InventoryResult Player::CanUseItem(ItemTemplate const* proto) const
return EQUIP_ERR_NO_REQUIRED_PROFICIENCY;
}
- InventoryResult result = EQUIP_ERR_OK;
-
- if (!sScriptMgr->CanUseItem(const_cast<Player*>(this), proto, result))
- {
- return result;
- }
-
if (getLevel() < proto->RequiredLevel)
{
return EQUIP_ERR_CANT_EQUIP_LEVEL_I;
@@ -2358,13 +2347,12 @@ InventoryResult Player::CanUseItem(ItemTemplate const* proto) const
return EQUIP_ERR_CANT_DO_RIGHT_NOW;
}
-#ifdef ELUNA
- InventoryResult eres = sEluna->OnCanUseItem(this, proto->ItemId);
- if (eres != EQUIP_ERR_OK)
+ InventoryResult result = EQUIP_ERR_OK;
+
+ if (!sScriptMgr->CanUseItem(const_cast<Player*>(this), proto, result))
{
- return eres;
+ return result;
}
-#endif
return EQUIP_ERR_OK;
}
@@ -2851,9 +2839,7 @@ Item* Player::EquipItem(uint16 pos, Item* pItem, bool update)
pItem2->SetState(ITEM_CHANGED, this);
ApplyEquipCooldown(pItem2);
-#ifdef ELUNA
- sEluna->OnEquip(this, pItem2, bag, slot);
-#endif
+ sScriptMgr->OnEquip(this, pItem2, bag, slot, update);
return pItem2;
}
@@ -2861,10 +2847,6 @@ Item* Player::EquipItem(uint16 pos, Item* pItem, bool update)
UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_EQUIP_ITEM, pItem->GetEntry());
UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_EQUIP_EPIC_ITEM, pItem->GetEntry(), slot);
-#ifdef ELUNA
- sEluna->OnEquip(this, pItem, bag, slot);
-#endif
-
sScriptMgr->OnEquip(this, pItem, bag, slot, update);
UpdateForQuestWorldObjects();
return pItem;
@@ -2889,9 +2871,7 @@ void Player::QuickEquipItem(uint16 pos, Item* pItem)
UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_EQUIP_ITEM, pItem->GetEntry());
UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_EQUIP_EPIC_ITEM, pItem->GetEntry(), slot);
-#ifdef ELUNA
- sEluna->OnEquip(this, pItem, (pos >> 8), slot);
-#endif
+ sScriptMgr->OnEquip(this, pItem, (pos >> 8), slot, true);
}
}
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 3ee8ac5006..bc189f3462 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -70,11 +70,6 @@
#include "WorldSession.h"
#include <math.h>
-#ifdef ELUNA
-#include "ElunaEventMgr.h"
-#include "LuaEngine.h"
-#endif
-
float baseMoveSpeed[MAX_MOVE_TYPE] =
{
2.5f, // MOVE_WALK
@@ -387,9 +382,8 @@ Unit::~Unit()
void Unit::Update(uint32 p_time)
{
-#ifdef ELUNA
- elunaEvents->Update(p_time);
-#endif
+ sScriptMgr->OnUnitUpdate(this, p_time);
+
// WARNING! Order of execution here is important, do not change.
// Spells must be processed with event system BEFORE they go to _UpdateSpells.
// Or else we may have some SPELL_STATE_FINISHED spells stalled in pointers, that is bad.
@@ -12991,10 +12985,11 @@ void Unit::SetInCombatState(bool PvP, Unit* enemy, uint32 duration)
controlled->SetInCombatState(PvP, enemy, duration);
}
-#ifdef ELUNA
+
if (Player* player = this->ToPlayer())
- sEluna->OnPlayerEnterCombat(player, enemy);
-#endif
+ {
+ sScriptMgr->OnPlayerEnterCombat(player, enemy);
+ }
}
void Unit::ClearInCombat()
@@ -13025,10 +13020,11 @@ void Unit::ClearInCombat()
for (uint8 i = 0; i < MAX_RUNES; ++i)
player->SetGracePeriod(i, 0);
}
-#ifdef ELUNA
+
if (Player* player = this->ToPlayer())
- sEluna->OnPlayerLeaveCombat(player);
-#endif
+ {
+ sScriptMgr->OnPlayerLeaveCombat(player);
+ }
}
void Unit::ClearInPetCombat()
diff --git a/src/server/game/Events/GameEventMgr.cpp b/src/server/game/Events/GameEventMgr.cpp
index 11254ccd6b..ca11e041ab 100644
--- a/src/server/game/Events/GameEventMgr.cpp
+++ b/src/server/game/Events/GameEventMgr.cpp
@@ -34,10 +34,6 @@
#include "WorldPacket.h"
#include <time.h>
-#ifdef ELUNA
-#include "LuaEngine.h"
-#endif
-
GameEventMgr* GameEventMgr::instance()
{
static GameEventMgr instance;
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index 1c7243135a..a3581964bd 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -6003,12 +6003,10 @@ uint32 ObjectMgr::GetNearestTaxiNode(float x, float y, float z, uint32 mapid, ui
uint32 submask = 1 << ((i - 1) % 32);
// skip not taxi network nodes
-#ifndef ELUNA
- if ((sTaxiNodesMask[field] & submask) == 0)
-#else
if (field >= TaxiMaskSize || (sTaxiNodesMask[field] & submask) == 0)
-#endif
+ {
continue;
+ }
float dist2 = (node->x - x) * (node->x - x) + (node->y - y) * (node->y - y) + (node->z - z) * (node->z - z);
if (found)
diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp
index b10cc2f9d0..4925dc6f02 100644
--- a/src/server/game/Handlers/CharacterHandler.cpp
+++ b/src/server/game/Handlers/CharacterHandler.cpp
@@ -56,10 +56,6 @@
#include "WorldPacket.h"
#include "WorldSession.h"
-#ifdef ELUNA
-#include "LuaEngine.h"
-#endif
-
class LoginQueryHolder : public CharacterDatabaseQueryHolder
{
private:
diff --git a/src/server/game/Handlers/ChatHandler.cpp b/src/server/game/Handlers/ChatHandler.cpp
index df7e5c6879..58f61d0c92 100644
--- a/src/server/game/Handlers/ChatHandler.cpp
+++ b/src/server/game/Handlers/ChatHandler.cpp
@@ -39,10 +39,6 @@
#include "WorldPacket.h"
#include "WorldSession.h"
-#ifdef ELUNA
-#include "LuaEngine.h"
-#endif
-
inline bool isNasty(uint8 c)
{
if (c == '\t')
@@ -431,11 +427,13 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData)
if (type == CHAT_MSG_PARTY_LEADER && !group->IsLeader(sender->GetGUID()))
return;
- sScriptMgr->OnPlayerChat(GetPlayer(), type, lang, msg, group);
-#ifdef ELUNA
- if (!sEluna->OnChat(GetPlayer(), type, lang, msg, group))
+ if (!sScriptMgr->CanPlayerUseChat(GetPlayer(), type, lang, msg, group))
+ {
return;
-#endif
+ }
+
+ sScriptMgr->OnPlayerChat(GetPlayer(), type, lang, msg, group);
+
WorldPacket data;
ChatHandler::BuildChatPacket(data, ChatMsg(type), Language(lang), sender, nullptr, msg);
group->BroadcastPacket(&data, false, group->GetMemberGroup(GetPlayer()->GetGUID()));
@@ -447,12 +445,13 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData)
{
if (Guild* guild = sGuildMgr->GetGuildById(GetPlayer()->GetGuildId()))
{
+ if (!sScriptMgr->CanPlayerUseChat(GetPlayer(), type, lang, msg, guild))
+ {
+ return;
+ }
+
sScriptMgr->OnPlayerChat(GetPlayer(), type, lang, msg, guild);
-#ifdef ELUNA
- if (!sEluna->OnChat(GetPlayer(), type, lang, msg, guild))
- return;
-#endif
guild->BroadcastToGuild(this, false, msg, lang == LANG_ADDON ? LANG_ADDON : LANG_UNIVERSAL);
}
}
@@ -464,12 +463,13 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData)
{
if (Guild* guild = sGuildMgr->GetGuildById(GetPlayer()->GetGuildId()))
{
+ if (sScriptMgr->CanPlayerUseChat(GetPlayer(), type, lang, msg, guild))
+ {
+ return;
+ }
+
sScriptMgr->OnPlayerChat(GetPlayer(), type, lang, msg, guild);
-#ifdef ELUNA
- if (!sEluna->OnChat(GetPlayer(), type, lang, msg, guild))
- return;
-#endif
guild->BroadcastToGuild(this, true, msg, lang == LANG_ADDON ? LANG_ADDON : LANG_UNIVERSAL);
}
}
@@ -486,11 +486,13 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData)
return;
}
- sScriptMgr->OnPlayerChat(GetPlayer(), type, lang, msg, group);
-#ifdef ELUNA
- if (!sEluna->OnChat(GetPlayer(), type, lang, msg, group))
+ if (!sScriptMgr->CanPlayerUseChat(GetPlayer(), type, lang, msg, group))
+ {
return;
-#endif
+ }
+
+ sScriptMgr->OnPlayerChat(GetPlayer(), type, lang, msg, group);
+
WorldPacket data;
ChatHandler::BuildChatPacket(data, CHAT_MSG_RAID, Language(lang), sender, nullptr, msg);
group->BroadcastPacket(&data, false);
@@ -507,11 +509,13 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData)
return;
}
- sScriptMgr->OnPlayerChat(GetPlayer(), type, lang, msg, group);
-#ifdef ELUNA
- if (!sEluna->OnChat(GetPlayer(), type, lang, msg, group))
+ if (!sScriptMgr->CanPlayerUseChat(GetPlayer(), type, lang, msg, group))
+ {
return;
-#endif
+ }
+
+ sScriptMgr->OnPlayerChat(GetPlayer(), type, lang, msg, group);
+
WorldPacket data;
ChatHandler::BuildChatPacket(data, CHAT_MSG_RAID_LEADER, Language(lang), sender, nullptr, msg);
group->BroadcastPacket(&data, false);
@@ -523,13 +527,15 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData)
if (!group || !group->isRaidGroup() || !(group->IsLeader(GetPlayer()->GetGUID()) || group->IsAssistant(GetPlayer()->GetGUID())) || group->isBGGroup())
return;
- sScriptMgr->OnPlayerChat(GetPlayer(), type, lang, msg, group);
-#ifdef ELUNA
- if (!sEluna->OnChat(GetPlayer(), type, lang, msg, group))
+ if (!sScriptMgr->CanPlayerUseChat(GetPlayer(), type, lang, msg, group))
+ {
return;
-#endif
+ }
+
+ sScriptMgr->OnPlayerChat(GetPlayer(), type, lang, msg, group);
+
+ // In battleground, raid warning is sent only to players in battleground - code is ok
WorldPacket data;
- //in battleground, raid warning is sent only to players in battleground - code is ok
ChatHandler::BuildChatPacket(data, CHAT_MSG_RAID_WARNING, Language(lang), sender, nullptr, msg);
group->BroadcastPacket(&data, false);
}
@@ -541,11 +547,13 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData)
if (!group || !group->isBGGroup())
return;
- sScriptMgr->OnPlayerChat(GetPlayer(), type, lang, msg, group);
-#ifdef ELUNA
- if (!sEluna->OnChat(GetPlayer(), type, lang, msg, group))
+ if (!sScriptMgr->CanPlayerUseChat(GetPlayer(), type, lang, msg, group))
+ {
return;
-#endif
+ }
+
+ sScriptMgr->OnPlayerChat(GetPlayer(), type, lang, msg, group);
+
WorldPacket data;
ChatHandler::BuildChatPacket(data, CHAT_MSG_BATTLEGROUND, Language(lang), sender, nullptr, msg);
group->BroadcastPacket(&data, false);
@@ -558,11 +566,13 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData)
if (!group || !group->isBGGroup() || !group->IsLeader(GetPlayer()->GetGUID()))
return;
- sScriptMgr->OnPlayerChat(GetPlayer(), type, lang, msg, group);
-#ifdef ELUNA
- if (!sEluna->OnChat(GetPlayer(), type, lang, msg, group))
+ if (!sScriptMgr->CanPlayerUseChat(GetPlayer(), type, lang, msg, group))
+ {
return;
-#endif
+ }
+
+ sScriptMgr->OnPlayerChat(GetPlayer(), type, lang, msg, group);
+
WorldPacket data;
ChatHandler::BuildChatPacket(data, CHAT_MSG_BATTLEGROUND_LEADER, Language(lang), sender, nullptr, msg);
group->BroadcastPacket(&data, false);
@@ -583,12 +593,13 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData)
{
if (Channel* chn = cMgr->GetChannel(channel, sender))
{
+ if (!sScriptMgr->CanPlayerUseChat(sender, type, lang, msg, chn))
+ {
+ return;
+ }
+
sScriptMgr->OnPlayerChat(sender, type, lang, msg, chn);
-#ifdef ELUNA
- if (!sEluna->OnChat(sender, type, lang, msg, chn))
- return;
-#endif
chn->Say(sender->GetGUID(), msg.c_str(), lang);
}
}
@@ -615,11 +626,12 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData)
sender->ToggleAFK();
}
- sScriptMgr->OnPlayerChat(sender, type, lang, msg);
-#ifdef ELUNA
- if (!sEluna->OnChat(sender, type, lang, msg))
+ if (!sScriptMgr->CanPlayerUseChat(sender, type, lang, msg))
+ {
return;
-#endif
+ }
+
+ sScriptMgr->OnPlayerChat(sender, type, lang, msg);
}
break;
}
@@ -642,11 +654,13 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData)
sender->ToggleDND();
}
- sScriptMgr->OnPlayerChat(sender, type, lang, msg);
-#ifdef ELUNA
- if (!sEluna->OnChat(sender, type, lang, msg))
+ if (!sScriptMgr->CanPlayerUseChat(sender, type, lang, msg))
+ {
return;
-#endif
+ }
+
+ sScriptMgr->OnPlayerChat(sender, type, lang, msg);
+
break;
}
default:
diff --git a/src/server/game/Handlers/LootHandler.cpp b/src/server/game/Handlers/LootHandler.cpp
index 62645ce22e..deb4a848f9 100644
--- a/src/server/game/Handlers/LootHandler.cpp
+++ b/src/server/game/Handlers/LootHandler.cpp
@@ -26,13 +26,10 @@
#include "ObjectMgr.h"
#include "Opcodes.h"
#include "Player.h"
+#include "ScriptMgr.h"
#include "WorldPacket.h"
#include "WorldSession.h"
-#ifdef ELUNA
-#include "LuaEngine.h"
-#endif
-
void WorldSession::HandleAutostoreLootItemOpcode(WorldPacket& recvData)
{
LOG_DEBUG("network", "WORLD: CMSG_AUTOSTORE_LOOT_ITEM");
@@ -210,9 +207,9 @@ void WorldSession::HandleLootMoneyOpcode(WorldPacket& /*recvData*/)
data << uint8(1); // "You loot..."
SendPacket(&data);
}
-#ifdef ELUNA
- sEluna->OnLootMoney(player, loot->gold);
-#endif
+
+ sScriptMgr->OnLootMoney(player, loot->gold);
+
loot->gold = 0;
// Delete the money loot record from the DB
@@ -494,10 +491,6 @@ void WorldSession::HandleLootMasterGiveOpcode(WorldPacket& recvData)
target->SendNewItem(newitem, uint32(item.count), false, false, true);
target->UpdateLootAchievements(&item, loot);
-#ifdef ELUNA
- sEluna->OnLootItem(target, newitem, item.count, lootguid);
-#endif
-
// mark as looted
item.count = 0;
item.is_looted = true;
diff --git a/src/server/game/Handlers/MiscHandler.cpp b/src/server/game/Handlers/MiscHandler.cpp
index b78632302f..124479c3d9 100644
--- a/src/server/game/Handlers/MiscHandler.cpp
+++ b/src/server/game/Handlers/MiscHandler.cpp
@@ -51,10 +51,6 @@
#include "WorldSession.h"
#include <zlib.h>
-#ifdef ELUNA
-#include "LuaEngine.h"
-#endif
-
void WorldSession::HandleRepopRequestOpcode(WorldPacket& recv_data)
{
LOG_DEBUG("network", "WORLD: Recvd CMSG_REPOP_REQUEST Message");
@@ -79,10 +75,6 @@ void WorldSession::HandleRepopRequestOpcode(WorldPacket& recv_data)
GetPlayer()->KillPlayer();
}
-#ifdef ELUNA
- sEluna->OnRepop(GetPlayer());
-#endif
-
//this is spirit release confirm?
GetPlayer()->RemovePet(nullptr, PET_SAVE_NOT_IN_SLOT, true);
GetPlayer()->BuildPlayerRepop();
diff --git a/src/server/game/Handlers/QuestHandler.cpp b/src/server/game/Handlers/QuestHandler.cpp
index bf0598afe4..ed0524c532 100644
--- a/src/server/game/Handlers/QuestHandler.cpp
+++ b/src/server/game/Handlers/QuestHandler.cpp
@@ -31,10 +31,6 @@
#include "WorldPacket.h"
#include "WorldSession.h"
-#ifdef ELUNA
-#include "LuaEngine.h"
-#endif
-
void WorldSession::HandleQuestgiverStatusQueryOpcode(WorldPacket& recvData)
{
ObjectGuid guid;
@@ -93,11 +89,6 @@ void WorldSession::HandleQuestgiverHelloOpcode(WorldPacket& recvData)
//if (!creature->GetTransport()) // pussywizard: reverted with new spline (old: without this check, npc would stay in place and the transport would continue moving, so the npc falls off. NPCs on transports don't have waypoints, so stopmoving is not needed)
creature->StopMoving();
-#ifdef ELUNA
- if (sEluna->OnGossipHello(_player, creature))
- return;
-#endif
-
if (sScriptMgr->OnGossipHello(_player, creature))
return;
@@ -425,9 +416,9 @@ void WorldSession::HandleQuestLogRemoveQuest(WorldPacket& recvData)
_player->AbandonQuest(questId); // remove all quest items player received before abandoning quest.
_player->RemoveActiveQuest(questId);
_player->RemoveTimedAchievement(ACHIEVEMENT_TIMED_TYPE_QUEST, questId);
-#ifdef ELUNA
- sEluna->OnQuestAbandon(_player, questId);
-#endif
+
+ sScriptMgr->OnQuestAbandon(_player, questId);
+
LOG_DEBUG("network.opcode", "Player %s abandoned quest %u", _player->GetGUID().ToString().c_str(), questId);
// check if Quest Tracker is enabled
if (sWorld->getBoolConfig(CONFIG_QUEST_ENABLE_QUEST_TRACKER))
diff --git a/src/server/game/Handlers/SpellHandler.cpp b/src/server/game/Handlers/SpellHandler.cpp
index 7fbdef0a47..cd3ed0014a 100644
--- a/src/server/game/Handlers/SpellHandler.cpp
+++ b/src/server/game/Handlers/SpellHandler.cpp
@@ -32,10 +32,6 @@
#include "WorldPacket.h"
#include "WorldSession.h"
-#ifdef ELUNA
-#include "LuaEngine.h"
-#endif
-
void WorldSession::HandleClientCastFlags(WorldPacket& recvPacket, uint8 castFlags, SpellCastTargets& targets)
{
// some spell cast packet including more data (for projectiles?)
diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp
index bca3dc34a0..fa3da68be9 100644
--- a/src/server/game/Maps/Map.cpp
+++ b/src/server/game/Maps/Map.cpp
@@ -40,10 +40,6 @@
#include "VMapMgr2.h"
#include "Vehicle.h"
-#ifdef ELUNA
-#include "LuaEngine.h"
-#endif
-
union u_map_magic
{
char asChar[4];
@@ -2999,37 +2995,38 @@ void InstanceMap::AfterPlayerUnlinkFromMap()
void InstanceMap::CreateInstanceScript(bool load, std::string data, uint32 completedEncounterMask)
{
- if (instance_data != nullptr)
+ if (instance_data)
+ {
return;
-#ifdef ELUNA
- bool isElunaAI = false;
- instance_data = sEluna->GetInstanceData(this);
+ }
+
+ bool isOtherAI = false;
+
+ sScriptMgr->OnBeforeCreateInstanceScript(this, instance_data, load, data, completedEncounterMask);
+
if (instance_data)
- isElunaAI = true;
+ isOtherAI = true;
// if Eluna AI was fetched succesfully we should not call CreateInstanceData nor set the unused scriptID
- if (!isElunaAI)
+ if (!isOtherAI)
{
-#endif
InstanceTemplate const* mInstance = sObjectMgr->GetInstanceTemplate(GetId());
if (mInstance)
{
i_script_id = mInstance->ScriptId;
instance_data = sScriptMgr->CreateInstanceScript(this);
}
-#ifdef ELUNA
}
-#endif
if (!instance_data)
return;
-#ifdef ELUNA
// use mangos behavior if we are dealing with Eluna AI
// initialize should then be called only if load is false
- if (!isElunaAI || !load)
-#endif
+ if (!isOtherAI || !load)
+ {
instance_data->Initialize();
+ }
if (load)
{
diff --git a/src/server/game/Maps/MapInstanced.cpp b/src/server/game/Maps/MapInstanced.cpp
index 5fe2169cd8..ec002a3ecf 100644
--- a/src/server/game/Maps/MapInstanced.cpp
+++ b/src/server/game/Maps/MapInstanced.cpp
@@ -23,12 +23,9 @@
#include "MapMgr.h"
#include "ObjectMgr.h"
#include "Player.h"
+#include "ScriptMgr.h"
#include "VMapFactory.h"
-#ifdef ELUNA
-#include "LuaEngine.h"
-#endif
-
MapInstanced::MapInstanced(uint32 id) : Map(id, 0, DUNGEON_DIFFICULTY_NORMAL)
{
// initialize instanced maps list
@@ -253,22 +250,16 @@ BattlegroundMap* MapInstanced::CreateBattleground(uint32 InstanceId, Battlegroun
bool MapInstanced::DestroyInstance(InstancedMaps::iterator& itr)
{
itr->second->RemoveAllPlayers();
+
if (itr->second->HavePlayers())
{
++itr;
return false;
}
- itr->second->UnloadAll();
+ sScriptMgr->OnDestroyInstance(this, itr->second);
- // Free up the instance id and allow it to be reused for bgs and arenas (other instances are handled in the InstanceSaveMgr)
- //if (itr->second->IsBattlegroundOrArena())
- // sMapMgr->FreeInstanceId(itr->second->GetInstanceId());
-
-#ifdef ELUNA
- //todo:[ELUNA] I'm not sure this is right.
- sEluna->FreeInstanceId(itr->second->GetInstanceId());
-#endif
+ itr->second->UnloadAll();
// erase map
delete itr->second;
diff --git a/src/server/game/Maps/MapInstanced.h b/src/server/game/Maps/MapInstanced.h
index 749fac5fc5..f08c5687ac 100644
--- a/src/server/game/Maps/MapInstanced.h
+++ b/src/server/game/Maps/MapInstanced.h
@@ -26,7 +26,7 @@ class MapInstanced : public Map
{
friend class MapMgr;
public:
- typedef std::unordered_map< uint32, Map*> InstancedMaps;
+ using InstancedMaps = std::unordered_map<uint32, Map*>;
MapInstanced(uint32 id);
~MapInstanced() override {}
diff --git a/src/server/game/Maps/MapMgr.cpp b/src/server/game/Maps/MapMgr.cpp
index 39f4b55dc4..dd2956fc3b 100644
--- a/src/server/game/Maps/MapMgr.cpp
+++ b/src/server/game/Maps/MapMgr.cpp
@@ -36,10 +36,6 @@
#include "World.h"
#include "WorldPacket.h"
-#ifdef ELUNA
-#include "LuaEngine.h"
-#endif
-
MapMgr::MapMgr()
{
i_timer[3].SetInterval(sWorld->getIntConfig(CONFIG_INTERVAL_MAPUPDATE));
diff --git a/src/server/game/Modules/ModuleMgr.cpp b/src/server/game/Modules/ModuleMgr.cpp
new file mode 100644
index 0000000000..e5d34efc6b
--- /dev/null
+++ b/src/server/game/Modules/ModuleMgr.cpp
@@ -0,0 +1,42 @@
+/*
+ * 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 Affero General Public License as published by the
+ * Free Software Foundation; either version 3 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 Affero 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 <http://www.gnu.org/licenses/>.
+ */
+
+#include "ModuleMgr.h"
+#include "Log.h"
+#include "Tokenize.h"
+
+namespace
+{
+ std::string_view _modulesList = {};
+}
+
+void Acore::Module::SetEnableModulesList(std::string_view modulesList)
+{
+ _modulesList = modulesList;
+}
+
+std::vector<std::string_view> Acore::Module::GetEnableModulesList()
+{
+ std::vector<std::string_view> _list;
+
+ for (auto const& modName : Acore::Tokenize(_modulesList, ',', false))
+ {
+ _list.emplace_back(modName);
+ }
+
+ return _list;
+}
diff --git a/src/server/game/Modules/ModuleMgr.h b/src/server/game/Modules/ModuleMgr.h
new file mode 100644
index 0000000000..3513dc5deb
--- /dev/null
+++ b/src/server/game/Modules/ModuleMgr.h
@@ -0,0 +1,31 @@
+/*
+ * 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 Affero General Public License as published by the
+ * Free Software Foundation; either version 3 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 Affero 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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _MODULE_MGR_H_
+#define _MODULE_MGR_H_
+
+#include "Define.h"
+#include <string_view>
+#include <vector>
+
+namespace Acore::Module
+{
+ AC_COMMON_API void SetEnableModulesList(std::string_view modulesList);
+ AC_COMMON_API std::vector<std::string_view> GetEnableModulesList();
+}
+
+#endif
diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp
index 1ff0d7c3fe..ceb73d5503 100644
--- a/src/server/game/Scripting/ScriptMgr.cpp
+++ b/src/server/game/Scripting/ScriptMgr.cpp
@@ -35,11 +35,6 @@
#include "Vehicle.h"
#include "WorldPacket.h"
-#ifdef ELUNA
-#include "ElunaUtility.h"
-#include "LuaEngine.h"
-#endif
-
struct TSpellSummary
{
uint8 Targets; // set of enum SelectTarget
@@ -49,7 +44,10 @@ struct TSpellSummary
#include "ScriptMgrMacros.h"
ScriptMgr::ScriptMgr()
- : _scriptCount(0), _scheduledScripts(0), _script_loader_callback(nullptr) { }
+ : _scriptCount(0),
+ _scheduledScripts(0),
+ _script_loader_callback(nullptr),
+ _modules_loader_callback(nullptr) { }
ScriptMgr::~ScriptMgr() { }
@@ -69,7 +67,11 @@ void ScriptMgr::Initialize()
ASSERT(_script_loader_callback,
"Script loader callback wasn't registered!");
+ ASSERT(_modules_loader_callback,
+ "Modules loader callback wasn't registered!");
+
_script_loader_callback();
+ _modules_loader_callback();
}
void ScriptMgr::Unload()
@@ -373,31 +375,40 @@ void ScriptMgr::OnSocketClose(std::shared_ptr<WorldSocket> socket)
FOREACH_SCRIPT(ServerScript)->OnSocketClose(socket);
}
-void ScriptMgr::OnPacketReceive(WorldSession* session, WorldPacket const& packet)
+bool ScriptMgr::CanPacketReceive(WorldSession* session, WorldPacket const& packet)
{
if (SCR_REG_LST(ServerScript).empty())
- return;
+ return true;
WorldPacket copy(packet);
- FOREACH_SCRIPT(ServerScript)->OnPacketReceive(session, copy);
+
+ bool ret = true;
+ FOR_SCRIPTS_RET(ServerScript, itr, end, ret) // return true by default if not scripts
+ if (!itr->second->CanPacketReceive(session, copy))
+ ret = false; // we change ret value only when scripts return false
+
+ return ret;
}
-void ScriptMgr::OnPacketSend(WorldSession* session, WorldPacket const& packet)
+bool ScriptMgr::CanPacketSend(WorldSession* session, WorldPacket const& packet)
{
ASSERT(session);
if (SCR_REG_LST(ServerScript).empty())
- return;
+ return true;
WorldPacket copy(packet);
- FOREACH_SCRIPT(ServerScript)->OnPacketSend(session, copy);
+
+ bool ret = true;
+ FOR_SCRIPTS_RET(ServerScript, itr, end, ret) // return true by default if not scripts
+ if (!itr->second->CanPacketSend(session, copy))
+ ret = false; // we change ret value only when scripts return false
+
+ return ret;
}
void ScriptMgr::OnOpenStateChange(bool open)
{
-#ifdef ELUNA
- sEluna->OnOpenStateChange(open);
-#endif
FOREACH_SCRIPT(WorldScript)->OnOpenStateChange(open);
}
@@ -408,17 +419,11 @@ void ScriptMgr::OnLoadCustomDatabaseTable()
void ScriptMgr::OnBeforeConfigLoad(bool reload)
{
-#ifdef ELUNA
- sEluna->OnConfigLoad(reload, true);
-#endif
FOREACH_SCRIPT(WorldScript)->OnBeforeConfigLoad(reload);
}
void ScriptMgr::OnAfterConfigLoad(bool reload)
{
-#ifdef ELUNA
- sEluna->OnConfigLoad(reload, false);
-#endif
FOREACH_SCRIPT(WorldScript)->OnAfterConfigLoad(reload);
}
@@ -434,25 +439,16 @@ void ScriptMgr::OnMotdChange(std::string& newMotd)
void ScriptMgr::OnShutdownInitiate(ShutdownExitCode code, ShutdownMask mask)
{
-#ifdef ELUNA
- sEluna->OnShutdownInitiate(code, mask);
-#endif
FOREACH_SCRIPT(WorldScript)->OnShutdownInitiate(code, mask);
}
void ScriptMgr::OnShutdownCancel()
{
-#ifdef ELUNA
- sEluna->OnShutdownCancel();
-#endif
FOREACH_SCRIPT(WorldScript)->OnShutdownCancel();
}
void ScriptMgr::OnWorldUpdate(uint32 diff)
{
-#ifdef ELUNA
- sEluna->OnWorldUpdate(diff);
-#endif
FOREACH_SCRIPT(WorldScript)->OnUpdate(diff);
}
@@ -514,9 +510,7 @@ void ScriptMgr::OnCreateMap(Map* map)
{
ASSERT(map);
-#ifdef ELUNA
- sEluna->OnCreate(map);
-#endif
+ FOREACH_SCRIPT(AllMapScript)->OnCreateMap(map);
SCR_MAP_BGN(WorldMapScript, map, itr, end, entry, IsWorldMap);
itr->second->OnCreate(map);
@@ -535,9 +529,7 @@ void ScriptMgr::OnDestroyMap(Map* map)
{
ASSERT(map);
-#ifdef ELUNA
- sEluna->OnDestroy(map);
-#endif
+ FOREACH_SCRIPT(AllMapScript)->OnDestroyMap(map);
SCR_MAP_BGN(WorldMapScript, map, itr, end, entry, IsWorldMap);
itr->second->OnDestroy(map);
@@ -593,11 +585,6 @@ void ScriptMgr::OnPlayerEnterMap(Map* map, Player* player)
ASSERT(map);
ASSERT(player);
-#ifdef ELUNA
- sEluna->OnMapChanged(player);
- sEluna->OnPlayerEnter(map, player);
-#endif
-
FOREACH_SCRIPT(AllMapScript)->OnPlayerEnterAll(map, player);
FOREACH_SCRIPT(PlayerScript)->OnMapChanged(player);
@@ -620,10 +607,6 @@ void ScriptMgr::OnPlayerLeaveMap(Map* map, Player* player)
ASSERT(map);
ASSERT(player);
-#ifdef ELUNA
- sEluna->OnPlayerLeave(map, player);
-#endif
-
FOREACH_SCRIPT(AllMapScript)->OnPlayerLeaveAll(map, player);
SCR_MAP_BGN(WorldMapScript, map, itr, end, entry, IsWorldMap);
@@ -643,9 +626,7 @@ void ScriptMgr::OnMapUpdate(Map* map, uint32 diff)
{
ASSERT(map);
-#ifdef ELUNA
- sEluna->OnUpdate(map, diff);
-#endif
+ FOREACH_SCRIPT(AllMapScript)->OnMapUpdate(map, diff);
SCR_MAP_BGN(WorldMapScript, map, itr, end, entry, IsWorldMap);
itr->second->OnUpdate(map, diff);
@@ -677,10 +658,15 @@ bool ScriptMgr::OnQuestAccept(Player* player, Item* item, Quest const* quest)
ASSERT(item);
ASSERT(quest);
-#ifdef ELUNA
- if (sEluna->OnQuestAccept(player, item, quest))
+ bool ret = true;
+ FOR_SCRIPTS_RET(AllItemScript, itr, end, ret) // return true by default if not scripts
+ if (!itr->second->CanItemQuestAccept(player, item, quest))
+ ret = false; // we change ret value only when scripts return false
+
+ if (!ret)
+ {
return false;
-#endif
+ }
GET_SCRIPT_RET(ItemScript, item->GetScriptId(), tmpscript, false);
ClearGossipMenuFor(player);
@@ -692,10 +678,15 @@ bool ScriptMgr::OnItemUse(Player* player, Item* item, SpellCastTargets const& ta
ASSERT(player);
ASSERT(item);
-#ifdef ELUNA
- if (!sEluna->OnUse(player, item, targets))
+ bool ret = false;
+ FOR_SCRIPTS_RET(AllItemScript, itr, end, ret) // return true by default if not scripts
+ if (itr->second->CanItemUse(player, item, targets))
+ ret = true; // we change ret value only when scripts return false
+
+ if (ret)
+ {
return true;
-#endif
+ }
GET_SCRIPT_RET(ItemScript, item->GetScriptId(), tmpscript, false);
return tmpscript->OnUse(player, item, targets);
@@ -706,10 +697,15 @@ bool ScriptMgr::OnItemExpire(Player* player, ItemTemplate const* proto)
ASSERT(player);
ASSERT(proto);
-#ifdef ELUNA
- if (sEluna->OnExpire(player, proto))
+ bool ret = true;
+ FOR_SCRIPTS_RET(AllItemScript, itr, end, ret) // return true by default if not scripts
+ if (!itr->second->CanItemExpire(player, proto))
+ ret = false; // we change ret value only when scripts return false
+
+ if (!ret)
+ {
return false;
-#endif
+ }
GET_SCRIPT_RET(ItemScript, proto->ScriptId, tmpscript, false);
return tmpscript->OnExpire(player, proto);
@@ -719,10 +715,17 @@ bool ScriptMgr::OnItemRemove(Player* player, Item* item)
{
ASSERT(player);
ASSERT(item);
-#ifdef ELUNA
- if (sEluna->OnRemove(player, item))
+
+ bool ret = true;
+ FOR_SCRIPTS_RET(AllItemScript, itr, end, ret) // return true by default if not scripts
+ if (!itr->second->CanItemRemove(player, item))
+ ret = false; // we change ret value only when scripts return false
+
+ if (!ret)
+ {
return false;
-#endif
+ }
+
GET_SCRIPT_RET(ItemScript, item->GetScriptId(), tmpscript, false);
return tmpscript->OnRemove(player, item);
}
@@ -742,9 +745,9 @@ void ScriptMgr::OnGossipSelect(Player* player, Item* item, uint32 sender, uint32
{
ASSERT(player);
ASSERT(item);
-#ifdef ELUNA
- sEluna->HandleGossipSelectOption(player, item, sender, action, "");
-#endif
+
+ FOREACH_SCRIPT(AllItemScript)->OnItemGossipSelect(player, item, sender, action);
+
GET_SCRIPT(ItemScript, item->GetScriptId(), tmpscript);
tmpscript->OnGossipSelect(player, item, sender, action);
}
@@ -753,26 +756,20 @@ void ScriptMgr::OnGossipSelectCode(Player* player, Item* item, uint32 sender, ui
{
ASSERT(player);
ASSERT(item);
-#ifdef ELUNA
- sEluna->HandleGossipSelectOption(player, item, sender, action, code);
-#endif
+
+ FOREACH_SCRIPT(AllItemScript)->OnItemGossipSelectCode(player, item, sender, action, code);
+
GET_SCRIPT(ItemScript, item->GetScriptId(), tmpscript);
tmpscript->OnGossipSelectCode(player, item, sender, action, code);
}
void ScriptMgr::OnGossipSelect(Player* player, uint32 menu_id, uint32 sender, uint32 action)
{
-#ifdef ELUNA
- sEluna->HandleGossipSelectOption(player, menu_id, sender, action, "");
-#endif
FOREACH_SCRIPT(PlayerScript)->OnGossipSelect(player, menu_id, sender, action);
}
void ScriptMgr::OnGossipSelectCode(Player* player, uint32 menu_id, uint32 sender, uint32 action, const char* code)
{
-#ifdef ELUNA
- sEluna->HandleGossipSelectOption(player, menu_id, sender, action, code);
-#endif
FOREACH_SCRIPT(PlayerScript)->OnGossipSelectCode(player, menu_id, sender, action, code);
}
@@ -780,10 +777,17 @@ bool ScriptMgr::OnGossipHello(Player* player, Creature* creature)
{
ASSERT(player);
ASSERT(creature);
-#ifdef ELUNA
- if (sEluna->OnGossipHello(player, creature))
+
+ bool ret = false;
+ FOR_SCRIPTS_RET(AllCreatureScript, itr, end, ret) // return true by default if not scripts
+ if (itr->second->CanCreatureGossipHello(player, creature))
+ ret = true; // we change ret value only when scripts return false
+
+ if (ret)
+ {
return true;
-#endif
+ }
+
GET_SCRIPT_RET(CreatureScript, creature->GetScriptId(), tmpscript, false);
ClearGossipMenuFor(player);
return tmpscript->OnGossipHello(player, creature);
@@ -793,10 +797,17 @@ bool ScriptMgr::OnGossipSelect(Player* player, Creature* creature, uint32 sender
{
ASSERT(player);
ASSERT(creature);
-#ifdef ELUNA
- if (sEluna->OnGossipSelect(player, creature, sender, action))
+
+ bool ret = false;
+ FOR_SCRIPTS_RET(AllCreatureScript, itr, end, ret) // return true by default if not scripts
+ if (itr->second->CanCreatureGossipSelect(player, creature, sender, action))
+ ret = true; // we change ret value only when scripts return false
+
+ if (ret)
+ {
return true;
-#endif
+ }
+
GET_SCRIPT_RET(CreatureScript, creature->GetScriptId(), tmpscript, false);
return tmpscript->OnGossipSelect(player, creature, sender, action);
}
@@ -806,10 +817,17 @@ bool ScriptMgr::OnGossipSelectCode(Player* player, Creature* creature, uint32 se
ASSERT(player);
ASSERT(creature);
ASSERT(code);
-#ifdef ELUNA
- if (sEluna->OnGossipSelectCode(player, creature, sender, action, code))
+
+ bool ret = false;
+ FOR_SCRIPTS_RET(AllCreatureScript, itr, end, ret) // return true by default if not scripts
+ if (itr->second->CanCreatureGossipSelectCode(player, creature, sender, action, code))
+ ret = true; // we change ret value only when scripts return false
+
+ if (ret)
+ {
return true;
-#endif
+ }
+
GET_SCRIPT_RET(CreatureScript, creature->GetScriptId(), tmpscript, false);
return tmpscript->OnGossipSelectCode(player, creature, sender, action, code);
}
@@ -820,6 +838,16 @@ bool ScriptMgr::OnQuestAccept(Player* player, Creature* creature, Quest const* q
ASSERT(creature);
ASSERT(quest);
+ bool ret = false;
+ FOR_SCRIPTS_RET(AllCreatureScript, itr, end, ret) // return true by default if not scripts
+ if (itr->second->CanCreatureQuestAccept(player, creature, quest))
+ ret = true; // we change ret value only when scripts return false
+
+ if (ret)
+ {
+ return true;
+ }
+
GET_SCRIPT_RET(CreatureScript, creature->GetScriptId(), tmpscript, false);
ClearGossipMenuFor(player);
return tmpscript->OnQuestAccept(player, creature, quest);
@@ -852,13 +880,17 @@ bool ScriptMgr::OnQuestReward(Player* player, Creature* creature, Quest const* q
ASSERT(player);
ASSERT(creature);
ASSERT(quest);
-#ifdef ELUNA
- if (sEluna->OnQuestReward(player, creature, quest, opt))
+
+ bool ret = false;
+ FOR_SCRIPTS_RET(AllCreatureScript, itr, end, ret) // return true by default if not scripts
+ if (itr->second->CanCreatureQuestReward(player, creature, quest, opt))
+ ret = true; // we change ret value only when scripts return false
+
+ if (ret)
{
- ClearGossipMenuFor(player);
- return false;
+ return true;
}
-#endif
+
GET_SCRIPT_RET(CreatureScript, creature->GetScriptId(), tmpscript, false);
ClearGossipMenuFor(player);
return tmpscript->OnQuestReward(player, creature, quest, opt);
@@ -878,10 +910,14 @@ CreatureAI* ScriptMgr::GetCreatureAI(Creature* creature)
{
ASSERT(creature);
-#ifdef ELUNA
- if (CreatureAI* luaAI = sEluna->GetAI(creature))
- return luaAI;
-#endif
+ CreatureAI* ret = nullptr;
+ FOR_SCRIPTS_RET(AllCreatureScript, itr, end, ret) // return true by default if not scripts
+ ret = itr->second->GetCreatureAI(creature); // we change ret value only when scripts return false
+
+ if (ret)
+ {
+ return ret;
+ }
GET_SCRIPT_RET(CreatureScript, creature->GetScriptId(), tmpscript, nullptr);
return tmpscript->GetAI(creature);
@@ -897,16 +933,33 @@ void ScriptMgr::OnCreatureUpdate(Creature* creature, uint32 diff)
tmpscript->OnUpdate(creature, diff);
}
+void ScriptMgr::OnCreatureAddWorld(Creature* creature)
+{
+ ASSERT(creature);
+ FOREACH_SCRIPT(AllCreatureScript)->OnCreatureAddWorld(creature);
+}
+
+void ScriptMgr::OnCreatureRemoveWorld(Creature* creature)
+{
+ ASSERT(creature);
+ FOREACH_SCRIPT(AllCreatureScript)->OnCreatureRemoveWorld(creature);
+}
+
bool ScriptMgr::OnGossipHello(Player* player, GameObject* go)
{
ASSERT(player);
ASSERT(go);
-#ifdef ELUNA
- if (sEluna->OnGossipHello(player, go))
- return true;
- if (sEluna->OnGameObjectUse(player, go))
+
+ bool ret = false;
+ FOR_SCRIPTS_RET(AllGameObjectScript, itr, end, ret)
+ if (itr->second->CanGameObjectGossipHello(player, go))
+ ret = true;
+
+ if (ret)
+ {
return true;
-#endif
+ }
+
GET_SCRIPT_RET(GameObjectScript, go->GetScriptId(), tmpscript, false);
ClearGossipMenuFor(player);
return tmpscript->OnGossipHello(player, go);
@@ -916,10 +969,17 @@ bool ScriptMgr::OnGossipSelect(Player* player, GameObject* go, uint32 sender, ui
{
ASSERT(player);
ASSERT(go);
-#ifdef ELUNA
- if (sEluna->OnGossipSelect(player, go, sender, action))
+
+ bool ret = false;
+ FOR_SCRIPTS_RET(AllGameObjectScript, itr, end, ret)
+ if (itr->second->CanGameObjectGossipSelect(player, go, sender, action))
+ ret = true;
+
+ if (ret)
+ {
return true;
-#endif
+ }
+
GET_SCRIPT_RET(GameObjectScript, go->GetScriptId(), tmpscript, false);
return tmpscript->OnGossipSelect(player, go, sender, action);
}
@@ -929,10 +989,17 @@ bool ScriptMgr::OnGossipSelectCode(Player* player, GameObject* go, uint32 sender
ASSERT(player);
ASSERT(go);
ASSERT(code);
-#ifdef ELUNA
- if (sEluna->OnGossipSelectCode(player, go, sender, action, code))
+
+ bool ret = false;
+ FOR_SCRIPTS_RET(AllGameObjectScript, itr, end, ret)
+ if (itr->second->CanGameObjectGossipSelectCode(player, go, sender, action, code))
+ ret = true;
+
+ if (ret)
+ {
return true;
-#endif
+ }
+
GET_SCRIPT_RET(GameObjectScript, go->GetScriptId(), tmpscript, false);
return tmpscript->OnGossipSelectCode(player, go, sender, action, code);
}
@@ -943,6 +1010,16 @@ bool ScriptMgr::OnQuestAccept(Player* player, GameObject* go, Quest const* quest
ASSERT(go);
ASSERT(quest);
+ bool ret = false;
+ FOR_SCRIPTS_RET(AllGameObjectScript, itr, end, ret)
+ if (itr->second->CanGameObjectQuestAccept(player, go, quest))
+ ret = true;
+
+ if (ret)
+ {
+ return true;
+ }
+
GET_SCRIPT_RET(GameObjectScript, go->GetScriptId(), tmpscript, false);
ClearGossipMenuFor(player);
return tmpscript->OnQuestAccept(player, go, quest);
@@ -953,14 +1030,17 @@ bool ScriptMgr::OnQuestReward(Player* player, GameObject* go, Quest const* quest
ASSERT(player);
ASSERT(go);
ASSERT(quest);
-#ifdef ELUNA
- if (sEluna->OnQuestAccept(player, go, quest))
- return false;
-#endif
-#ifdef ELUNA
- if (sEluna->OnQuestReward(player, go, quest, opt))
- return false;
-#endif
+
+ bool ret = false;
+ FOR_SCRIPTS_RET(AllGameObjectScript, itr, end, ret)
+ if (itr->second->CanGameObjectQuestReward(player, go, quest, opt))
+ ret = true;
+
+ if (ret)
+ {
+ return true;
+ }
+
GET_SCRIPT_RET(GameObjectScript, go->GetScriptId(), tmpscript, false);
ClearGossipMenuFor(player);
return tmpscript->OnQuestReward(player, go, quest, opt);
@@ -980,6 +1060,8 @@ void ScriptMgr::OnGameObjectDestroyed(GameObject* go, Player* player)
{
ASSERT(go);
+ FOREACH_SCRIPT(AllGameObjectScript)->OnGameObjectDestroyed(go, player);
+
GET_SCRIPT(GameObjectScript, go->GetScriptId(), tmpscript);
tmpscript->OnDestroyed(go, player);
}
@@ -988,6 +1070,8 @@ void ScriptMgr::OnGameObjectDamaged(GameObject* go, Player* player)
{
ASSERT(go);
+ FOREACH_SCRIPT(AllGameObjectScript)->OnGameObjectDamaged(go, player);
+
GET_SCRIPT(GameObjectScript, go->GetScriptId(), tmpscript);
tmpscript->OnDamaged(go, player);
}
@@ -996,6 +1080,8 @@ void ScriptMgr::OnGameObjectLootStateChanged(GameObject* go, uint32 state, Unit*
{
ASSERT(go);
+ FOREACH_SCRIPT(AllGameObjectScript)->OnGameObjectLootStateChanged(go, state, unit);
+
GET_SCRIPT(GameObjectScript, go->GetScriptId(), tmpscript);
tmpscript->OnLootStateChanged(go, state, unit);
}
@@ -1004,6 +1090,8 @@ void ScriptMgr::OnGameObjectStateChanged(GameObject* go, uint32 state)
{
ASSERT(go);
+ FOREACH_SCRIPT(AllGameObjectScript)->OnGameObjectStateChanged(go, state);
+
GET_SCRIPT(GameObjectScript, go->GetScriptId(), tmpscript);
tmpscript->OnGameObjectStateChanged(go, state);
}
@@ -1012,9 +1100,7 @@ void ScriptMgr::OnGameObjectUpdate(GameObject* go, uint32 diff)
{
ASSERT(go);
-#ifdef ELUNA
- sEluna->UpdateAI(go, diff);
-#endif
+ FOREACH_SCRIPT(AllGameObjectScript)->OnGameObjectUpdate(go, diff);
GET_SCRIPT(GameObjectScript, go->GetScriptId(), tmpscript);
tmpscript->OnUpdate(go, diff);
@@ -1024,22 +1110,46 @@ GameObjectAI* ScriptMgr::GetGameObjectAI(GameObject* go)
{
ASSERT(go);
-#ifdef ELUNA
- sEluna->OnSpawn(go);
-#endif
+ GameObjectAI* ret = nullptr;
+ FOR_SCRIPTS_RET(AllGameObjectScript, itr, end, ret)
+ ret = itr->second->GetGameObjectAI(go);
+
+ if (ret)
+ {
+ return ret;
+ }
GET_SCRIPT_RET(GameObjectScript, go->GetScriptId(), tmpscript, nullptr);
return tmpscript->GetAI(go);
}
+void ScriptMgr::OnGameObjectAddWorld(GameObject* go)
+{
+ ASSERT(go);
+ FOREACH_SCRIPT(AllGameObjectScript)->OnGameObjectAddWorld(go);
+}
+
+void ScriptMgr::OnGameObjectRemoveWorld(GameObject* go)
+{
+ ASSERT(go);
+ FOREACH_SCRIPT(AllGameObjectScript)->OnGameObjectRemoveWorld(go);
+}
+
bool ScriptMgr::OnAreaTrigger(Player* player, AreaTrigger const* trigger)
{
ASSERT(player);
ASSERT(trigger);
-#ifdef ELUNA
- if (sEluna->OnAreaTrigger(player, trigger))
+
+ bool ret = true;
+ FOR_SCRIPTS_RET(ElunaScript, itr, end, ret) // return true by default if not scripts
+ if (!itr->second->CanAreaTrigger(player, trigger))
+ ret = false; // we change ret value only when scripts return false
+
+ if (!ret)
+ {
return false;
-#endif
+ }
+
GET_SCRIPT_RET(AreaTriggerScript, sObjectMgr->GetAreaTriggerScriptId(trigger->entry), tmpscript, false);
return tmpscript->OnTrigger(player, trigger);
}
@@ -1076,9 +1186,7 @@ void ScriptMgr::OnWeatherChange(Weather* weather, WeatherState state, float grad
{
ASSERT(weather);
-#ifdef ELUNA
- sEluna->OnChange(weather, weather->GetZone(), state, grade);
-#endif
+ FOREACH_SCRIPT(ElunaScript)->OnWeatherChange(weather, state, grade);
GET_SCRIPT(WeatherScript, weather->GetScriptId(), tmpscript);
tmpscript->OnChange(weather, state, grade);
@@ -1097,10 +1205,6 @@ void ScriptMgr::OnAuctionAdd(AuctionHouseObject* ah, AuctionEntry* entry)
ASSERT(ah);
ASSERT(entry);
-#ifdef ELUNA
- sEluna->OnAdd(ah, entry);
-#endif
-
FOREACH_SCRIPT(AuctionHouseScript)->OnAuctionAdd(ah, entry);
}
@@ -1109,10 +1213,6 @@ void ScriptMgr::OnAuctionRemove(AuctionHouseObject* ah, AuctionEntry* entry)
ASSERT(ah);
ASSERT(entry);
-#ifdef ELUNA
- sEluna->OnRemove(ah, entry);
-#endif
-
FOREACH_SCRIPT(AuctionHouseScript)->OnAuctionRemove(ah, entry);
}
@@ -1121,10 +1221,6 @@ void ScriptMgr::OnAuctionSuccessful(AuctionHouseObject* ah, AuctionEntry* entry)
ASSERT(ah);
ASSERT(entry);
-#ifdef ELUNA
- sEluna->OnSuccessful(ah, entry);
-#endif
-
FOREACH_SCRIPT(AuctionHouseScript)->OnAuctionSuccessful(ah, entry);
}
@@ -1133,10 +1229,6 @@ void ScriptMgr::OnAuctionExpire(AuctionHouseObject* ah, AuctionEntry* entry)
ASSERT(ah);
ASSERT(entry);
-#ifdef ELUNA
- sEluna->OnExpire(ah, entry);
-#endif
-
FOREACH_SCRIPT(AuctionHouseScript)->OnAuctionExpire(ah, entry);
}
@@ -1188,10 +1280,6 @@ void ScriptMgr::OnInstall(Vehicle* veh)
ASSERT(veh);
ASSERT(veh->GetBase()->GetTypeId() == TYPEID_UNIT);
-#ifdef ELUNA
- sEluna->OnInstall(veh);
-#endif
-
GET_SCRIPT(VehicleScript, veh->GetBase()->ToCreature()->GetScriptId(), tmpscript);
tmpscript->OnInstall(veh);
}
@@ -1201,10 +1289,6 @@ void ScriptMgr::OnUninstall(Vehicle* veh)
ASSERT(veh);
ASSERT(veh->GetBase()->GetTypeId() == TYPEID_UNIT);
-#ifdef ELUNA
- sEluna->OnUninstall(veh);
-#endif
-
GET_SCRIPT(VehicleScript, veh->GetBase()->ToCreature()->GetScriptId(), tmpscript);
tmpscript->OnUninstall(veh);
}
@@ -1224,10 +1308,6 @@ void ScriptMgr::OnInstallAccessory(Vehicle* veh, Creature* accessory)
ASSERT(veh->GetBase()->GetTypeId() == TYPEID_UNIT);
ASSERT(accessory);
-#ifdef ELUNA
- sEluna->OnInstallAccessory(veh, accessory);
-#endif
-
GET_SCRIPT(VehicleScript, veh->GetBase()->ToCreature()->GetScriptId(), tmpscript);
tmpscript->OnInstallAccessory(veh, accessory);
}
@@ -1238,10 +1318,6 @@ void ScriptMgr::OnAddPassenger(Vehicle* veh, Unit* passenger, int8 seatId)
ASSERT(veh->GetBase()->GetTypeId() == TYPEID_UNIT);
ASSERT(passenger);
-#ifdef ELUNA
- sEluna->OnAddPassenger(veh, passenger, seatId);
-#endif
-
GET_SCRIPT(VehicleScript, veh->GetBase()->ToCreature()->GetScriptId(), tmpscript);
tmpscript->OnAddPassenger(veh, passenger, seatId);
}
@@ -1252,10 +1328,6 @@ void ScriptMgr::OnRemovePassenger(Vehicle* veh, Unit* passenger)
ASSERT(veh->GetBase()->GetTypeId() == TYPEID_UNIT);
ASSERT(passenger);
-#ifdef ELUNA
- sEluna->OnRemovePassenger(veh, passenger);
-#endif
-
GET_SCRIPT(VehicleScript, veh->GetBase()->ToCreature()->GetScriptId(), tmpscript);
tmpscript->OnRemovePassenger(veh, passenger);
}
@@ -1311,20 +1383,19 @@ void ScriptMgr::OnRelocate(Transport* transport, uint32 waypointId, uint32 mapId
void ScriptMgr::OnStartup()
{
-#ifdef ELUNA
- sEluna->OnStartup();
-#endif
FOREACH_SCRIPT(WorldScript)->OnStartup();
}
void ScriptMgr::OnShutdown()
{
-#ifdef ELUNA
- sEluna->OnShutdown();
-#endif
FOREACH_SCRIPT(WorldScript)->OnShutdown();
}
+void ScriptMgr::OnBeforeWorldInitialized()
+{
+ FOREACH_SCRIPT(WorldScript)->OnBeforeWorldInitialized();
+}
+
bool ScriptMgr::OnCriteriaCheck(uint32 scriptId, Player* source, Unit* target, uint32 criteria_id)
{
ASSERT(source);
@@ -1357,9 +1428,6 @@ void ScriptMgr::OnPlayerReleasedGhost(Player* player)
void ScriptMgr::OnPVPKill(Player* killer, Player* killed)
{
-#ifdef ELUNA
- sEluna->OnPVPKill(killer, killed);
-#endif
FOREACH_SCRIPT(PlayerScript)->OnPVPKill(killer, killed);
}
@@ -1370,9 +1438,6 @@ void ScriptMgr::OnPlayerPVPFlagChange(Player* player, bool state)
void ScriptMgr::OnCreatureKill(Player* killer, Creature* killed)
{
-#ifdef ELUNA
- sEluna->OnCreatureKill(killer, killed);
-#endif
FOREACH_SCRIPT(PlayerScript)->OnCreatureKill(killer, killed);
}
@@ -1383,57 +1448,36 @@ void ScriptMgr::OnCreatureKilledByPet(Player* petOwner, Creature* killed)
void ScriptMgr::OnPlayerKilledByCreature(Creature* killer, Player* killed)
{
-#ifdef ELUNA
- sEluna->OnPlayerKilledByCreature(killer, killed);
-#endif
FOREACH_SCRIPT(PlayerScript)->OnPlayerKilledByCreature(killer, killed);
}
void ScriptMgr::OnPlayerLevelChanged(Player* player, uint8 oldLevel)
{
-#ifdef ELUNA
- sEluna->OnLevelChanged(player, oldLevel);
-#endif
FOREACH_SCRIPT(PlayerScript)->OnLevelChanged(player, oldLevel);
}
void ScriptMgr::OnPlayerFreeTalentPointsChanged(Player* player, uint32 points)
{
-#ifdef ELUNA
- sEluna->OnFreeTalentPointsChanged(player, points);
-#endif
FOREACH_SCRIPT(PlayerScript)->OnFreeTalentPointsChanged(player, points);
}
void ScriptMgr::OnPlayerTalentsReset(Player* player, bool noCost)
{
-#ifdef ELUNA
- sEluna->OnTalentsReset(player, noCost);
-#endif
FOREACH_SCRIPT(PlayerScript)->OnTalentsReset(player, noCost);
}
void ScriptMgr::OnPlayerMoneyChanged(Player* player, int32& amount)
{
-#ifdef ELUNA
- sEluna->OnMoneyChanged(player, amount);
-#endif
FOREACH_SCRIPT(PlayerScript)->OnMoneyChanged(player, amount);
}
void ScriptMgr::OnGivePlayerXP(Player* player, uint32& amount, Unit* victim)
{
-#ifdef ELUNA
- sEluna->OnGiveXP(player, amount, victim);
-#endif
FOREACH_SCRIPT(PlayerScript)->OnGiveXP(player, amount, victim);
}
void ScriptMgr::OnPlayerReputationChange(Player* player, uint32 factionID, int32& standing, bool incremental)
{
-#ifdef ELUNA
- sEluna->OnReputationChange(player, factionID, standing, incremental);
-#endif
FOREACH_SCRIPT(PlayerScript)->OnReputationChange(player, factionID, standing, incremental);
}
@@ -1454,25 +1498,16 @@ void ScriptMgr::OnPlayerForgotSpell(Player* player, uint32 spellID)
void ScriptMgr::OnPlayerDuelRequest(Player* target, Player* challenger)
{
-#ifdef ELUNA
- sEluna->OnDuelRequest(target, challenger);
-#endif
FOREACH_SCRIPT(PlayerScript)->OnDuelRequest(target, challenger);
}
void ScriptMgr::OnPlayerDuelStart(Player* player1, Player* player2)
{
-#ifdef ELUNA
- sEluna->OnDuelStart(player1, player2);
-#endif
FOREACH_SCRIPT(PlayerScript)->OnDuelStart(player1, player2);
}
void ScriptMgr::OnPlayerDuelEnd(Player* winner, Player* loser, DuelCompleteType type)
{
-#ifdef ELUNA
- sEluna->OnDuelEnd(winner, loser, type);
-#endif
FOREACH_SCRIPT(PlayerScript)->OnDuelEnd(winner, loser, type);
}
@@ -1508,25 +1543,16 @@ void ScriptMgr::OnPlayerChat(Player* player, uint32 type, uint32 lang, std::stri
void ScriptMgr::OnPlayerEmote(Player* player, uint32 emote)
{
-#ifdef ELUNA
- sEluna->OnEmote(player, emote);
-#endif
FOREACH_SCRIPT(PlayerScript)->OnEmote(player, emote);
}
void ScriptMgr::OnPlayerTextEmote(Player* player, uint32 textEmote, uint32 emoteNum, ObjectGuid guid)
{
-#ifdef ELUNA
- sEluna->OnTextEmote(player, textEmote, emoteNum, guid);
-#endif
FOREACH_SCRIPT(PlayerScript)->OnTextEmote(player, textEmote, emoteNum, guid);
}
void ScriptMgr::OnPlayerSpellCast(Player* player, Spell* spell, bool skipCheck)
{
-#ifdef ELUNA
- sEluna->OnSpellCast(player, spell, skipCheck);
-#endif
FOREACH_SCRIPT(PlayerScript)->OnSpellCast(player, spell, skipCheck);
}
@@ -1542,9 +1568,6 @@ void ScriptMgr::OnPlayerUpdate(Player* player, uint32 p_time)
void ScriptMgr::OnPlayerLogin(Player* player)
{
-#ifdef ELUNA
- sEluna->OnLogin(player);
-#endif
FOREACH_SCRIPT(PlayerScript)->OnLogin(player);
}
@@ -1555,33 +1578,21 @@ void ScriptMgr::OnPlayerLoadFromDB(Player* player)
void ScriptMgr::OnPlayerLogout(Player* player)
{
-#ifdef ELUNA
- sEluna->OnLogout(player);
-#endif
FOREACH_SCRIPT(PlayerScript)->OnLogout(player);
}
void ScriptMgr::OnPlayerCreate(Player* player)
{
-#ifdef ELUNA
- sEluna->OnCreate(player);
-#endif
FOREACH_SCRIPT(PlayerScript)->OnCreate(player);
}
void ScriptMgr::OnPlayerSave(Player* player)
{
-#ifdef ELUNA
- sEluna->OnSave(player);
-#endif
FOREACH_SCRIPT(PlayerScript)->OnSave(player);
}
void ScriptMgr::OnPlayerDelete(ObjectGuid guid, uint32 accountId)
{
-#ifdef ELUNA
- sEluna->OnDelete(guid.GetCounter());
-#endif
FOREACH_SCRIPT(PlayerScript)->OnDelete(guid, accountId);
}
@@ -1592,17 +1603,11 @@ void ScriptMgr::OnPlayerFailedDelete(ObjectGuid guid, uint32 accountId)
void ScriptMgr::OnPlayerBindToInstance(Player* player, Difficulty difficulty, uint32 mapid, bool permanent)
{
-#ifdef ELUNA
- sEluna->OnBindToInstance(player, difficulty, mapid, permanent);
-#endif
FOREACH_SCRIPT(PlayerScript)->OnBindToInstance(player, difficulty, mapid, permanent);
}
void ScriptMgr::OnPlayerUpdateZone(Player* player, uint32 newZone, uint32 newArea)
{
-#ifdef ELUNA
- sEluna->OnUpdateZone(player, newZone, newArea);
-#endif
FOREACH_SCRIPT(PlayerScript)->OnUpdateZone(player, newZone, newArea);
}
@@ -1745,9 +1750,6 @@ void ScriptMgr::OnQuestRewardItem(Player* player, Item* item, uint32 count)
void ScriptMgr::OnFirstLogin(Player* player)
{
-#ifdef ELUNA
- sEluna->OnFirstLogin(player);
-#endif
FOREACH_SCRIPT(PlayerScript)->OnFirstLogin(player);
}
@@ -1832,90 +1834,57 @@ void ScriptMgr::OnFailedPasswordChange(uint32 accountId)
// Guild
void ScriptMgr::OnGuildAddMember(Guild* guild, Player* player, uint8& plRank)
{
-#ifdef ELUNA
- sEluna->OnAddMember(guild, player, plRank);
-#endif
FOREACH_SCRIPT(GuildScript)->OnAddMember(guild, player, plRank);
}
void ScriptMgr::OnGuildRemoveMember(Guild* guild, Player* player, bool isDisbanding, bool isKicked)
{
-#ifdef ELUNA
- sEluna->OnRemoveMember(guild, player, isDisbanding);
-#endif
FOREACH_SCRIPT(GuildScript)->OnRemoveMember(guild, player, isDisbanding, isKicked);
}
void ScriptMgr::OnGuildMOTDChanged(Guild* guild, const std::string& newMotd)
{
-#ifdef ELUNA
- sEluna->OnMOTDChanged(guild, newMotd);
-#endif
FOREACH_SCRIPT(GuildScript)->OnMOTDChanged(guild, newMotd);
}
void ScriptMgr::OnGuildInfoChanged(Guild* guild, const std::string& newInfo)
{
-#ifdef ELUNA
- sEluna->OnInfoChanged(guild, newInfo);
-#endif
FOREACH_SCRIPT(GuildScript)->OnInfoChanged(guild, newInfo);
}
void ScriptMgr::OnGuildCreate(Guild* guild, Player* leader, const std::string& name)
{
-#ifdef ELUNA
- sEluna->OnCreate(guild, leader, name);
-#endif
FOREACH_SCRIPT(GuildScript)->OnCreate(guild, leader, name);
}
void ScriptMgr::OnGuildDisband(Guild* guild)
{
-#ifdef ELUNA
- sEluna->OnDisband(guild);
-#endif
FOREACH_SCRIPT(GuildScript)->OnDisband(guild);
}
void ScriptMgr::OnGuildMemberWitdrawMoney(Guild* guild, Player* player, uint32& amount, bool isRepair)
{
-#ifdef ELUNA
- sEluna->OnMemberWitdrawMoney(guild, player, amount, isRepair);
-#endif
FOREACH_SCRIPT(GuildScript)->OnMemberWitdrawMoney(guild, player, amount, isRepair);
}
void ScriptMgr::OnGuildMemberDepositMoney(Guild* guild, Player* player, uint32& amount)
{
-#ifdef ELUNA
- sEluna->OnMemberDepositMoney(guild, player, amount);
-#endif
FOREACH_SCRIPT(GuildScript)->OnMemberDepositMoney(guild, player, amount);
}
void ScriptMgr::OnGuildItemMove(Guild* guild, Player* player, Item* pItem, bool isSrcBank, uint8 srcContainer, uint8 srcSlotId,
bool isDestBank, uint8 destContainer, uint8 destSlotId)
{
-#ifdef ELUNA
- sEluna->OnItemMove(guild, player, pItem, isSrcBank, srcContainer, srcSlotId, isDestBank, destContainer, destSlotId);
-#endif
FOREACH_SCRIPT(GuildScript)->OnItemMove(guild, player, pItem, isSrcBank, srcContainer, srcSlotId, isDestBank, destContainer, destSlotId);
}
void ScriptMgr::OnGuildEvent(Guild* guild, uint8 eventType, ObjectGuid::LowType playerGuid1, ObjectGuid::LowType playerGuid2, uint8 newRank)
{
-#ifdef ELUNA
- sEluna->OnEvent(guild, eventType, playerGuid1, playerGuid2, newRank);
-#endif
FOREACH_SCRIPT(GuildScript)->OnEvent(guild, eventType, playerGuid1, playerGuid2, newRank);
}
void ScriptMgr::OnGuildBankEvent(Guild* guild, uint8 eventType, uint8 tabId, ObjectGuid::LowType playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId)
{
-#ifdef ELUNA
- sEluna->OnBankEvent(guild, eventType, tabId, playerGuid, itemOrMoney, itemStackCount, destTabId);
-#endif
FOREACH_SCRIPT(GuildScript)->OnBankEvent(guild, eventType, tabId, playerGuid, itemOrMoney, itemStackCount, destTabId);
}
@@ -1923,45 +1892,30 @@ void ScriptMgr::OnGuildBankEvent(Guild* guild, uint8 eventType, uint8 tabId, Obj
void ScriptMgr::OnGroupAddMember(Group* group, ObjectGuid guid)
{
ASSERT(group);
-#ifdef ELUNA
- sEluna->OnAddMember(group, guid);
-#endif
FOREACH_SCRIPT(GroupScript)->OnAddMember(group, guid);
}
void ScriptMgr::OnGroupInviteMember(Group* group, ObjectGuid guid)
{
ASSERT(group);
-#ifdef ELUNA
- sEluna->OnInviteMember(group, guid);
-#endif
FOREACH_SCRIPT(GroupScript)->OnInviteMember(group, guid);
}
void ScriptMgr::OnGroupRemoveMember(Group* group, ObjectGuid guid, RemoveMethod method, ObjectGuid kicker, const char* reason)
{
ASSERT(group);
-#ifdef ELUNA
- sEluna->OnRemoveMember(group, guid, method);
-#endif
FOREACH_SCRIPT(GroupScript)->OnRemoveMember(group, guid, method, kicker, reason);
}
void ScriptMgr::OnGroupChangeLeader(Group* group, ObjectGuid newLeaderGuid, ObjectGuid oldLeaderGuid)
{
ASSERT(group);
-#ifdef ELUNA
- sEluna->OnChangeLeader(group, newLeaderGuid, oldLeaderGuid);
-#endif
FOREACH_SCRIPT(GroupScript)->OnChangeLeader(group, newLeaderGuid, oldLeaderGuid);
}
void ScriptMgr::OnGroupDisband(Group* group)
{
ASSERT(group);
-#ifdef ELUNA
- sEluna->OnDisband(group);
-#endif
FOREACH_SCRIPT(GroupScript)->OnDisband(group);
}
@@ -2223,17 +2177,11 @@ void ScriptMgr::OnCalcMaxDuration(Aura const* aura, int32& maxDuration)
void ScriptMgr::OnGameEventStart(uint16 EventID)
{
-#ifdef ELUNA
- sEluna->OnGameEventStart(EventID);
-#endif
FOREACH_SCRIPT(GameEventScript)->OnStart(EventID);
}
void ScriptMgr::OnGameEventStop(uint16 EventID)
{
-#ifdef ELUNA
- sEluna->OnGameEventStop(EventID);
-#endif
FOREACH_SCRIPT(GameEventScript)->OnStop(EventID);
}
@@ -2666,6 +2614,87 @@ void ScriptMgr::OnSetServerSideVisibilityDetect(Player* player, ServerSideVisibi
FOREACH_SCRIPT(PlayerScript)->OnSetServerSideVisibilityDetect(player, type, sec);
}
+void ScriptMgr::OnPlayerResurrect(Player* player, float restore_percent, bool applySickness)
+{
+ FOREACH_SCRIPT(PlayerScript)->OnPlayerResurrect(player, restore_percent, applySickness);
+}
+
+bool ScriptMgr::CanPlayerUseChat(Player* player, uint32 type, uint32 language, std::string& msg)
+{
+ bool ret = true;
+
+ FOR_SCRIPTS_RET(PlayerScript, itr, end, ret) // return true by default if not scripts
+ if (!itr->second->CanPlayerUseChat(player, type, language, msg))
+ ret = false; // we change ret value only when scripts return false
+
+ return ret;
+}
+
+bool ScriptMgr::CanPlayerUseChat(Player* player, uint32 type, uint32 language, std::string& msg, Player* receiver)
+{
+ bool ret = true;
+
+ FOR_SCRIPTS_RET(PlayerScript, itr, end, ret) // return true by default if not scripts
+ if (!itr->second->CanPlayerUseChat(player, type, language, msg, receiver))
+ ret = false; // we change ret value only when scripts return false
+
+ return ret;
+}
+
+bool ScriptMgr::CanPlayerUseChat(Player* player, uint32 type, uint32 language, std::string& msg, Group* group)
+{
+ bool ret = true;
+
+ FOR_SCRIPTS_RET(PlayerScript, itr, end, ret) // return true by default if not scripts
+ if (!itr->second->CanPlayerUseChat(player, type, language, msg, group))
+ ret = false; // we change ret value only when scripts return false
+
+ return ret;
+}
+
+bool ScriptMgr::CanPlayerUseChat(Player* player, uint32 type, uint32 language, std::string& msg, Guild* guild)
+{
+ bool ret = true;
+
+ FOR_SCRIPTS_RET(PlayerScript, itr, end, ret) // return true by default if not scripts
+ if (!itr->second->CanPlayerUseChat(player, type, language, msg, guild))
+ ret = false; // we change ret value only when scripts return false
+
+ return ret;
+}
+
+bool ScriptMgr::CanPlayerUseChat(Player* player, uint32 type, uint32 language, std::string& msg, Channel* channel)
+{
+ bool ret = true;
+
+ FOR_SCRIPTS_RET(PlayerScript, itr, end, ret) // return true by default if not scripts
+ if (!itr->second->CanPlayerUseChat(player, type, language, msg, channel))
+ ret = false; // we change ret value only when scripts return false
+
+ return ret;
+}
+
+void ScriptMgr::OnPlayerLearnTalents(Player* player, uint32 talentId, uint32 talentRank, uint32 spellid)
+{
+ FOREACH_SCRIPT(PlayerScript)->OnPlayerLearnTalents(player, talentId, talentRank, spellid);
+}
+
+void ScriptMgr::OnPlayerEnterCombat(Player* player, Unit* enemy)
+{
+ FOREACH_SCRIPT(PlayerScript)->OnPlayerEnterCombat(player, enemy);
+}
+
+void ScriptMgr::OnPlayerLeaveCombat(Player* player)
+{
+ FOREACH_SCRIPT(PlayerScript)->OnPlayerLeaveCombat(player);
+}
+
+void ScriptMgr::OnQuestAbandon(Player* player, uint32 questId)
+{
+ FOREACH_SCRIPT(PlayerScript)->OnQuestAbandon(player, questId);
+}
+
+// Player anti cheat
void ScriptMgr::AnticheatSetSkipOnePacketForASH(Player* player, bool apply)
{
FOREACH_SCRIPT(PlayerScript)->AnticheatSetSkipOnePacketForASH(player, apply);
@@ -2816,6 +2845,12 @@ bool ScriptMgr::IsCustomBuildValuesUpdate(Unit const* unit, uint8 updateType, By
return ret;
}
+void ScriptMgr::OnUnitUpdate(Unit* unit, uint32 diff)
+{
+ FOREACH_SCRIPT(UnitScript)->OnUnitUpdate(unit, diff);
+}
+
+// BG scripts
void ScriptMgr::OnQueueUpdate(BattlegroundQueue* queue, BattlegroundBracketId bracket_id, bool isRated, uint32 arenaRatedTeamId)
{
FOREACH_SCRIPT(BGScript)->OnQueueUpdate(queue, bracket_id, isRated, arenaRatedTeamId);
@@ -2854,6 +2889,21 @@ bool ScriptMgr::OnBeforeSendExitMessageArenaQueue(BattlegroundQueue* queue, Grou
return ret;
}
+void ScriptMgr::OnBattlegroundEnd(Battleground* bg, TeamId winnerTeam)
+{
+ FOREACH_SCRIPT(BGScript)->OnBattlegroundEnd(bg, winnerTeam);
+}
+
+void ScriptMgr::OnBattlegroundDestroy(Battleground* bg)
+{
+ FOREACH_SCRIPT(BGScript)->OnBattlegroundDestroy(bg);
+}
+
+void ScriptMgr::OnBattlegroundCreate(Battleground* bg)
+{
+ FOREACH_SCRIPT(BGScript)->OnBattlegroundCreate(bg);
+}
+
bool ScriptMgr::CanModAuraEffectDamageDone(AuraEffect const* auraEff, Unit* target, AuraApplication const* aurApp, uint8 mode, bool apply)
{
bool ret = true;
@@ -2929,6 +2979,22 @@ void ScriptMgr::OnBeforeAuraRankForLevel(SpellInfo const* spellInfo, SpellInfo c
FOREACH_SCRIPT(SpellSC)->OnBeforeAuraRankForLevel(spellInfo, latestSpellInfo, level);
}
+void ScriptMgr::OnDummyEffect(WorldObject* caster, uint32 spellID, SpellEffIndex effIndex, GameObject* gameObjTarget)
+{
+ FOREACH_SCRIPT(SpellSC)->OnDummyEffect(caster, spellID, effIndex, gameObjTarget);
+}
+
+void ScriptMgr::OnDummyEffect(WorldObject* caster, uint32 spellID, SpellEffIndex effIndex, Creature* creatureTarget)
+{
+ FOREACH_SCRIPT(SpellSC)->OnDummyEffect(caster, spellID, effIndex, creatureTarget);
+}
+
+void ScriptMgr::OnDummyEffect(WorldObject* caster, uint32 spellID, SpellEffIndex effIndex, Item* itemTarget)
+{
+ FOREACH_SCRIPT(SpellSC)->OnDummyEffect(caster, spellID, effIndex, itemTarget);
+}
+
+// AchievementScript
void ScriptMgr::SetRealmCompleted(AchievementEntry const* achievement)
{
FOREACH_SCRIPT(AchievementScript)->SetRealmCompleted(achievement);
@@ -3145,9 +3211,9 @@ void ScriptMgr::OnPlayerSetPhase(const AuraEffect* auraEff, AuraApplication cons
FOREACH_SCRIPT(MiscScript)->OnPlayerSetPhase(auraEff, aurApp, mode, apply, newPhase);
}
-void ScriptMgr::OnHandleDevCommand(Player* player, std::string& argstr)
+void ScriptMgr::GetDialogStatus(Player* player, Object* questgiver)
{
- FOREACH_SCRIPT(CommandSC)->OnHandleDevCommand(player, argstr);
+ FOREACH_SCRIPT(MiscScript)->GetDialogStatus(player, questgiver);
}
void ScriptMgr::OnAfterDatabasesLoaded(uint32 updateFlags)
@@ -3155,6 +3221,79 @@ void ScriptMgr::OnAfterDatabasesLoaded(uint32 updateFlags)
FOREACH_SCRIPT(DatabaseScript)->OnAfterDatabasesLoaded(updateFlags);
}
+// Command script custom
+void ScriptMgr::OnHandleDevCommand(Player* player, std::string& argstr)
+{
+ FOREACH_SCRIPT(CommandSC)->OnHandleDevCommand(player, argstr);
+}
+
+bool ScriptMgr::CanExecuteCommand(ChatHandler& handler, std::string_view cmdStr)
+{
+ bool ret = true;
+
+ FOR_SCRIPTS_RET(CommandSC, itr, end, ret) // return true by default if not scripts
+ if (!itr->second->CanExecuteCommand(handler, cmdStr))
+ ret = false; // we change ret value only when scripts return false
+
+ return ret;
+}
+
+// World object
+void ScriptMgr::OnWorldObjectDestroy(WorldObject* object)
+{
+ ASSERT(object);
+ FOREACH_SCRIPT(WorldObjectScript)->OnWorldObjectDestroy(object);
+}
+
+void ScriptMgr::OnWorldObjectCreate(WorldObject* object)
+{
+ ASSERT(object);
+ FOREACH_SCRIPT(WorldObjectScript)->OnWorldObjectCreate(object);
+}
+
+void ScriptMgr::OnWorldObjectSetMap(WorldObject* object, Map* map)
+{
+ ASSERT(object);
+ FOREACH_SCRIPT(WorldObjectScript)->OnWorldObjectSetMap(object, map);
+}
+
+void ScriptMgr::OnWorldObjectResetMap(WorldObject* object)
+{
+ ASSERT(object);
+ FOREACH_SCRIPT(WorldObjectScript)->OnWorldObjectResetMap(object);
+}
+
+void ScriptMgr::OnWorldObjectUpdate(WorldObject* object, uint32 diff)
+{
+ ASSERT(object);
+ FOREACH_SCRIPT(WorldObjectScript)->OnWorldObjectUpdate(object, diff);
+}
+
+// Pet
+void ScriptMgr::OnPetAddToWorld(Pet* pet)
+{
+ ASSERT(pet);
+ FOREACH_SCRIPT(PetScript)->OnPetAddToWorld(pet);
+}
+
+// Loot
+void ScriptMgr::OnLootMoney(Player* player, uint32 gold)
+{
+ ASSERT(player);
+ FOREACH_SCRIPT(LootScript)->OnLootMoney(player, gold);
+}
+
+// Map script
+void ScriptMgr::OnBeforeCreateInstanceScript(InstanceMap* instanceMap, InstanceScript* instanceData, bool load, std::string data, uint32 completedEncounterMask)
+{
+ FOREACH_SCRIPT(AllMapScript)->OnBeforeCreateInstanceScript(instanceMap, instanceData, load, data, completedEncounterMask);
+}
+
+void ScriptMgr::OnDestroyInstance(MapInstanced* mapInstanced, Map* map)
+{
+ FOREACH_SCRIPT(AllMapScript)->OnDestroyInstance(mapInstanced, map);
+}
+
///-
AllMapScript::AllMapScript(const char* name)
: ScriptObject(name)
@@ -3438,6 +3577,31 @@ DatabaseScript::DatabaseScript(const char* name) : ScriptObject(name)
ScriptRegistry<DatabaseScript>::AddScript(this);
}
+WorldObjectScript::WorldObjectScript(const char* name) : ScriptObject(name)
+{
+ ScriptRegistry<WorldObjectScript>::AddScript(this);
+}
+
+LootScript::LootScript(const char* name) : ScriptObject(name)
+{
+ ScriptRegistry<LootScript>::AddScript(this);
+}
+
+ElunaScript::ElunaScript(const char* name) : ScriptObject(name)
+{
+ ScriptRegistry<ElunaScript>::AddScript(this);
+}
+
+AllItemScript::AllItemScript(const char* name) : ScriptObject(name)
+{
+ ScriptRegistry<AllItemScript>::AddScript(this);
+}
+
+AllGameObjectScript::AllGameObjectScript(const char* name) : ScriptObject(name)
+{
+ ScriptRegistry<AllGameObjectScript>::AddScript(this);
+}
+
// Specialize for each script type class like so:
template class ScriptRegistry<SpellScriptLoader>;
template class ScriptRegistry<ServerScript>;
@@ -3480,3 +3644,8 @@ template class ScriptRegistry<PetScript>;
template class ScriptRegistry<ArenaScript>;
template class ScriptRegistry<CommandSC>;
template class ScriptRegistry<DatabaseScript>;
+template class ScriptRegistry<WorldObjectScript>;
+template class ScriptRegistry<LootScript>;
+template class ScriptRegistry<ElunaScript>;
+template class ScriptRegistry<AllItemScript>;
+template class ScriptRegistry<AllGameObjectScript>;
diff --git a/src/server/game/Scripting/ScriptMgr.h b/src/server/game/Scripting/ScriptMgr.h
index 9f93024548..f0622cca01 100644
--- a/src/server/game/Scripting/ScriptMgr.h
+++ b/src/server/game/Scripting/ScriptMgr.h
@@ -43,43 +43,44 @@ class Battleground;
class BattlegroundMap;
class BattlegroundQueue;
class Channel;
+class ChatHandler;
class Creature;
class CreatureAI;
class DynamicObject;
class GameObject;
class GameObjectAI;
-class Guild;
class GridMap;
class Group;
+class Guild;
class InstanceMap;
class InstanceScript;
class Item;
class Map;
+class MotionTransport;
class OutdoorPvP;
class Player;
class Quest;
class ScriptMgr;
class Spell;
-class SpellScript;
-class SpellInfo;
class SpellCastTargets;
-class Transport;
+class SpellInfo;
+class SpellScript;
class StaticTransport;
-class MotionTransport;
+class Transport;
class Unit;
class Vehicle;
+class WorldObject;
class WorldPacket;
class WorldSocket;
-class WorldObject;
struct AchievementCriteriaData;
struct AuctionEntry;
-struct ConditionSourceInfo;
struct Condition;
+struct ConditionSourceInfo;
struct DungeonProgressionRequirements;
+struct GroupQueueInfo;
struct ItemTemplate;
struct OutdoorPvPData;
-struct GroupQueueInfo;
struct TargetInfo;
namespace Acore::ChatCommands
@@ -167,13 +168,24 @@ public:
// being open; it is not.
virtual void OnSocketClose(std::shared_ptr<WorldSocket> /*socket*/) { }
- // Called when a packet is sent to a client. The packet object is a copy of the original packet, so reading
- // and modifying it is safe.
- virtual void OnPacketSend(WorldSession* /*session*/, WorldPacket& /*packet*/) { }
+ /**
+ * @brief This hook called when a packet is sent to a client. The packet object is a copy of the original packet, so reading and modifying it is safe.
+ *
+ * @param session Contains information about the WorldSession
+ * @param packet Contains information about the WorldPacket
+ * @return True if you want to continue sending the packet, false if you want to disallow sending the packet
+ */
+ [[nodiscard]] virtual bool CanPacketSend(WorldSession* /*session*/, WorldPacket& /*packet*/) { return true; }
- // Called when a (valid) packet is received by a client. The packet object is a copy of the original packet, so
- // reading and modifying it is safe. Make sure to check WorldSession pointer before usage, it might be null in case of auth packets
- virtual void OnPacketReceive(WorldSession* /*session*/, WorldPacket& /*packet*/) { }
+ /**
+ * @brief Called when a (valid) packet is received by a client. The packet object is a copy of the original packet, so
+ * reading and modifying it is safe. Make sure to check WorldSession pointer before usage, it might be null in case of auth packets
+ *
+ * @param session Contains information about the WorldSession
+ * @param packet Contains information about the WorldPacket
+ * @return True if you want to continue receive the packet, false if you want to disallow receive the packet
+ */
+ [[nodiscard]] virtual bool CanPacketReceive(WorldSession* /*session*/, WorldPacket& /*packet*/) { return true; }
};
class WorldScript : public ScriptObject
@@ -217,7 +229,12 @@ public:
*
* @param version The cache version that we will be sending to the Client.
*/
- virtual void OnBeforeFinalizePlayerWorldSession(uint32& /*cacheVersion*/) {}
+ virtual void OnBeforeFinalizePlayerWorldSession(uint32& /*cacheVersion*/) { }
+
+ /**
+ * @brief This hook runs after all scripts loading and before itialized
+ */
+ virtual void OnBeforeWorldInitialized() { }
};
class FormulaScript : public ScriptObject
@@ -426,6 +443,14 @@ public:
[[nodiscard]] virtual bool CanSetPhaseMask(Unit const* /*unit*/, uint32 /*newPhaseMask*/, bool /*update*/) { return true; }
[[nodiscard]] virtual bool IsCustomBuildValuesUpdate(Unit const* /*unit*/, uint8 /*updateType*/, ByteBuffer& /*fieldBuffer*/, Player const* /*target*/, uint16 /*index*/) { return false; }
+
+ /**
+ * @brief This hook runs in Unit::Update
+ *
+ * @param unit Contains information about the Unit
+ * @param diff Contains information about the diff time
+ */
+ virtual void OnUnitUpdate(Unit* /*unit*/, uint32 /*diff*/) { }
};
class MovementHandlerScript : public ScriptObject
@@ -444,11 +469,62 @@ protected:
AllMapScript(const char* name);
public:
- // Called when a player enters any Map
+ /**
+ * @brief This hook called when a player enters any Map
+ *
+ * @param map Contains information about the Map
+ * @param player Contains information about the Player
+ */
virtual void OnPlayerEnterAll(Map* /*map*/, Player* /*player*/) { }
- // Called when a player leave any Map
+ /**
+ * @brief This hook called when a player leave any Map
+ *
+ * @param map Contains information about the Map
+ * @param player Contains information about the Player
+ */
virtual void OnPlayerLeaveAll(Map* /*map*/, Player* /*player*/) { }
+
+ /**
+ * @brief This hook called before create instance script
+ *
+ * @param instanceMap Contains information about the WorldSession
+ * @param instanceData Contains information about the WorldPacket
+ * @param load if true loading instance save data
+ * @param data Contains information about the instance save data
+ * @param completedEncounterMask Contains information about the completed encouter mask
+ */
+ virtual void OnBeforeCreateInstanceScript(InstanceMap* /*instanceMap*/, InstanceScript* /*instanceData*/, bool /*load*/, std::string /*data*/, uint32 /*completedEncounterMask*/) { }
+
+ /**
+ * @brief This hook called before destroy instance
+ *
+ * @param mapInstanced Contains information about the MapInstanced
+ * @param map Contains information about the Map
+ */
+ virtual void OnDestroyInstance(MapInstanced* /*mapInstanced*/, Map* /*map*/) { }
+
+ /**
+ * @brief This hook called before creating map
+ *
+ * @param map Contains information about the Map
+ */
+ virtual void OnCreateMap(Map* /*map*/) { }
+
+ /**
+ * @brief This hook called before destroing map
+ *
+ * @param map Contains information about the Map
+ */
+ virtual void OnDestroyMap(Map* /*map*/) { }
+
+ /**
+ * @brief This hook called before updating map
+ *
+ * @param map Contains information about the Map
+ * @param diff Contains information about the diff time
+ */
+ virtual void OnMapUpdate(Map* /*map*/, uint32 /*diff*/) { }
};
class AllCreatureScript : public ScriptObject
@@ -462,6 +538,147 @@ public:
// Called from End of Creature SelectLevel.
virtual void Creature_SelectLevel(const CreatureTemplate* /*cinfo*/, Creature* /*creature*/) { }
+
+ /**
+ * @brief This hook runs after add creature in world
+ *
+ * @param creature Contains information about the Creature
+ */
+ virtual void OnCreatureAddWorld(Creature* /*creature*/) { }
+
+ /**
+ * @brief This hook runs after remove creature in world
+ *
+ * @param creature Contains information about the Creature
+ */
+ virtual void OnCreatureRemoveWorld(Creature* /*creature*/) { }
+
+ /**
+ * @brief This hook called when a player opens a gossip dialog with the creature.
+ *
+ * @param player Contains information about the Player
+ * @param creature Contains information about the Creature
+ *
+ * @return False if you want to continue, true if you want to disable
+ */
+ [[nodiscard]] virtual bool CanCreatureGossipHello(Player* /*player*/, Creature* /*creature*/) { return false; }
+
+ /**
+ * @brief This hook called when a player selects a gossip item in the creature's gossip menu.
+ *
+ * @param player Contains information about the Player
+ * @param creature Contains information about the Creature
+ * @param sender Contains information about the sender type
+ * @param action Contains information about the action id
+ *
+ * @return False if you want to continue, true if you want to disable
+ */
+ [[nodiscard]] virtual bool CanCreatureGossipSelect(Player* /*player*/, Creature* /*creature*/, uint32 /*sender*/, uint32 /*action*/) { return false; }
+
+ /**
+ * @brief This hook called when a player selects a gossip with a code in the creature's gossip menu.
+ *
+ * @param player Contains information about the Player
+ * @param creature Contains information about the Creature
+ * @param sender Contains information about the sender type
+ * @param action Contains information about the action id
+ * @param code Contains information about the code entered
+ *
+ * @return True if you want to continue, false if you want to disable
+ */
+ [[nodiscard]] virtual bool CanCreatureGossipSelectCode(Player* /*player*/, Creature* /*creature*/, uint32 /*sender*/, uint32 /*action*/, const char* /*code*/) { return false; }
+
+ // Called when a player accepts a quest from the creature.
+ [[nodiscard]] virtual bool CanCreatureQuestAccept(Player* /*player*/, Creature* /*creature*/, Quest const* /*quest*/) { return false; }
+
+ // Called when a player selects a quest reward.
+ [[nodiscard]] virtual bool CanCreatureQuestReward(Player* /*player*/, Creature* /*creature*/, Quest const* /*quest*/, uint32 /*opt*/) { return false; }
+
+ // Called when a CreatureAI object is needed for the creature.
+ [[nodiscard]] virtual CreatureAI* GetCreatureAI(Creature* /*creature*/) const { return nullptr; }
+};
+
+class AllItemScript : public ScriptObject
+{
+protected:
+ AllItemScript(const char* name);
+
+public:
+ // Called when a player accepts a quest from the item.
+ [[nodiscard]] virtual bool CanItemQuestAccept(Player* /*player*/, Item* /*item*/, Quest const* /*quest*/) { return true; }
+
+ // Called when a player uses the item.
+ [[nodiscard]] virtual bool CanItemUse(Player* /*player*/, Item* /*item*/, SpellCastTargets const& /*targets*/) { return false; }
+
+ // Called when the item is destroyed.
+ [[nodiscard]] virtual bool CanItemRemove(Player* /*player*/, Item* /*item*/) { return true; }
+
+ // Called when the item expires (is destroyed).
+ [[nodiscard]] virtual bool CanItemExpire(Player* /*player*/, ItemTemplate const* /*proto*/) { return true; }
+
+ // Called when a player selects an option in an item gossip window
+ virtual void OnItemGossipSelect(Player* /*player*/, Item* /*item*/, uint32 /*sender*/, uint32 /*action*/) { }
+
+ // Called when a player selects an option in an item gossip window
+ virtual void OnItemGossipSelectCode(Player* /*player*/, Item* /*item*/, uint32 /*sender*/, uint32 /*action*/, const char* /*code*/) { }
+};
+
+class AllGameObjectScript : public ScriptObject
+{
+protected:
+ AllGameObjectScript(const char* name);
+
+public:
+ /**
+ * @brief This hook runs after add game object in world
+ *
+ * @param go Contains information about the GameObject
+ */
+ virtual void OnGameObjectAddWorld(GameObject* /*go*/) { }
+
+ /**
+ * @brief This hook runs after remove game object in world
+ *
+ * @param go Contains information about the GameObject
+ */
+ virtual void OnGameObjectRemoveWorld(GameObject* /*go*/) { }
+
+ /**
+ * @brief This hook runs after remove game object in world
+ *
+ * @param go Contains information about the GameObject
+ */
+ virtual void OnGameObjectUpdate(GameObject* /*go*/, uint32 /*diff*/) { }
+
+ // Called when a player opens a gossip dialog with the gameobject.
+ [[nodiscard]] virtual bool CanGameObjectGossipHello(Player* /*player*/, GameObject* /*go*/) { return false; }
+
+ // Called when a player selects a gossip item in the gameobject's gossip menu.
+ [[nodiscard]] virtual bool CanGameObjectGossipSelect(Player* /*player*/, GameObject* /*go*/, uint32 /*sender*/, uint32 /*action*/) { return false; }
+
+ // Called when a player selects a gossip with a code in the gameobject's gossip menu.
+ [[nodiscard]] virtual bool CanGameObjectGossipSelectCode(Player* /*player*/, GameObject* /*go*/, uint32 /*sender*/, uint32 /*action*/, const char* /*code*/) { return false; }
+
+ // Called when a player accepts a quest from the gameobject.
+ [[nodiscard]] virtual bool CanGameObjectQuestAccept(Player* /*player*/, GameObject* /*go*/, Quest const* /*quest*/) { return false; }
+
+ // Called when a player selects a quest reward.
+ [[nodiscard]] virtual bool CanGameObjectQuestReward(Player* /*player*/, GameObject* /*go*/, Quest const* /*quest*/, uint32 /*opt*/) { return false; }
+
+ // Called when the game object is destroyed (destructible buildings only).
+ virtual void OnGameObjectDestroyed(GameObject* /*go*/, Player* /*player*/) { }
+
+ // Called when the game object is damaged (destructible buildings only).
+ virtual void OnGameObjectDamaged(GameObject* /*go*/, Player* /*player*/) { }
+
+ // Called when the game object loot state is changed.
+ virtual void OnGameObjectLootStateChanged(GameObject* /*go*/, uint32 /*state*/, Unit* /*unit*/) { }
+
+ // Called when the game object state is changed.
+ virtual void OnGameObjectStateChanged(GameObject* /*go*/, uint32 /*state*/) { }
+
+ // Called when a GameObjectAI object is needed for the gameobject.
+ virtual GameObjectAI* GetGameObjectAI(GameObject* /*go*/) const { return nullptr; }
};
class CreatureScript : public ScriptObject, public UpdatableScript<Creature>
@@ -1064,6 +1281,105 @@ public:
virtual void OnSetServerSideVisibilityDetect(Player* /*player*/, ServerSideVisibilityType& /*type*/, AccountTypes& /*sec*/) { }
+ virtual void OnPlayerResurrect(Player* /*player*/, float /*restore_percent*/, bool /*applySickness*/) { }
+
+ /**
+ * @brief This hook called before player sending message in default chat
+ *
+ * @param player Contains information about the Player sender
+ * @param type Contains information about the chat message type
+ * @param language Contains information about the language type
+ * @param msg Contains information about the message
+ *
+ * @return True if you want to continue sending the message, false if you want to disable sending the message
+ */
+ [[nodiscard]] virtual bool CanPlayerUseChat(Player* /*player*/, uint32 /*type*/, uint32 /*language*/, std::string& /*msg*/) { return true; }
+
+ /**
+ * @brief This hook called before player sending message to other player via private
+ *
+ * @param player Contains information about the Player sender
+ * @param type Contains information about the chat message type
+ * @param language Contains information about the language type
+ * @param msg Contains information about the message
+ * @param receiver Contains information about the Player receiver
+ *
+ * @return True if you want to continue sending the message, false if you want to disable sending the message
+ */
+ [[nodiscard]] virtual bool CanPlayerUseChat(Player* /*player*/, uint32 /*type*/, uint32 /*language*/, std::string& /*msg*/, Player* /*receiver*/) { return true; }
+
+ /**
+ * @brief This hook called before player sending message to group
+ *
+ * @param player Contains information about the Player sender
+ * @param type Contains information about the chat message type
+ * @param language Contains information about the language type
+ * @param msg Contains information about the message
+ * @param group Contains information about the Group
+ *
+ * @return True if you want to continue sending the message, false if you want to disable sending the message
+ */
+ [[nodiscard]] virtual bool CanPlayerUseChat(Player* /*player*/, uint32 /*type*/, uint32 /*language*/, std::string& /*msg*/, Group* /*group*/) { return true; }
+
+ /**
+ * @brief This hook called before player sending message to guild
+ *
+ * @param player Contains information about the Player sender
+ * @param type Contains information about the chat message type
+ * @param language Contains information about the language type
+ * @param msg Contains information about the message
+ * @param guild Contains information about the Guild
+ *
+ * @return True if you want to continue sending the message, false if you want to disable sending the message
+ */
+ [[nodiscard]] virtual bool CanPlayerUseChat(Player* /*player*/, uint32 /*type*/, uint32 /*language*/, std::string& /*msg*/, Guild* /*guild*/) { return true; }
+
+ /**
+ * @brief This hook called before player sending message to channel
+ *
+ * @param player Contains information about the Player sender
+ * @param type Contains information about the chat message type
+ * @param language Contains information about the language type
+ * @param msg Contains information about the message
+ * @param channel Contains information about the Channel
+ *
+ * @return True if you want to continue sending the message, false if you want to disable sending the message
+ */
+ [[nodiscard]] virtual bool CanPlayerUseChat(Player* /*player*/, uint32 /*type*/, uint32 /*language*/, std::string& /*msg*/, Channel* /*channel*/) { return true; }
+
+ /**
+ * @brief This hook called after player learning talents
+ *
+ * @param player Contains information about the Player
+ * @param talentId Contains information about the talent id
+ * @param talentRank Contains information about the talent rank
+ * @param spellid Contains information about the spell id
+ */
+ virtual void OnPlayerLearnTalents(Player* /*player*/, uint32 /*talentId*/, uint32 /*talentRank*/, uint32 /*spellid*/) { }
+
+ /**
+ * @brief This hook called after player entering combat
+ *
+ * @param player Contains information about the Player
+ * @param Unit Contains information about the Unit
+ */
+ virtual void OnPlayerEnterCombat(Player* /*player*/, Unit* /*enemy*/) { }
+
+ /**
+ * @brief This hook called after player leave combat
+ *
+ * @param player Contains information about the Player
+ */
+ virtual void OnPlayerLeaveCombat(Player* /*player*/) { }
+
+ /**
+ * @brief This hook called after player abandoning quest
+ *
+ * @param player Contains information about the Player
+ * @param questId Contains information about the quest id
+ */
+ virtual void OnQuestAbandon(Player* /*player*/, uint32 /*questId*/) { }
+
// Passive Anticheat System
virtual void AnticheatSetSkipOnePacketForASH(Player* /*player*/, bool /*apply*/) { }
virtual void AnticheatSetCanFlybyServer(Player* /*player*/, bool /*apply*/) { }
@@ -1211,7 +1527,11 @@ protected:
public:
[[nodiscard]] bool IsDatabaseBound() const override { return false; }
- // Start Battlegroud
+ /**
+ * @brief This hook runs before start Battleground
+ *
+ * @param bg Contains information about the Battleground
+ */
virtual void OnBattlegroundStart(Battleground* /*bg*/) { }
// End Battleground
@@ -1262,6 +1582,28 @@ public:
* @return True if you want to continue sending the message, false if you want to disable the message
*/
[[nodiscard]] virtual bool OnBeforeSendExitMessageArenaQueue(BattlegroundQueue* /*queue*/, GroupQueueInfo* /*ginfo*/) { return true; }
+
+ /**
+ * @brief This hook runs after end Battleground
+ *
+ * @param bg Contains information about the Battleground
+ * @param TeamId Contains information about the winneer team
+ */
+ virtual void OnBattlegroundEnd(Battleground* /*bg*/, TeamId /*winner team*/) { }
+
+ /**
+ * @brief This hook runs before Battleground destroy
+ *
+ * @param bg Contains information about the Battleground
+ */
+ virtual void OnBattlegroundDestroy(Battleground* /*bg*/) { }
+
+ /**
+ * @brief This hook runs after Battleground create
+ *
+ * @param bg Contains information about the Battleground
+ */
+ virtual void OnBattlegroundCreate(Battleground* /*bg*/) { }
};
class ArenaTeamScript : public ScriptObject
@@ -1307,6 +1649,36 @@ public:
virtual void OnRemoveAuraScaleTargets(Spell* /*spell*/, TargetInfo& /*targetInfo*/, uint8 /*auraScaleMask*/, bool& /*needErase*/) { }
virtual void OnBeforeAuraRankForLevel(SpellInfo const* /*spellInfo*/, SpellInfo const* /*latestSpellInfo*/, uint8 /*level*/) { }
+
+ /**
+ * @brief This hook called after spell dummy effect
+ *
+ * @param caster Contains information about the WorldObject
+ * @param spellID Contains information about the spell id
+ * @param effIndex Contains information about the SpellEffIndex
+ * @param gameObjTarget Contains information about the GameObject
+ */
+ virtual void OnDummyEffect(WorldObject* /*caster*/, uint32 /*spellID*/, SpellEffIndex /*effIndex*/, GameObject* /*gameObjTarget*/) { }
+
+ /**
+ * @brief This hook called after spell dummy effect
+ *
+ * @param caster Contains information about the WorldObject
+ * @param spellID Contains information about the spell id
+ * @param effIndex Contains information about the SpellEffIndex
+ * @param creatureTarget Contains information about the Creature
+ */
+ virtual void OnDummyEffect(WorldObject* /*caster*/, uint32 /*spellID*/, SpellEffIndex /*effIndex*/, Creature* /*creatureTarget*/) { }
+
+ /**
+ * @brief This hook called after spell dummy effect
+ *
+ * @param caster Contains information about the WorldObject
+ * @param spellID Contains information about the spell id
+ * @param effIndex Contains information about the SpellEffIndex
+ * @param itemTarget Contains information about the Item
+ */
+ virtual void OnDummyEffect(WorldObject* /*caster*/, uint32 /*spellID*/, SpellEffIndex /*effIndex*/, Item* /*itemTarget*/) { }
};
// this class can be used to be extended by Modules
@@ -1381,6 +1753,13 @@ public:
[[nodiscard]] virtual bool CanUnlearnSpellDefault(Pet* /*pet*/, SpellInfo const* /*spellEntry*/) { return true; }
[[nodiscard]] virtual bool CanResetTalents(Pet* /*pet*/) { return true; }
+
+ /**
+ * @brief This hook called after add pet in world
+ *
+ * @param pet Contains information about the Pet
+ */
+ virtual void OnPetAddToWorld(Pet* /*pet*/) { }
};
class ArenaScript : public ScriptObject
@@ -1443,6 +1822,14 @@ public:
virtual void OnPlayerSetPhase(const AuraEffect* /*auraEff*/, AuraApplication const* /*aurApp*/, uint8 /*mode*/, bool /*apply*/, uint32& /*newPhase*/) { }
virtual void OnInstanceSave(InstanceSave* /*instanceSave*/) { }
+
+ /**
+ * @brief This hook called before get Quest Dialog Status
+ *
+ * @param player Contains information about the Player
+ * @param questgiver Contains information about the Object
+ */
+ virtual void GetDialogStatus(Player* /*player*/, Object* /*questgiver*/) { }
};
class CommandSC : public ScriptObject
@@ -1455,7 +1842,15 @@ public:
bool IsDatabaseBound() const { return false; }
- virtual void OnHandleDevCommand(Player* /*player*/, std::string& /*argstr*/) { }
+ virtual void OnHandleDevCommand(Player* /*player*/, std::string& /*argstr*/) { }
+
+ /**
+ * @brief This hook runs execute chat command
+ *
+ * @param handler Contains information about the ChatHandler
+ * @param cmdStr Contains information about the command name
+ */
+ [[nodiscard]] virtual bool CanExecuteCommand(ChatHandler& /*handler*/, std::string_view /*cmdStr*/) { return true; }
};
class DatabaseScript : public ScriptObject
@@ -1468,7 +1863,93 @@ public:
bool IsDatabaseBound() const { return false; }
- virtual void OnAfterDatabasesLoaded(uint32 /*updateFlags*/) {}
+ virtual void OnAfterDatabasesLoaded(uint32 /*updateFlags*/) { }
+};
+
+class WorldObjectScript : public ScriptObject
+{
+protected:
+
+ WorldObjectScript(const char* name);
+
+public:
+
+ bool IsDatabaseBound() const { return false; }
+
+ /**
+ * @brief This hook called before destroy world object
+ *
+ * @param object Contains information about the WorldObject
+ */
+ virtual void OnWorldObjectDestroy(WorldObject* /*object*/) { }
+
+ /**
+ * @brief This hook called after create world object
+ *
+ * @param object Contains information about the WorldObject
+ */
+ virtual void OnWorldObjectCreate(WorldObject* /*object*/) { }
+
+ /**
+ * @brief This hook called after world object set to map
+ *
+ * @param object Contains information about the WorldObject
+ */
+ virtual void OnWorldObjectSetMap(WorldObject* /*object*/, Map* /*map*/ ) { }
+
+ /**
+ * @brief This hook called after world object reset
+ *
+ * @param object Contains information about the WorldObject
+ */
+ virtual void OnWorldObjectResetMap(WorldObject* /*object*/) { }
+
+ /**
+ * @brief This hook called after world object update
+ *
+ * @param object Contains information about the WorldObject
+ * @param diff Contains information about the diff time
+ */
+ virtual void OnWorldObjectUpdate(WorldObject* /*object*/, uint32 /*diff*/) { }
+};
+
+class LootScript : public ScriptObject
+{
+protected:
+
+ LootScript(const char* name);
+
+public:
+
+ bool IsDatabaseBound() const { return false; }
+
+ /**
+ * @brief This hook called before money loot
+ *
+ * @param player Contains information about the Player
+ * @param gold Contains information about money
+ */
+ virtual void OnLootMoney(Player* /*player*/, uint32 /*gold*/) { }
+};
+
+class ElunaScript : public ScriptObject
+{
+protected:
+
+ ElunaScript(const char* name);
+
+public:
+ /**
+ * @brief This hook called when the weather changes in the zone this script is associated with.
+ *
+ * @param weather Contains information about the Weather
+ * @param state Contains information about the WeatherState
+ * @param grade Contains information about the grade
+ */
+ virtual void OnWeatherChange(Weather* /*weather*/, WeatherState /*state*/, float /*grade*/) { }
+
+ // Called when the area trigger is activated by a player.
+ [[nodiscard]] virtual bool CanAreaTrigger(Player* /*player*/, AreaTrigger const* /*trigger*/) { return false; }
};
// Manages registration, loading, and execution of scripts.
@@ -1493,6 +1974,7 @@ public: /* Initialization */
uint32 GetScriptCount() const { return _scriptCount; }
typedef void(*ScriptLoaderCallbackType)();
+ typedef void(*ModulesLoaderCallbackType)();
/// Sets the script loader callback which is invoked to load scripts
/// (Workaround for circular dependency game <-> scripts)
@@ -1501,6 +1983,13 @@ public: /* Initialization */
_script_loader_callback = script_loader_callback;
}
+ /// Sets the modules loader callback which is invoked to load modules
+ /// (Workaround for circular dependency game <-> modules)
+ void SetModulesLoader(ModulesLoaderCallbackType script_loader_callback)
+ {
+ _modules_loader_callback = script_loader_callback;
+ }
+
public: /* Unloading */
void Unload();
@@ -1514,8 +2003,8 @@ public: /* ServerScript */
void OnNetworkStop();
void OnSocketOpen(std::shared_ptr<WorldSocket> socket);
void OnSocketClose(std::shared_ptr<WorldSocket> socket);
- void OnPacketReceive(WorldSession* session, WorldPacket const& packet);
- void OnPacketSend(WorldSession* session, WorldPacket const& packet);
+ bool CanPacketReceive(WorldSession* session, WorldPacket const& packet);
+ bool CanPacketSend(WorldSession* session, WorldPacket const& packet);
public: /* WorldScript */
void OnLoadCustomDatabaseTable();
@@ -1529,6 +2018,7 @@ public: /* WorldScript */
void OnWorldUpdate(uint32 diff);
void OnStartup();
void OnShutdown();
+ void OnBeforeWorldInitialized();
public: /* FormulaScript */
void OnHonorCalculation(float& honor, uint8 level, float multiplier);
@@ -1573,6 +2063,8 @@ public: /* CreatureScript */
uint32 GetDialogStatus(Player* player, Creature* creature);
CreatureAI* GetCreatureAI(Creature* creature);
void OnCreatureUpdate(Creature* creature, uint32 diff);
+ void OnCreatureAddWorld(Creature* creature);
+ void OnCreatureRemoveWorld(Creature* creature);
public: /* GameObjectScript */
bool OnGossipHello(Player* player, GameObject* go);
@@ -1587,6 +2079,8 @@ public: /* GameObjectScript */
void OnGameObjectStateChanged(GameObject* go, uint32 state);
void OnGameObjectUpdate(GameObject* go, uint32 diff);
GameObjectAI* GetGameObjectAI(GameObject* go);
+ void OnGameObjectAddWorld(GameObject* go);
+ void OnGameObjectRemoveWorld(GameObject* go);
public: /* AreaTriggerScript */
bool OnAreaTrigger(Player* player, AreaTrigger const* trigger);
@@ -1773,6 +2267,18 @@ public: /* PlayerScript */
bool CanInitTrade(Player* player, Player* target);
void OnSetServerSideVisibility(Player* player, ServerSideVisibilityType& type, AccountTypes& sec);
void OnSetServerSideVisibilityDetect(Player* player, ServerSideVisibilityType& type, AccountTypes& sec);
+ void OnPlayerResurrect(Player* player, float restore_percent, bool applySickness);
+ bool CanPlayerUseChat(Player* player, uint32 type, uint32 language, std::string& msg);
+ bool CanPlayerUseChat(Player* player, uint32 type, uint32 language, std::string& msg, Player* receiver);
+ bool CanPlayerUseChat(Player* player, uint32 type, uint32 language, std::string& msg, Group* group);
+ bool CanPlayerUseChat(Player* player, uint32 type, uint32 language, std::string& msg, Guild* guild);
+ bool CanPlayerUseChat(Player* player, uint32 type, uint32 language, std::string& msg, Channel* channel);
+ void OnPlayerLearnTalents(Player* player, uint32 talentId, uint32 talentRank, uint32 spellid);
+ void OnPlayerEnterCombat(Player* player, Unit* enemy);
+ void OnPlayerLeaveCombat(Player* player);
+ void OnQuestAbandon(Player* player, uint32 questId);
+
+ // Anti cheat
void AnticheatSetSkipOnePacketForASH(Player* player, bool apply);
void AnticheatSetCanFlybyServer(Player* player, bool apply);
void AnticheatSetUnderACKmount(Player* player);
@@ -1850,6 +2356,7 @@ public: /* UnitScript */
bool IsNeedModHealPercent(Unit const* unit, AuraEffect* auraEff, float& doneTotalMod, SpellInfo const* spellProto);
bool CanSetPhaseMask(Unit const* unit, uint32 newPhaseMask, bool update);
bool IsCustomBuildValuesUpdate(Unit const* unit, uint8 updateType, ByteBuffer& fieldBuffer, Player const* target, uint16 index);
+ void OnUnitUpdate(Unit* unit, uint32 diff);
public: /* MovementHandlerScript */
void OnPlayerMove(Player* player, MovementInfo movementInfo, uint32 opcode);
@@ -1860,9 +2367,8 @@ public: /* AllCreatureScript */
void Creature_SelectLevel(const CreatureTemplate* cinfo, Creature* creature);
public: /* AllMapScript */
- //listener functions are called by OnPlayerEnterMap and OnPlayerLeaveMap
- //void OnPlayerEnterAll(Map* map, Player* player);
- //void OnPlayerLeaveAll(Map* map, Player* player);
+ void OnBeforeCreateInstanceScript(InstanceMap* instanceMap, InstanceScript* instanceData, bool load, std::string data, uint32 completedEncounterMask);
+ void OnDestroyInstance(MapInstanced* mapInstanced, Map* map);
public: /* BGScript */
void OnBattlegroundStart(Battleground* bg);
@@ -1880,6 +2386,9 @@ public: /* BGScript */
bool CanSendMessageBGQueue(BattlegroundQueue* queue, Player* leader, Battleground* bg, PvPDifficultyEntry const* bracketEntry);
bool OnBeforeSendJoinMessageArenaQueue(BattlegroundQueue* queue, Player* leader, GroupQueueInfo* ginfo, PvPDifficultyEntry const* bracketEntry, bool isRated);
bool OnBeforeSendExitMessageArenaQueue(BattlegroundQueue* queue, GroupQueueInfo* ginfo);
+ void OnBattlegroundEnd(Battleground* bg, TeamId winnerTeamId);
+ void OnBattlegroundDestroy(Battleground* bg);
+ void OnBattlegroundCreate(Battleground* bg);
public: /* Arena Team Script */
void OnGetSlotByType(const uint32 type, uint8& slot);
@@ -1899,6 +2408,9 @@ public: /* SpellSC */
void OnScaleAuraUnitAdd(Spell* spell, Unit* target, uint32 effectMask, bool checkIfValid, bool implicit, uint8 auraScaleMask, TargetInfo& targetInfo);
void OnRemoveAuraScaleTargets(Spell* spell, TargetInfo& targetInfo, uint8 auraScaleMask, bool& needErase);
void OnBeforeAuraRankForLevel(SpellInfo const* spellInfo, SpellInfo const* latestSpellInfo, uint8 level);
+ void OnDummyEffect(WorldObject* caster, uint32 spellID, SpellEffIndex effIndex, GameObject* gameObjTarget);
+ void OnDummyEffect(WorldObject* caster, uint32 spellID, SpellEffIndex effIndex, Creature* creatureTarget);
+ void OnDummyEffect(WorldObject* caster, uint32 spellID, SpellEffIndex effIndex, Item* itemTarget);
public: /* GameEventScript */
void OnGameEventStart(uint16 EventID);
@@ -1909,53 +2421,71 @@ public: /* MailScript */
public: /* AchievementScript */
- void SetRealmCompleted(AchievementEntry const* achievement);
- bool IsCompletedCriteria(AchievementMgr* mgr, AchievementCriteriaEntry const* achievementCriteria, AchievementEntry const* achievement, CriteriaProgress const* progress);
- bool IsRealmCompleted(AchievementGlobalMgr const* globalmgr, AchievementEntry const* achievement, std::chrono::system_clock::time_point completionTime);
- void OnBeforeCheckCriteria(AchievementMgr* mgr, AchievementCriteriaEntryList const* achievementCriteriaList);
- bool CanCheckCriteria(AchievementMgr* mgr, AchievementCriteriaEntry const* achievementCriteria);
+ void SetRealmCompleted(AchievementEntry const* achievement);
+ bool IsCompletedCriteria(AchievementMgr* mgr, AchievementCriteriaEntry const* achievementCriteria, AchievementEntry const* achievement, CriteriaProgress const* progress);
+ bool IsRealmCompleted(AchievementGlobalMgr const* globalmgr, AchievementEntry const* achievement, std::chrono::system_clock::time_point completionTime);
+ void OnBeforeCheckCriteria(AchievementMgr* mgr, AchievementCriteriaEntryList const* achievementCriteriaList);
+ bool CanCheckCriteria(AchievementMgr* mgr, AchievementCriteriaEntry const* achievementCriteria);
+
+public: /* PetScript */
+
+ void OnInitStatsForLevel(Guardian* guardian, uint8 petlevel);
+ void OnCalculateMaxTalentPointsForLevel(Pet* pet, uint8 level, uint8& points);
+ bool CanUnlearnSpellSet(Pet* pet, uint32 level, uint32 spell);
+ bool CanUnlearnSpellDefault(Pet* pet, SpellInfo const* spellEntry);
+ bool CanResetTalents(Pet* pet);
+
+public: /* ArenaScript */
+
+ bool CanAddMember(ArenaTeam* team, ObjectGuid PlayerGuid);
+ void OnGetPoints(ArenaTeam* team, uint32 memberRating, float& points);
+ bool CanSaveToDB(ArenaTeam* team);
+
+public: /* MiscScript */
+
+ void OnConstructObject(Object* origin);
+ void OnDestructObject(Object* origin);
+ void OnConstructPlayer(Player* origin);
+ void OnDestructPlayer(Player* origin);
+ void OnConstructGroup(Group* origin);
+ void OnDestructGroup(Group* origin);
+ void OnConstructInstanceSave(InstanceSave* origin);
+ void OnDestructInstanceSave(InstanceSave* origin);
+ void OnItemCreate(Item* item, ItemTemplate const* itemProto, Player const* owner);
+ bool CanApplySoulboundFlag(Item* item, ItemTemplate const* proto);
+ bool CanItemApplyEquipSpell(Player* player, Item* item);
+ bool CanSendAuctionHello(WorldSession const* session, ObjectGuid guid, Creature* creature);
+ void ValidateSpellAtCastSpell(Player* player, uint32& oldSpellId, uint32& spellId, uint8& castCount, uint8& castFlags);
+ void OnPlayerSetPhase(const AuraEffect* auraEff, AuraApplication const* aurApp, uint8 mode, bool apply, uint32& newPhase);
+ void ValidateSpellAtCastSpellResult(Player* player, Unit* mover, Spell* spell, uint32 oldSpellId, uint32 spellId);
+ void OnAfterLootTemplateProcess(Loot* loot, LootTemplate const* tab, LootStore const& store, Player* lootOwner, bool personal, bool noEmptyError, uint16 lootMode);
+ void OnInstanceSave(InstanceSave* instanceSave);
+ void GetDialogStatus(Player* player, Object* questgiver);
- public: /* PetScript */
+public: /* CommandSC */
- void OnInitStatsForLevel(Guardian* guardian, uint8 petlevel);
- void OnCalculateMaxTalentPointsForLevel(Pet* pet, uint8 level, uint8& points);
- bool CanUnlearnSpellSet(Pet* pet, uint32 level, uint32 spell);
- bool CanUnlearnSpellDefault(Pet* pet, SpellInfo const* spellEntry);
- bool CanResetTalents(Pet* pet);
+ void OnHandleDevCommand(Player* player, std::string& argstr);
+ bool CanExecuteCommand(ChatHandler& handler, std::string_view cmdStr);
- public: /* ArenaScript */
+public: /* DatabaseScript */
- bool CanAddMember(ArenaTeam* team, ObjectGuid PlayerGuid);
- void OnGetPoints(ArenaTeam* team, uint32 memberRating, float& points);
- bool CanSaveToDB(ArenaTeam* team);
+ void OnAfterDatabasesLoaded(uint32 updateFlags);
- public: /* MiscScript */
+public: /* WorldObjectScript */
- void OnConstructObject(Object* origin);
- void OnDestructObject(Object* origin);
- void OnConstructPlayer(Player* origin);
- void OnDestructPlayer(Player* origin);
- void OnConstructGroup(Group* origin);
- void OnDestructGroup(Group* origin);
- void OnConstructInstanceSave(InstanceSave* origin);
- void OnDestructInstanceSave(InstanceSave* origin);
- void OnItemCreate(Item* item, ItemTemplate const* itemProto, Player const* owner);
- bool CanApplySoulboundFlag(Item* item, ItemTemplate const* proto);
- bool CanItemApplyEquipSpell(Player* player, Item* item);
- bool CanSendAuctionHello(WorldSession const* session, ObjectGuid guid, Creature* creature);
- void ValidateSpellAtCastSpell(Player* player, uint32& oldSpellId, uint32& spellId, uint8& castCount, uint8& castFlags);
- void OnPlayerSetPhase(const AuraEffect* auraEff, AuraApplication const* aurApp, uint8 mode, bool apply, uint32& newPhase);
- void ValidateSpellAtCastSpellResult(Player* player, Unit* mover, Spell* spell, uint32 oldSpellId, uint32 spellId);
- void OnAfterLootTemplateProcess(Loot* loot, LootTemplate const* tab, LootStore const& store, Player* lootOwner, bool personal, bool noEmptyError, uint16 lootMode);
- void OnInstanceSave(InstanceSave* instanceSave);
+ void OnWorldObjectDestroy(WorldObject* object);
+ void OnWorldObjectCreate(WorldObject* object);
+ void OnWorldObjectSetMap(WorldObject* object, Map* map);
+ void OnWorldObjectResetMap(WorldObject* object);
+ void OnWorldObjectUpdate(WorldObject* object, uint32 diff);
- public: /* CommandSC */
+public: /* PetScript */
- void OnHandleDevCommand(Player* player, std::string& argstr);
+ void OnPetAddToWorld(Pet* pet);
- public: /* DatabaseScript */
+public: /* LootScript */
- void OnAfterDatabasesLoaded(uint32 updateFlags);
+ void OnLootMoney(Player* player, uint32 gold);
private:
uint32 _scriptCount;
@@ -1964,6 +2494,7 @@ private:
std::atomic<long> _scheduledScripts;
ScriptLoaderCallbackType _script_loader_callback;
+ ModulesLoaderCallbackType _modules_loader_callback;
};
namespace Acore::SpellScripts
diff --git a/src/server/game/Server/WorldSession.cpp b/src/server/game/Server/WorldSession.cpp
index 56b1dd208b..dade8e2058 100644
--- a/src/server/game/Server/WorldSession.cpp
+++ b/src/server/game/Server/WorldSession.cpp
@@ -51,10 +51,6 @@
#include "WorldSocket.h"
#include <zlib.h>
-#ifdef ELUNA
-#include "LuaEngine.h"
-#endif
-
namespace
{
std::string const DefaultPlayerName = "<none>";
@@ -254,12 +250,10 @@ void WorldSession::SendPacket(WorldPacket const* packet)
}
#endif // !ACORE_DEBUG
- sScriptMgr->OnPacketSend(this, *packet);
-
-#ifdef ELUNA
- if (!sEluna->OnPacketSend(this, *packet))
+ if (!sScriptMgr->CanPacketSend(this, *packet))
+ {
return;
-#endif
+ }
LOG_TRACE("network.opcode", "S->C: %s %s", GetPlayerInfo().c_str(), GetOpcodeNameForLogging(static_cast<OpcodeServer>(packet->GetOpcode())).c_str());
m_Socket->SendPacket(*packet);
@@ -346,11 +340,11 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater)
}
else if (_player->IsInWorld() && AntiDOS.EvaluateOpcode(*packet, currentTime))
{
- sScriptMgr->OnPacketReceive(this, *packet);
-#ifdef ELUNA
- if (!sEluna->OnPacketReceive(this, *packet))
+ if (!sScriptMgr->CanPacketReceive(this, *packet))
+ {
break;
-#endif
+ }
+
opHandle->Call(this, *packet);
LogUnprocessedTail(packet);
}
@@ -358,11 +352,11 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater)
case STATUS_TRANSFER:
if (_player && !_player->IsInWorld() && AntiDOS.EvaluateOpcode(*packet, currentTime))
{
- sScriptMgr->OnPacketReceive(this, *packet);
-#ifdef ELUNA
- if (!sEluna->OnPacketReceive(this, *packet))
+ if (!sScriptMgr->CanPacketReceive(this, *packet))
+ {
break;
-#endif
+ }
+
opHandle->Call(this, *packet);
LogUnprocessedTail(packet);
}
@@ -373,11 +367,11 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater)
if (AntiDOS.EvaluateOpcode(*packet, currentTime))
{
- sScriptMgr->OnPacketReceive(this, *packet);
-#ifdef ELUNA
- if (!sEluna->OnPacketReceive(this, *packet))
+ if (!sScriptMgr->CanPacketReceive(this, *packet))
+ {
break;
-#endif
+ }
+
opHandle->Call(this, *packet);
LogUnprocessedTail(packet);
}
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
index 75496f3c64..0544af44dc 100644
--- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp
+++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
@@ -40,10 +40,6 @@
#include "Vehicle.h"
#include "WorldPacket.h"
-#ifdef ELUNA
-#include "LuaEngine.h"
-#endif
-
class Aura;
//
// EFFECT HANDLER NOTES
@@ -6231,11 +6227,12 @@ void AuraEffect::HandlePeriodicTriggerSpellWithValueAuraTick(Unit* target, Unit*
}
else
{
-#ifdef ELUNA
Creature* c = target->ToCreature();
if (c && caster)
- sEluna->OnDummyEffect(caster, GetId(), SpellEffIndex(GetEffIndex()), target->ToCreature());
-#endif
+ {
+ sScriptMgr->OnDummyEffect(caster, GetId(), SpellEffIndex(GetEffIndex()), target->ToCreature());
+ }
+
LOG_DEBUG("spells.aura", "AuraEffect::HandlePeriodicTriggerSpellWithValueAuraTick: Spell %u has non-existent spell %u in EffectTriggered[%d] and is therefor not triggered.", GetId(), triggerSpellId, GetEffIndex());
}
}
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index 7afdd46aaa..8bd2922b46 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -15,11 +15,6 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifdef ELUNA
-#include "ElunaUtility.h"
-#include "LuaEngine.h"
-#endif
-
#include "Spell.h"
#include "ArenaSpectator.h"
#include "BattlefieldMgr.h"
@@ -3586,9 +3581,7 @@ void Spell::_cast(bool skipCheck)
{
// now that we've done the basic check, now run the scripts
// should be done before the spell is actually executed
-#ifdef ELUNA
- sEluna->OnSpellCast(playerCaster, this, skipCheck);
-#endif
+ sScriptMgr->OnPlayerSpellCast(playerCaster, this, skipCheck);
// As of 3.0.2 pets begin attacking their owner's target immediately
// Let any pets know we've attacked something. Check DmgClass for harmful spells only
diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp
index c66198a0ac..337fd4c7ef 100644
--- a/src/server/game/Spells/SpellEffects.cpp
+++ b/src/server/game/Spells/SpellEffects.cpp
@@ -62,10 +62,6 @@
#include "WorldPacket.h"
#include "WorldSession.h"
-#ifdef ELUNA
-#include "LuaEngine.h"
-#endif
-
pEffect SpellEffects[TOTAL_SPELL_EFFECTS] =
{
&Spell::EffectNULL, // 0
@@ -788,14 +784,19 @@ void Spell::EffectDummy(SpellEffIndex effIndex)
// normal DB scripted effect
LOG_DEBUG("spells.aura", "Spell ScriptStart spellid %u in EffectDummy(%u)", m_spellInfo->Id, effIndex);
m_caster->GetMap()->ScriptsStart(sSpellScripts, uint32(m_spellInfo->Id | (effIndex << 24)), m_caster, unitTarget);
-#ifdef ELUNA
+
if (gameObjTarget)
- sEluna->OnDummyEffect(m_caster, m_spellInfo->Id, effIndex, gameObjTarget);
+ {
+ sScriptMgr->OnDummyEffect(m_caster, m_spellInfo->Id, effIndex, gameObjTarget);
+ }
else if (unitTarget && unitTarget->GetTypeId() == TYPEID_UNIT)
- sEluna->OnDummyEffect(m_caster, m_spellInfo->Id, effIndex, unitTarget->ToCreature());
+ {
+ sScriptMgr->OnDummyEffect(m_caster, m_spellInfo->Id, effIndex, unitTarget->ToCreature());
+ }
else if (itemTarget)
- sEluna->OnDummyEffect(m_caster, m_spellInfo->Id, effIndex, itemTarget);
-#endif
+ {
+ sScriptMgr->OnDummyEffect(m_caster, m_spellInfo->Id, effIndex, itemTarget);
+ }
}
void Spell::EffectTriggerSpell(SpellEffIndex effIndex)
diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp
index cd18fc6091..c79390c02c 100644
--- a/src/server/game/World/World.cpp
+++ b/src/server/game/World/World.cpp
@@ -92,10 +92,6 @@
#include <boost/asio/ip/address.hpp>
#include <cmath>
-#ifdef ELUNA
-#include "LuaEngine.h"
-#endif
-
std::atomic_long World::m_stopEvent = false;
uint8 World::m_ExitCode = SHUTDOWN_EXIT_CODE;
uint32 World::m_worldLoopCounter = 0;
@@ -444,15 +440,6 @@ void World::LoadConfigSettings(bool reload)
// Set realm id and enable db logging
sLog->SetRealmId(realm.Id.Realm);
-#ifdef ELUNA
- ///- Initialize Lua Engine
- if (!reload)
- {
- LOG_INFO("eluna", "Initialize Eluna Lua Engine...");
- Eluna::Initialize();
- }
-#endif
-
sScriptMgr->OnBeforeConfigLoad(reload);
///- Read the player limit and the Message of the day from the config file
@@ -2081,12 +2068,7 @@ void World::SetInitialWorldSettings()
LOG_INFO("server.loading", "Load Channels...");
ChannelMgr::LoadChannels();
-#ifdef ELUNA
- ///- 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.
-#endif
+ sScriptMgr->OnBeforeWorldInitialized();
if (sWorld->getBoolConfig(CONFIG_PRELOAD_ALL_NON_INSTANCED_MAP_GRIDS))
{
diff --git a/src/server/scripts/CMakeLists.txt b/src/server/scripts/CMakeLists.txt
index 7b501ef49f..c363a367b1 100644
--- a/src/server/scripts/CMakeLists.txt
+++ b/src/server/scripts/CMakeLists.txt
@@ -53,26 +53,6 @@ if(SCRIPTS MATCHES "minimal")
list(APPEND SCRIPTS_WHITELIST Commands Spells)
endif()
-# Add support old api modules
-CU_GET_GLOBAL("AC_ADD_SCRIPTS_LIST")
-CU_GET_GLOBAL("AC_ADD_SCRIPTS_INCLUDE")
-
-set("AC_SCRIPTS_INCLUDES" "")
-set("AC_MODULE_LIST" "")
-set("AC_SCRIPTS_LIST" "")
-
-foreach(include ${AC_ADD_SCRIPTS_INCLUDE})
- set("AC_SCRIPTS_INCLUDES" "#include \"${include}\"\n${AC_SCRIPTS_INCLUDES}")
-endforeach()
-
-foreach(void ${AC_ADD_SCRIPTS_LIST})
- set("AC_MODULE_LIST" "void ${void};\n${AC_MODULE_LIST}")
-endforeach()
-
-foreach(scriptName ${AC_ADD_SCRIPTS_LIST})
- set("AC_SCRIPTS_LIST" " ${scriptName};\n${AC_SCRIPTS_LIST}")
-endforeach()
-
# Set the SCRIPTS_${SCRIPT_MODULE} variables from the
# variables set above
foreach(SCRIPT_MODULE ${SCRIPT_MODULE_LIST})
@@ -109,47 +89,8 @@ foreach(SCRIPT_MODULE ${SCRIPT_MODULE_LIST})
endif()
endforeach()
-# Set the MODULES_${SOURCE_MODULE} variables from the
-# variables set above
-foreach(SOURCE_MODULE ${MODULES_MODULE_LIST})
- ModuleNameToVariable(${SOURCE_MODULE} MODULE_MODULE_VARIABLE)
-
- if(${MODULE_MODULE_VARIABLE} STREQUAL "default")
- set(${MODULE_MODULE_VARIABLE} ${MODULES_DEFAULT_LINKAGE})
- endif()
-
- # Use only static for deprecated api loaders
- if (AC_SCRIPTS_INCLUDES MATCHES "${SOURCE_MODULE}")
- set(${MODULE_MODULE_VARIABLE} "static")
- endif()
-
- # Use only static for mod-eluna-lua-engine
- if (SOURCE_MODULE MATCHES "mod-eluna-lua-engine")
- set(${MODULE_MODULE_VARIABLE} "static")
- endif()
-
- # Build the Graph values
- if(${MODULE_MODULE_VARIABLE} MATCHES "dynamic")
- GetProjectNameOfModuleName(${SOURCE_MODULE} MODULE_SOURCE_PROJECT_NAME)
- GetNativeSharedLibraryName(${MODULE_SOURCE_PROJECT_NAME} MODULE_PROJECT_LIBRARY)
- list(APPEND MODULE_GRAPH_KEYS ${MODULE_SOURCE_PROJECT_NAME})
- set(MODULE_GRAPH_VALUE_DISPLAY_${MODULE_SOURCE_PROJECT_NAME} ${MODULE_PROJECT_LIBRARY})
- list(APPEND MODULE_GRAPH_VALUE_CONTAINS_MODULES_${MODULE_SOURCE_PROJECT_NAME} ${SOURCE_MODULE})
- elseif(${MODULE_MODULE_VARIABLE} MATCHES "static")
- list(APPEND MODULE_GRAPH_KEYS worldserver)
- set(MODULE_GRAPH_VALUE_DISPLAY_worldserver worldserver)
- list(APPEND MODULE_GRAPH_VALUE_CONTAINS_MODULES_worldserver ${SOURCE_MODULE})
- else()
- list(APPEND MODULE_GRAPH_KEYS disabled)
- set(MODULE_GRAPH_VALUE_DISPLAY_disabled disabled)
- list(APPEND MODULE_GRAPH_VALUE_CONTAINS_MODULES_disabled ${SOURCE_MODULE})
- endif()
-endforeach()
-
list(SORT SCRIPT_GRAPH_KEYS)
-list(SORT MODULE_GRAPH_KEYS)
list(REMOVE_DUPLICATES SCRIPT_GRAPH_KEYS)
-list(REMOVE_DUPLICATES MODULE_GRAPH_KEYS)
# Display the script graph
message("* Script configuration (${SCRIPTS}):
@@ -169,24 +110,6 @@ endforeach()
message("")
-# Display the module graph
-message("* Modules configuration (${MODULES}):
- |")
-
-foreach(MODULE_GRAPH_KEY ${MODULE_GRAPH_KEYS})
- if(NOT MODULE_GRAPH_KEY STREQUAL "disabled")
- message(" +- ${MODULE_GRAPH_VALUE_DISPLAY_${MODULE_GRAPH_KEY}}")
- else()
- message(" | ${MODULE_GRAPH_VALUE_DISPLAY_${MODULE_GRAPH_KEY}}")
- endif()
- foreach(MODULE_GRAPH_PROJECT_ENTRY ${MODULE_GRAPH_VALUE_CONTAINS_MODULES_${MODULE_GRAPH_KEY}})
- message(" | +- ${MODULE_GRAPH_PROJECT_ENTRY}")
- endforeach()
- message(" |")
-endforeach()
-
-message("")
-
# Base sources which are used by every script project
if(USE_SCRIPTPCH)
set(PRIVATE_PCH_HEADER ScriptPCH.h)
@@ -310,98 +233,6 @@ foreach(SCRIPT_MODULE ${SCRIPT_MODULE_LIST})
endif()
endforeach()
-# Generates the actual module projects
-# Fills the STATIC_SCRIPT_MODULES and DYNAMIC_SCRIPT_MODULE_PROJECTS variables
-# which contain the names which scripts are linked statically/dynamically and
-# adds the sources of the static modules to the PRIVATE_SOURCES_MODULES variable.
-foreach(SOURCE_MODULE ${MODULES_MODULE_LIST})
- GetPathToModuleSource(${SOURCE_MODULE} MODULE_SOURCE_PATH)
- ModuleNameToVariable(${SOURCE_MODULE} MODULE_MODULE_VARIABLE)
-
- if((${MODULE_MODULE_VARIABLE} STREQUAL "disabled") OR
- (${MODULE_MODULE_VARIABLE} STREQUAL "static"))
-
- # Uninstall disabled modules
- GetProjectNameOfModuleName(${SOURCE_MODULE} MODULE_SOURCE_PROJECT_NAME)
- GetNativeSharedLibraryName(${MODULE_SOURCE_PROJECT_NAME} SCRIPT_MODULE_OUTPUT_NAME)
- list(APPEND DISABLED_SCRIPT_MODULE_PROJECTS ${INSTALL_OFFSET}/${SCRIPT_MODULE_OUTPUT_NAME})
- if(${MODULE_MODULE_VARIABLE} STREQUAL "static")
-
- # Add the module content to the whole static module
- CollectSourceFiles(${MODULE_SOURCE_PATH} PRIVATE_SOURCES_MODULES)
- CollectIncludeDirectories(${MODULE_SOURCE_PATH} PUBLIC_INCLUDES)
-
- # Skip deprecated api loaders
- if (AC_SCRIPTS_INCLUDES MATCHES "${SOURCE_MODULE}")
- message("> Module (${SOURCE_MODULE}) using deprecated loader api")
- continue()
- endif()
-
- # Skip mod-eluna-lua-engine
- if (SOURCE_MODULE MATCHES "mod-eluna-lua-engine")
- continue()
- endif()
-
- # Add the module name to STATIC_SCRIPT_MODULES
- list(APPEND STATIC_SCRIPT_MODULES ${SOURCE_MODULE})
-
- endif()
- elseif(${MODULE_MODULE_VARIABLE} STREQUAL "dynamic")
-
- # Generate an own dynamic module which is loadable on runtime
- # Add the module content to the whole static module
- unset(MODULE_SOURCE_PRIVATE_SOURCES)
- CollectSourceFiles(${MODULE_SOURCE_PATH} MODULE_SOURCE_PRIVATE_SOURCES)
- CollectIncludeDirectories(${MODULE_SOURCE_PATH} PUBLIC_INCLUDES)
-
- # Configure the scriptloader
- ConfigureScriptLoader(${SOURCE_MODULE} SCRIPT_MODULE_PRIVATE_SCRIPTLOADER ON ${SOURCE_MODULE})
- GetProjectNameOfModuleName(${SOURCE_MODULE} MODULE_SOURCE_PROJECT_NAME)
-
- # Add the module name to DYNAMIC_SCRIPT_MODULES
- list(APPEND DYNAMIC_SCRIPT_MODULE_PROJECTS ${MODULE_SOURCE_PROJECT_NAME})
-
- # Create the script module project
- add_library(${MODULE_SOURCE_PROJECT_NAME} SHARED
- ${MODULE_SOURCE_PRIVATE_SOURCES}
- ${SCRIPT_MODULE_PRIVATE_SCRIPTLOADER})
-
- target_link_libraries(${MODULE_SOURCE_PROJECT_NAME}
- PRIVATE
- acore-core-interface
- PUBLIC
- game)
-
- target_include_directories(${MODULE_SOURCE_PROJECT_NAME}
- PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}
- ${PUBLIC_INCLUDES})
-
- set_target_properties(${MODULE_SOURCE_PROJECT_NAME}
- PROPERTIES
- FOLDER
- "scripts")
-
- if(UNIX)
- install(TARGETS ${MODULE_SOURCE_PROJECT_NAME}
- DESTINATION ${INSTALL_OFFSET} COMPONENT ${MODULE_SOURCE_PROJECT_NAME})
- elseif(WIN32)
- install(TARGETS ${MODULE_SOURCE_PROJECT_NAME}
- RUNTIME DESTINATION ${INSTALL_OFFSET} COMPONENT ${MODULE_SOURCE_PROJECT_NAME})
- if(MSVC)
- # Place the script modules in the script subdirectory
- set_target_properties(${MODULE_SOURCE_PROJECT_NAME} PROPERTIES
- RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/bin/Debug/scripts
- RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/bin/Release/scripts
- RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_BINARY_DIR}/bin/RelWithDebInfo/scripts
- RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_BINARY_DIR}/bin/MinSizeRel/scripts)
- endif()
- endif()
- else()
- message(FATAL_ERROR "Unknown value \"${${MODULE_MODULE_VARIABLE}}\" for module (${SOURCE_MODULE})!")
- endif()
-endforeach()
-
# Add the dynamic script modules to the worldserver as dependency
set(WORLDSERVER_DYNAMIC_SCRIPT_MODULES_DEPENDENCIES ${DYNAMIC_SCRIPT_MODULE_PROJECTS} PARENT_SCOPE)
@@ -412,8 +243,7 @@ list(REMOVE_DUPLICATES SCRIPT_MODULE_PRIVATE_SCRIPTLOADER)
add_library(scripts STATIC
ScriptLoader.h
${SCRIPT_MODULE_PRIVATE_SCRIPTLOADER}
- ${PRIVATE_SOURCES_SCRIPTS}
- ${PRIVATE_SOURCES_MODULES})
+ ${PRIVATE_SOURCES_SCRIPTS})
target_link_libraries(scripts
PRIVATE
diff --git a/src/server/scripts/Commands/cs_server.cpp b/src/server/scripts/Commands/cs_server.cpp
index 1759e10429..7ccd4d2305 100644
--- a/src/server/scripts/Commands/cs_server.cpp
+++ b/src/server/scripts/Commands/cs_server.cpp
@@ -27,6 +27,7 @@
#include "Config.h"
#include "GitRevision.h"
#include "Language.h"
+#include "ModuleMgr.h"
#include "MySQLThreading.h"
#include "Player.h"
#include "Realm.h"
@@ -219,6 +220,14 @@ public:
handler->PSendSysMessage("LoginDatabase queue size: %zu", LoginDatabase.QueueSize());
handler->PSendSysMessage("CharacterDatabase queue size: %zu", CharacterDatabase.QueueSize());
handler->PSendSysMessage("WorldDatabase queue size: %zu", WorldDatabase.QueueSize());
+
+ handler->SendSysMessage("> List enable modules:");
+
+ for (auto const& modName : Acore::Module::GetEnableModulesList())
+ {
+ handler->SendSysMessage(Acore::StringFormatFmt("- {}", modName));
+ }
+
return true;
}
diff --git a/src/server/scripts/ScriptLoader.cpp.in.cmake b/src/server/scripts/ScriptLoader.cpp.in.cmake
index 303218ec5c..a994096273 100644
--- a/src/server/scripts/ScriptLoader.cpp.in.cmake
+++ b/src/server/scripts/ScriptLoader.cpp.in.cmake
@@ -24,10 +24,6 @@
#include <vector>
#include <string>
-// Add deprecated api loaders include
-@AC_SCRIPTS_INCLUDES@
-// Add module scripts define
-@AC_MODULE_LIST@
// Add default scripts include
@ACORE_SCRIPTS_FORWARD_DECL@
#ifdef ACORE_IS_DYNAMIC_SCRIPTLOADER
@@ -56,10 +52,8 @@ AC_SCRIPT_API char const* GetScriptModule()
/// Exposed in script modules to register all scripts to the ScriptMgr.
AC_SCRIPT_API void AddScripts()
{
- // Default scripts and modules
-@ACORE_SCRIPTS_INVOKE@
- // Deprecated api modules
-@AC_SCRIPTS_LIST@}
+ // Default scripts
+@ACORE_SCRIPTS_INVOKE@}
/// Exposed in script modules to get the build directive of the module.
AC_SCRIPT_API char const* GetBuildDirective()
diff --git a/src/server/shared/DataStores/DBCStore.h b/src/server/shared/DataStores/DBCStore.h
index 1d83d2a423..dbe5ae5701 100644
--- a/src/server/shared/DataStores/DBCStore.h
+++ b/src/server/shared/DataStores/DBCStore.h
@@ -184,7 +184,6 @@ public:
[[nodiscard]] T const* LookupEntry(uint32 id) const { return (id >= _indexTableSize) ? nullptr : _indexTable.AsT[id]; }
[[nodiscard]] T const* AssertEntry(uint32 id) const { return ASSERT_NOTNULL(LookupEntry(id)); }
-#ifdef ELUNA
void SetEntry(uint32 id, T* t)
{
if (id >= _indexTableSize)
@@ -203,7 +202,6 @@ public:
delete _indexTable.AsT[id];
_indexTable.AsT[id] = t;
}
-#endif
[[nodiscard]] uint32 GetNumRows() const { return _indexTableSize; }
diff --git a/src/server/worldserver/CMakeLists.txt b/src/server/worldserver/CMakeLists.txt
index 94c2714b8e..bb7b75d30b 100644
--- a/src/server/worldserver/CMakeLists.txt
+++ b/src/server/worldserver/CMakeLists.txt
@@ -57,6 +57,7 @@ target_link_libraries(worldserver
PRIVATE
acore-core-interface
PUBLIC
+ modules
scripts
game
gsoap
@@ -68,9 +69,13 @@ set_target_properties(worldserver
FOLDER
"server")
+# Add all dynamic projects as dependency to the worldserver
+if(WORLDSERVER_DYNAMIC_SCRIPT_MODULES_DEPENDENCIES)
+ add_dependencies(worldserver ${WORLDSERVER_DYNAMIC_SCRIPT_MODULES_DEPENDENCIES})
+endif()
+
# Install config
CopyDefaultConfig(worldserver)
-CollectModulesConfig()
if( UNIX )
install(TARGETS worldserver DESTINATION bin)
diff --git a/src/server/worldserver/Main.cpp b/src/server/worldserver/Main.cpp
index de0f741ba9..b7398caf15 100644
--- a/src/server/worldserver/Main.cpp
+++ b/src/server/worldserver/Main.cpp
@@ -38,6 +38,7 @@
#include "IoContext.h"
#include "MapMgr.h"
#include "Metric.h"
+#include "ModulesScriptLoader.h"
#include "MySQLThreading.h"
#include "ObjectAccessor.h"
#include "OpenSSLCrypto.h"
@@ -61,9 +62,7 @@
#include <openssl/crypto.h>
#include <openssl/opensslv.h>
-#ifdef ELUNA
-#include "LuaEngine.h"
-#endif
+#include "ModuleMgr.h"
#ifdef _WIN32
#include "ServiceWin32.h"
@@ -279,6 +278,8 @@ int main(int argc, char** argv)
SetProcessPriority("server.worldserver", sConfigMgr->GetOption<int32>(CONFIG_PROCESSOR_AFFINITY, 0), sConfigMgr->GetOption<bool>(CONFIG_HIGH_PRIORITY, false));
sScriptMgr->SetScriptLoader(AddScripts);
+ sScriptMgr->SetModulesLoader(AddModulesScripts);
+
std::shared_ptr<void> sScriptMgrHandle(nullptr, [](void*)
{
sScriptMgr->Unload();
@@ -315,6 +316,8 @@ int main(int argc, char** argv)
sMetric->Unload();
});
+ Acore::Module::SetEnableModulesList(AC_MODULES_LIST);
+
// Loading modules configs
sConfigMgr->PrintLoadedModulesConfigs();
@@ -329,10 +332,6 @@ int main(int argc, char** argv)
sOutdoorPvPMgr->Die(); // unload it before MapMgr
sMapMgr->UnloadAll(); // unload all grids (including locked in memory)
-
-#ifdef ELUNA
- Eluna::Uninitialize();
-#endif
});
// Start the Remote Access port (acceptor) if enabled
@@ -448,7 +447,7 @@ bool StartDB()
MySQL::Library_Init();
// Load databases
- DatabaseLoader loader("server.worldserver");
+ DatabaseLoader loader("server.worldserver", DatabaseLoader::DATABASE_NONE, AC_MODULES_LIST);
loader
.AddDatabase(LoginDatabase, "Login")
.AddDatabase(CharacterDatabase, "Character")