From fad214efe018dcb56ce11e717e41e1eddea96599 Mon Sep 17 00:00:00 2001 From: Kargatum Date: Sat, 11 Dec 2021 01:05:28 +0700 Subject: [PATCH] feat(Core/ScriptMgr): replace macro and cleanup (#9598) --- .../Scripting/ScriptDefines/AccountScript.cpp | 83 + .../AchievementCriteriaScript.cpp | 28 + .../ScriptDefines/AchievementScript.cpp | 80 + .../ScriptDefines/AllCreatureScript.cpp | 60 + .../ScriptDefines/AllGameObjectScript.cpp | 39 + .../Scripting/ScriptDefines/AllMapScript.cpp | 353 ++ .../ScriptDefines/AreaTriggerScript.cpp | 38 + .../Scripting/ScriptDefines/ArenaScript.cpp | 57 + .../ScriptDefines/ArenaTeamScript.cpp | 59 + .../ScriptDefines/AuctionHouseScript.cpp | 119 + .../game/Scripting/ScriptDefines/BGScript.cpp | 191 + .../ScriptDefines/BattlegroundScript.cpp | 26 + .../Scripting/ScriptDefines/CommandSC.cpp | 42 + .../Scripting/ScriptDefines/CommandScript.cpp | 33 + .../ScriptDefines/ConditionScript.cpp | 27 + .../ScriptDefines/CreatureScript.cpp | 186 + .../ScriptDefines/DatabaseScript.cpp | 27 + .../ScriptDefines/DynamicObjectScript.cpp | 29 + .../Scripting/ScriptDefines/FormulaScript.cpp | 94 + .../ScriptDefines/GameEventScript.cpp | 35 + .../ScriptDefines/GameObjectScript.cpp | 224 ++ .../Scripting/ScriptDefines/GlobalScript.cpp | 124 + .../Scripting/ScriptDefines/GroupScript.cpp | 92 + .../Scripting/ScriptDefines/GuildScript.cpp | 123 + .../ScriptDefines/InstanceMapScript.cpp | 27 + .../Scripting/ScriptDefines/ItemScript.cpp | 141 + .../Scripting/ScriptDefines/LootScript.cpp | 29 + .../Scripting/ScriptDefines/MailScript.cpp | 27 + .../Scripting/ScriptDefines/MiscScript.cpp | 184 + .../ScriptDefines/MovementHandlerScript.cpp | 27 + .../ScriptDefines/OutdoorPvPScript.cpp | 28 + .../Scripting/ScriptDefines/PetScript.cpp | 90 + .../Scripting/ScriptDefines/PlayerScript.cpp | 1514 ++++++++ .../Scripting/ScriptDefines/ServerScript.cpp | 97 + .../game/Scripting/ScriptDefines/SpellSC.cpp | 158 + .../ScriptDefines/SpellScriptLoader.cpp | 77 + .../ScriptDefines/TransportScript.cpp | 71 + .../Scripting/ScriptDefines/UnitScript.cpp | 200 + .../Scripting/ScriptDefines/VehicleScript.cpp | 89 + .../Scripting/ScriptDefines/WeatherScript.cpp | 44 + .../ScriptDefines/WorldObjectScript.cpp | 69 + .../Scripting/ScriptDefines/WorldScript.cpp | 115 + src/server/game/Scripting/ScriptMgr.cpp | 3235 +---------------- src/server/game/Scripting/ScriptMgrMacros.h | 65 +- 44 files changed, 5289 insertions(+), 3167 deletions(-) create mode 100644 src/server/game/Scripting/ScriptDefines/AccountScript.cpp create mode 100644 src/server/game/Scripting/ScriptDefines/AchievementCriteriaScript.cpp create mode 100644 src/server/game/Scripting/ScriptDefines/AchievementScript.cpp create mode 100644 src/server/game/Scripting/ScriptDefines/AllCreatureScript.cpp create mode 100644 src/server/game/Scripting/ScriptDefines/AllGameObjectScript.cpp create mode 100644 src/server/game/Scripting/ScriptDefines/AllMapScript.cpp create mode 100644 src/server/game/Scripting/ScriptDefines/AreaTriggerScript.cpp create mode 100644 src/server/game/Scripting/ScriptDefines/ArenaScript.cpp create mode 100644 src/server/game/Scripting/ScriptDefines/ArenaTeamScript.cpp create mode 100644 src/server/game/Scripting/ScriptDefines/AuctionHouseScript.cpp create mode 100644 src/server/game/Scripting/ScriptDefines/BGScript.cpp create mode 100644 src/server/game/Scripting/ScriptDefines/BattlegroundScript.cpp create mode 100644 src/server/game/Scripting/ScriptDefines/CommandSC.cpp create mode 100644 src/server/game/Scripting/ScriptDefines/CommandScript.cpp create mode 100644 src/server/game/Scripting/ScriptDefines/ConditionScript.cpp create mode 100644 src/server/game/Scripting/ScriptDefines/CreatureScript.cpp create mode 100644 src/server/game/Scripting/ScriptDefines/DatabaseScript.cpp create mode 100644 src/server/game/Scripting/ScriptDefines/DynamicObjectScript.cpp create mode 100644 src/server/game/Scripting/ScriptDefines/FormulaScript.cpp create mode 100644 src/server/game/Scripting/ScriptDefines/GameEventScript.cpp create mode 100644 src/server/game/Scripting/ScriptDefines/GameObjectScript.cpp create mode 100644 src/server/game/Scripting/ScriptDefines/GlobalScript.cpp create mode 100644 src/server/game/Scripting/ScriptDefines/GroupScript.cpp create mode 100644 src/server/game/Scripting/ScriptDefines/GuildScript.cpp create mode 100644 src/server/game/Scripting/ScriptDefines/InstanceMapScript.cpp create mode 100644 src/server/game/Scripting/ScriptDefines/ItemScript.cpp create mode 100644 src/server/game/Scripting/ScriptDefines/LootScript.cpp create mode 100644 src/server/game/Scripting/ScriptDefines/MailScript.cpp create mode 100644 src/server/game/Scripting/ScriptDefines/MiscScript.cpp create mode 100644 src/server/game/Scripting/ScriptDefines/MovementHandlerScript.cpp create mode 100644 src/server/game/Scripting/ScriptDefines/OutdoorPvPScript.cpp create mode 100644 src/server/game/Scripting/ScriptDefines/PetScript.cpp create mode 100644 src/server/game/Scripting/ScriptDefines/PlayerScript.cpp create mode 100644 src/server/game/Scripting/ScriptDefines/ServerScript.cpp create mode 100644 src/server/game/Scripting/ScriptDefines/SpellSC.cpp create mode 100644 src/server/game/Scripting/ScriptDefines/SpellScriptLoader.cpp create mode 100644 src/server/game/Scripting/ScriptDefines/TransportScript.cpp create mode 100644 src/server/game/Scripting/ScriptDefines/UnitScript.cpp create mode 100644 src/server/game/Scripting/ScriptDefines/VehicleScript.cpp create mode 100644 src/server/game/Scripting/ScriptDefines/WeatherScript.cpp create mode 100644 src/server/game/Scripting/ScriptDefines/WorldObjectScript.cpp create mode 100644 src/server/game/Scripting/ScriptDefines/WorldScript.cpp diff --git a/src/server/game/Scripting/ScriptDefines/AccountScript.cpp b/src/server/game/Scripting/ScriptDefines/AccountScript.cpp new file mode 100644 index 000000000..99ac4c799 --- /dev/null +++ b/src/server/game/Scripting/ScriptDefines/AccountScript.cpp @@ -0,0 +1,83 @@ +/* + * 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 . + */ + +#include "ScriptMgr.h" +#include "ScriptMgrMacros.h" + +void ScriptMgr::OnAccountLogin(uint32 accountId) +{ + ExecuteScript([&](AccountScript* script) + { + script->OnAccountLogin(accountId); + }); +} + +//void ScriptMgr::OnAccountLogout(uint32 accountId) +//{ +// ExecuteScript([&](AccountScript* script) +// { +// script->OnAccountLogout(accountId); +// }); +//} + +void ScriptMgr::OnLastIpUpdate(uint32 accountId, std::string ip) +{ + ExecuteScript([&](AccountScript* script) + { + script->OnLastIpUpdate(accountId, ip); + }); +} + +void ScriptMgr::OnFailedAccountLogin(uint32 accountId) +{ + ExecuteScript([&](AccountScript* script) + { + script->OnFailedAccountLogin(accountId); + }); +} + +void ScriptMgr::OnEmailChange(uint32 accountId) +{ + ExecuteScript([&](AccountScript* script) + { + script->OnEmailChange(accountId); + }); +} + +void ScriptMgr::OnFailedEmailChange(uint32 accountId) +{ + ExecuteScript([&](AccountScript* script) + { + script->OnFailedEmailChange(accountId); + }); +} + +void ScriptMgr::OnPasswordChange(uint32 accountId) +{ + ExecuteScript([&](AccountScript* script) + { + script->OnPasswordChange(accountId); + }); +} + +void ScriptMgr::OnFailedPasswordChange(uint32 accountId) +{ + ExecuteScript([&](AccountScript* script) + { + script->OnFailedPasswordChange(accountId); + }); +} diff --git a/src/server/game/Scripting/ScriptDefines/AchievementCriteriaScript.cpp b/src/server/game/Scripting/ScriptDefines/AchievementCriteriaScript.cpp new file mode 100644 index 000000000..871dc8865 --- /dev/null +++ b/src/server/game/Scripting/ScriptDefines/AchievementCriteriaScript.cpp @@ -0,0 +1,28 @@ +/* + * 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 . + */ + +#include "ScriptMgr.h" +#include "ScriptMgrMacros.h" + +bool ScriptMgr::OnCriteriaCheck(uint32 scriptId, Player* source, Unit* target, uint32 criteria_id) +{ + ASSERT(source); + // target can be nullptr. + + auto tempScript = ScriptRegistry::GetScriptById(scriptId); + return tempScript ? tempScript->OnCheck(source, target, criteria_id) : false; +} diff --git a/src/server/game/Scripting/ScriptDefines/AchievementScript.cpp b/src/server/game/Scripting/ScriptDefines/AchievementScript.cpp new file mode 100644 index 000000000..e99ade7e4 --- /dev/null +++ b/src/server/game/Scripting/ScriptDefines/AchievementScript.cpp @@ -0,0 +1,80 @@ +/* + * 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 . + */ + +#include "ScriptMgr.h" +#include "ScriptMgrMacros.h" + +void ScriptMgr::SetRealmCompleted(AchievementEntry const* achievement) +{ + ExecuteScript([&](AchievementScript* script) + { + script->SetRealmCompleted(achievement); + }); +} + +bool ScriptMgr::IsCompletedCriteria(AchievementMgr* mgr, AchievementCriteriaEntry const* achievementCriteria, AchievementEntry const* achievement, CriteriaProgress const* progress) +{ + auto ret = IsValidBoolScript([&](AchievementScript* script) + { + return !script->IsCompletedCriteria(mgr, achievementCriteria, achievement, progress); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +bool ScriptMgr::IsRealmCompleted(AchievementGlobalMgr const* globalmgr, AchievementEntry const* achievement, SystemTimePoint completionTime) +{ + auto ret = IsValidBoolScript([&](AchievementScript* script) + { + return !script->IsRealmCompleted(globalmgr, achievement, completionTime); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +void ScriptMgr::OnBeforeCheckCriteria(AchievementMgr* mgr, AchievementCriteriaEntryList const* achievementCriteriaList) +{ + ExecuteScript([&](AchievementScript* script) + { + script->OnBeforeCheckCriteria(mgr, achievementCriteriaList); + }); +} + +bool ScriptMgr::CanCheckCriteria(AchievementMgr* mgr, AchievementCriteriaEntry const* achievementCriteria) +{ + auto ret = IsValidBoolScript([&](AchievementScript* script) + { + return !script->CanCheckCriteria(mgr, achievementCriteria); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} diff --git a/src/server/game/Scripting/ScriptDefines/AllCreatureScript.cpp b/src/server/game/Scripting/ScriptDefines/AllCreatureScript.cpp new file mode 100644 index 000000000..8fa40dd2b --- /dev/null +++ b/src/server/game/Scripting/ScriptDefines/AllCreatureScript.cpp @@ -0,0 +1,60 @@ +/* + * 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 . + */ + +#include "ScriptMgr.h" +#include "ScriptMgrMacros.h" + +void ScriptMgr::OnCreatureAddWorld(Creature* creature) +{ + ASSERT(creature); + + ExecuteScript([&](AllCreatureScript* script) + { + script->OnCreatureAddWorld(creature); + }); +} + +void ScriptMgr::OnCreatureRemoveWorld(Creature* creature) +{ + ASSERT(creature); + + ExecuteScript([&](AllCreatureScript* script) + { + script->OnCreatureRemoveWorld(creature); + }); +} + +void ScriptMgr::Creature_SelectLevel(const CreatureTemplate* cinfo, Creature* creature) +{ + ExecuteScript([&](AllCreatureScript* script) + { + script->Creature_SelectLevel(cinfo, creature); + }); +} + +//bool ScriptMgr::CanCreatureSendListInventory(Player* player, Creature* creature, uint32 vendorEntry) +//{ +// auto ret = IsValidBoolScript([&](AllCreatureScript* script) +// { +// return !script->CanCreatureSendListInventory(player, creature, vendorEntry); +// }); +// +// if (ret && *ret) +// return false; +// +// return true; +//} diff --git a/src/server/game/Scripting/ScriptDefines/AllGameObjectScript.cpp b/src/server/game/Scripting/ScriptDefines/AllGameObjectScript.cpp new file mode 100644 index 000000000..39d4d62b2 --- /dev/null +++ b/src/server/game/Scripting/ScriptDefines/AllGameObjectScript.cpp @@ -0,0 +1,39 @@ +/* + * 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 . + */ + +#include "ScriptMgr.h" +#include "ScriptMgrMacros.h" + +void ScriptMgr::OnGameObjectAddWorld(GameObject* go) +{ + ASSERT(go); + + ExecuteScript([&](AllGameObjectScript* script) + { + script->OnGameObjectAddWorld(go); + }); +} + +void ScriptMgr::OnGameObjectRemoveWorld(GameObject* go) +{ + ASSERT(go); + + ExecuteScript([&](AllGameObjectScript* script) + { + script->OnGameObjectRemoveWorld(go); + }); +} diff --git a/src/server/game/Scripting/ScriptDefines/AllMapScript.cpp b/src/server/game/Scripting/ScriptDefines/AllMapScript.cpp new file mode 100644 index 000000000..5dc11d58b --- /dev/null +++ b/src/server/game/Scripting/ScriptDefines/AllMapScript.cpp @@ -0,0 +1,353 @@ +/* + * 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 . + */ + +#include "ScriptMgr.h" +#include "ScriptMgrMacros.h" + +namespace +{ + template + inline void ForeachMaps([[maybe_unused]] Map* map, [[maybe_unused]] std::function executeHook) + { + static_assert(Acore::dependant_false_v, "Unsupported type used for ForeachMaps"); + } + + template<> + inline void ForeachMaps(Map* map, std::function executeHook) + { + auto mapEntry = map->GetEntry(); + + if (!mapEntry) + { + return; + } + + if (!mapEntry->IsWorldMap()) + { + return; + } + + if (ScriptRegistry::ScriptPointerList.empty()) + { + return; + } + + for (auto const& [scriptID, script] : ScriptRegistry::ScriptPointerList) + { + MapEntry const* mapEntry = script->GetEntry(); + if (!mapEntry) + { + continue; + } + + if (mapEntry->MapID != map->GetId()) + { + continue; + } + + executeHook(script); + return; + } + } + + template<> + inline void ForeachMaps(Map* map, std::function executeHook) + { + auto mapEntry = map->GetEntry(); + + if (!mapEntry) + { + return; + } + + if (!mapEntry->IsDungeon()) + { + return; + } + + if (ScriptRegistry::ScriptPointerList.empty()) + { + return; + } + + for (auto const& [scriptID, script] : ScriptRegistry::ScriptPointerList) + { + MapEntry const* mapEntry = script->GetEntry(); + if (!mapEntry) + { + continue; + } + + if (mapEntry->MapID != map->GetId()) + { + continue; + } + + executeHook(script); + return; + } + } + + template<> + inline void ForeachMaps(Map* map, std::function executeHook) + { + auto mapEntry = map->GetEntry(); + + if (!mapEntry) + { + return; + } + + if (!mapEntry->IsBattleground()) + { + return; + } + + if (ScriptRegistry::ScriptPointerList.empty()) + { + return; + } + + for (auto const& [scriptID, script] : ScriptRegistry::ScriptPointerList) + { + MapEntry const* mapEntry = script->GetEntry(); + if (!mapEntry) + { + continue; + } + + if (mapEntry->MapID != map->GetId()) + { + continue; + } + + executeHook(script); + return; + } + } +} + +void ScriptMgr::OnCreateMap(Map* map) +{ + ASSERT(map); + + ExecuteScript([&](AllMapScript* script) + { + script->OnCreateMap(map); + }); + + ForeachMaps(map, + [&](WorldMapScript* script) + { + script->OnCreate(map); + }); + + ForeachMaps(map, + [&](InstanceMapScript* script) + { + script->OnCreate((InstanceMap*)map); + }); + + ForeachMaps(map, + [&](BattlegroundMapScript* script) + { + script->OnCreate((BattlegroundMap*)map); + }); +} + +void ScriptMgr::OnDestroyMap(Map* map) +{ + ASSERT(map); + + ExecuteScript([&](AllMapScript* script) + { + script->OnDestroyMap(map); + }); + + ForeachMaps(map, + [&](WorldMapScript* script) + { + script->OnDestroy(map); + }); + + ForeachMaps(map, + [&](InstanceMapScript* script) + { + script->OnDestroy((InstanceMap*)map); + }); + + ForeachMaps(map, + [&](BattlegroundMapScript* script) + { + script->OnDestroy((BattlegroundMap*)map); + }); +} + +void ScriptMgr::OnLoadGridMap(Map* map, GridMap* gmap, uint32 gx, uint32 gy) +{ + ASSERT(map); + ASSERT(gmap); + + ForeachMaps(map, + [&](WorldMapScript* script) + { + script->OnLoadGridMap(map, gmap, gx, gy); + }); + + ForeachMaps(map, + [&](InstanceMapScript* script) + { + script->OnLoadGridMap((InstanceMap*)map, gmap, gx, gy); + }); + + ForeachMaps(map, + [&](BattlegroundMapScript* script) + { + script->OnLoadGridMap((BattlegroundMap*)map, gmap, gx, gy); + }); +} + +void ScriptMgr::OnUnloadGridMap(Map* map, GridMap* gmap, uint32 gx, uint32 gy) +{ + ASSERT(map); + ASSERT(gmap); + + ForeachMaps(map, + [&](WorldMapScript* script) + { + script->OnUnloadGridMap(map, gmap, gx, gy); + }); + + ForeachMaps(map, + [&](InstanceMapScript* script) + { + script->OnUnloadGridMap((InstanceMap*)map, gmap, gx, gy); + }); + + ForeachMaps(map, + [&](BattlegroundMapScript* script) + { + script->OnUnloadGridMap((BattlegroundMap*)map, gmap, gx, gy); + }); +} + +void ScriptMgr::OnPlayerEnterMap(Map* map, Player* player) +{ + ASSERT(map); + ASSERT(player); + + ExecuteScript([&](AllMapScript* script) + { + script->OnPlayerEnterAll(map, player); + }); + + ExecuteScript([&](PlayerScript* script) + { + script->OnMapChanged(player); + }); + + ForeachMaps(map, + [&](WorldMapScript* script) + { + script->OnPlayerEnter(map, player); + }); + + ForeachMaps(map, + [&](InstanceMapScript* script) + { + script->OnPlayerEnter((InstanceMap*)map, player); + }); + + ForeachMaps(map, + [&](BattlegroundMapScript* script) + { + script->OnPlayerEnter((BattlegroundMap*)map, player); + }); +} + +void ScriptMgr::OnPlayerLeaveMap(Map* map, Player* player) +{ + ASSERT(map); + ASSERT(player); + + ExecuteScript([&](AllMapScript* script) + { + script->OnPlayerLeaveAll(map, player); + }); + + ForeachMaps(map, + [&](WorldMapScript* script) + { + script->OnPlayerLeave(map, player); + }); + + ForeachMaps(map, + [&](InstanceMapScript* script) + { + script->OnPlayerLeave((InstanceMap*)map, player); + }); + + ForeachMaps(map, + [&](BattlegroundMapScript* script) + { + script->OnPlayerLeave((BattlegroundMap*)map, player); + }); +} + +void ScriptMgr::OnMapUpdate(Map* map, uint32 diff) +{ + ASSERT(map); + + ExecuteScript([&](AllMapScript* script) + { + script->OnMapUpdate(map, diff); + }); + + ForeachMaps(map, + [&](WorldMapScript* script) + { + script->OnUpdate(map, diff); + }); + + ForeachMaps(map, + [&](InstanceMapScript* script) + { + script->OnUpdate((InstanceMap*)map, diff); + }); + + ForeachMaps(map, + [&](BattlegroundMapScript* script) + { + script->OnUpdate((BattlegroundMap*)map, diff); + }); +} + +void ScriptMgr::OnBeforeCreateInstanceScript(InstanceMap* instanceMap, InstanceScript* instanceData, bool load, std::string data, uint32 completedEncounterMask) +{ + ExecuteScript([&](AllMapScript* script) + { + script->OnBeforeCreateInstanceScript(instanceMap, instanceData, load, data, completedEncounterMask); + }); +} + +void ScriptMgr::OnDestroyInstance(MapInstanced* mapInstanced, Map* map) +{ + ExecuteScript([&](AllMapScript* script) + { + script->OnDestroyInstance(mapInstanced, map); + }); +} diff --git a/src/server/game/Scripting/ScriptDefines/AreaTriggerScript.cpp b/src/server/game/Scripting/ScriptDefines/AreaTriggerScript.cpp new file mode 100644 index 000000000..fa3a04deb --- /dev/null +++ b/src/server/game/Scripting/ScriptDefines/AreaTriggerScript.cpp @@ -0,0 +1,38 @@ +/* + * 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 . + */ + +#include "ScriptMgr.h" +#include "ScriptMgrMacros.h" + +bool ScriptMgr::OnAreaTrigger(Player* player, AreaTrigger const* trigger) +{ + ASSERT(player); + ASSERT(trigger); + + auto ret = IsValidBoolScript([&](ElunaScript* script) + { + return script->CanAreaTrigger(player, trigger); + }); + + if (ret && *ret) + { + return false; + } + + auto tempScript = ScriptRegistry::GetScriptById(sObjectMgr->GetAreaTriggerScriptId(trigger->entry)); + return tempScript ? tempScript->OnTrigger(player, trigger) : false; +} diff --git a/src/server/game/Scripting/ScriptDefines/ArenaScript.cpp b/src/server/game/Scripting/ScriptDefines/ArenaScript.cpp new file mode 100644 index 000000000..0bfc33184 --- /dev/null +++ b/src/server/game/Scripting/ScriptDefines/ArenaScript.cpp @@ -0,0 +1,57 @@ +/* + * 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 . + */ + +#include "ScriptMgr.h" +#include "ScriptMgrMacros.h" + +bool ScriptMgr::CanAddMember(ArenaTeam* team, ObjectGuid PlayerGuid) +{ + auto ret = IsValidBoolScript([&](ArenaScript* script) + { + return !script->CanAddMember(team, PlayerGuid); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +void ScriptMgr::OnGetPoints(ArenaTeam* team, uint32 memberRating, float& points) +{ + ExecuteScript([&](ArenaScript* script) + { + script->OnGetPoints(team, memberRating, points); + }); +} + +bool ScriptMgr::CanSaveToDB(ArenaTeam* team) +{ + auto ret = IsValidBoolScript([&](ArenaScript* script) + { + return !script->CanSaveToDB(team); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} diff --git a/src/server/game/Scripting/ScriptDefines/ArenaTeamScript.cpp b/src/server/game/Scripting/ScriptDefines/ArenaTeamScript.cpp new file mode 100644 index 000000000..25555347a --- /dev/null +++ b/src/server/game/Scripting/ScriptDefines/ArenaTeamScript.cpp @@ -0,0 +1,59 @@ +/* + * 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 . + */ + +#include "ScriptMgr.h" +#include "ScriptMgrMacros.h" + +void ScriptMgr::OnGetSlotByType(const uint32 type, uint8& slot) +{ + ExecuteScript([&](ArenaTeamScript* script) + { + script->OnGetSlotByType(type, slot); + }); +} + +void ScriptMgr::OnGetArenaPoints(ArenaTeam* at, float& points) +{ + ExecuteScript([&](ArenaTeamScript* script) + { + script->OnGetArenaPoints(at, points); + }); +} + +void ScriptMgr::OnArenaTypeIDToQueueID(const BattlegroundTypeId bgTypeId, const uint8 arenaType, uint32& queueTypeID) +{ + ExecuteScript([&](ArenaTeamScript* script) + { + script->OnTypeIDToQueueID(bgTypeId, arenaType, queueTypeID); + }); +} + +void ScriptMgr::OnArenaQueueIdToArenaType(const BattlegroundQueueTypeId bgQueueTypeId, uint8& ArenaType) +{ + ExecuteScript([&](ArenaTeamScript* script) + { + script->OnQueueIdToArenaType(bgQueueTypeId, ArenaType); + }); +} + +void ScriptMgr::OnSetArenaMaxPlayersPerTeam(const uint8 arenaType, uint32& maxPlayerPerTeam) +{ + ExecuteScript([&](ArenaTeamScript* script) + { + script->OnSetArenaMaxPlayersPerTeam(arenaType, maxPlayerPerTeam); + }); +} diff --git a/src/server/game/Scripting/ScriptDefines/AuctionHouseScript.cpp b/src/server/game/Scripting/ScriptDefines/AuctionHouseScript.cpp new file mode 100644 index 000000000..e0255d26d --- /dev/null +++ b/src/server/game/Scripting/ScriptDefines/AuctionHouseScript.cpp @@ -0,0 +1,119 @@ +/* + * 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 . + */ + +#include "ScriptMgr.h" +#include "ScriptMgrMacros.h" + +void ScriptMgr::OnAuctionAdd(AuctionHouseObject* ah, AuctionEntry* entry) +{ + ASSERT(ah); + ASSERT(entry); + + ExecuteScript([&](AuctionHouseScript* script) + { + script->OnAuctionAdd(ah, entry); + }); +} + +void ScriptMgr::OnAuctionRemove(AuctionHouseObject* ah, AuctionEntry* entry) +{ + ASSERT(ah); + ASSERT(entry); + + ExecuteScript([&](AuctionHouseScript* script) + { + script->OnAuctionRemove(ah, entry); + }); +} + +void ScriptMgr::OnAuctionSuccessful(AuctionHouseObject* ah, AuctionEntry* entry) +{ + ASSERT(ah); + ASSERT(entry); + + ExecuteScript([&](AuctionHouseScript* script) + { + script->OnAuctionSuccessful(ah, entry); + }); +} + +void ScriptMgr::OnAuctionExpire(AuctionHouseObject* ah, AuctionEntry* entry) +{ + ASSERT(ah); + ASSERT(entry); + + ExecuteScript([&](AuctionHouseScript* script) + { + script->OnAuctionExpire(ah, entry); + }); +} + +void ScriptMgr::OnBeforeAuctionHouseMgrSendAuctionWonMail(AuctionHouseMgr* auctionHouseMgr, AuctionEntry* auction, Player* bidder, uint32& bidder_accId, bool& sendNotification, bool& updateAchievementCriteria, bool& sendMail) +{ + ExecuteScript([&](AuctionHouseScript* script) + { + script->OnBeforeAuctionHouseMgrSendAuctionWonMail(auctionHouseMgr, auction, bidder, bidder_accId, sendNotification, updateAchievementCriteria, sendMail); + }); +} + +void ScriptMgr::OnBeforeAuctionHouseMgrSendAuctionSalePendingMail(AuctionHouseMgr* auctionHouseMgr, AuctionEntry* auction, Player* owner, uint32& owner_accId, bool& sendMail) +{ + ExecuteScript([&](AuctionHouseScript* script) + { + script->OnBeforeAuctionHouseMgrSendAuctionSalePendingMail(auctionHouseMgr, auction, owner, owner_accId, sendMail); + }); +} + +void ScriptMgr::OnBeforeAuctionHouseMgrSendAuctionSuccessfulMail(AuctionHouseMgr* auctionHouseMgr, AuctionEntry* auction, Player* owner, uint32& owner_accId, uint32& profit, bool& sendNotification, bool& updateAchievementCriteria, bool& sendMail) +{ + ExecuteScript([&](AuctionHouseScript* script) + { + script->OnBeforeAuctionHouseMgrSendAuctionSuccessfulMail(auctionHouseMgr, auction, owner, owner_accId, profit, sendNotification, updateAchievementCriteria, sendMail); + }); +} + +void ScriptMgr::OnBeforeAuctionHouseMgrSendAuctionExpiredMail(AuctionHouseMgr* auctionHouseMgr, AuctionEntry* auction, Player* owner, uint32& owner_accId, bool& sendNotification, bool& sendMail) +{ + ExecuteScript([&](AuctionHouseScript* script) + { + script->OnBeforeAuctionHouseMgrSendAuctionExpiredMail(auctionHouseMgr, auction, owner, owner_accId, sendNotification, sendMail); + }); +} + +void ScriptMgr::OnBeforeAuctionHouseMgrSendAuctionOutbiddedMail(AuctionHouseMgr* auctionHouseMgr, AuctionEntry* auction, Player* oldBidder, uint32& oldBidder_accId, Player* newBidder, uint32& newPrice, bool& sendNotification, bool& sendMail) +{ + ExecuteScript([&](AuctionHouseScript* script) + { + script->OnBeforeAuctionHouseMgrSendAuctionOutbiddedMail(auctionHouseMgr, auction, oldBidder, oldBidder_accId, newBidder, newPrice, sendNotification, sendMail); + }); +} + +void ScriptMgr::OnBeforeAuctionHouseMgrSendAuctionCancelledToBidderMail(AuctionHouseMgr* auctionHouseMgr, AuctionEntry* auction, Player* bidder, uint32& bidder_accId, bool& sendMail) +{ + ExecuteScript([&](AuctionHouseScript* script) + { + script->OnBeforeAuctionHouseMgrSendAuctionCancelledToBidderMail(auctionHouseMgr, auction, bidder, bidder_accId, sendMail); + }); +} + +void ScriptMgr::OnBeforeAuctionHouseMgrUpdate() +{ + ExecuteScript([&](AuctionHouseScript* script) + { + script->OnBeforeAuctionHouseMgrUpdate(); + }); +} diff --git a/src/server/game/Scripting/ScriptDefines/BGScript.cpp b/src/server/game/Scripting/ScriptDefines/BGScript.cpp new file mode 100644 index 000000000..602cb342a --- /dev/null +++ b/src/server/game/Scripting/ScriptDefines/BGScript.cpp @@ -0,0 +1,191 @@ +/* + * 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 . + */ + +#include "ScriptMgr.h" +#include "ScriptMgrMacros.h" + +void ScriptMgr::OnBattlegroundStart(Battleground* bg) +{ + ExecuteScript([&](BGScript* script) + { + script->OnBattlegroundStart(bg); + }); +} + +void ScriptMgr::OnBattlegroundEndReward(Battleground* bg, Player* player, TeamId winnerTeamId) +{ + ExecuteScript([&](BGScript* script) + { + script->OnBattlegroundEndReward(bg, player, winnerTeamId); + }); +} + +void ScriptMgr::OnBattlegroundUpdate(Battleground* bg, uint32 diff) +{ + ExecuteScript([&](BGScript* script) + { + script->OnBattlegroundUpdate(bg, diff); + }); +} + +void ScriptMgr::OnBattlegroundAddPlayer(Battleground* bg, Player* player) +{ + ExecuteScript([&](BGScript* script) + { + script->OnBattlegroundAddPlayer(bg, player); + }); +} + +void ScriptMgr::OnBattlegroundBeforeAddPlayer(Battleground* bg, Player* player) +{ + ExecuteScript([&](BGScript* script) + { + script->OnBattlegroundBeforeAddPlayer(bg, player); + }); +} + +void ScriptMgr::OnBattlegroundRemovePlayerAtLeave(Battleground* bg, Player* player) +{ + ExecuteScript([&](BGScript* script) + { + script->OnBattlegroundRemovePlayerAtLeave(bg, player); + }); +} + +void ScriptMgr::OnAddGroup(BattlegroundQueue* queue, GroupQueueInfo* ginfo, uint32& index, Player* leader, Group* grp, PvPDifficultyEntry const* bracketEntry, bool isPremade) +{ + ExecuteScript([&](BGScript* script) + { + script->OnAddGroup(queue, ginfo, index, leader, grp, bracketEntry, isPremade); + }); +} + +bool ScriptMgr::CanFillPlayersToBG(BattlegroundQueue* queue, Battleground* bg, const int32 aliFree, const int32 hordeFree, BattlegroundBracketId bracket_id) +{ + auto ret = IsValidBoolScript([&](BGScript* script) + { + return !script->CanFillPlayersToBG(queue, bg, aliFree, hordeFree, bracket_id); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +bool ScriptMgr::CanFillPlayersToBGWithSpecific(BattlegroundQueue* queue, Battleground* bg, const int32 aliFree, const int32 hordeFree, + BattlegroundBracketId thisBracketId, BattlegroundQueue* specificQueue, BattlegroundBracketId specificBracketId) +{ + auto ret = IsValidBoolScript([&](BGScript* script) + { + return !script->CanFillPlayersToBGWithSpecific(queue, bg, aliFree, hordeFree, thisBracketId, specificQueue, specificBracketId); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +void ScriptMgr::OnCheckNormalMatch(BattlegroundQueue* queue, uint32& Coef, Battleground* bgTemplate, BattlegroundBracketId bracket_id, uint32& minPlayers, uint32& maxPlayers) +{ + ExecuteScript([&](BGScript* script) + { + script->OnCheckNormalMatch(queue, Coef, bgTemplate, bracket_id, minPlayers, maxPlayers); + }); +} + +void ScriptMgr::OnQueueUpdate(BattlegroundQueue* queue, BattlegroundBracketId bracket_id, bool isRated, uint32 arenaRatedTeamId) +{ + ExecuteScript([&](BGScript* script) + { + script->OnQueueUpdate(queue, bracket_id, isRated, arenaRatedTeamId); + }); +} + +bool ScriptMgr::CanSendMessageBGQueue(BattlegroundQueue* queue, Player* leader, Battleground* bg, PvPDifficultyEntry const* bracketEntry) +{ + auto ret = IsValidBoolScript([&](BGScript* script) + { + return !script->CanSendMessageBGQueue(queue, leader, bg, bracketEntry); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +bool ScriptMgr::OnBeforeSendJoinMessageArenaQueue(BattlegroundQueue* queue, Player* leader, GroupQueueInfo* ginfo, PvPDifficultyEntry const* bracketEntry, bool isRated) +{ + auto ret = IsValidBoolScript([&](BGScript* script) + { + return !script->OnBeforeSendJoinMessageArenaQueue(queue, leader, ginfo, bracketEntry, isRated); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +bool ScriptMgr::OnBeforeSendExitMessageArenaQueue(BattlegroundQueue* queue, GroupQueueInfo* ginfo) +{ + auto ret = IsValidBoolScript([&](BGScript* script) + { + return !script->OnBeforeSendExitMessageArenaQueue(queue, ginfo); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +void ScriptMgr::OnBattlegroundEnd(Battleground* bg, TeamId winnerTeam) +{ + ExecuteScript([&](BGScript* script) + { + script->OnBattlegroundEnd(bg, winnerTeam); + }); +} + +void ScriptMgr::OnBattlegroundDestroy(Battleground* bg) +{ + ExecuteScript([&](BGScript* script) + { + script->OnBattlegroundDestroy(bg); + }); +} + +void ScriptMgr::OnBattlegroundCreate(Battleground* bg) +{ + ExecuteScript([&](BGScript* script) + { + script->OnBattlegroundCreate(bg); + }); +} diff --git a/src/server/game/Scripting/ScriptDefines/BattlegroundScript.cpp b/src/server/game/Scripting/ScriptDefines/BattlegroundScript.cpp new file mode 100644 index 000000000..90aee0057 --- /dev/null +++ b/src/server/game/Scripting/ScriptDefines/BattlegroundScript.cpp @@ -0,0 +1,26 @@ +/* + * 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 . + */ + +#include "ScriptMgr.h" +#include "ScriptMgrMacros.h" + +Battleground* ScriptMgr::CreateBattleground(BattlegroundTypeId /*typeId*/) +{ + // TODO: Implement script-side battlegrounds. + ABORT(); + return nullptr; +} diff --git a/src/server/game/Scripting/ScriptDefines/CommandSC.cpp b/src/server/game/Scripting/ScriptDefines/CommandSC.cpp new file mode 100644 index 000000000..a92ff2297 --- /dev/null +++ b/src/server/game/Scripting/ScriptDefines/CommandSC.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 . + */ + +#include "ScriptMgr.h" +#include "ScriptMgrMacros.h" + +void ScriptMgr::OnHandleDevCommand(Player* player, std::string& argstr) +{ + ExecuteScript([&](CommandSC* script) + { + script->OnHandleDevCommand(player, argstr); + }); +} + +bool ScriptMgr::CanExecuteCommand(ChatHandler& handler, std::string_view cmdStr) +{ + auto ret = IsValidBoolScript([&](CommandSC* script) + { + return !script->CanExecuteCommand(handler, cmdStr); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} diff --git a/src/server/game/Scripting/ScriptDefines/CommandScript.cpp b/src/server/game/Scripting/ScriptDefines/CommandScript.cpp new file mode 100644 index 000000000..1aff3e3bb --- /dev/null +++ b/src/server/game/Scripting/ScriptDefines/CommandScript.cpp @@ -0,0 +1,33 @@ +/* + * 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 . + */ + +#include "ScriptMgr.h" +#include "ScriptMgrMacros.h" +#include "Chat.h" + +Acore::ChatCommands::ChatCommandTable ScriptMgr::GetChatCommands() +{ + Acore::ChatCommands::ChatCommandTable table; + + for (auto const& [scriptID, script] : ScriptRegistry::ScriptPointerList) + { + Acore::ChatCommands::ChatCommandTable cmds = script->GetCommands(); + std::move(cmds.begin(), cmds.end(), std::back_inserter(table)); + } + + return table; +} diff --git a/src/server/game/Scripting/ScriptDefines/ConditionScript.cpp b/src/server/game/Scripting/ScriptDefines/ConditionScript.cpp new file mode 100644 index 000000000..68d239028 --- /dev/null +++ b/src/server/game/Scripting/ScriptDefines/ConditionScript.cpp @@ -0,0 +1,27 @@ +/* + * 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 . + */ + +#include "ScriptMgr.h" +#include "ScriptMgrMacros.h" + +bool ScriptMgr::OnConditionCheck(Condition* condition, ConditionSourceInfo& sourceInfo) +{ + ASSERT(condition); + + auto tempScript = ScriptRegistry::GetScriptById(condition->ScriptId); + return tempScript ? tempScript->OnConditionCheck(condition, sourceInfo) : true; +} diff --git a/src/server/game/Scripting/ScriptDefines/CreatureScript.cpp b/src/server/game/Scripting/ScriptDefines/CreatureScript.cpp new file mode 100644 index 000000000..e4e54c7dc --- /dev/null +++ b/src/server/game/Scripting/ScriptDefines/CreatureScript.cpp @@ -0,0 +1,186 @@ +/* + * 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 . + */ + +#include "ScriptMgr.h" +#include "ScriptMgrMacros.h" +#include "ScriptedGossip.h" + +bool ScriptMgr::OnGossipHello(Player* player, Creature* creature) +{ + ASSERT(player); + ASSERT(creature); + + auto ret = IsValidBoolScript([&](AllCreatureScript* script) + { + return script->CanCreatureGossipHello(player, creature); + }); + + if (ret && *ret) + { + return true; + } + + auto tempScript = ScriptRegistry::GetScriptById(creature->GetScriptId()); + ClearGossipMenuFor(player); + return tempScript ? tempScript->OnGossipHello(player, creature) : false; +} + +bool ScriptMgr::OnGossipSelect(Player* player, Creature* creature, uint32 sender, uint32 action) +{ + ASSERT(player); + ASSERT(creature); + + auto ret = IsValidBoolScript([&](AllCreatureScript* script) + { + return script->CanCreatureGossipSelect(player, creature, sender, action); + }); + + if (ret && *ret) + { + return true; + } + + auto tempScript = ScriptRegistry::GetScriptById(creature->GetScriptId()); + return tempScript ? tempScript->OnGossipSelect(player, creature, sender, action) : false; +} + +bool ScriptMgr::OnGossipSelectCode(Player* player, Creature* creature, uint32 sender, uint32 action, const char* code) +{ + ASSERT(player); + ASSERT(creature); + ASSERT(code); + + auto ret = IsValidBoolScript([&](AllCreatureScript* script) + { + return script->CanCreatureGossipSelectCode(player, creature, sender, action, code); + }); + + if (ret && *ret) + { + return true; + } + + auto tempScript = ScriptRegistry::GetScriptById(creature->GetScriptId()); + return tempScript ? tempScript->OnGossipSelectCode(player, creature, sender, action, code) : false; +} + +bool ScriptMgr::OnQuestAccept(Player* player, Creature* creature, Quest const* quest) +{ + ASSERT(player); + ASSERT(creature); + ASSERT(quest); + + auto ret = IsValidBoolScript([&](AllCreatureScript* script) + { + return script->CanCreatureQuestAccept(player, creature, quest); + }); + + if (ret && *ret) + { + return true; + } + + auto tempScript = ScriptRegistry::GetScriptById(creature->GetScriptId()); + ClearGossipMenuFor(player); + return tempScript ? tempScript->OnQuestAccept(player, creature, quest) : false; +} + +bool ScriptMgr::OnQuestSelect(Player* player, Creature* creature, Quest const* quest) +{ + ASSERT(player); + ASSERT(creature); + ASSERT(quest); + + auto tempScript = ScriptRegistry::GetScriptById(creature->GetScriptId()); + ClearGossipMenuFor(player); + return tempScript ? tempScript->OnQuestSelect(player, creature, quest) : false; +} + +bool ScriptMgr::OnQuestComplete(Player* player, Creature* creature, Quest const* quest) +{ + ASSERT(player); + ASSERT(creature); + ASSERT(quest); + + auto tempScript = ScriptRegistry::GetScriptById(creature->GetScriptId()); + ClearGossipMenuFor(player); + return tempScript ? tempScript->OnQuestComplete(player, creature, quest) : false; +} + +bool ScriptMgr::OnQuestReward(Player* player, Creature* creature, Quest const* quest, uint32 opt) +{ + ASSERT(player); + ASSERT(creature); + ASSERT(quest); + + auto ret = IsValidBoolScript([&](AllCreatureScript* script) + { + return script->CanCreatureQuestReward(player, creature, quest, opt); + }); + + if (ret && *ret) + { + return true; + } + + auto tempScript = ScriptRegistry::GetScriptById(creature->GetScriptId()); + ClearGossipMenuFor(player); + return tempScript ? tempScript->OnQuestReward(player, creature, quest, opt) : false; +} + +uint32 ScriptMgr::GetDialogStatus(Player* player, Creature* creature) +{ + ASSERT(player); + ASSERT(creature); + + auto tempScript = ScriptRegistry::GetScriptById(creature->GetScriptId()); + ClearGossipMenuFor(player); + return tempScript ? tempScript->GetDialogStatus(player, creature) : DIALOG_STATUS_SCRIPTED_NO_STATUS; +} + +CreatureAI* ScriptMgr::GetCreatureAI(Creature* creature) +{ + ASSERT(creature); + + auto retAI = GetReturnAIScript([creature](AllCreatureScript* script) + { + return script->GetCreatureAI(creature); + }); + + if (retAI) + { + return retAI; + } + + auto tempScript = ScriptRegistry::GetScriptById(creature->GetScriptId()); + return tempScript ? tempScript->GetAI(creature) : nullptr; +} + +void ScriptMgr::OnCreatureUpdate(Creature* creature, uint32 diff) +{ + ASSERT(creature); + + ExecuteScript([&](AllCreatureScript* script) + { + script->OnAllCreatureUpdate(creature, diff); + }); + + if (auto tempScript = ScriptRegistry::GetScriptById(creature->GetScriptId())) + { + tempScript->OnUpdate(creature, diff); + } +} diff --git a/src/server/game/Scripting/ScriptDefines/DatabaseScript.cpp b/src/server/game/Scripting/ScriptDefines/DatabaseScript.cpp new file mode 100644 index 000000000..b4debdf2f --- /dev/null +++ b/src/server/game/Scripting/ScriptDefines/DatabaseScript.cpp @@ -0,0 +1,27 @@ +/* + * 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 . + */ + +#include "ScriptMgr.h" +#include "ScriptMgrMacros.h" + +void ScriptMgr::OnAfterDatabasesLoaded(uint32 updateFlags) +{ + ExecuteScript([&](DatabaseScript* script) + { + script->OnAfterDatabasesLoaded(updateFlags); + }); +} diff --git a/src/server/game/Scripting/ScriptDefines/DynamicObjectScript.cpp b/src/server/game/Scripting/ScriptDefines/DynamicObjectScript.cpp new file mode 100644 index 000000000..80f126930 --- /dev/null +++ b/src/server/game/Scripting/ScriptDefines/DynamicObjectScript.cpp @@ -0,0 +1,29 @@ +/* + * 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 . + */ + +#include "ScriptMgr.h" +#include "ScriptMgrMacros.h" + +void ScriptMgr::OnDynamicObjectUpdate(DynamicObject* dynobj, uint32 diff) +{ + ASSERT(dynobj); + + for (auto const& [scriptID, script] : ScriptRegistry::ScriptPointerList) + { + script->OnUpdate(dynobj, diff); + } +} diff --git a/src/server/game/Scripting/ScriptDefines/FormulaScript.cpp b/src/server/game/Scripting/ScriptDefines/FormulaScript.cpp new file mode 100644 index 000000000..c4d029b0a --- /dev/null +++ b/src/server/game/Scripting/ScriptDefines/FormulaScript.cpp @@ -0,0 +1,94 @@ +/* + * 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 . + */ + +#include "ScriptMgr.h" +#include "ScriptMgrMacros.h" + +void ScriptMgr::OnHonorCalculation(float& honor, uint8 level, float multiplier) +{ + ExecuteScript([&](FormulaScript* script) + { + script->OnHonorCalculation(honor, level, multiplier); + }); +} + +void ScriptMgr::OnGrayLevelCalculation(uint8& grayLevel, uint8 playerLevel) +{ + ExecuteScript([&](FormulaScript* script) + { + script->OnGrayLevelCalculation(grayLevel, playerLevel); + }); +} + +void ScriptMgr::OnColorCodeCalculation(XPColorChar& color, uint8 playerLevel, uint8 mobLevel) +{ + ExecuteScript([&](FormulaScript* script) + { + script->OnColorCodeCalculation(color, playerLevel, mobLevel); + }); +} + +void ScriptMgr::OnZeroDifferenceCalculation(uint8& diff, uint8 playerLevel) +{ + ExecuteScript([&](FormulaScript* script) + { + script->OnZeroDifferenceCalculation(diff, playerLevel); + }); +} + +void ScriptMgr::OnBaseGainCalculation(uint32& gain, uint8 playerLevel, uint8 mobLevel, ContentLevels content) +{ + ExecuteScript([&](FormulaScript* script) + { + script->OnBaseGainCalculation(gain, playerLevel, mobLevel, content); + }); +} + +void ScriptMgr::OnGainCalculation(uint32& gain, Player* player, Unit* unit) +{ + ASSERT(player); + ASSERT(unit); + + ExecuteScript([&](FormulaScript* script) + { + script->OnGainCalculation(gain, player, unit); + }); +} + +void ScriptMgr::OnGroupRateCalculation(float& rate, uint32 count, bool isRaid) +{ + ExecuteScript([&](FormulaScript* script) + { + script->OnGroupRateCalculation(rate, count, isRaid); + }); +} + +void ScriptMgr::OnAfterArenaRatingCalculation(Battleground* const bg, int32& winnerMatchmakerChange, int32& loserMatchmakerChange, int32& winnerChange, int32& loserChange) +{ + ExecuteScript([&](FormulaScript* script) + { + script->OnAfterArenaRatingCalculation(bg, winnerMatchmakerChange, loserMatchmakerChange, winnerChange, loserChange); + }); +} + +void ScriptMgr::OnBeforeUpdatingPersonalRating(int32& mod, uint32 type) +{ + ExecuteScript([&](FormulaScript* script) + { + script->OnBeforeUpdatingPersonalRating(mod, type); + }); +} diff --git a/src/server/game/Scripting/ScriptDefines/GameEventScript.cpp b/src/server/game/Scripting/ScriptDefines/GameEventScript.cpp new file mode 100644 index 000000000..d489083ce --- /dev/null +++ b/src/server/game/Scripting/ScriptDefines/GameEventScript.cpp @@ -0,0 +1,35 @@ +/* + * 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 . + */ + +#include "ScriptMgr.h" +#include "ScriptMgrMacros.h" + +void ScriptMgr::OnGameEventStart(uint16 EventID) +{ + ExecuteScript([&](GameEventScript* script) + { + script->OnStart(EventID); + }); +} + +void ScriptMgr::OnGameEventStop(uint16 EventID) +{ + ExecuteScript([&](GameEventScript* script) + { + script->OnStop(EventID); + }); +} diff --git a/src/server/game/Scripting/ScriptDefines/GameObjectScript.cpp b/src/server/game/Scripting/ScriptDefines/GameObjectScript.cpp new file mode 100644 index 000000000..abf62eb58 --- /dev/null +++ b/src/server/game/Scripting/ScriptDefines/GameObjectScript.cpp @@ -0,0 +1,224 @@ +/* + * 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 . + */ + +#include "ScriptMgr.h" +#include "ScriptMgrMacros.h" +#include "ScriptedGossip.h" + +bool ScriptMgr::OnGossipHello(Player* player, GameObject* go) +{ + ASSERT(player); + ASSERT(go); + + auto ret = IsValidBoolScript([&](AllGameObjectScript* script) + { + return script->CanGameObjectGossipHello(player, go); + }); + + if (ret && *ret) + { + return true; + } + + auto tempScript = ScriptRegistry::GetScriptById(go->GetScriptId()); + ClearGossipMenuFor(player); + return tempScript ? tempScript->OnGossipHello(player, go) : false; +} + +bool ScriptMgr::OnGossipSelect(Player* player, GameObject* go, uint32 sender, uint32 action) +{ + ASSERT(player); + ASSERT(go); + + auto ret = IsValidBoolScript([&](AllGameObjectScript* script) + { + return script->CanGameObjectGossipSelect(player, go, sender, action); + }); + + if (ret && *ret) + { + return true; + } + + auto tempScript = ScriptRegistry::GetScriptById(go->GetScriptId()); + return tempScript ? tempScript->OnGossipSelect(player, go, sender, action) : false; +} + +bool ScriptMgr::OnGossipSelectCode(Player* player, GameObject* go, uint32 sender, uint32 action, const char* code) +{ + ASSERT(player); + ASSERT(go); + ASSERT(code); + + auto ret = IsValidBoolScript([&](AllGameObjectScript* script) + { + return script->CanGameObjectGossipSelectCode(player, go, sender, action, code); + }); + + if (ret && *ret) + { + return true; + } + + auto tempScript = ScriptRegistry::GetScriptById(go->GetScriptId()); + return tempScript ? tempScript->OnGossipSelectCode(player, go, sender, action, code) : false; +} + +bool ScriptMgr::OnQuestAccept(Player* player, GameObject* go, Quest const* quest) +{ + ASSERT(player); + ASSERT(go); + ASSERT(quest); + + auto ret = IsValidBoolScript([&](AllGameObjectScript* script) + { + return script->CanGameObjectQuestAccept(player, go, quest); + }); + + if (ret && *ret) + { + return true; + } + + auto tempScript = ScriptRegistry::GetScriptById(go->GetScriptId()); + ClearGossipMenuFor(player); + return tempScript ? tempScript->OnQuestAccept(player, go, quest) : false; +} + +bool ScriptMgr::OnQuestReward(Player* player, GameObject* go, Quest const* quest, uint32 opt) +{ + ASSERT(player); + ASSERT(go); + ASSERT(quest); + + auto ret = IsValidBoolScript([&](AllGameObjectScript* script) + { + return script->CanGameObjectQuestReward(player, go, quest, opt); + }); + + if (ret && *ret) + { + return true; + } + + auto tempScript = ScriptRegistry::GetScriptById(go->GetScriptId()); + ClearGossipMenuFor(player); + return tempScript ? tempScript->OnQuestReward(player, go, quest, opt) : false; +} + +uint32 ScriptMgr::GetDialogStatus(Player* player, GameObject* go) +{ + ASSERT(player); + ASSERT(go); + + auto tempScript = ScriptRegistry::GetScriptById(go->GetScriptId()); + ClearGossipMenuFor(player); + return tempScript ? tempScript->GetDialogStatus(player, go) : DIALOG_STATUS_SCRIPTED_NO_STATUS; +} + +void ScriptMgr::OnGameObjectDestroyed(GameObject* go, Player* player) +{ + ASSERT(go); + + ExecuteScript([&](AllGameObjectScript* script) + { + script->OnGameObjectDestroyed(go, player); + }); + + if (auto tempScript = ScriptRegistry::GetScriptById(go->GetScriptId())) + { + tempScript->OnDestroyed(go, player); + } +} + +void ScriptMgr::OnGameObjectDamaged(GameObject* go, Player* player) +{ + ASSERT(go); + + ExecuteScript([&](AllGameObjectScript* script) + { + script->OnGameObjectDamaged(go, player); + }); + + if (auto tempScript = ScriptRegistry::GetScriptById(go->GetScriptId())) + { + tempScript->OnDamaged(go, player); + } +} + +void ScriptMgr::OnGameObjectLootStateChanged(GameObject* go, uint32 state, Unit* unit) +{ + ASSERT(go); + + ExecuteScript([&](AllGameObjectScript* script) + { + script->OnGameObjectLootStateChanged(go, state, unit); + }); + + if (auto tempScript = ScriptRegistry::GetScriptById(go->GetScriptId())) + { + tempScript->OnLootStateChanged(go, state, unit); + } +} + +void ScriptMgr::OnGameObjectStateChanged(GameObject* go, uint32 state) +{ + ASSERT(go); + + ExecuteScript([&](AllGameObjectScript* script) + { + script->OnGameObjectStateChanged(go, state); + }); + + if (auto tempScript = ScriptRegistry::GetScriptById(go->GetScriptId())) + { + tempScript->OnGameObjectStateChanged(go, state); + } +} + +void ScriptMgr::OnGameObjectUpdate(GameObject* go, uint32 diff) +{ + ASSERT(go); + + ExecuteScript([&](AllGameObjectScript* script) + { + script->OnGameObjectUpdate(go, diff); + }); + + if (auto tempScript = ScriptRegistry::GetScriptById(go->GetScriptId())) + { + tempScript->OnUpdate(go, diff); + } +} + +GameObjectAI* ScriptMgr::GetGameObjectAI(GameObject* go) +{ + ASSERT(go); + + auto retAI = GetReturnAIScript([go](AllGameObjectScript* script) + { + return script->GetGameObjectAI(go); + }); + + if (retAI) + { + return retAI; + } + + auto tempScript = ScriptRegistry::GetScriptById(go->GetScriptId()); + return tempScript ? tempScript->GetAI(go) : nullptr; +} diff --git a/src/server/game/Scripting/ScriptDefines/GlobalScript.cpp b/src/server/game/Scripting/ScriptDefines/GlobalScript.cpp new file mode 100644 index 000000000..642f5b3fe --- /dev/null +++ b/src/server/game/Scripting/ScriptDefines/GlobalScript.cpp @@ -0,0 +1,124 @@ +/* + * 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 . + */ + +#include "ScriptMgr.h" +#include "ScriptMgrMacros.h" + +void ScriptMgr::OnGlobalItemDelFromDB(CharacterDatabaseTransaction trans, ObjectGuid::LowType itemGuid) +{ + ASSERT(trans); + ASSERT(itemGuid); + + ExecuteScript([&](GlobalScript* script) + { + script->OnItemDelFromDB(trans, itemGuid); + }); +} + +void ScriptMgr::OnGlobalMirrorImageDisplayItem(const Item* item, uint32& display) +{ + ExecuteScript([&](GlobalScript* script) + { + script->OnMirrorImageDisplayItem(item, display); + }); +} + +void ScriptMgr::OnBeforeUpdateArenaPoints(ArenaTeam* at, std::map& ap) +{ + ExecuteScript([&](GlobalScript* script) + { + script->OnBeforeUpdateArenaPoints(at, ap); + }); +} + +void ScriptMgr::OnAfterRefCount(Player const* player, Loot& loot, bool canRate, uint16 lootMode, LootStoreItem* LootStoreItem, uint32& maxcount, LootStore const& store) +{ + ExecuteScript([&](GlobalScript* script) + { + script->OnAfterRefCount(player, LootStoreItem, loot, canRate, lootMode, maxcount, store); + }); +} + +void ScriptMgr::OnBeforeDropAddItem(Player const* player, Loot& loot, bool canRate, uint16 lootMode, LootStoreItem* LootStoreItem, LootStore const& store) +{ + ExecuteScript([&](GlobalScript* script) + { + script->OnBeforeDropAddItem(player, loot, canRate, lootMode, LootStoreItem, store); + }); +} + +bool ScriptMgr::OnItemRoll(Player const* player, LootStoreItem const* lootStoreItem, float& chance, Loot& loot, LootStore const& store) +{ + auto ret = IsValidBoolScript([&](GlobalScript* script) + { + return !script->OnItemRoll(player, lootStoreItem, chance, loot, store); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +bool ScriptMgr::OnBeforeLootEqualChanced(Player const* player, LootStoreItemList EqualChanced, Loot& loot, LootStore const& store) +{ + auto ret = IsValidBoolScript([&](GlobalScript* script) + { + return !script->OnBeforeLootEqualChanced(player, EqualChanced, loot, store); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +void ScriptMgr::OnInitializeLockedDungeons(Player* player, uint8& level, uint32& lockData, lfg::LFGDungeonData const* dungeon) +{ + ExecuteScript([&](GlobalScript* script) + { + script->OnInitializeLockedDungeons(player, level, lockData, dungeon); + }); +} + +void ScriptMgr::OnAfterInitializeLockedDungeons(Player* player) +{ + ExecuteScript([&](GlobalScript* script) + { + script->OnAfterInitializeLockedDungeons(player); + }); +} + +void ScriptMgr::OnAfterUpdateEncounterState(Map* map, EncounterCreditType type, uint32 creditEntry, Unit* source, Difficulty difficulty_fixed, DungeonEncounterList const* encounters, uint32 dungeonCompleted, bool updated) +{ + ExecuteScript([&](GlobalScript* script) + { + script->OnAfterUpdateEncounterState(map, type, creditEntry, source, difficulty_fixed, encounters, dungeonCompleted, updated); + }); +} + +void ScriptMgr::OnBeforeWorldObjectSetPhaseMask(WorldObject const* worldObject, uint32& oldPhaseMask, uint32& newPhaseMask, bool& useCombinedPhases, bool& update) +{ + ExecuteScript([&](GlobalScript* script) + { + script->OnBeforeWorldObjectSetPhaseMask(worldObject, oldPhaseMask, newPhaseMask, useCombinedPhases, update); + }); +} diff --git a/src/server/game/Scripting/ScriptDefines/GroupScript.cpp b/src/server/game/Scripting/ScriptDefines/GroupScript.cpp new file mode 100644 index 000000000..306949402 --- /dev/null +++ b/src/server/game/Scripting/ScriptDefines/GroupScript.cpp @@ -0,0 +1,92 @@ +/* + * 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 . + */ + +#include "ScriptMgr.h" +#include "ScriptMgrMacros.h" + +void ScriptMgr::OnGroupAddMember(Group* group, ObjectGuid guid) +{ + ASSERT(group); + + ExecuteScript([&](GroupScript* script) + { + script->OnAddMember(group, guid); + }); +} + +void ScriptMgr::OnGroupInviteMember(Group* group, ObjectGuid guid) +{ + ASSERT(group); + + ExecuteScript([&](GroupScript* script) + { + script->OnInviteMember(group, guid); + }); +} + +void ScriptMgr::OnGroupRemoveMember(Group* group, ObjectGuid guid, RemoveMethod method, ObjectGuid kicker, const char* reason) +{ + ASSERT(group); + + ExecuteScript([&](GroupScript* script) + { + script->OnRemoveMember(group, guid, method, kicker, reason); + }); +} + +void ScriptMgr::OnGroupChangeLeader(Group* group, ObjectGuid newLeaderGuid, ObjectGuid oldLeaderGuid) +{ + ASSERT(group); + + ExecuteScript([&](GroupScript* script) + { + script->OnChangeLeader(group, newLeaderGuid, oldLeaderGuid); + }); +} + +void ScriptMgr::OnGroupDisband(Group* group) +{ + ASSERT(group); + + ExecuteScript([&](GroupScript* script) + { + script->OnDisband(group); + }); +} + +bool ScriptMgr::CanGroupJoinBattlegroundQueue(Group const* group, Player* member, Battleground const* bgTemplate, uint32 MinPlayerCount, bool isRated, uint32 arenaSlot) +{ + auto ret = IsValidBoolScript([&](GroupScript* script) + { + return !script->CanGroupJoinBattlegroundQueue(group, member, bgTemplate, MinPlayerCount, isRated, arenaSlot); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +void ScriptMgr::OnCreate(Group* group, Player* leader) +{ + ExecuteScript([&](GroupScript* script) + { + script->OnCreate(group, leader); + }); +} diff --git a/src/server/game/Scripting/ScriptDefines/GuildScript.cpp b/src/server/game/Scripting/ScriptDefines/GuildScript.cpp new file mode 100644 index 000000000..6ca69523e --- /dev/null +++ b/src/server/game/Scripting/ScriptDefines/GuildScript.cpp @@ -0,0 +1,123 @@ +/* + * 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 . + */ + +#include "ScriptMgr.h" +#include "ScriptMgrMacros.h" + +void ScriptMgr::OnGuildAddMember(Guild* guild, Player* player, uint8& plRank) +{ + ExecuteScript([&](GuildScript* script) + { + script->OnAddMember(guild, player, plRank); + }); +} + +void ScriptMgr::OnGuildRemoveMember(Guild* guild, Player* player, bool isDisbanding, bool isKicked) +{ + ExecuteScript([&](GuildScript* script) + { + script->OnRemoveMember(guild, player, isDisbanding, isKicked); + }); +} + +void ScriptMgr::OnGuildMOTDChanged(Guild* guild, const std::string& newMotd) +{ + ExecuteScript([&](GuildScript* script) + { + script->OnMOTDChanged(guild, newMotd); + }); +} + +void ScriptMgr::OnGuildInfoChanged(Guild* guild, const std::string& newInfo) +{ + ExecuteScript([&](GuildScript* script) + { + script->OnInfoChanged(guild, newInfo); + }); +} + +void ScriptMgr::OnGuildCreate(Guild* guild, Player* leader, const std::string& name) +{ + ExecuteScript([&](GuildScript* script) + { + script->OnCreate(guild, leader, name); + }); +} + +void ScriptMgr::OnGuildDisband(Guild* guild) +{ + ExecuteScript([&](GuildScript* script) + { + script->OnDisband(guild); + }); +} + +void ScriptMgr::OnGuildMemberWitdrawMoney(Guild* guild, Player* player, uint32& amount, bool isRepair) +{ + ExecuteScript([&](GuildScript* script) + { + script->OnMemberWitdrawMoney(guild, player, amount, isRepair); + }); +} + +void ScriptMgr::OnGuildMemberDepositMoney(Guild* guild, Player* player, uint32& amount) +{ + ExecuteScript([&](GuildScript* script) + { + script->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) +{ + ExecuteScript([&](GuildScript* script) + { + script->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) +{ + ExecuteScript([&](GuildScript* script) + { + script->OnEvent(guild, eventType, playerGuid1, playerGuid2, newRank); + }); +} + +void ScriptMgr::OnGuildBankEvent(Guild* guild, uint8 eventType, uint8 tabId, ObjectGuid::LowType playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId) +{ + ExecuteScript([&](GuildScript* script) + { + script->OnBankEvent(guild, eventType, tabId, playerGuid, itemOrMoney, itemStackCount, destTabId); + }); +} + +bool ScriptMgr::CanGuildSendBankList(Guild const* guild, WorldSession* session, uint8 tabId, bool sendAllSlots) +{ + auto ret = IsValidBoolScript([&](GuildScript* script) + { + return !script->CanGuildSendBankList(guild, session, tabId, sendAllSlots); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} diff --git a/src/server/game/Scripting/ScriptDefines/InstanceMapScript.cpp b/src/server/game/Scripting/ScriptDefines/InstanceMapScript.cpp new file mode 100644 index 000000000..18f7a9eb8 --- /dev/null +++ b/src/server/game/Scripting/ScriptDefines/InstanceMapScript.cpp @@ -0,0 +1,27 @@ +/* + * 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 . + */ + +#include "ScriptMgr.h" +#include "ScriptMgrMacros.h" + +InstanceScript* ScriptMgr::CreateInstanceScript(InstanceMap* map) +{ + ASSERT(map); + + auto tempScript = ScriptRegistry::GetScriptById(map->GetScriptId()); + return tempScript ? tempScript->GetInstanceScript(map) : nullptr; +} diff --git a/src/server/game/Scripting/ScriptDefines/ItemScript.cpp b/src/server/game/Scripting/ScriptDefines/ItemScript.cpp new file mode 100644 index 000000000..44e82f0aa --- /dev/null +++ b/src/server/game/Scripting/ScriptDefines/ItemScript.cpp @@ -0,0 +1,141 @@ +/* + * 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 . + */ + +#include "ScriptMgr.h" +#include "ScriptMgrMacros.h" +#include "ScriptedGossip.h" + +bool ScriptMgr::OnQuestAccept(Player* player, Item* item, Quest const* quest) +{ + ASSERT(player); + ASSERT(item); + ASSERT(quest); + + auto ret = IsValidBoolScript([&](AllItemScript* script) + { + return !script->CanItemQuestAccept(player, item, quest); + }); + + if (ret && *ret) + { + return false; + } + + auto tempScript = ScriptRegistry::GetScriptById(item->GetScriptId()); + ClearGossipMenuFor(player); + return tempScript ? tempScript->OnQuestAccept(player, item, quest) : false; +} + +bool ScriptMgr::OnItemUse(Player* player, Item* item, SpellCastTargets const& targets) +{ + ASSERT(player); + ASSERT(item); + + auto ret = IsValidBoolScript([&](AllItemScript* script) + { + return script->CanItemUse(player, item, targets); + }); + + if (ret && *ret) + { + return true; + } + + auto tempScript = ScriptRegistry::GetScriptById(item->GetScriptId()); + return tempScript ? tempScript->OnUse(player, item, targets) : false; +} + +bool ScriptMgr::OnItemExpire(Player* player, ItemTemplate const* proto) +{ + ASSERT(player); + ASSERT(proto); + + auto ret = IsValidBoolScript([&](AllItemScript* script) + { + return !script->CanItemExpire(player, proto); + }); + + if (ret && *ret) + { + return false; + } + + auto tempScript = ScriptRegistry::GetScriptById(proto->ScriptId); + return tempScript ? tempScript->OnExpire(player, proto) : false; +} + +bool ScriptMgr::OnItemRemove(Player* player, Item* item) +{ + ASSERT(player); + ASSERT(item); + + auto ret = IsValidBoolScript([&](AllItemScript* script) + { + return !script->CanItemRemove(player, item); + }); + + if (ret && *ret) + { + return false; + } + + auto tempScript = ScriptRegistry::GetScriptById(item->GetScriptId()); + return tempScript ? tempScript->OnRemove(player, item) : false; +} + +bool ScriptMgr::OnCastItemCombatSpell(Player* player, Unit* victim, SpellInfo const* spellInfo, Item* item) +{ + ASSERT(player); + ASSERT(victim); + ASSERT(spellInfo); + ASSERT(item); + + auto tempScript = ScriptRegistry::GetScriptById(item->GetScriptId()); + return tempScript ? tempScript->OnCastItemCombatSpell(player, victim, spellInfo, item) : true; +} + +void ScriptMgr::OnGossipSelect(Player* player, Item* item, uint32 sender, uint32 action) +{ + ASSERT(player); + ASSERT(item); + + ExecuteScript([&](AllItemScript* script) + { + script->OnItemGossipSelect(player, item, sender, action); + }); + + if (auto tempScript = ScriptRegistry::GetScriptById(item->GetScriptId())) + { + tempScript->OnGossipSelect(player, item, sender, action); + } +} + +void ScriptMgr::OnGossipSelectCode(Player* player, Item* item, uint32 sender, uint32 action, const char* code) +{ + ASSERT(player); + ASSERT(item); + + ExecuteScript([&](AllItemScript* script) + { + script->OnItemGossipSelectCode(player, item, sender, action, code); + }); + + if (auto tempScript = ScriptRegistry::GetScriptById(item->GetScriptId())) + { + tempScript->OnGossipSelectCode(player, item, sender, action, code); + } +} diff --git a/src/server/game/Scripting/ScriptDefines/LootScript.cpp b/src/server/game/Scripting/ScriptDefines/LootScript.cpp new file mode 100644 index 000000000..b213d6468 --- /dev/null +++ b/src/server/game/Scripting/ScriptDefines/LootScript.cpp @@ -0,0 +1,29 @@ +/* + * 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 . + */ + +#include "ScriptMgr.h" +#include "ScriptMgrMacros.h" + +void ScriptMgr::OnLootMoney(Player* player, uint32 gold) +{ + ASSERT(player); + + ExecuteScript([&](LootScript* script) + { + script->OnLootMoney(player, gold); + }); +} diff --git a/src/server/game/Scripting/ScriptDefines/MailScript.cpp b/src/server/game/Scripting/ScriptDefines/MailScript.cpp new file mode 100644 index 000000000..1d5cd11a1 --- /dev/null +++ b/src/server/game/Scripting/ScriptDefines/MailScript.cpp @@ -0,0 +1,27 @@ +/* + * 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 . + */ + +#include "ScriptMgr.h" +#include "ScriptMgrMacros.h" + +void ScriptMgr::OnBeforeMailDraftSendMailTo(MailDraft* mailDraft, MailReceiver const& receiver, MailSender const& sender, MailCheckMask& checked, uint32& deliver_delay, uint32& custom_expiration, bool& deleteMailItemsFromDB, bool& sendMail) +{ + ExecuteScript([&](MailScript* script) + { + script->OnBeforeMailDraftSendMailTo(mailDraft, receiver, sender, checked, deliver_delay, custom_expiration, deleteMailItemsFromDB, sendMail);\ + }); +} diff --git a/src/server/game/Scripting/ScriptDefines/MiscScript.cpp b/src/server/game/Scripting/ScriptDefines/MiscScript.cpp new file mode 100644 index 000000000..cf50229c8 --- /dev/null +++ b/src/server/game/Scripting/ScriptDefines/MiscScript.cpp @@ -0,0 +1,184 @@ +/* + * 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 . + */ + +#include "ScriptMgr.h" +#include "ScriptMgrMacros.h" + +void ScriptMgr::OnItemCreate(Item* item, ItemTemplate const* itemProto, Player const* owner) +{ + ExecuteScript([&](MiscScript* script) + { + script->OnItemCreate(item, itemProto, owner); + }); +} + +bool ScriptMgr::CanApplySoulboundFlag(Item* item, ItemTemplate const* proto) +{ + auto ret = IsValidBoolScript([&](MiscScript* script) + { + return !script->CanApplySoulboundFlag(item, proto); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +void ScriptMgr::OnConstructObject(Object* origin) +{ + ExecuteScript([&](MiscScript* script) + { + script->OnConstructObject(origin); + }); +} + +void ScriptMgr::OnDestructObject(Object* origin) +{ + ExecuteScript([&](MiscScript* script) + { + script->OnDestructObject(origin); + }); +} + +void ScriptMgr::OnConstructPlayer(Player* origin) +{ + ExecuteScript([&](MiscScript* script) + { + script->OnConstructPlayer(origin); + }); +} + +void ScriptMgr::OnDestructPlayer(Player* origin) +{ + ExecuteScript([&](MiscScript* script) + { + script->OnDestructPlayer(origin); + }); +} + +void ScriptMgr::OnConstructGroup(Group* origin) +{ + ExecuteScript([&](MiscScript* script) + { + script->OnConstructGroup(origin); + }); +} + +void ScriptMgr::OnDestructGroup(Group* origin) +{ + ExecuteScript([&](MiscScript* script) + { + script->OnDestructGroup(origin); + }); +} + +void ScriptMgr::OnConstructInstanceSave(InstanceSave* origin) +{ + ExecuteScript([&](MiscScript* script) + { + script->OnConstructInstanceSave(origin); + }); +} + +void ScriptMgr::OnDestructInstanceSave(InstanceSave* origin) +{ + ExecuteScript([&](MiscScript* script) + { + script->OnDestructInstanceSave(origin); + }); +} + +bool ScriptMgr::CanItemApplyEquipSpell(Player* player, Item* item) +{ + auto ret = IsValidBoolScript([&](MiscScript* script) + { + return !script->CanItemApplyEquipSpell(player, item); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +bool ScriptMgr::CanSendAuctionHello(WorldSession const* session, ObjectGuid guid, Creature* creature) +{ + auto ret = IsValidBoolScript([&](MiscScript* script) + { + return !script->CanSendAuctionHello(session, guid, creature); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +void ScriptMgr::ValidateSpellAtCastSpell(Player* player, uint32& oldSpellId, uint32& spellId, uint8& castCount, uint8& castFlags) +{ + ExecuteScript([&](MiscScript* script) + { + script->ValidateSpellAtCastSpell(player, oldSpellId, spellId, castCount, castFlags); + }); +} + +void ScriptMgr::ValidateSpellAtCastSpellResult(Player* player, Unit* mover, Spell* spell, uint32 oldSpellId, uint32 spellId) +{ + ExecuteScript([&](MiscScript* script) + { + script->ValidateSpellAtCastSpellResult(player, mover, spell, oldSpellId, spellId); + }); +} + +void ScriptMgr::OnAfterLootTemplateProcess(Loot* loot, LootTemplate const* tab, LootStore const& store, Player* lootOwner, bool personal, bool noEmptyError, uint16 lootMode) +{ + ExecuteScript([&](MiscScript* script) + { + script->OnAfterLootTemplateProcess(loot, tab, store, lootOwner, personal, noEmptyError, lootMode); + }); +} + +void ScriptMgr::OnInstanceSave(InstanceSave* instanceSave) +{ + ExecuteScript([&](MiscScript* script) + { + script->OnInstanceSave(instanceSave); + }); +} + +void ScriptMgr::OnPlayerSetPhase(const AuraEffect* auraEff, AuraApplication const* aurApp, uint8 mode, bool apply, uint32& newPhase) +{ + ExecuteScript([&](MiscScript* script) + { + script->OnPlayerSetPhase(auraEff, aurApp, mode, apply, newPhase); + }); +} + +void ScriptMgr::GetDialogStatus(Player* player, Object* questgiver) +{ + ExecuteScript([&](MiscScript* script) + { + script->GetDialogStatus(player, questgiver); + }); +} diff --git a/src/server/game/Scripting/ScriptDefines/MovementHandlerScript.cpp b/src/server/game/Scripting/ScriptDefines/MovementHandlerScript.cpp new file mode 100644 index 000000000..d6a926cca --- /dev/null +++ b/src/server/game/Scripting/ScriptDefines/MovementHandlerScript.cpp @@ -0,0 +1,27 @@ +/* + * 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 . + */ + +#include "ScriptMgr.h" +#include "ScriptMgrMacros.h" + +void ScriptMgr::OnPlayerMove(Player* player, MovementInfo movementInfo, uint32 opcode) +{ + ExecuteScript([&](MovementHandlerScript* script) + { + script->OnPlayerMove(player, movementInfo, opcode); + }); +} diff --git a/src/server/game/Scripting/ScriptDefines/OutdoorPvPScript.cpp b/src/server/game/Scripting/ScriptDefines/OutdoorPvPScript.cpp new file mode 100644 index 000000000..60ae644f8 --- /dev/null +++ b/src/server/game/Scripting/ScriptDefines/OutdoorPvPScript.cpp @@ -0,0 +1,28 @@ +/* + * 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 . + */ + +#include "ScriptMgr.h" +#include "ScriptMgrMacros.h" +#include "OutdoorPvPMgr.h" + +OutdoorPvP* ScriptMgr::CreateOutdoorPvP(OutdoorPvPData const* data) +{ + ASSERT(data); + + auto tempScript = ScriptRegistry::GetScriptById(data->ScriptId); + return tempScript ? tempScript->GetOutdoorPvP() : nullptr; +} diff --git a/src/server/game/Scripting/ScriptDefines/PetScript.cpp b/src/server/game/Scripting/ScriptDefines/PetScript.cpp new file mode 100644 index 000000000..1d3b45b5e --- /dev/null +++ b/src/server/game/Scripting/ScriptDefines/PetScript.cpp @@ -0,0 +1,90 @@ +/* + * 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 . + */ + +#include "ScriptMgr.h" +#include "ScriptMgrMacros.h" + +void ScriptMgr::OnInitStatsForLevel(Guardian* guardian, uint8 petlevel) +{ + ExecuteScript([&](PetScript* script) + { + script->OnInitStatsForLevel(guardian, petlevel); + }); +} + +void ScriptMgr::OnCalculateMaxTalentPointsForLevel(Pet* pet, uint8 level, uint8& points) +{ + ExecuteScript([&](PetScript* script) + { + script->OnCalculateMaxTalentPointsForLevel(pet, level, points); + }); +} + +bool ScriptMgr::CanUnlearnSpellSet(Pet* pet, uint32 level, uint32 spell) +{ + auto ret = IsValidBoolScript([&](PetScript* script) + { + return !script->CanUnlearnSpellSet(pet, level, spell); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +bool ScriptMgr::CanUnlearnSpellDefault(Pet* pet, SpellInfo const* spellEntry) +{ + auto ret = IsValidBoolScript([&](PetScript* script) + { + return !script->CanUnlearnSpellDefault(pet, spellEntry); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +bool ScriptMgr::CanResetTalents(Pet* pet) +{ + auto ret = IsValidBoolScript([&](PetScript* script) + { + return !script->CanResetTalents(pet); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +void ScriptMgr::OnPetAddToWorld(Pet* pet) +{ + ASSERT(pet); + + ExecuteScript([&](PetScript* script) + { + script->OnPetAddToWorld(pet); + }); +} diff --git a/src/server/game/Scripting/ScriptDefines/PlayerScript.cpp b/src/server/game/Scripting/ScriptDefines/PlayerScript.cpp new file mode 100644 index 000000000..8ffd177f3 --- /dev/null +++ b/src/server/game/Scripting/ScriptDefines/PlayerScript.cpp @@ -0,0 +1,1514 @@ +/* + * 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 . + */ + +#include "ScriptMgr.h" +#include "ScriptMgrMacros.h" + +void ScriptMgr::OnBeforePlayerDurabilityRepair(Player* player, ObjectGuid npcGUID, ObjectGuid itemGUID, float& discountMod, uint8 guildBank) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnBeforeDurabilityRepair(player, npcGUID, itemGUID, discountMod, guildBank); + }); +} + +void ScriptMgr::OnGossipSelect(Player* player, uint32 menu_id, uint32 sender, uint32 action) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnGossipSelect(player, menu_id, sender, action); + }); +} + +void ScriptMgr::OnGossipSelectCode(Player* player, uint32 menu_id, uint32 sender, uint32 action, const char* code) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnGossipSelectCode(player, menu_id, sender, action, code); + }); +} + +void ScriptMgr::OnPlayerCompleteQuest(Player* player, Quest const* quest) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnPlayerCompleteQuest(player, quest); + }); +} + +void ScriptMgr::OnSendInitialPacketsBeforeAddToMap(Player* player, WorldPacket& data) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnSendInitialPacketsBeforeAddToMap(player, data); + }); +} + +void ScriptMgr::OnBattlegroundDesertion(Player* player, BattlegroundDesertionType const desertionType) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnBattlegroundDesertion(player, desertionType); + }); +} + +void ScriptMgr::OnPlayerReleasedGhost(Player* player) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnPlayerReleasedGhost(player); + }); +} + +void ScriptMgr::OnPVPKill(Player* killer, Player* killed) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnPVPKill(killer, killed); + }); +} + +void ScriptMgr::OnPlayerPVPFlagChange(Player* player, bool state) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnPlayerPVPFlagChange(player, state); + }); +} + +void ScriptMgr::OnCreatureKill(Player* killer, Creature* killed) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnCreatureKill(killer, killed); + }); +} + +void ScriptMgr::OnCreatureKilledByPet(Player* petOwner, Creature* killed) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnCreatureKilledByPet(petOwner, killed); + }); +} + +void ScriptMgr::OnPlayerKilledByCreature(Creature* killer, Player* killed) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnPlayerKilledByCreature(killer, killed); + }); +} + +void ScriptMgr::OnPlayerLevelChanged(Player* player, uint8 oldLevel) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnLevelChanged(player, oldLevel); + }); +} + +void ScriptMgr::OnPlayerFreeTalentPointsChanged(Player* player, uint32 points) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnFreeTalentPointsChanged(player, points); + }); +} + +void ScriptMgr::OnPlayerTalentsReset(Player* player, bool noCost) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnTalentsReset(player, noCost); + }); +} + +void ScriptMgr::OnPlayerMoneyChanged(Player* player, int32& amount) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnMoneyChanged(player, amount); + }); +} + +void ScriptMgr::OnGivePlayerXP(Player* player, uint32& amount, Unit* victim) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnGiveXP(player, amount, victim); + }); +} + +void ScriptMgr::OnPlayerReputationChange(Player* player, uint32 factionID, int32& standing, bool incremental) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnReputationChange(player, factionID, standing, incremental); + }); +} + +void ScriptMgr::OnPlayerReputationRankChange(Player* player, uint32 factionID, ReputationRank newRank, ReputationRank oldRank, bool increased) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnReputationRankChange(player, factionID, newRank, oldRank, increased); + }); +} + +void ScriptMgr::OnPlayerLearnSpell(Player* player, uint32 spellID) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnLearnSpell(player, spellID); + }); +} + +void ScriptMgr::OnPlayerForgotSpell(Player* player, uint32 spellID) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnForgotSpell(player, spellID); + }); +} + +void ScriptMgr::OnPlayerDuelRequest(Player* target, Player* challenger) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnDuelRequest(target, challenger); + }); +} + +void ScriptMgr::OnPlayerDuelStart(Player* player1, Player* player2) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnDuelStart(player1, player2); + }); +} + +void ScriptMgr::OnPlayerDuelEnd(Player* winner, Player* loser, DuelCompleteType type) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnDuelEnd(winner, loser, type); + }); +} + +void ScriptMgr::OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string& msg) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnChat(player, type, lang, msg); + }); +} + +void ScriptMgr::OnBeforeSendChatMessage(Player* player, uint32& type, uint32& lang, std::string& msg) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnBeforeSendChatMessage(player, type, lang, msg); + }); +} + +void ScriptMgr::OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string& msg, Player* receiver) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnChat(player, type, lang, msg, receiver); + }); +} + +void ScriptMgr::OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string& msg, Group* group) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnChat(player, type, lang, msg, group); + }); +} + +void ScriptMgr::OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string& msg, Guild* guild) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnChat(player, type, lang, msg, guild); + }); +} + +void ScriptMgr::OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string& msg, Channel* channel) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnChat(player, type, lang, msg, channel); + }); +} + +void ScriptMgr::OnPlayerEmote(Player* player, uint32 emote) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnEmote(player, emote); + }); +} + +void ScriptMgr::OnPlayerTextEmote(Player* player, uint32 textEmote, uint32 emoteNum, ObjectGuid guid) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnTextEmote(player, textEmote, emoteNum, guid); + }); +} + +void ScriptMgr::OnPlayerSpellCast(Player* player, Spell* spell, bool skipCheck) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnSpellCast(player, spell, skipCheck); + }); +} + +void ScriptMgr::OnBeforePlayerUpdate(Player* player, uint32 p_time) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnBeforeUpdate(player, p_time); + }); +} + +void ScriptMgr::OnPlayerUpdate(Player* player, uint32 p_time) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnUpdate(player, p_time); + }); +} + +void ScriptMgr::OnPlayerLogin(Player* player) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnLogin(player); + }); +} + +void ScriptMgr::OnPlayerLoadFromDB(Player* player) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnLoadFromDB(player); + }); +} + +void ScriptMgr::OnPlayerLogout(Player* player) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnLogout(player); + }); +} + +void ScriptMgr::OnPlayerCreate(Player* player) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnCreate(player); + }); +} + +void ScriptMgr::OnPlayerSave(Player* player) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnSave(player); + }); +} + +void ScriptMgr::OnPlayerDelete(ObjectGuid guid, uint32 accountId) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnDelete(guid, accountId); + }); +} + +void ScriptMgr::OnPlayerFailedDelete(ObjectGuid guid, uint32 accountId) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnFailedDelete(guid, accountId); + }); +} + +void ScriptMgr::OnPlayerBindToInstance(Player* player, Difficulty difficulty, uint32 mapid, bool permanent) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnBindToInstance(player, difficulty, mapid, permanent); + }); +} + +void ScriptMgr::OnPlayerUpdateZone(Player* player, uint32 newZone, uint32 newArea) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnUpdateZone(player, newZone, newArea); + }); +} + +void ScriptMgr::OnPlayerUpdateArea(Player* player, uint32 oldArea, uint32 newArea) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnUpdateArea(player, oldArea, newArea); + }); +} + +bool ScriptMgr::OnBeforePlayerTeleport(Player* player, uint32 mapid, float x, float y, float z, float orientation, uint32 options, Unit* target) +{ + auto ret = IsValidBoolScript([&](PlayerScript* script) + { + return !script->OnBeforeTeleport(player, mapid, x, y, z, orientation, options, target); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +void ScriptMgr::OnPlayerUpdateFaction(Player* player) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnUpdateFaction(player); + }); +} + +void ScriptMgr::OnPlayerAddToBattleground(Player* player, Battleground* bg) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnAddToBattleground(player, bg); + }); +} + +void ScriptMgr::OnPlayerQueueRandomDungeon(Player* player, uint32 & rDungeonId) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnQueueRandomDungeon(player, rDungeonId); + }); +} + +void ScriptMgr::OnPlayerRemoveFromBattleground(Player* player, Battleground* bg) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnRemoveFromBattleground(player, bg); + }); +} + +bool ScriptMgr::OnBeforeAchievementComplete(Player* player, AchievementEntry const* achievement) +{ + auto ret = IsValidBoolScript([&](PlayerScript* script) + { + return !script->OnBeforeAchiComplete(player, achievement); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +void ScriptMgr::OnAchievementComplete(Player* player, AchievementEntry const* achievement) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnAchiComplete(player, achievement); + }); +} + +bool ScriptMgr::OnBeforeCriteriaProgress(Player* player, AchievementCriteriaEntry const* criteria) +{ + auto ret = IsValidBoolScript([&](PlayerScript* script) + { + return !script->OnBeforeCriteriaProgress(player, criteria); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +void ScriptMgr::OnCriteriaProgress(Player* player, AchievementCriteriaEntry const* criteria) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnCriteriaProgress(player, criteria); + }); +} + +void ScriptMgr::OnAchievementSave(CharacterDatabaseTransaction trans, Player* player, uint16 achiId, CompletedAchievementData achiData) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnAchiSave(trans, player, achiId, achiData); + }); +} + +void ScriptMgr::OnCriteriaSave(CharacterDatabaseTransaction trans, Player* player, uint16 critId, CriteriaProgress criteriaData) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnCriteriaSave(trans, player, critId, criteriaData); + }); +} + +void ScriptMgr::OnPlayerBeingCharmed(Player* player, Unit* charmer, uint32 oldFactionId, uint32 newFactionId) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnBeingCharmed(player, charmer, oldFactionId, newFactionId); + }); +} + +void ScriptMgr::OnAfterPlayerSetVisibleItemSlot(Player* player, uint8 slot, Item* item) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnAfterSetVisibleItemSlot(player, slot, item); + }); +} + +void ScriptMgr::OnAfterPlayerMoveItemFromInventory(Player* player, Item* it, uint8 bag, uint8 slot, bool update) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnAfterMoveItemFromInventory(player, it, bag, slot, update); + }); +} + +void ScriptMgr::OnEquip(Player* player, Item* it, uint8 bag, uint8 slot, bool update) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnEquip(player, it, bag, slot, update); + }); +} + +void ScriptMgr::OnPlayerJoinBG(Player* player) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnPlayerJoinBG(player); + }); +} + +void ScriptMgr::OnPlayerJoinArena(Player* player) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnPlayerJoinArena(player); + }); +} + +void ScriptMgr::GetCustomGetArenaTeamId(const Player* player, uint8 slot, uint32& teamID) const +{ + ExecuteScript([&](PlayerScript* script) + { + script->GetCustomGetArenaTeamId(player, slot, teamID); + }); +} + +void ScriptMgr::GetCustomArenaPersonalRating(const Player* player, uint8 slot, uint32& rating) const +{ + ExecuteScript([&](PlayerScript* script) + { + script->GetCustomArenaPersonalRating(player, slot, rating); + }); +} + +void ScriptMgr::OnGetMaxPersonalArenaRatingRequirement(const Player* player, uint32 minSlot, uint32& maxArenaRating) const +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnGetMaxPersonalArenaRatingRequirement(player, minSlot, maxArenaRating); + }); +} + +void ScriptMgr::OnLootItem(Player* player, Item* item, uint32 count, ObjectGuid lootguid) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnLootItem(player, item, count, lootguid); + }); +} + +void ScriptMgr::OnCreateItem(Player* player, Item* item, uint32 count) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnCreateItem(player, item, count); + }); +} + +void ScriptMgr::OnQuestRewardItem(Player* player, Item* item, uint32 count) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnQuestRewardItem(player, item, count); + }); +} + +void ScriptMgr::OnFirstLogin(Player* player) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnFirstLogin(player); + }); +} + +bool ScriptMgr::CanJoinInBattlegroundQueue(Player* player, ObjectGuid BattlemasterGuid, BattlegroundTypeId BGTypeID, uint8 joinAsGroup, GroupJoinBattlegroundResult& err) +{ + auto ret = IsValidBoolScript([&](PlayerScript* script) + { + return !script->CanJoinInBattlegroundQueue(player, BattlemasterGuid, BGTypeID, joinAsGroup, err); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +bool ScriptMgr::ShouldBeRewardedWithMoneyInsteadOfExp(Player* player) +{ + auto ret = IsValidBoolScript([&](PlayerScript* script) + { + return script->ShouldBeRewardedWithMoneyInsteadOfExp(player); + }); + + if (ret && *ret) + { + return true; + } + + return false; +} + +void ScriptMgr::OnBeforeTempSummonInitStats(Player* player, TempSummon* tempSummon, uint32& duration) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnBeforeTempSummonInitStats(player, tempSummon, duration); + }); +} + +void ScriptMgr::OnBeforeGuardianInitStatsForLevel(Player* player, Guardian* guardian, CreatureTemplate const* cinfo, PetType& petType) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnBeforeGuardianInitStatsForLevel(player, guardian, cinfo, petType); + }); +} + +void ScriptMgr::OnAfterGuardianInitStatsForLevel(Player* player, Guardian* guardian) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnAfterGuardianInitStatsForLevel(player, guardian); + }); +} + +void ScriptMgr::OnBeforeLoadPetFromDB(Player* player, uint32& petentry, uint32& petnumber, bool& current, bool& forceLoadFromDB) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnBeforeLoadPetFromDB(player, petentry, petnumber, current, forceLoadFromDB); + }); +} + +void ScriptMgr::OnBeforeBuyItemFromVendor(Player* player, ObjectGuid vendorguid, uint32 vendorslot, uint32& item, uint8 count, uint8 bag, uint8 slot) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnBeforeBuyItemFromVendor(player, vendorguid, vendorslot, item, count, bag, slot); + }); +} + +void ScriptMgr::OnAfterStoreOrEquipNewItem(Player* player, uint32 vendorslot, Item* item, uint8 count, uint8 bag, uint8 slot, ItemTemplate const* pProto, Creature* pVendor, VendorItem const* crItem, bool bStore) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnAfterStoreOrEquipNewItem(player, vendorslot, item, count, bag, slot, pProto, pVendor, crItem, bStore); + }); +} + +void ScriptMgr::OnAfterUpdateMaxPower(Player* player, Powers& power, float& value) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnAfterUpdateMaxPower(player, power, value); + }); +} + +void ScriptMgr::OnAfterUpdateMaxHealth(Player* player, float& value) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnAfterUpdateMaxHealth(player, value); + }); +} + +void ScriptMgr::OnBeforeUpdateAttackPowerAndDamage(Player* player, float& level, float& val2, bool ranged) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnBeforeUpdateAttackPowerAndDamage(player, level, val2, ranged); + }); +} + +void ScriptMgr::OnAfterUpdateAttackPowerAndDamage(Player* player, float& level, float& base_attPower, float& attPowerMod, float& attPowerMultiplier, bool ranged) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnAfterUpdateAttackPowerAndDamage(player, level, base_attPower, attPowerMod, attPowerMultiplier, ranged); + }); +} + +void ScriptMgr::OnBeforeInitTalentForLevel(Player* player, uint8& level, uint32& talentPointsForLevel) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnBeforeInitTalentForLevel(player, level, talentPointsForLevel); + }); +} +bool ScriptMgr::OnBeforePlayerQuestComplete(Player* player, uint32 quest_id) +{ + auto ret = IsValidBoolScript([&](PlayerScript* script) + { + return !script->OnBeforeQuestComplete(player, quest_id); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +void ScriptMgr::OnBeforeStoreOrEquipNewItem(Player* player, uint32 vendorslot, uint32& item, uint8 count, uint8 bag, uint8 slot, ItemTemplate const* pProto, Creature* pVendor, VendorItem const* crItem, bool bStore) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnBeforeStoreOrEquipNewItem(player, vendorslot, item, count, bag, slot, pProto, pVendor, crItem, bStore); + }); +} + +bool ScriptMgr::CanJoinInArenaQueue(Player* player, ObjectGuid BattlemasterGuid, uint8 arenaslot, BattlegroundTypeId BGTypeID, uint8 joinAsGroup, uint8 IsRated, GroupJoinBattlegroundResult& err) +{ + auto ret = IsValidBoolScript([&](PlayerScript* script) + { + return !script->CanJoinInArenaQueue(player, BattlemasterGuid, arenaslot, BGTypeID, joinAsGroup, IsRated, err); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +bool ScriptMgr::CanBattleFieldPort(Player* player, uint8 arenaType, BattlegroundTypeId BGTypeID, uint8 action) +{ + auto ret = IsValidBoolScript([&](PlayerScript* script) + { + return !script->CanBattleFieldPort(player, arenaType, BGTypeID, action); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +bool ScriptMgr::CanGroupInvite(Player* player, std::string& membername) +{ + auto ret = IsValidBoolScript([&](PlayerScript* script) + { + return !script->CanGroupInvite(player, membername); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +bool ScriptMgr::CanGroupAccept(Player* player, Group* group) +{ + auto ret = IsValidBoolScript([&](PlayerScript* script) + { + return !script->CanGroupAccept(player, group); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +bool ScriptMgr::CanSellItem(Player* player, Item* item, Creature* creature) +{ + auto ret = IsValidBoolScript([&](PlayerScript* script) + { + return !script->CanSellItem(player, item, creature); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +bool ScriptMgr::CanSendMail(Player* player, ObjectGuid receiverGuid, ObjectGuid mailbox, std::string& subject, std::string& body, uint32 money, uint32 COD, Item* item) +{ + auto ret = IsValidBoolScript([&](PlayerScript* script) + { + return !script->CanSendMail(player, receiverGuid, mailbox, subject, body, money, COD, item); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +void ScriptMgr::PetitionBuy(Player* player, Creature* creature, uint32& charterid, uint32& cost, uint32& type) +{ + ExecuteScript([&](PlayerScript* script) + { + script->PetitionBuy(player, creature, charterid, cost, type); + }); +} + +void ScriptMgr::PetitionShowList(Player* player, Creature* creature, uint32& CharterEntry, uint32& CharterDispayID, uint32& CharterCost) +{ + ExecuteScript([&](PlayerScript* script) + { + script->PetitionShowList(player, creature, CharterEntry, CharterDispayID, CharterCost); + }); +} + +void ScriptMgr::OnRewardKillRewarder(Player* player, bool isDungeon, float& rate) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnRewardKillRewarder(player, isDungeon, rate); + }); +} + +bool ScriptMgr::CanGiveMailRewardAtGiveLevel(Player* player, uint8 level) +{ + auto ret = IsValidBoolScript([&](PlayerScript* script) + { + return !script->CanGiveMailRewardAtGiveLevel(player, level); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +void ScriptMgr::OnDeleteFromDB(CharacterDatabaseTransaction trans, uint32 guid) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnDeleteFromDB(trans, guid); + }); +} + +bool ScriptMgr::CanRepopAtGraveyard(Player* player) +{ + auto ret = IsValidBoolScript([&](PlayerScript* script) + { + return !script->CanRepopAtGraveyard(player); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +void ScriptMgr::OnGetMaxSkillValue(Player* player, uint32 skill, int32& result, bool IsPure) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnGetMaxSkillValue(player, skill, result, IsPure); + }); +} + +bool ScriptMgr::CanAreaExploreAndOutdoor(Player* player) +{ + auto ret = IsValidBoolScript([&](PlayerScript* script) + { + return !script->CanAreaExploreAndOutdoor(player); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +void ScriptMgr::OnVictimRewardBefore(Player* player, Player* victim, uint32& killer_title, uint32& victim_title) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnVictimRewardBefore(player, victim, killer_title, victim_title); + }); +} + +void ScriptMgr::OnVictimRewardAfter(Player* player, Player* victim, uint32& killer_title, uint32& victim_rank, float& honor_f) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnVictimRewardAfter(player, victim, killer_title, victim_rank, honor_f); + }); +} + +void ScriptMgr::OnCustomScalingStatValueBefore(Player* player, ItemTemplate const* proto, uint8 slot, bool apply, uint32& CustomScalingStatValue) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnCustomScalingStatValueBefore(player, proto, slot, apply, CustomScalingStatValue); + }); +} + +void ScriptMgr::OnCustomScalingStatValue(Player* player, ItemTemplate const* proto, uint32& statType, int32& val, uint8 itemProtoStatNumber, uint32 ScalingStatValue, ScalingStatValuesEntry const* ssv) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnCustomScalingStatValue(player, proto, statType, val, itemProtoStatNumber, ScalingStatValue, ssv); + }); +} + +bool ScriptMgr::CanArmorDamageModifier(Player* player) +{ + auto ret = IsValidBoolScript([&](PlayerScript* script) + { + return !script->CanArmorDamageModifier(player); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +void ScriptMgr::OnGetFeralApBonus(Player* player, int32& feral_bonus, int32 dpsMod, ItemTemplate const* proto, ScalingStatValuesEntry const* ssv) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnGetFeralApBonus(player, feral_bonus, dpsMod, proto, ssv); + }); +} + +bool ScriptMgr::CanApplyWeaponDependentAuraDamageMod(Player* player, Item* item, WeaponAttackType attackType, AuraEffect const* aura, bool apply) +{ + auto ret = IsValidBoolScript([&](PlayerScript* script) + { + return !script->CanApplyWeaponDependentAuraDamageMod(player, item, attackType, aura, apply); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +bool ScriptMgr::CanApplyEquipSpell(Player* player, SpellInfo const* spellInfo, Item* item, bool apply, bool form_change) +{ + auto ret = IsValidBoolScript([&](PlayerScript* script) + { + return !script->CanApplyEquipSpell(player, spellInfo, item, apply, form_change); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +bool ScriptMgr::CanApplyEquipSpellsItemSet(Player* player, ItemSetEffect* eff) +{ + auto ret = IsValidBoolScript([&](PlayerScript* script) + { + return !script->CanApplyEquipSpellsItemSet(player, eff); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +bool ScriptMgr::CanCastItemCombatSpell(Player* player, Unit* target, WeaponAttackType attType, uint32 procVictim, uint32 procEx, Item* item, ItemTemplate const* proto) +{ + auto ret = IsValidBoolScript([&](PlayerScript* script) + { + return !script->CanCastItemCombatSpell(player, target, attType, procVictim, procEx, item, proto); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +bool ScriptMgr::CanCastItemUseSpell(Player* player, Item* item, SpellCastTargets const& targets, uint8 cast_count, uint32 glyphIndex) +{ + auto ret = IsValidBoolScript([&](PlayerScript* script) + { + return !script->CanCastItemUseSpell(player, item, targets, cast_count, glyphIndex); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +void ScriptMgr::OnApplyAmmoBonuses(Player* player, ItemTemplate const* proto, float& currentAmmoDPS) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnApplyAmmoBonuses(player, proto, currentAmmoDPS); + }); +} + +bool ScriptMgr::CanEquipItem(Player* player, uint8 slot, uint16& dest, Item* pItem, bool swap, bool not_loading) +{ + auto ret = IsValidBoolScript([&](PlayerScript* script) + { + return !script->CanEquipItem(player, slot, dest, pItem, swap, not_loading); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +bool ScriptMgr::CanUnequipItem(Player* player, uint16 pos, bool swap) +{ + auto ret = IsValidBoolScript([&](PlayerScript* script) + { + return !script->CanUnequipItem(player, pos, swap); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +bool ScriptMgr::CanUseItem(Player* player, ItemTemplate const* proto, InventoryResult& result) +{ + auto ret = IsValidBoolScript([&](PlayerScript* script) + { + return !script->CanUseItem(player, proto, result); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +bool ScriptMgr::CanSaveEquipNewItem(Player* player, Item* item, uint16 pos, bool update) +{ + auto ret = IsValidBoolScript([&](PlayerScript* script) + { + return !script->CanSaveEquipNewItem(player, item, pos, update); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +bool ScriptMgr::CanApplyEnchantment(Player* player, Item* item, EnchantmentSlot slot, bool apply, bool apply_dur, bool ignore_condition) +{ + auto ret = IsValidBoolScript([&](PlayerScript* script) + { + return !script->CanApplyEnchantment(player, item, slot, apply, apply_dur, ignore_condition); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +void ScriptMgr::OnGetQuestRate(Player* player, float& result) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnGetQuestRate(player, result); + }); +} + +bool ScriptMgr::PassedQuestKilledMonsterCredit(Player* player, Quest const* qinfo, uint32 entry, uint32 real_entry, ObjectGuid guid) +{ + auto ret = IsValidBoolScript([&](PlayerScript* script) + { + return !script->PassedQuestKilledMonsterCredit(player, qinfo, entry, real_entry, guid); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +bool ScriptMgr::CheckItemInSlotAtLoadInventory(Player* player, Item* item, uint8 slot, uint8& err, uint16& dest) +{ + auto ret = IsValidBoolScript([&](PlayerScript* script) + { + return !script->CheckItemInSlotAtLoadInventory(player, item, slot, err, dest); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +bool ScriptMgr::NotAvoidSatisfy(Player* player, DungeonProgressionRequirements const* ar, uint32 target_map, bool report) +{ + auto ret = IsValidBoolScript([&](PlayerScript* script) + { + return !script->NotAvoidSatisfy(player, ar, target_map, report); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +bool ScriptMgr::NotVisibleGloballyFor(Player* player, Player const* u) +{ + auto ret = IsValidBoolScript([&](PlayerScript* script) + { + return !script->NotVisibleGloballyFor(player, u); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +void ScriptMgr::OnGetArenaPersonalRating(Player* player, uint8 slot, uint32& result) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnGetArenaPersonalRating(player, slot, result); + }); +} + +void ScriptMgr::OnGetArenaTeamId(Player* player, uint8 slot, uint32& result) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnGetArenaTeamId(player, slot, result); + }); +} + +void ScriptMgr::OnIsFFAPvP(Player* player, bool& result) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnIsFFAPvP(player, result); + }); +} + +void ScriptMgr::OnIsPvP(Player* player, bool& result) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnIsPvP(player, result); + }); +} + +void ScriptMgr::OnGetMaxSkillValueForLevel(Player* player, uint16& result) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnGetMaxSkillValueForLevel(player, result); + }); +} + +bool ScriptMgr::NotSetArenaTeamInfoField(Player* player, uint8 slot, ArenaTeamInfoType type, uint32 value) +{ + auto ret = IsValidBoolScript([&](PlayerScript* script) + { + return !script->NotSetArenaTeamInfoField(player, slot, type, value); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +bool ScriptMgr::CanJoinLfg(Player* player, uint8 roles, lfg::LfgDungeonSet& dungeons, const std::string& comment) +{ + auto ret = IsValidBoolScript([&](PlayerScript* script) + { + return !script->CanJoinLfg(player, roles, dungeons, comment); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +bool ScriptMgr::CanEnterMap(Player* player, MapEntry const* entry, InstanceTemplate const* instance, MapDifficulty const* mapDiff, bool loginCheck) +{ + auto ret = IsValidBoolScript([&](PlayerScript* script) + { + return !script->CanEnterMap(player, entry, instance, mapDiff, loginCheck); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +bool ScriptMgr::CanInitTrade(Player* player, Player* target) +{ + auto ret = IsValidBoolScript([&](PlayerScript* script) + { + return !script->CanInitTrade(player, target); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +void ScriptMgr::OnSetServerSideVisibility(Player* player, ServerSideVisibilityType& type, AccountTypes& sec) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnSetServerSideVisibility(player, type, sec); + }); +} + +void ScriptMgr::OnSetServerSideVisibilityDetect(Player* player, ServerSideVisibilityType& type, AccountTypes& sec) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnSetServerSideVisibilityDetect(player, type, sec); + }); +} + +//void ScriptMgr::OnGiveHonorPoints(Player* player, float& honor, Unit* victim) +//{ +// ExecuteScript([&](PlayerScript* script) +// { +// script->OnGiveHonorPoints(player, honor, victim); +// }); +//} +// +//void ScriptMgr::OnAfterResurrect(Player* player, float restore_percent, bool applySickness) +//{ +// ExecuteScript([&](PlayerScript* script) +// { +// script->OnAfterResurrect(player, restore_percent, applySickness); +// }); +//} + +void ScriptMgr::OnPlayerResurrect(Player* player, float restore_percent, bool applySickness) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnPlayerResurrect(player, restore_percent, applySickness); + }); +} + +bool ScriptMgr::CanPlayerUseChat(Player* player, uint32 type, uint32 language, std::string& msg) +{ + auto ret = IsValidBoolScript([&](PlayerScript* script) + { + return !script->CanPlayerUseChat(player, type, language, msg); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +bool ScriptMgr::CanPlayerUseChat(Player* player, uint32 type, uint32 language, std::string& msg, Player* receiver) +{ + auto ret = IsValidBoolScript([&](PlayerScript* script) + { + return !script->CanPlayerUseChat(player, type, language, msg, receiver); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +bool ScriptMgr::CanPlayerUseChat(Player* player, uint32 type, uint32 language, std::string& msg, Group* group) +{ + auto ret = IsValidBoolScript([&](PlayerScript* script) + { + return !script->CanPlayerUseChat(player, type, language, msg, group); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +bool ScriptMgr::CanPlayerUseChat(Player* player, uint32 type, uint32 language, std::string& msg, Guild* guild) +{ + auto ret = IsValidBoolScript([&](PlayerScript* script) + { + return !script->CanPlayerUseChat(player, type, language, msg, guild); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +bool ScriptMgr::CanPlayerUseChat(Player* player, uint32 type, uint32 language, std::string& msg, Channel* channel) +{ + auto ret = IsValidBoolScript([&](PlayerScript* script) + { + return !script->CanPlayerUseChat(player, type, language, msg, channel); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +void ScriptMgr::OnPlayerLearnTalents(Player* player, uint32 talentId, uint32 talentRank, uint32 spellid) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnPlayerLearnTalents(player, talentId, talentRank, spellid); + }); +} + +void ScriptMgr::OnPlayerEnterCombat(Player* player, Unit* enemy) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnPlayerEnterCombat(player, enemy); + }); +} + +void ScriptMgr::OnPlayerLeaveCombat(Player* player) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnPlayerLeaveCombat(player); + }); +} + +void ScriptMgr::OnQuestAbandon(Player* player, uint32 questId) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnQuestAbandon(player, questId); + }); +} + +// Player anti cheat +void ScriptMgr::AnticheatSetSkipOnePacketForASH(Player* player, bool apply) +{ + ExecuteScript([&](PlayerScript* script) + { + script->AnticheatSetSkipOnePacketForASH(player, apply); + }); +} + +void ScriptMgr::AnticheatSetCanFlybyServer(Player* player, bool apply) +{ + ExecuteScript([&](PlayerScript* script) + { + script->AnticheatSetCanFlybyServer(player, apply); + }); +} + +void ScriptMgr::AnticheatSetUnderACKmount(Player* player) +{ + ExecuteScript([&](PlayerScript* script) + { + script->AnticheatSetUnderACKmount(player); + }); +} + +void ScriptMgr::AnticheatSetRootACKUpd(Player* player) +{ + ExecuteScript([&](PlayerScript* script) + { + script->AnticheatSetRootACKUpd(player); + }); +} + +void ScriptMgr::AnticheatSetJumpingbyOpcode(Player* player, bool jump) +{ + ExecuteScript([&](PlayerScript* script) + { + script->AnticheatSetJumpingbyOpcode(player, jump); + }); +} + +void ScriptMgr::AnticheatUpdateMovementInfo(Player* player, MovementInfo const& movementInfo) +{ + ExecuteScript([&](PlayerScript* script) + { + script->AnticheatUpdateMovementInfo(player, movementInfo); + }); +} + +bool ScriptMgr::AnticheatHandleDoubleJump(Player* player, Unit* mover) +{ + auto ret = IsValidBoolScript([&](PlayerScript* script) + { + return !script->AnticheatHandleDoubleJump(player, mover); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +bool ScriptMgr::AnticheatCheckMovementInfo(Player* player, MovementInfo const& movementInfo, Unit* mover, bool jump) +{ + auto ret = IsValidBoolScript([&](PlayerScript* script) + { + return !script->AnticheatCheckMovementInfo(player, movementInfo, mover, jump); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} diff --git a/src/server/game/Scripting/ScriptDefines/ServerScript.cpp b/src/server/game/Scripting/ScriptDefines/ServerScript.cpp new file mode 100644 index 000000000..ca8f7cf67 --- /dev/null +++ b/src/server/game/Scripting/ScriptDefines/ServerScript.cpp @@ -0,0 +1,97 @@ +/* + * 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 . + */ + +#include "ScriptMgr.h" +#include "ScriptMgrMacros.h" + +void ScriptMgr::OnNetworkStart() +{ + ExecuteScript([&](ServerScript* script) + { + script->OnNetworkStart(); + }); +} + +void ScriptMgr::OnNetworkStop() +{ + ExecuteScript([&](ServerScript* script) + { + script->OnNetworkStop(); + }); +} + +void ScriptMgr::OnSocketOpen(std::shared_ptr socket) +{ + ASSERT(socket); + + ExecuteScript([&](ServerScript* script) + { + script->OnSocketOpen(socket); + }); +} + +void ScriptMgr::OnSocketClose(std::shared_ptr socket) +{ + ASSERT(socket); + + ExecuteScript([&](ServerScript* script) + { + script->OnSocketClose(socket); + }); +} + +bool ScriptMgr::CanPacketReceive(WorldSession* session, WorldPacket const& packet) +{ + if (ScriptRegistry::ScriptPointerList.empty()) + return true; + + WorldPacket copy(packet); + + auto ret = IsValidBoolScript([&](ServerScript* script) + { + return !script->CanPacketReceive(session, copy); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +bool ScriptMgr::CanPacketSend(WorldSession* session, WorldPacket const& packet) +{ + ASSERT(session); + + if (ScriptRegistry::ScriptPointerList.empty()) + return true; + + WorldPacket copy(packet); + + auto ret = IsValidBoolScript([&](ServerScript* script) + { + return !script->CanPacketSend(session, copy); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} diff --git a/src/server/game/Scripting/ScriptDefines/SpellSC.cpp b/src/server/game/Scripting/ScriptDefines/SpellSC.cpp new file mode 100644 index 000000000..c84bb104e --- /dev/null +++ b/src/server/game/Scripting/ScriptDefines/SpellSC.cpp @@ -0,0 +1,158 @@ +/* + * 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 . + */ + +#include "ScriptMgr.h" +#include "ScriptMgrMacros.h" + +void ScriptMgr::OnCalcMaxDuration(Aura const* aura, int32& maxDuration) +{ + ExecuteScript([&](SpellSC* script) + { + script->OnCalcMaxDuration(aura, maxDuration); + }); +} + +bool ScriptMgr::CanModAuraEffectDamageDone(AuraEffect const* auraEff, Unit* target, AuraApplication const* aurApp, uint8 mode, bool apply) +{ + auto ret = IsValidBoolScript([&](SpellSC* script) + { + return !script->CanModAuraEffectDamageDone(auraEff, target, aurApp, mode, apply); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +bool ScriptMgr::CanModAuraEffectModDamagePercentDone(AuraEffect const* auraEff, Unit* target, AuraApplication const* aurApp, uint8 mode, bool apply) +{ + auto ret = IsValidBoolScript([&](SpellSC* script) + { + return !script->CanModAuraEffectModDamagePercentDone(auraEff, target, aurApp, mode, apply); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +void ScriptMgr::OnSpellCheckCast(Spell* spell, bool strict, SpellCastResult& res) +{ + ExecuteScript([&](SpellSC* script) + { + script->OnSpellCheckCast(spell, strict, res); + }); +} + +bool ScriptMgr::CanPrepare(Spell* spell, SpellCastTargets const* targets, AuraEffect const* triggeredByAura) +{ + auto ret = IsValidBoolScript([&](SpellSC* script) + { + return !script->CanPrepare(spell, targets, triggeredByAura); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +bool ScriptMgr::CanScalingEverything(Spell* spell) +{ + auto ret = IsValidBoolScript([&](SpellSC* script) + { + return script->CanScalingEverything(spell); + }); + + if (ret && *ret) + { + return true; + } + + return false; +} + +bool ScriptMgr::CanSelectSpecTalent(Spell* spell) +{ + auto ret = IsValidBoolScript([&](SpellSC* script) + { + return !script->CanSelectSpecTalent(spell); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +void ScriptMgr::OnScaleAuraUnitAdd(Spell* spell, Unit* target, uint32 effectMask, bool checkIfValid, bool implicit, uint8 auraScaleMask, TargetInfo& targetInfo) +{ + ExecuteScript([&](SpellSC* script) + { + script->OnScaleAuraUnitAdd(spell, target, effectMask, checkIfValid, implicit, auraScaleMask, targetInfo); + }); +} + +void ScriptMgr::OnRemoveAuraScaleTargets(Spell* spell, TargetInfo& targetInfo, uint8 auraScaleMask, bool& needErase) +{ + ExecuteScript([&](SpellSC* script) + { + script->OnRemoveAuraScaleTargets(spell, targetInfo, auraScaleMask, needErase); + }); +} + +void ScriptMgr::OnBeforeAuraRankForLevel(SpellInfo const* spellInfo, SpellInfo const* latestSpellInfo, uint8 level) +{ + ExecuteScript([&](SpellSC* script) + { + script->OnBeforeAuraRankForLevel(spellInfo, latestSpellInfo, level); + }); +} + +void ScriptMgr::OnDummyEffect(WorldObject* caster, uint32 spellID, SpellEffIndex effIndex, GameObject* gameObjTarget) +{ + ExecuteScript([&](SpellSC* script) + { + script->OnDummyEffect(caster, spellID, effIndex, gameObjTarget); + }); +} + +void ScriptMgr::OnDummyEffect(WorldObject* caster, uint32 spellID, SpellEffIndex effIndex, Creature* creatureTarget) +{ + ExecuteScript([&](SpellSC* script) + { + script->OnDummyEffect(caster, spellID, effIndex, creatureTarget); + }); +} + +void ScriptMgr::OnDummyEffect(WorldObject* caster, uint32 spellID, SpellEffIndex effIndex, Item* itemTarget) +{ + ExecuteScript([&](SpellSC* script) + { + script->OnDummyEffect(caster, spellID, effIndex, itemTarget); + }); +} diff --git a/src/server/game/Scripting/ScriptDefines/SpellScriptLoader.cpp b/src/server/game/Scripting/ScriptDefines/SpellScriptLoader.cpp new file mode 100644 index 000000000..8ee566638 --- /dev/null +++ b/src/server/game/Scripting/ScriptDefines/SpellScriptLoader.cpp @@ -0,0 +1,77 @@ +/* + * 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 . + */ + +#include "ScriptMgr.h" +#include "ScriptMgrMacros.h" +#include "SpellScript.h" + +void ScriptMgr::CreateSpellScripts(uint32 spellId, std::list& scriptVector) +{ + SpellScriptsBounds bounds = sObjectMgr->GetSpellScriptsBounds(spellId); + + for (SpellScriptsContainer::iterator itr = bounds.first; itr != bounds.second; ++itr) + { + SpellScriptLoader* tempScript = ScriptRegistry::GetScriptById(itr->second); + if (!tempScript) + continue; + + SpellScript* script = tempScript->GetSpellScript(); + + if (!script) + continue; + + script->_Init(&tempScript->GetName(), spellId); + + scriptVector.push_back(script); + } +} + +void ScriptMgr::CreateAuraScripts(uint32 spellId, std::list& scriptVector) +{ + SpellScriptsBounds bounds = sObjectMgr->GetSpellScriptsBounds(spellId); + + for (SpellScriptsContainer::iterator itr = bounds.first; itr != bounds.second; ++itr) + { + SpellScriptLoader* tempScript = ScriptRegistry::GetScriptById(itr->second); + if (!tempScript) + continue; + + AuraScript* script = tempScript->GetAuraScript(); + + if (!script) + continue; + + script->_Init(&tempScript->GetName(), spellId); + + scriptVector.push_back(script); + } +} + +void ScriptMgr::CreateSpellScriptLoaders(uint32 spellId, std::vector>& scriptVector) +{ + SpellScriptsBounds bounds = sObjectMgr->GetSpellScriptsBounds(spellId); + scriptVector.reserve(std::distance(bounds.first, bounds.second)); + + for (SpellScriptsContainer::iterator itr = bounds.first; itr != bounds.second; ++itr) + { + SpellScriptLoader* tempScript = ScriptRegistry::GetScriptById(itr->second); + if (!tempScript) + continue; + + scriptVector.emplace_back(tempScript, itr); + } +} diff --git a/src/server/game/Scripting/ScriptDefines/TransportScript.cpp b/src/server/game/Scripting/ScriptDefines/TransportScript.cpp new file mode 100644 index 000000000..90916d2e4 --- /dev/null +++ b/src/server/game/Scripting/ScriptDefines/TransportScript.cpp @@ -0,0 +1,71 @@ +/* + * 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 . + */ + +#include "ScriptMgr.h" +#include "ScriptMgrMacros.h" +#include "Transport.h" + +void ScriptMgr::OnAddPassenger(Transport* transport, Player* player) +{ + ASSERT(transport); + ASSERT(player); + + if (auto tempScript = ScriptRegistry::GetScriptById(transport->GetScriptId())) + { + tempScript->OnAddPassenger(transport, player); + } +} + +void ScriptMgr::OnAddCreaturePassenger(Transport* transport, Creature* creature) +{ + ASSERT(transport); + ASSERT(creature); + + if (auto tempScript = ScriptRegistry::GetScriptById(transport->GetScriptId())) + { + tempScript->OnAddCreaturePassenger(transport, creature); + } +} + +void ScriptMgr::OnRemovePassenger(Transport* transport, Player* player) +{ + ASSERT(transport); + ASSERT(player); + + if (auto tempScript = ScriptRegistry::GetScriptById(transport->GetScriptId())) + { + tempScript->OnRemovePassenger(transport, player); + } +} + +void ScriptMgr::OnTransportUpdate(Transport* transport, uint32 diff) +{ + ASSERT(transport); + + if (auto tempScript = ScriptRegistry::GetScriptById(transport->GetScriptId())) + { + tempScript->OnUpdate(transport, diff); + } +} + +void ScriptMgr::OnRelocate(Transport* transport, uint32 waypointId, uint32 mapId, float x, float y, float z) +{ + if (auto tempScript = ScriptRegistry::GetScriptById(transport->GetScriptId())) + { + tempScript->OnRelocate(transport, waypointId, mapId, x, y, z); + } +} diff --git a/src/server/game/Scripting/ScriptDefines/UnitScript.cpp b/src/server/game/Scripting/ScriptDefines/UnitScript.cpp new file mode 100644 index 000000000..c2e6ce19c --- /dev/null +++ b/src/server/game/Scripting/ScriptDefines/UnitScript.cpp @@ -0,0 +1,200 @@ +/* + * 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 . + */ + +#include "ScriptMgr.h" +#include "ScriptMgrMacros.h" + +uint32 ScriptMgr::DealDamage(Unit* AttackerUnit, Unit* pVictim, uint32 damage, DamageEffectType damagetype) +{ + if (ScriptRegistry::ScriptPointerList.empty()) + { + return damage; + } + + for (auto const& [scriptID, script] : ScriptRegistry::ScriptPointerList) + { + auto const& dmg = script->DealDamage(AttackerUnit, pVictim, damage, damagetype); + if (dmg != damage) + { + return damage; + } + } + + return damage; +} + +void ScriptMgr::OnHeal(Unit* healer, Unit* reciever, uint32& gain) +{ + ExecuteScript([&](UnitScript* script) + { + script->OnHeal(healer, reciever, gain); + }); +} + +void ScriptMgr::OnDamage(Unit* attacker, Unit* victim, uint32& damage) +{ + ExecuteScript([&](UnitScript* script) + { + script->OnDamage(attacker, victim, damage); + }); +} + +void ScriptMgr::ModifyPeriodicDamageAurasTick(Unit* target, Unit* attacker, uint32& damage) +{ + ExecuteScript([&](UnitScript* script) + { + script->ModifyPeriodicDamageAurasTick(target, attacker, damage); + }); +} + +void ScriptMgr::ModifyMeleeDamage(Unit* target, Unit* attacker, uint32& damage) +{ + ExecuteScript([&](UnitScript* script) + { + script->ModifyMeleeDamage(target, attacker, damage); + }); +} + +void ScriptMgr::ModifySpellDamageTaken(Unit* target, Unit* attacker, int32& damage) +{ + ExecuteScript([&](UnitScript* script) + { + script->ModifySpellDamageTaken(target, attacker, damage); + }); +} + +void ScriptMgr::ModifyHealRecieved(Unit* target, Unit* attacker, uint32& damage) +{ + ExecuteScript([&](UnitScript* script) + { + script->ModifyHealRecieved(target, attacker, damage); + }); +} + +void ScriptMgr::OnBeforeRollMeleeOutcomeAgainst(const Unit* attacker, const Unit* victim, WeaponAttackType attType, int32& attackerMaxSkillValueForLevel, int32& victimMaxSkillValueForLevel, int32& attackerWeaponSkill, int32& victimDefenseSkill, int32& crit_chance, int32& miss_chance, int32& dodge_chance, int32& parry_chance, int32& block_chance) +{ + ExecuteScript([&](UnitScript* script) + { + script->OnBeforeRollMeleeOutcomeAgainst(attacker, victim, attType, attackerMaxSkillValueForLevel, victimMaxSkillValueForLevel, attackerWeaponSkill, victimDefenseSkill, crit_chance, miss_chance, dodge_chance, parry_chance, block_chance); + }); +} + +void ScriptMgr::OnAuraRemove(Unit* unit, AuraApplication* aurApp, AuraRemoveMode mode) +{ + ExecuteScript([&](UnitScript* script) + { + script->OnAuraRemove(unit, aurApp, mode); + }); +} + +bool ScriptMgr::IfNormalReaction(Unit const* unit, Unit const* target, ReputationRank& repRank) +{ + auto ret = IsValidBoolScript([&](UnitScript* script) + { + return !script->IfNormalReaction(unit, target, repRank); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +bool ScriptMgr::IsNeedModSpellDamagePercent(Unit const* unit, AuraEffect* auraEff, float& doneTotalMod, SpellInfo const* spellProto) +{ + auto ret = IsValidBoolScript([&](UnitScript* script) + { + return !script->IsNeedModSpellDamagePercent(unit, auraEff, doneTotalMod, spellProto); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +bool ScriptMgr::IsNeedModMeleeDamagePercent(Unit const* unit, AuraEffect* auraEff, float& doneTotalMod, SpellInfo const* spellProto) +{ + auto ret = IsValidBoolScript([&](UnitScript* script) + { + return !script->IsNeedModMeleeDamagePercent(unit, auraEff, doneTotalMod, spellProto); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +bool ScriptMgr::IsNeedModHealPercent(Unit const* unit, AuraEffect* auraEff, float& doneTotalMod, SpellInfo const* spellProto) +{ + auto ret = IsValidBoolScript([&](UnitScript* script) + { + return !script->IsNeedModHealPercent(unit, auraEff, doneTotalMod, spellProto); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +bool ScriptMgr::CanSetPhaseMask(Unit const* unit, uint32 newPhaseMask, bool update) +{ + auto ret = IsValidBoolScript([&](UnitScript* script) + { + return !script->CanSetPhaseMask(unit, newPhaseMask, update); + }); + + if (ret && *ret) + { + return false; + } + + return true; +} + +bool ScriptMgr::IsCustomBuildValuesUpdate(Unit const* unit, uint8 updateType, ByteBuffer& fieldBuffer, Player const* target, uint16 index) +{ + auto ret = IsValidBoolScript([&](UnitScript* script) + { + return script->IsCustomBuildValuesUpdate(unit, updateType, fieldBuffer, target, index); + }); + + if (ret && *ret) + { + return true; + } + + return false; +} + +void ScriptMgr::OnUnitUpdate(Unit* unit, uint32 diff) +{ + ExecuteScript([&](UnitScript* script) + { + script->OnUnitUpdate(unit, diff); + }); +} diff --git a/src/server/game/Scripting/ScriptDefines/VehicleScript.cpp b/src/server/game/Scripting/ScriptDefines/VehicleScript.cpp new file mode 100644 index 000000000..df6dd5967 --- /dev/null +++ b/src/server/game/Scripting/ScriptDefines/VehicleScript.cpp @@ -0,0 +1,89 @@ +/* + * 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 . + */ + +#include "ScriptMgr.h" +#include "ScriptMgrMacros.h" +#include "Vehicle.h" + +void ScriptMgr::OnInstall(Vehicle* veh) +{ + ASSERT(veh); + ASSERT(veh->GetBase()->GetTypeId() == TYPEID_UNIT); + + if (auto tempScript = ScriptRegistry::GetScriptById(veh->GetBase()->ToCreature()->GetScriptId())) + { + tempScript->OnInstall(veh); + } +} + +void ScriptMgr::OnUninstall(Vehicle* veh) +{ + ASSERT(veh); + ASSERT(veh->GetBase()->GetTypeId() == TYPEID_UNIT); + + if (auto tempScript = ScriptRegistry::GetScriptById(veh->GetBase()->ToCreature()->GetScriptId())) + { + tempScript->OnUninstall(veh); + } +} + +void ScriptMgr::OnReset(Vehicle* veh) +{ + ASSERT(veh); + ASSERT(veh->GetBase()->GetTypeId() == TYPEID_UNIT); + + if (auto tempScript = ScriptRegistry::GetScriptById(veh->GetBase()->ToCreature()->GetScriptId())) + { + tempScript->OnReset(veh); + } +} + +void ScriptMgr::OnInstallAccessory(Vehicle* veh, Creature* accessory) +{ + ASSERT(veh); + ASSERT(veh->GetBase()->GetTypeId() == TYPEID_UNIT); + ASSERT(accessory); + + if (auto tempScript = ScriptRegistry::GetScriptById(veh->GetBase()->ToCreature()->GetScriptId())) + { + tempScript->OnInstallAccessory(veh, accessory); + } +} + +void ScriptMgr::OnAddPassenger(Vehicle* veh, Unit* passenger, int8 seatId) +{ + ASSERT(veh); + ASSERT(veh->GetBase()->GetTypeId() == TYPEID_UNIT); + ASSERT(passenger); + + if (auto tempScript = ScriptRegistry::GetScriptById(veh->GetBase()->ToCreature()->GetScriptId())) + { + tempScript->OnAddPassenger(veh, passenger, seatId); + } +} + +void ScriptMgr::OnRemovePassenger(Vehicle* veh, Unit* passenger) +{ + ASSERT(veh); + ASSERT(veh->GetBase()->GetTypeId() == TYPEID_UNIT); + ASSERT(passenger); + + if (auto tempScript = ScriptRegistry::GetScriptById(veh->GetBase()->ToCreature()->GetScriptId())) + { + tempScript->OnRemovePassenger(veh, passenger); + } +} diff --git a/src/server/game/Scripting/ScriptDefines/WeatherScript.cpp b/src/server/game/Scripting/ScriptDefines/WeatherScript.cpp new file mode 100644 index 000000000..2375ad530 --- /dev/null +++ b/src/server/game/Scripting/ScriptDefines/WeatherScript.cpp @@ -0,0 +1,44 @@ +/* + * 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 . + */ + +#include "ScriptMgr.h" +#include "ScriptMgrMacros.h" + +void ScriptMgr::OnWeatherChange(Weather* weather, WeatherState state, float grade) +{ + ASSERT(weather); + + ExecuteScript([&](ElunaScript* script) + { + script->OnWeatherChange(weather, state, grade); + }); + + if (auto tempScript = ScriptRegistry::GetScriptById(weather->GetScriptId())) + { + tempScript->OnChange(weather, state, grade); + } +} + +void ScriptMgr::OnWeatherUpdate(Weather* weather, uint32 diff) +{ + ASSERT(weather); + + if (auto tempScript = ScriptRegistry::GetScriptById(weather->GetScriptId())) + { + tempScript->OnUpdate(weather, diff); + } +} diff --git a/src/server/game/Scripting/ScriptDefines/WorldObjectScript.cpp b/src/server/game/Scripting/ScriptDefines/WorldObjectScript.cpp new file mode 100644 index 000000000..e41a820e0 --- /dev/null +++ b/src/server/game/Scripting/ScriptDefines/WorldObjectScript.cpp @@ -0,0 +1,69 @@ +/* + * 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 . + */ + +#include "ScriptMgr.h" +#include "ScriptMgrMacros.h" + +void ScriptMgr::OnWorldObjectDestroy(WorldObject* object) +{ + ASSERT(object); + + ExecuteScript([&](WorldObjectScript* script) + { + script->OnWorldObjectDestroy(object); + }); +} + +void ScriptMgr::OnWorldObjectCreate(WorldObject* object) +{ + ASSERT(object); + + ExecuteScript([&](WorldObjectScript* script) + { + script->OnWorldObjectCreate(object); + }); +} + +void ScriptMgr::OnWorldObjectSetMap(WorldObject* object, Map* map) +{ + ASSERT(object); + + ExecuteScript([&](WorldObjectScript* script) + { + script->OnWorldObjectSetMap(object, map); + }); +} + +void ScriptMgr::OnWorldObjectResetMap(WorldObject* object) +{ + ASSERT(object); + + ExecuteScript([&](WorldObjectScript* script) + { + script->OnWorldObjectResetMap(object); + }); +} + +void ScriptMgr::OnWorldObjectUpdate(WorldObject* object, uint32 diff) +{ + ASSERT(object); + + ExecuteScript([&](WorldObjectScript* script) + { + script->OnWorldObjectUpdate(object, diff); + }); +} diff --git a/src/server/game/Scripting/ScriptDefines/WorldScript.cpp b/src/server/game/Scripting/ScriptDefines/WorldScript.cpp new file mode 100644 index 000000000..633c7944b --- /dev/null +++ b/src/server/game/Scripting/ScriptDefines/WorldScript.cpp @@ -0,0 +1,115 @@ +/* + * 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 . + */ + +#include "ScriptMgr.h" +#include "ScriptMgrMacros.h" + +void ScriptMgr::OnOpenStateChange(bool open) +{ + ExecuteScript([&](WorldScript* script) + { + script->OnOpenStateChange(open); + }); +} + +void ScriptMgr::OnLoadCustomDatabaseTable() +{ + ExecuteScript([&](WorldScript* script) + { + script->OnLoadCustomDatabaseTable(); + }); +} + +void ScriptMgr::OnBeforeConfigLoad(bool reload) +{ + ExecuteScript([&](WorldScript* script) + { + script->OnBeforeConfigLoad(reload); + }); +} + +void ScriptMgr::OnAfterConfigLoad(bool reload) +{ + ExecuteScript([&](WorldScript* script) + { + script->OnAfterConfigLoad(reload); + }); +} + +void ScriptMgr::OnBeforeFinalizePlayerWorldSession(uint32& cacheVersion) +{ + ExecuteScript([&](WorldScript* script) + { + script->OnBeforeFinalizePlayerWorldSession(cacheVersion); + }); +} + +void ScriptMgr::OnMotdChange(std::string& newMotd) +{ + ExecuteScript([&](WorldScript* script) + { + script->OnMotdChange(newMotd); + }); +} + +void ScriptMgr::OnShutdownInitiate(ShutdownExitCode code, ShutdownMask mask) +{ + ExecuteScript([&](WorldScript* script) + { + script->OnShutdownInitiate(code, mask); + }); +} + +void ScriptMgr::OnShutdownCancel() +{ + ExecuteScript([&](WorldScript* script) + { + script->OnShutdownCancel(); + }); +} + +void ScriptMgr::OnWorldUpdate(uint32 diff) +{ + ExecuteScript([&](WorldScript* script) + { + script->OnUpdate(diff); + }); +} + +void ScriptMgr::OnStartup() +{ + ExecuteScript([&](WorldScript* script) + { + script->OnStartup(); + }); +} + +void ScriptMgr::OnShutdown() +{ + ExecuteScript([&](WorldScript* script) + { + script->OnShutdown(); + }); +} + +void ScriptMgr::OnBeforeWorldInitialized() +{ + ExecuteScript([&](WorldScript* script) + { + script->OnBeforeWorldInitialized(); + }); +} diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp index 6925fd23d..361e2ef5f 100644 --- a/src/server/game/Scripting/ScriptMgr.cpp +++ b/src/server/game/Scripting/ScriptMgr.cpp @@ -16,25 +16,25 @@ */ #include "ScriptMgr.h" -#include "Chat.h" -#include "Config.h" -#include "CreatureAI.h" -#include "DBCStores.h" -#include "DatabaseEnv.h" -#include "GossipDef.h" -#include "InstanceScript.h" -#include "ObjectMgr.h" -#include "OutdoorPvPMgr.h" -#include "Player.h" -#include "ScriptMgrMacros.h" -#include "ScriptSystem.h" -#include "ScriptedGossip.h" +#include "SpellMgr.h" +#include "UnitAI.h" #include "SmartAI.h" -#include "SpellInfo.h" -#include "SpellScript.h" -#include "Transport.h" -#include "Vehicle.h" -#include "WorldPacket.h" +#include "ScriptSystem.h" +#include "InstanceScript.h" + +namespace +{ + template + inline void SCR_CLEAR() + { + for (auto const& [scriptID, script] : ScriptRegistry::ScriptPointerList) + { + delete script; + } + + ScriptRegistry::ScriptPointerList.clear(); + } +} struct TSpellSummary { @@ -75,56 +75,52 @@ void ScriptMgr::Initialize() void ScriptMgr::Unload() { -#define SCR_CLEAR(T) \ - for (SCR_REG_ITR(T) itr = SCR_REG_LST(T).begin(); itr != SCR_REG_LST(T).end(); ++itr) \ - delete itr->second; \ - SCR_REG_LST(T).clear(); - - // Clear scripts for every script type. - SCR_CLEAR(SpellScriptLoader); - SCR_CLEAR(ServerScript); - SCR_CLEAR(WorldScript); - SCR_CLEAR(FormulaScript); - SCR_CLEAR(WorldMapScript); - SCR_CLEAR(InstanceMapScript); - SCR_CLEAR(BattlegroundMapScript); - SCR_CLEAR(ItemScript); - SCR_CLEAR(CreatureScript); - SCR_CLEAR(GameObjectScript); - SCR_CLEAR(AreaTriggerScript); - SCR_CLEAR(BattlegroundScript); - SCR_CLEAR(OutdoorPvPScript); - SCR_CLEAR(CommandScript); - SCR_CLEAR(WeatherScript); - SCR_CLEAR(AuctionHouseScript); - SCR_CLEAR(ConditionScript); - SCR_CLEAR(VehicleScript); - SCR_CLEAR(DynamicObjectScript); - SCR_CLEAR(TransportScript); - SCR_CLEAR(AchievementCriteriaScript); - SCR_CLEAR(PlayerScript); - SCR_CLEAR(AccountScript); - SCR_CLEAR(GuildScript); - SCR_CLEAR(GroupScript); - SCR_CLEAR(GlobalScript); - SCR_CLEAR(ModuleScript); - SCR_CLEAR(BGScript); - SCR_CLEAR(AchievementScript); - SCR_CLEAR(ArenaTeamScript); - SCR_CLEAR(SpellSC); - SCR_CLEAR(GameEventScript); - SCR_CLEAR(MailScript); - SCR_CLEAR(MiscScript); - SCR_CLEAR(PetScript); - SCR_CLEAR(ArenaScript); - SCR_CLEAR(CommandSC); - SCR_CLEAR(DatabaseScript); - SCR_CLEAR(AllCreatureScript); - SCR_CLEAR(AllItemScript); - SCR_CLEAR(AllGameObjectScript); - SCR_CLEAR(ElunaScript); - -#undef SCR_CLEAR + SCR_CLEAR(); + SCR_CLEAR(); + SCR_CLEAR(); + SCR_CLEAR(); + SCR_CLEAR(); + SCR_CLEAR(); + SCR_CLEAR(); + SCR_CLEAR(); + SCR_CLEAR(); + SCR_CLEAR(); + SCR_CLEAR(); + SCR_CLEAR(); + SCR_CLEAR(); + SCR_CLEAR(); + SCR_CLEAR(); + SCR_CLEAR(); + SCR_CLEAR(); + SCR_CLEAR(); + SCR_CLEAR(); + SCR_CLEAR(); + SCR_CLEAR(); + SCR_CLEAR(); + SCR_CLEAR(); + SCR_CLEAR(); + SCR_CLEAR(); + SCR_CLEAR(); + SCR_CLEAR(); + SCR_CLEAR(); + SCR_CLEAR(); + SCR_CLEAR(); + SCR_CLEAR(); + SCR_CLEAR(); + SCR_CLEAR(); + SCR_CLEAR(); + SCR_CLEAR(); + SCR_CLEAR(); + SCR_CLEAR(); + SCR_CLEAR(); + SCR_CLEAR(); + SCR_CLEAR(); + SCR_CLEAR(); + SCR_CLEAR(); + SCR_CLEAR(); + SCR_CLEAR(); + SCR_CLEAR(); + SCR_CLEAR(); delete[] SpellSummary; } @@ -292,3017 +288,6 @@ void ScriptMgr::FillSpellSummary() } } -void ScriptMgr::CreateSpellScripts(uint32 spellId, std::list& scriptVector) -{ - SpellScriptsBounds bounds = sObjectMgr->GetSpellScriptsBounds(spellId); - - for (SpellScriptsContainer::iterator itr = bounds.first; itr != bounds.second; ++itr) - { - SpellScriptLoader* tmpscript = ScriptRegistry::GetScriptById(itr->second); - if (!tmpscript) - continue; - - SpellScript* script = tmpscript->GetSpellScript(); - - if (!script) - continue; - - script->_Init(&tmpscript->GetName(), spellId); - - scriptVector.push_back(script); - } -} - -void ScriptMgr::CreateAuraScripts(uint32 spellId, std::list& scriptVector) -{ - SpellScriptsBounds bounds = sObjectMgr->GetSpellScriptsBounds(spellId); - - for (SpellScriptsContainer::iterator itr = bounds.first; itr != bounds.second; ++itr) - { - SpellScriptLoader* tmpscript = ScriptRegistry::GetScriptById(itr->second); - if (!tmpscript) - continue; - - AuraScript* script = tmpscript->GetAuraScript(); - - if (!script) - continue; - - script->_Init(&tmpscript->GetName(), spellId); - - scriptVector.push_back(script); - } -} - -void ScriptMgr::CreateSpellScriptLoaders(uint32 spellId, std::vector >& scriptVector) -{ - SpellScriptsBounds bounds = sObjectMgr->GetSpellScriptsBounds(spellId); - scriptVector.reserve(std::distance(bounds.first, bounds.second)); - - for (SpellScriptsContainer::iterator itr = bounds.first; itr != bounds.second; ++itr) - { - SpellScriptLoader* tmpscript = ScriptRegistry::GetScriptById(itr->second); - if (!tmpscript) - continue; - - scriptVector.push_back(std::make_pair(tmpscript, itr)); - } -} - -void ScriptMgr::OnBeforePlayerDurabilityRepair(Player* player, ObjectGuid npcGUID, ObjectGuid itemGUID, float& discountMod, uint8 guildBank) -{ - FOREACH_SCRIPT(PlayerScript)->OnBeforeDurabilityRepair(player, npcGUID, itemGUID, discountMod, guildBank); -} - -void ScriptMgr::OnNetworkStart() -{ - FOREACH_SCRIPT(ServerScript)->OnNetworkStart(); -} - -void ScriptMgr::OnNetworkStop() -{ - FOREACH_SCRIPT(ServerScript)->OnNetworkStop(); -} - -void ScriptMgr::OnSocketOpen(std::shared_ptr socket) -{ - ASSERT(socket); - - FOREACH_SCRIPT(ServerScript)->OnSocketOpen(socket); -} - -void ScriptMgr::OnSocketClose(std::shared_ptr socket) -{ - ASSERT(socket); - - FOREACH_SCRIPT(ServerScript)->OnSocketClose(socket); -} - -bool ScriptMgr::CanPacketReceive(WorldSession* session, WorldPacket const& packet) -{ - if (SCR_REG_LST(ServerScript).empty()) - return true; - - WorldPacket copy(packet); - - 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; -} - -bool ScriptMgr::CanPacketSend(WorldSession* session, WorldPacket const& packet) -{ - ASSERT(session); - - if (SCR_REG_LST(ServerScript).empty()) - return true; - - WorldPacket copy(packet); - - 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) -{ - FOREACH_SCRIPT(WorldScript)->OnOpenStateChange(open); -} - -void ScriptMgr::OnLoadCustomDatabaseTable() -{ - FOREACH_SCRIPT(WorldScript)->OnLoadCustomDatabaseTable(); -} - -void ScriptMgr::OnBeforeConfigLoad(bool reload) -{ - FOREACH_SCRIPT(WorldScript)->OnBeforeConfigLoad(reload); -} - -void ScriptMgr::OnAfterConfigLoad(bool reload) -{ - FOREACH_SCRIPT(WorldScript)->OnAfterConfigLoad(reload); -} - -void ScriptMgr::OnBeforeFinalizePlayerWorldSession(uint32& cacheVersion) -{ - FOREACH_SCRIPT(WorldScript)->OnBeforeFinalizePlayerWorldSession(cacheVersion); -} - -void ScriptMgr::OnMotdChange(std::string& newMotd) -{ - FOREACH_SCRIPT(WorldScript)->OnMotdChange(newMotd); -} - -void ScriptMgr::OnShutdownInitiate(ShutdownExitCode code, ShutdownMask mask) -{ - FOREACH_SCRIPT(WorldScript)->OnShutdownInitiate(code, mask); -} - -void ScriptMgr::OnShutdownCancel() -{ - FOREACH_SCRIPT(WorldScript)->OnShutdownCancel(); -} - -void ScriptMgr::OnWorldUpdate(uint32 diff) -{ - FOREACH_SCRIPT(WorldScript)->OnUpdate(diff); -} - -void ScriptMgr::OnHonorCalculation(float& honor, uint8 level, float multiplier) -{ - FOREACH_SCRIPT(FormulaScript)->OnHonorCalculation(honor, level, multiplier); -} - -void ScriptMgr::OnGrayLevelCalculation(uint8& grayLevel, uint8 playerLevel) -{ - FOREACH_SCRIPT(FormulaScript)->OnGrayLevelCalculation(grayLevel, playerLevel); -} - -void ScriptMgr::OnColorCodeCalculation(XPColorChar& color, uint8 playerLevel, uint8 mobLevel) -{ - FOREACH_SCRIPT(FormulaScript)->OnColorCodeCalculation(color, playerLevel, mobLevel); -} - -void ScriptMgr::OnZeroDifferenceCalculation(uint8& diff, uint8 playerLevel) -{ - FOREACH_SCRIPT(FormulaScript)->OnZeroDifferenceCalculation(diff, playerLevel); -} - -void ScriptMgr::OnBaseGainCalculation(uint32& gain, uint8 playerLevel, uint8 mobLevel, ContentLevels content) -{ - FOREACH_SCRIPT(FormulaScript)->OnBaseGainCalculation(gain, playerLevel, mobLevel, content); -} - -void ScriptMgr::OnGainCalculation(uint32& gain, Player* player, Unit* unit) -{ - ASSERT(player); - ASSERT(unit); - - FOREACH_SCRIPT(FormulaScript)->OnGainCalculation(gain, player, unit); -} - -void ScriptMgr::OnGroupRateCalculation(float& rate, uint32 count, bool isRaid) -{ - FOREACH_SCRIPT(FormulaScript)->OnGroupRateCalculation(rate, count, isRaid); -} - -#define SCR_MAP_BGN(M, V, I, E, C, T) \ - if (V->GetEntry() && V->GetEntry()->T()) \ - { \ - FOR_SCRIPTS(M, I, E) \ - { \ - MapEntry const* C = I->second->GetEntry(); \ - if (!C) \ - continue; \ - if (C->MapID == V->GetId()) \ - { -#define SCR_MAP_END \ - return; \ - } \ - } \ - } - -void ScriptMgr::OnCreateMap(Map* map) -{ - ASSERT(map); - - FOREACH_SCRIPT(AllMapScript)->OnCreateMap(map); - - SCR_MAP_BGN(WorldMapScript, map, itr, end, entry, IsWorldMap); - itr->second->OnCreate(map); - SCR_MAP_END; - - SCR_MAP_BGN(InstanceMapScript, map, itr, end, entry, IsDungeon); - itr->second->OnCreate((InstanceMap*)map); - SCR_MAP_END; - - SCR_MAP_BGN(BattlegroundMapScript, map, itr, end, entry, IsBattleground); - itr->second->OnCreate((BattlegroundMap*)map); - SCR_MAP_END; -} - -void ScriptMgr::OnDestroyMap(Map* map) -{ - ASSERT(map); - - FOREACH_SCRIPT(AllMapScript)->OnDestroyMap(map); - - SCR_MAP_BGN(WorldMapScript, map, itr, end, entry, IsWorldMap); - itr->second->OnDestroy(map); - SCR_MAP_END; - - SCR_MAP_BGN(InstanceMapScript, map, itr, end, entry, IsDungeon); - itr->second->OnDestroy((InstanceMap*)map); - SCR_MAP_END; - - SCR_MAP_BGN(BattlegroundMapScript, map, itr, end, entry, IsBattleground); - itr->second->OnDestroy((BattlegroundMap*)map); - SCR_MAP_END; -} - -void ScriptMgr::OnLoadGridMap(Map* map, GridMap* gmap, uint32 gx, uint32 gy) -{ - ASSERT(map); - ASSERT(gmap); - - SCR_MAP_BGN(WorldMapScript, map, itr, end, entry, IsWorldMap); - itr->second->OnLoadGridMap(map, gmap, gx, gy); - SCR_MAP_END; - - SCR_MAP_BGN(InstanceMapScript, map, itr, end, entry, IsDungeon); - itr->second->OnLoadGridMap((InstanceMap*)map, gmap, gx, gy); - SCR_MAP_END; - - SCR_MAP_BGN(BattlegroundMapScript, map, itr, end, entry, IsBattleground); - itr->second->OnLoadGridMap((BattlegroundMap*)map, gmap, gx, gy); - SCR_MAP_END; -} - -void ScriptMgr::OnUnloadGridMap(Map* map, GridMap* gmap, uint32 gx, uint32 gy) -{ - ASSERT(map); - ASSERT(gmap); - - SCR_MAP_BGN(WorldMapScript, map, itr, end, entry, IsWorldMap); - itr->second->OnUnloadGridMap(map, gmap, gx, gy); - SCR_MAP_END; - - SCR_MAP_BGN(InstanceMapScript, map, itr, end, entry, IsDungeon); - itr->second->OnUnloadGridMap((InstanceMap*)map, gmap, gx, gy); - SCR_MAP_END; - - SCR_MAP_BGN(BattlegroundMapScript, map, itr, end, entry, IsBattleground); - itr->second->OnUnloadGridMap((BattlegroundMap*)map, gmap, gx, gy); - SCR_MAP_END; -} - -void ScriptMgr::OnPlayerEnterMap(Map* map, Player* player) -{ - ASSERT(map); - ASSERT(player); - - FOREACH_SCRIPT(AllMapScript)->OnPlayerEnterAll(map, player); - - FOREACH_SCRIPT(PlayerScript)->OnMapChanged(player); - - SCR_MAP_BGN(WorldMapScript, map, itr, end, entry, IsWorldMap); - itr->second->OnPlayerEnter(map, player); - SCR_MAP_END; - - SCR_MAP_BGN(InstanceMapScript, map, itr, end, entry, IsDungeon); - itr->second->OnPlayerEnter((InstanceMap*)map, player); - SCR_MAP_END; - - SCR_MAP_BGN(BattlegroundMapScript, map, itr, end, entry, IsBattleground); - itr->second->OnPlayerEnter((BattlegroundMap*)map, player); - SCR_MAP_END; -} - -void ScriptMgr::OnPlayerLeaveMap(Map* map, Player* player) -{ - ASSERT(map); - ASSERT(player); - - FOREACH_SCRIPT(AllMapScript)->OnPlayerLeaveAll(map, player); - - SCR_MAP_BGN(WorldMapScript, map, itr, end, entry, IsWorldMap); - itr->second->OnPlayerLeave(map, player); - SCR_MAP_END; - - SCR_MAP_BGN(InstanceMapScript, map, itr, end, entry, IsDungeon); - itr->second->OnPlayerLeave((InstanceMap*)map, player); - SCR_MAP_END; - - SCR_MAP_BGN(BattlegroundMapScript, map, itr, end, entry, IsBattleground); - itr->second->OnPlayerLeave((BattlegroundMap*)map, player); - SCR_MAP_END; -} - -void ScriptMgr::OnMapUpdate(Map* map, uint32 diff) -{ - ASSERT(map); - - FOREACH_SCRIPT(AllMapScript)->OnMapUpdate(map, diff); - - SCR_MAP_BGN(WorldMapScript, map, itr, end, entry, IsWorldMap); - itr->second->OnUpdate(map, diff); - SCR_MAP_END; - - SCR_MAP_BGN(InstanceMapScript, map, itr, end, entry, IsDungeon); - itr->second->OnUpdate((InstanceMap*)map, diff); - SCR_MAP_END; - - SCR_MAP_BGN(BattlegroundMapScript, map, itr, end, entry, IsBattleground); - itr->second->OnUpdate((BattlegroundMap*)map, diff); - SCR_MAP_END; -} - -#undef SCR_MAP_BGN -#undef SCR_MAP_END - -InstanceScript* ScriptMgr::CreateInstanceScript(InstanceMap* map) -{ - ASSERT(map); - - GET_SCRIPT_RET(InstanceMapScript, map->GetScriptId(), tmpscript, nullptr); - return tmpscript->GetInstanceScript(map); -} - -bool ScriptMgr::OnQuestAccept(Player* player, Item* item, Quest const* quest) -{ - ASSERT(player); - ASSERT(item); - ASSERT(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; - } - - GET_SCRIPT_RET(ItemScript, item->GetScriptId(), tmpscript, false); - ClearGossipMenuFor(player); - return tmpscript->OnQuestAccept(player, item, quest); -} - -bool ScriptMgr::OnItemUse(Player* player, Item* item, SpellCastTargets const& targets) -{ - ASSERT(player); - ASSERT(item); - - 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; - } - - GET_SCRIPT_RET(ItemScript, item->GetScriptId(), tmpscript, false); - return tmpscript->OnUse(player, item, targets); -} - -bool ScriptMgr::OnItemExpire(Player* player, ItemTemplate const* proto) -{ - ASSERT(player); - ASSERT(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; - } - - GET_SCRIPT_RET(ItemScript, proto->ScriptId, tmpscript, false); - return tmpscript->OnExpire(player, proto); -} - -bool ScriptMgr::OnItemRemove(Player* player, Item* item) -{ - ASSERT(player); - ASSERT(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; - } - - GET_SCRIPT_RET(ItemScript, item->GetScriptId(), tmpscript, false); - return tmpscript->OnRemove(player, item); -} - -bool ScriptMgr::OnCastItemCombatSpell(Player* player, Unit* victim, SpellInfo const* spellInfo, Item* item) -{ - ASSERT(player); - ASSERT(victim); - ASSERT(spellInfo); - ASSERT(item); - - GET_SCRIPT_RET(ItemScript, item->GetScriptId(), tmpscript, true); - return tmpscript->OnCastItemCombatSpell(player, victim, spellInfo, item); -} - -void ScriptMgr::OnGossipSelect(Player* player, Item* item, uint32 sender, uint32 action) -{ - ASSERT(player); - ASSERT(item); - - FOREACH_SCRIPT(AllItemScript)->OnItemGossipSelect(player, item, sender, action); - - GET_SCRIPT(ItemScript, item->GetScriptId(), tmpscript); - tmpscript->OnGossipSelect(player, item, sender, action); -} - -void ScriptMgr::OnGossipSelectCode(Player* player, Item* item, uint32 sender, uint32 action, const char* code) -{ - ASSERT(player); - ASSERT(item); - - 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) -{ - FOREACH_SCRIPT(PlayerScript)->OnGossipSelect(player, menu_id, sender, action); -} - -void ScriptMgr::OnGossipSelectCode(Player* player, uint32 menu_id, uint32 sender, uint32 action, const char* code) -{ - FOREACH_SCRIPT(PlayerScript)->OnGossipSelectCode(player, menu_id, sender, action, code); -} - -bool ScriptMgr::OnGossipHello(Player* player, Creature* creature) -{ - ASSERT(player); - ASSERT(creature); - - auto ret = IsValidBoolScript([&](AllCreatureScript* script) - { - return script->CanCreatureGossipHello(player, creature); - }); - - if (ret && *ret) - { - return true; - } - - GET_SCRIPT_RET(CreatureScript, creature->GetScriptId(), tmpscript, false); - ClearGossipMenuFor(player); - return tmpscript->OnGossipHello(player, creature); -} - -bool ScriptMgr::OnGossipSelect(Player* player, Creature* creature, uint32 sender, uint32 action) -{ - ASSERT(player); - ASSERT(creature); - - auto ret = IsValidBoolScript([&](AllCreatureScript* script) - { - return script->CanCreatureGossipSelect(player, creature, sender, action); - }); - - if (ret && *ret) - { - return true; - } - - GET_SCRIPT_RET(CreatureScript, creature->GetScriptId(), tmpscript, false); - return tmpscript->OnGossipSelect(player, creature, sender, action); -} - -bool ScriptMgr::OnGossipSelectCode(Player* player, Creature* creature, uint32 sender, uint32 action, const char* code) -{ - ASSERT(player); - ASSERT(creature); - ASSERT(code); - - auto ret = IsValidBoolScript([&](AllCreatureScript* script) - { - return script->CanCreatureGossipSelectCode(player, creature, sender, action, code); - }); - - if (ret && *ret) - { - return true; - } - - GET_SCRIPT_RET(CreatureScript, creature->GetScriptId(), tmpscript, false); - return tmpscript->OnGossipSelectCode(player, creature, sender, action, code); -} - -bool ScriptMgr::OnQuestAccept(Player* player, Creature* creature, Quest const* quest) -{ - ASSERT(player); - ASSERT(creature); - ASSERT(quest); - - auto ret = IsValidBoolScript([&](AllCreatureScript* script) - { - return script->CanCreatureQuestAccept(player, creature, quest); - }); - - if (ret && *ret) - { - return true; - } - - GET_SCRIPT_RET(CreatureScript, creature->GetScriptId(), tmpscript, false); - ClearGossipMenuFor(player); - return tmpscript->OnQuestAccept(player, creature, quest); -} - -bool ScriptMgr::OnQuestSelect(Player* player, Creature* creature, Quest const* quest) -{ - ASSERT(player); - ASSERT(creature); - ASSERT(quest); - - GET_SCRIPT_RET(CreatureScript, creature->GetScriptId(), tmpscript, false); - ClearGossipMenuFor(player); - return tmpscript->OnQuestSelect(player, creature, quest); -} - -bool ScriptMgr::OnQuestComplete(Player* player, Creature* creature, Quest const* quest) -{ - ASSERT(player); - ASSERT(creature); - ASSERT(quest); - - GET_SCRIPT_RET(CreatureScript, creature->GetScriptId(), tmpscript, false); - ClearGossipMenuFor(player); - return tmpscript->OnQuestComplete(player, creature, quest); -} - -bool ScriptMgr::OnQuestReward(Player* player, Creature* creature, Quest const* quest, uint32 opt) -{ - ASSERT(player); - ASSERT(creature); - ASSERT(quest); - - auto ret = IsValidBoolScript([&](AllCreatureScript* script) - { - return script->CanCreatureQuestReward(player, creature, quest, opt); - }); - - if (ret && *ret) - { - return true; - } - - GET_SCRIPT_RET(CreatureScript, creature->GetScriptId(), tmpscript, false); - ClearGossipMenuFor(player); - return tmpscript->OnQuestReward(player, creature, quest, opt); -} - -uint32 ScriptMgr::GetDialogStatus(Player* player, Creature* creature) -{ - ASSERT(player); - ASSERT(creature); - - GET_SCRIPT_RET(CreatureScript, creature->GetScriptId(), tmpscript, DIALOG_STATUS_SCRIPTED_NO_STATUS); - ClearGossipMenuFor(player); - return tmpscript->GetDialogStatus(player, creature); -} - -CreatureAI* ScriptMgr::GetCreatureAI(Creature* creature) -{ - ASSERT(creature); - - CreatureAI* ret = nullptr; - - GetReturnIndexScripts(ret, [creature](AllCreatureScript* script) - { - return script->GetCreatureAI(creature); - }); - - if (ret) - { - return ret; - } - - GET_SCRIPT_RET(CreatureScript, creature->GetScriptId(), tmpscript, nullptr); - return tmpscript->GetAI(creature); -} - -void ScriptMgr::OnCreatureUpdate(Creature* creature, uint32 diff) -{ - ASSERT(creature); - - FOREACH_SCRIPT(AllCreatureScript)->OnAllCreatureUpdate(creature, diff); - - GET_SCRIPT(CreatureScript, creature->GetScriptId(), tmpscript); - 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); - - auto ret = IsValidBoolScript([&](AllGameObjectScript* script) - { - return script->CanGameObjectGossipHello(player, go); - }); - - if (ret && *ret) - { - return true; - } - - GET_SCRIPT_RET(GameObjectScript, go->GetScriptId(), tmpscript, false); - ClearGossipMenuFor(player); - return tmpscript->OnGossipHello(player, go); -} - -bool ScriptMgr::OnGossipSelect(Player* player, GameObject* go, uint32 sender, uint32 action) -{ - ASSERT(player); - ASSERT(go); - - auto ret = IsValidBoolScript([&](AllGameObjectScript* script) - { - return script->CanGameObjectGossipSelect(player, go, sender, action); - }); - - if (ret && *ret) - { - return true; - } - - GET_SCRIPT_RET(GameObjectScript, go->GetScriptId(), tmpscript, false); - return tmpscript->OnGossipSelect(player, go, sender, action); -} - -bool ScriptMgr::OnGossipSelectCode(Player* player, GameObject* go, uint32 sender, uint32 action, const char* code) -{ - ASSERT(player); - ASSERT(go); - ASSERT(code); - - auto ret = IsValidBoolScript([&](AllGameObjectScript* script) - { - return script->CanGameObjectGossipSelectCode(player, go, sender, action, code); - }); - - if (ret && *ret) - { - return true; - } - - GET_SCRIPT_RET(GameObjectScript, go->GetScriptId(), tmpscript, false); - return tmpscript->OnGossipSelectCode(player, go, sender, action, code); -} - -bool ScriptMgr::OnQuestAccept(Player* player, GameObject* go, Quest const* quest) -{ - ASSERT(player); - ASSERT(go); - ASSERT(quest); - - auto ret = IsValidBoolScript([&](AllGameObjectScript* script) - { - return script->CanGameObjectQuestAccept(player, go, quest); - }); - - if (ret && *ret) - { - return true; - } - - GET_SCRIPT_RET(GameObjectScript, go->GetScriptId(), tmpscript, false); - ClearGossipMenuFor(player); - return tmpscript->OnQuestAccept(player, go, quest); -} - -bool ScriptMgr::OnQuestReward(Player* player, GameObject* go, Quest const* quest, uint32 opt) -{ - ASSERT(player); - ASSERT(go); - ASSERT(quest); - - auto ret = IsValidBoolScript([&](AllGameObjectScript* script) - { - return script->CanGameObjectQuestReward(player, go, quest, opt); - }); - - if (ret && *ret) - { - return true; - } - - GET_SCRIPT_RET(GameObjectScript, go->GetScriptId(), tmpscript, false); - ClearGossipMenuFor(player); - return tmpscript->OnQuestReward(player, go, quest, opt); -} - -uint32 ScriptMgr::GetDialogStatus(Player* player, GameObject* go) -{ - ASSERT(player); - ASSERT(go); - - GET_SCRIPT_RET(GameObjectScript, go->GetScriptId(), tmpscript, DIALOG_STATUS_SCRIPTED_NO_STATUS); - ClearGossipMenuFor(player); - return tmpscript->GetDialogStatus(player, go); -} - -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); -} - -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); -} - -void ScriptMgr::OnGameObjectLootStateChanged(GameObject* go, uint32 state, Unit* unit) -{ - ASSERT(go); - - FOREACH_SCRIPT(AllGameObjectScript)->OnGameObjectLootStateChanged(go, state, unit); - - GET_SCRIPT(GameObjectScript, go->GetScriptId(), tmpscript); - tmpscript->OnLootStateChanged(go, state, unit); -} - -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); -} - -void ScriptMgr::OnGameObjectUpdate(GameObject* go, uint32 diff) -{ - ASSERT(go); - - FOREACH_SCRIPT(AllGameObjectScript)->OnGameObjectUpdate(go, diff); - - GET_SCRIPT(GameObjectScript, go->GetScriptId(), tmpscript); - tmpscript->OnUpdate(go, diff); -} - -GameObjectAI* ScriptMgr::GetGameObjectAI(GameObject* go) -{ - ASSERT(go); - - GameObjectAI* ret = nullptr; - - GetReturnIndexScripts(ret, [go](AllGameObjectScript* script) - { - return script->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); - - auto ret = IsValidBoolScript([&](ElunaScript* script) - { - return script->CanAreaTrigger(player, trigger); - }); - - if (ret && *ret) - { - return false; - } - - GET_SCRIPT_RET(AreaTriggerScript, sObjectMgr->GetAreaTriggerScriptId(trigger->entry), tmpscript, false); - return tmpscript->OnTrigger(player, trigger); -} - -Battleground* ScriptMgr::CreateBattleground(BattlegroundTypeId /*typeId*/) -{ - // TODO: Implement script-side battlegrounds. - ABORT(); - return nullptr; -} - -OutdoorPvP* ScriptMgr::CreateOutdoorPvP(OutdoorPvPData const* data) -{ - ASSERT(data); - - GET_SCRIPT_RET(OutdoorPvPScript, data->ScriptId, tmpscript, nullptr); - return tmpscript->GetOutdoorPvP(); -} - -Acore::ChatCommands::ChatCommandTable ScriptMgr::GetChatCommands() -{ - Acore::ChatCommands::ChatCommandTable table; - - FOR_SCRIPTS(CommandScript, itr, end) - { - Acore::ChatCommands::ChatCommandTable cmds = itr->second->GetCommands(); - std::move(cmds.begin(), cmds.end(), std::back_inserter(table)); - } - - return table; -} - -void ScriptMgr::OnWeatherChange(Weather* weather, WeatherState state, float grade) -{ - ASSERT(weather); - - FOREACH_SCRIPT(ElunaScript)->OnWeatherChange(weather, state, grade); - - GET_SCRIPT(WeatherScript, weather->GetScriptId(), tmpscript); - tmpscript->OnChange(weather, state, grade); -} - -void ScriptMgr::OnWeatherUpdate(Weather* weather, uint32 diff) -{ - ASSERT(weather); - - GET_SCRIPT(WeatherScript, weather->GetScriptId(), tmpscript); - tmpscript->OnUpdate(weather, diff); -} - -void ScriptMgr::OnAuctionAdd(AuctionHouseObject* ah, AuctionEntry* entry) -{ - ASSERT(ah); - ASSERT(entry); - - FOREACH_SCRIPT(AuctionHouseScript)->OnAuctionAdd(ah, entry); -} - -void ScriptMgr::OnAuctionRemove(AuctionHouseObject* ah, AuctionEntry* entry) -{ - ASSERT(ah); - ASSERT(entry); - - FOREACH_SCRIPT(AuctionHouseScript)->OnAuctionRemove(ah, entry); -} - -void ScriptMgr::OnAuctionSuccessful(AuctionHouseObject* ah, AuctionEntry* entry) -{ - ASSERT(ah); - ASSERT(entry); - - FOREACH_SCRIPT(AuctionHouseScript)->OnAuctionSuccessful(ah, entry); -} - -void ScriptMgr::OnAuctionExpire(AuctionHouseObject* ah, AuctionEntry* entry) -{ - ASSERT(ah); - ASSERT(entry); - - FOREACH_SCRIPT(AuctionHouseScript)->OnAuctionExpire(ah, entry); -} - -void ScriptMgr::OnBeforeAuctionHouseMgrSendAuctionWonMail(AuctionHouseMgr* auctionHouseMgr, AuctionEntry* auction, Player* bidder, uint32& bidder_accId, bool& sendNotification, bool& updateAchievementCriteria, bool& sendMail) -{ - FOREACH_SCRIPT(AuctionHouseScript)->OnBeforeAuctionHouseMgrSendAuctionWonMail(auctionHouseMgr, auction, bidder, bidder_accId, sendNotification, updateAchievementCriteria, sendMail); -} - -void ScriptMgr::OnBeforeAuctionHouseMgrSendAuctionSalePendingMail(AuctionHouseMgr* auctionHouseMgr, AuctionEntry* auction, Player* owner, uint32& owner_accId, bool& sendMail) -{ - FOREACH_SCRIPT(AuctionHouseScript)->OnBeforeAuctionHouseMgrSendAuctionSalePendingMail(auctionHouseMgr, auction, owner, owner_accId, sendMail); -} - -void ScriptMgr::OnBeforeAuctionHouseMgrSendAuctionSuccessfulMail(AuctionHouseMgr* auctionHouseMgr, AuctionEntry* auction, Player* owner, uint32& owner_accId, uint32& profit, bool& sendNotification, bool& updateAchievementCriteria, bool& sendMail) -{ - FOREACH_SCRIPT(AuctionHouseScript)->OnBeforeAuctionHouseMgrSendAuctionSuccessfulMail(auctionHouseMgr, auction, owner, owner_accId, profit, sendNotification, updateAchievementCriteria, sendMail); -} - -void ScriptMgr::OnBeforeAuctionHouseMgrSendAuctionExpiredMail(AuctionHouseMgr* auctionHouseMgr, AuctionEntry* auction, Player* owner, uint32& owner_accId, bool& sendNotification, bool& sendMail) -{ - FOREACH_SCRIPT(AuctionHouseScript)->OnBeforeAuctionHouseMgrSendAuctionExpiredMail(auctionHouseMgr, auction, owner, owner_accId, sendNotification, sendMail); -} - -void ScriptMgr::OnBeforeAuctionHouseMgrSendAuctionOutbiddedMail(AuctionHouseMgr* auctionHouseMgr, AuctionEntry* auction, Player* oldBidder, uint32& oldBidder_accId, Player* newBidder, uint32& newPrice, bool& sendNotification, bool& sendMail) -{ - FOREACH_SCRIPT(AuctionHouseScript)->OnBeforeAuctionHouseMgrSendAuctionOutbiddedMail(auctionHouseMgr, auction, oldBidder, oldBidder_accId, newBidder, newPrice, sendNotification, sendMail); -} - -void ScriptMgr::OnBeforeAuctionHouseMgrSendAuctionCancelledToBidderMail(AuctionHouseMgr* auctionHouseMgr, AuctionEntry* auction, Player* bidder, uint32& bidder_accId, bool& sendMail) -{ - FOREACH_SCRIPT(AuctionHouseScript)->OnBeforeAuctionHouseMgrSendAuctionCancelledToBidderMail(auctionHouseMgr, auction, bidder, bidder_accId, sendMail); -} - -void ScriptMgr::OnBeforeAuctionHouseMgrUpdate() -{ - FOREACH_SCRIPT(AuctionHouseScript)->OnBeforeAuctionHouseMgrUpdate(); -} - -bool ScriptMgr::OnConditionCheck(Condition* condition, ConditionSourceInfo& sourceInfo) -{ - ASSERT(condition); - - GET_SCRIPT_RET(ConditionScript, condition->ScriptId, tmpscript, true); - return tmpscript->OnConditionCheck(condition, sourceInfo); -} - -void ScriptMgr::OnInstall(Vehicle* veh) -{ - ASSERT(veh); - ASSERT(veh->GetBase()->GetTypeId() == TYPEID_UNIT); - - GET_SCRIPT(VehicleScript, veh->GetBase()->ToCreature()->GetScriptId(), tmpscript); - tmpscript->OnInstall(veh); -} - -void ScriptMgr::OnUninstall(Vehicle* veh) -{ - ASSERT(veh); - ASSERT(veh->GetBase()->GetTypeId() == TYPEID_UNIT); - - GET_SCRIPT(VehicleScript, veh->GetBase()->ToCreature()->GetScriptId(), tmpscript); - tmpscript->OnUninstall(veh); -} - -void ScriptMgr::OnReset(Vehicle* veh) -{ - ASSERT(veh); - ASSERT(veh->GetBase()->GetTypeId() == TYPEID_UNIT); - - GET_SCRIPT(VehicleScript, veh->GetBase()->ToCreature()->GetScriptId(), tmpscript); - tmpscript->OnReset(veh); -} - -void ScriptMgr::OnInstallAccessory(Vehicle* veh, Creature* accessory) -{ - ASSERT(veh); - ASSERT(veh->GetBase()->GetTypeId() == TYPEID_UNIT); - ASSERT(accessory); - - GET_SCRIPT(VehicleScript, veh->GetBase()->ToCreature()->GetScriptId(), tmpscript); - tmpscript->OnInstallAccessory(veh, accessory); -} - -void ScriptMgr::OnAddPassenger(Vehicle* veh, Unit* passenger, int8 seatId) -{ - ASSERT(veh); - ASSERT(veh->GetBase()->GetTypeId() == TYPEID_UNIT); - ASSERT(passenger); - - GET_SCRIPT(VehicleScript, veh->GetBase()->ToCreature()->GetScriptId(), tmpscript); - tmpscript->OnAddPassenger(veh, passenger, seatId); -} - -void ScriptMgr::OnRemovePassenger(Vehicle* veh, Unit* passenger) -{ - ASSERT(veh); - ASSERT(veh->GetBase()->GetTypeId() == TYPEID_UNIT); - ASSERT(passenger); - - GET_SCRIPT(VehicleScript, veh->GetBase()->ToCreature()->GetScriptId(), tmpscript); - tmpscript->OnRemovePassenger(veh, passenger); -} - -void ScriptMgr::OnDynamicObjectUpdate(DynamicObject* dynobj, uint32 diff) -{ - ASSERT(dynobj); - - FOR_SCRIPTS(DynamicObjectScript, itr, end) - itr->second->OnUpdate(dynobj, diff); -} - -void ScriptMgr::OnAddPassenger(Transport* transport, Player* player) -{ - ASSERT(transport); - ASSERT(player); - - GET_SCRIPT(TransportScript, transport->GetScriptId(), tmpscript); - tmpscript->OnAddPassenger(transport, player); -} - -void ScriptMgr::OnAddCreaturePassenger(Transport* transport, Creature* creature) -{ - ASSERT(transport); - ASSERT(creature); - - GET_SCRIPT(TransportScript, transport->GetScriptId(), tmpscript); - tmpscript->OnAddCreaturePassenger(transport, creature); -} - -void ScriptMgr::OnRemovePassenger(Transport* transport, Player* player) -{ - ASSERT(transport); - ASSERT(player); - - GET_SCRIPT(TransportScript, transport->GetScriptId(), tmpscript); - tmpscript->OnRemovePassenger(transport, player); -} - -void ScriptMgr::OnTransportUpdate(Transport* transport, uint32 diff) -{ - ASSERT(transport); - - GET_SCRIPT(TransportScript, transport->GetScriptId(), tmpscript); - tmpscript->OnUpdate(transport, diff); -} - -void ScriptMgr::OnRelocate(Transport* transport, uint32 waypointId, uint32 mapId, float x, float y, float z) -{ - GET_SCRIPT(TransportScript, transport->GetScriptId(), tmpscript); - tmpscript->OnRelocate(transport, waypointId, mapId, x, y, z); -} - -void ScriptMgr::OnStartup() -{ - FOREACH_SCRIPT(WorldScript)->OnStartup(); -} - -void ScriptMgr::OnShutdown() -{ - 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); - // target can be nullptr. - - GET_SCRIPT_RET(AchievementCriteriaScript, scriptId, tmpscript, false); - return tmpscript->OnCheck(source, target, criteria_id); -} - -// Player -void ScriptMgr::OnPlayerCompleteQuest(Player* player, Quest const* quest) -{ - FOREACH_SCRIPT(PlayerScript)->OnPlayerCompleteQuest(player, quest); -} - -void ScriptMgr::OnSendInitialPacketsBeforeAddToMap(Player* player, WorldPacket& data) -{ - FOREACH_SCRIPT(PlayerScript)->OnSendInitialPacketsBeforeAddToMap(player, data); -} - -void ScriptMgr::OnBattlegroundDesertion(Player* player, BattlegroundDesertionType const desertionType) -{ - FOREACH_SCRIPT(PlayerScript)->OnBattlegroundDesertion(player, desertionType); -} - -void ScriptMgr::OnPlayerReleasedGhost(Player* player) -{ - FOREACH_SCRIPT(PlayerScript)->OnPlayerReleasedGhost(player); -} - -void ScriptMgr::OnPVPKill(Player* killer, Player* killed) -{ - FOREACH_SCRIPT(PlayerScript)->OnPVPKill(killer, killed); -} - -void ScriptMgr::OnPlayerPVPFlagChange(Player* player, bool state) -{ - FOREACH_SCRIPT(PlayerScript)->OnPlayerPVPFlagChange(player, state); -} - -void ScriptMgr::OnCreatureKill(Player* killer, Creature* killed) -{ - FOREACH_SCRIPT(PlayerScript)->OnCreatureKill(killer, killed); -} - -void ScriptMgr::OnCreatureKilledByPet(Player* petOwner, Creature* killed) -{ - FOREACH_SCRIPT(PlayerScript)->OnCreatureKilledByPet(petOwner, killed); -} - -void ScriptMgr::OnPlayerKilledByCreature(Creature* killer, Player* killed) -{ - FOREACH_SCRIPT(PlayerScript)->OnPlayerKilledByCreature(killer, killed); -} - -void ScriptMgr::OnPlayerLevelChanged(Player* player, uint8 oldLevel) -{ - FOREACH_SCRIPT(PlayerScript)->OnLevelChanged(player, oldLevel); -} - -void ScriptMgr::OnPlayerFreeTalentPointsChanged(Player* player, uint32 points) -{ - FOREACH_SCRIPT(PlayerScript)->OnFreeTalentPointsChanged(player, points); -} - -void ScriptMgr::OnPlayerTalentsReset(Player* player, bool noCost) -{ - FOREACH_SCRIPT(PlayerScript)->OnTalentsReset(player, noCost); -} - -void ScriptMgr::OnPlayerMoneyChanged(Player* player, int32& amount) -{ - FOREACH_SCRIPT(PlayerScript)->OnMoneyChanged(player, amount); -} - -void ScriptMgr::OnGivePlayerXP(Player* player, uint32& amount, Unit* victim) -{ - FOREACH_SCRIPT(PlayerScript)->OnGiveXP(player, amount, victim); -} - -void ScriptMgr::OnPlayerReputationChange(Player* player, uint32 factionID, int32& standing, bool incremental) -{ - FOREACH_SCRIPT(PlayerScript)->OnReputationChange(player, factionID, standing, incremental); -} - -void ScriptMgr::OnPlayerReputationRankChange(Player* player, uint32 factionID, ReputationRank newRank, ReputationRank oldRank, bool increased) -{ - FOREACH_SCRIPT(PlayerScript)->OnReputationRankChange(player, factionID, newRank, oldRank, increased); -} - -void ScriptMgr::OnPlayerLearnSpell(Player* player, uint32 spellID) -{ - FOREACH_SCRIPT(PlayerScript)->OnLearnSpell(player, spellID); -} - -void ScriptMgr::OnPlayerForgotSpell(Player* player, uint32 spellID) -{ - FOREACH_SCRIPT(PlayerScript)->OnForgotSpell(player, spellID); -} - -void ScriptMgr::OnPlayerDuelRequest(Player* target, Player* challenger) -{ - FOREACH_SCRIPT(PlayerScript)->OnDuelRequest(target, challenger); -} - -void ScriptMgr::OnPlayerDuelStart(Player* player1, Player* player2) -{ - FOREACH_SCRIPT(PlayerScript)->OnDuelStart(player1, player2); -} - -void ScriptMgr::OnPlayerDuelEnd(Player* winner, Player* loser, DuelCompleteType type) -{ - FOREACH_SCRIPT(PlayerScript)->OnDuelEnd(winner, loser, type); -} - -void ScriptMgr::OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string& msg) -{ - FOREACH_SCRIPT(PlayerScript)->OnChat(player, type, lang, msg); -} - -void ScriptMgr::OnBeforeSendChatMessage(Player* player, uint32& type, uint32& lang, std::string& msg) -{ - FOREACH_SCRIPT(PlayerScript)->OnBeforeSendChatMessage(player, type, lang, msg); -} - -void ScriptMgr::OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string& msg, Player* receiver) -{ - FOREACH_SCRIPT(PlayerScript)->OnChat(player, type, lang, msg, receiver); -} - -void ScriptMgr::OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string& msg, Group* group) -{ - FOREACH_SCRIPT(PlayerScript)->OnChat(player, type, lang, msg, group); -} - -void ScriptMgr::OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string& msg, Guild* guild) -{ - FOREACH_SCRIPT(PlayerScript)->OnChat(player, type, lang, msg, guild); -} - -void ScriptMgr::OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string& msg, Channel* channel) -{ - FOREACH_SCRIPT(PlayerScript)->OnChat(player, type, lang, msg, channel); -} - -void ScriptMgr::OnPlayerEmote(Player* player, uint32 emote) -{ - FOREACH_SCRIPT(PlayerScript)->OnEmote(player, emote); -} - -void ScriptMgr::OnPlayerTextEmote(Player* player, uint32 textEmote, uint32 emoteNum, ObjectGuid guid) -{ - FOREACH_SCRIPT(PlayerScript)->OnTextEmote(player, textEmote, emoteNum, guid); -} - -void ScriptMgr::OnPlayerSpellCast(Player* player, Spell* spell, bool skipCheck) -{ - FOREACH_SCRIPT(PlayerScript)->OnSpellCast(player, spell, skipCheck); -} - -void ScriptMgr::OnBeforePlayerUpdate(Player* player, uint32 p_time) -{ - FOREACH_SCRIPT(PlayerScript)->OnBeforeUpdate(player, p_time); -} - -void ScriptMgr::OnPlayerUpdate(Player* player, uint32 p_time) -{ - FOREACH_SCRIPT(PlayerScript)->OnUpdate(player, p_time); -} - -void ScriptMgr::OnPlayerLogin(Player* player) -{ - FOREACH_SCRIPT(PlayerScript)->OnLogin(player); -} - -void ScriptMgr::OnPlayerLoadFromDB(Player* player) -{ - FOREACH_SCRIPT(PlayerScript)->OnLoadFromDB(player); -} - -void ScriptMgr::OnPlayerLogout(Player* player) -{ - FOREACH_SCRIPT(PlayerScript)->OnLogout(player); -} - -void ScriptMgr::OnPlayerCreate(Player* player) -{ - FOREACH_SCRIPT(PlayerScript)->OnCreate(player); -} - -void ScriptMgr::OnPlayerSave(Player* player) -{ - FOREACH_SCRIPT(PlayerScript)->OnSave(player); -} - -void ScriptMgr::OnPlayerDelete(ObjectGuid guid, uint32 accountId) -{ - FOREACH_SCRIPT(PlayerScript)->OnDelete(guid, accountId); -} - -void ScriptMgr::OnPlayerFailedDelete(ObjectGuid guid, uint32 accountId) -{ - FOREACH_SCRIPT(PlayerScript)->OnFailedDelete(guid, accountId); -} - -void ScriptMgr::OnPlayerBindToInstance(Player* player, Difficulty difficulty, uint32 mapid, bool permanent) -{ - FOREACH_SCRIPT(PlayerScript)->OnBindToInstance(player, difficulty, mapid, permanent); -} - -void ScriptMgr::OnPlayerUpdateZone(Player* player, uint32 newZone, uint32 newArea) -{ - FOREACH_SCRIPT(PlayerScript)->OnUpdateZone(player, newZone, newArea); -} - -void ScriptMgr::OnPlayerUpdateArea(Player* player, uint32 oldArea, uint32 newArea) -{ - FOREACH_SCRIPT(PlayerScript)->OnUpdateArea(player, oldArea, newArea); -} - -bool ScriptMgr::OnBeforePlayerTeleport(Player* player, uint32 mapid, float x, float y, float z, float orientation, uint32 options, Unit* target) -{ - bool ret = true; - FOR_SCRIPTS_RET(PlayerScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->OnBeforeTeleport(player, mapid, x, y, z, orientation, options, target)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -void ScriptMgr::OnPlayerUpdateFaction(Player* player) -{ - FOREACH_SCRIPT(PlayerScript)->OnUpdateFaction(player); -} - -void ScriptMgr::OnPlayerAddToBattleground(Player* player, Battleground* bg) -{ - FOREACH_SCRIPT(PlayerScript)->OnAddToBattleground(player, bg); -} - -void ScriptMgr::OnPlayerQueueRandomDungeon(Player* player, uint32 & rDungeonId) -{ - FOREACH_SCRIPT(PlayerScript)->OnQueueRandomDungeon(player, rDungeonId); -} - -void ScriptMgr::OnPlayerRemoveFromBattleground(Player* player, Battleground* bg) -{ - FOREACH_SCRIPT(PlayerScript)->OnRemoveFromBattleground(player, bg); -} - -bool ScriptMgr::OnBeforeAchievementComplete(Player* player, AchievementEntry const* achievement) -{ - bool ret = true; - - FOR_SCRIPTS_RET(PlayerScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->OnBeforeAchiComplete(player, achievement)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -void ScriptMgr::OnAchievementComplete(Player* player, AchievementEntry const* achievement) -{ - FOREACH_SCRIPT(PlayerScript)->OnAchiComplete(player, achievement); -} - -bool ScriptMgr::OnBeforeCriteriaProgress(Player* player, AchievementCriteriaEntry const* criteria) -{ - bool ret = true; - - FOR_SCRIPTS_RET(PlayerScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->OnBeforeCriteriaProgress(player, criteria)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -void ScriptMgr::OnCriteriaProgress(Player* player, AchievementCriteriaEntry const* criteria) -{ - FOREACH_SCRIPT(PlayerScript)->OnCriteriaProgress(player, criteria); -} - -void ScriptMgr::OnAchievementSave(CharacterDatabaseTransaction trans, Player* player, uint16 achiId, CompletedAchievementData achiData) -{ - FOREACH_SCRIPT(PlayerScript)->OnAchiSave(trans, player, achiId, achiData); -} - -void ScriptMgr::OnCriteriaSave(CharacterDatabaseTransaction trans, Player* player, uint16 critId, CriteriaProgress criteriaData) -{ - FOREACH_SCRIPT(PlayerScript)->OnCriteriaSave(trans, player, critId, criteriaData); -} - -void ScriptMgr::OnPlayerBeingCharmed(Player* player, Unit* charmer, uint32 oldFactionId, uint32 newFactionId) -{ - FOREACH_SCRIPT(PlayerScript)->OnBeingCharmed(player, charmer, oldFactionId, newFactionId); -} - -void ScriptMgr::OnAfterPlayerSetVisibleItemSlot(Player* player, uint8 slot, Item* item) -{ - FOREACH_SCRIPT(PlayerScript)->OnAfterSetVisibleItemSlot(player, slot, item); -} - -void ScriptMgr::OnAfterPlayerMoveItemFromInventory(Player* player, Item* it, uint8 bag, uint8 slot, bool update) -{ - FOREACH_SCRIPT(PlayerScript)->OnAfterMoveItemFromInventory(player, it, bag, slot, update); -} - -void ScriptMgr::OnEquip(Player* player, Item* it, uint8 bag, uint8 slot, bool update) -{ - FOREACH_SCRIPT(PlayerScript)->OnEquip(player, it, bag, slot, update); -} - -void ScriptMgr::OnPlayerJoinBG(Player* player) -{ - FOREACH_SCRIPT(PlayerScript)->OnPlayerJoinBG(player); -} - -void ScriptMgr::OnPlayerJoinArena(Player* player) -{ - FOREACH_SCRIPT(PlayerScript)->OnPlayerJoinArena(player); -} - -void ScriptMgr::GetCustomGetArenaTeamId(const Player* player, uint8 slot, uint32& teamID) const -{ - FOREACH_SCRIPT(PlayerScript)->GetCustomGetArenaTeamId(player, slot, teamID); -} - -void ScriptMgr::GetCustomArenaPersonalRating(const Player* player, uint8 slot, uint32& rating) const -{ - FOREACH_SCRIPT(PlayerScript)->GetCustomArenaPersonalRating(player, slot, rating); -} - -void ScriptMgr::OnGetMaxPersonalArenaRatingRequirement(const Player* player, uint32 minSlot, uint32& maxArenaRating) const -{ - FOREACH_SCRIPT(PlayerScript)->OnGetMaxPersonalArenaRatingRequirement(player, minSlot, maxArenaRating); -} - -void ScriptMgr::OnLootItem(Player* player, Item* item, uint32 count, ObjectGuid lootguid) -{ - FOREACH_SCRIPT(PlayerScript)->OnLootItem(player, item, count, lootguid); -} - -void ScriptMgr::OnCreateItem(Player* player, Item* item, uint32 count) -{ - FOREACH_SCRIPT(PlayerScript)->OnCreateItem(player, item, count); -} - -void ScriptMgr::OnQuestRewardItem(Player* player, Item* item, uint32 count) -{ - FOREACH_SCRIPT(PlayerScript)->OnQuestRewardItem(player, item, count); -} - -void ScriptMgr::OnFirstLogin(Player* player) -{ - FOREACH_SCRIPT(PlayerScript)->OnFirstLogin(player); -} - -bool ScriptMgr::CanJoinInBattlegroundQueue(Player* player, ObjectGuid BattlemasterGuid, BattlegroundTypeId BGTypeID, uint8 joinAsGroup, GroupJoinBattlegroundResult& err) -{ - bool ret = true; - - FOR_SCRIPTS_RET(PlayerScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->CanJoinInBattlegroundQueue(player, BattlemasterGuid, BGTypeID, joinAsGroup, err)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -bool ScriptMgr::ShouldBeRewardedWithMoneyInsteadOfExp(Player* player) -{ - bool ret = false; // return false by default if not scripts - - FOR_SCRIPTS_RET(PlayerScript, itr, end, ret) - if (itr->second->ShouldBeRewardedWithMoneyInsteadOfExp(player)) - ret = true; // we change ret value only when a script returns true - - return ret; -} - -void ScriptMgr::OnBeforeTempSummonInitStats(Player* player, TempSummon* tempSummon, uint32& duration) -{ - FOREACH_SCRIPT(PlayerScript)->OnBeforeTempSummonInitStats(player, tempSummon, duration); -} - -void ScriptMgr::OnBeforeGuardianInitStatsForLevel(Player* player, Guardian* guardian, CreatureTemplate const* cinfo, PetType& petType) -{ - FOREACH_SCRIPT(PlayerScript)->OnBeforeGuardianInitStatsForLevel(player, guardian, cinfo, petType); -} - -void ScriptMgr::OnAfterGuardianInitStatsForLevel(Player* player, Guardian* guardian) -{ - FOREACH_SCRIPT(PlayerScript)->OnAfterGuardianInitStatsForLevel(player, guardian); -} - -void ScriptMgr::OnBeforeLoadPetFromDB(Player* player, uint32& petentry, uint32& petnumber, bool& current, bool& forceLoadFromDB) -{ - FOREACH_SCRIPT(PlayerScript)->OnBeforeLoadPetFromDB(player, petentry, petnumber, current, forceLoadFromDB); -} - -// Account -void ScriptMgr::OnAccountLogin(uint32 accountId) -{ - FOREACH_SCRIPT(AccountScript)->OnAccountLogin(accountId); -} - -void ScriptMgr::OnLastIpUpdate(uint32 accountId, std::string ip) -{ - FOREACH_SCRIPT(AccountScript)->OnLastIpUpdate(accountId, ip); -} - -void ScriptMgr::OnFailedAccountLogin(uint32 accountId) -{ - FOREACH_SCRIPT(AccountScript)->OnFailedAccountLogin(accountId); -} - -void ScriptMgr::OnEmailChange(uint32 accountId) -{ - FOREACH_SCRIPT(AccountScript)->OnEmailChange(accountId); -} - -void ScriptMgr::OnFailedEmailChange(uint32 accountId) -{ - FOREACH_SCRIPT(AccountScript)->OnFailedEmailChange(accountId); -} - -void ScriptMgr::OnPasswordChange(uint32 accountId) -{ - FOREACH_SCRIPT(AccountScript)->OnPasswordChange(accountId); -} - -void ScriptMgr::OnFailedPasswordChange(uint32 accountId) -{ - FOREACH_SCRIPT(AccountScript)->OnFailedPasswordChange(accountId); -} - -// Guild -void ScriptMgr::OnGuildAddMember(Guild* guild, Player* player, uint8& plRank) -{ - FOREACH_SCRIPT(GuildScript)->OnAddMember(guild, player, plRank); -} - -void ScriptMgr::OnGuildRemoveMember(Guild* guild, Player* player, bool isDisbanding, bool isKicked) -{ - FOREACH_SCRIPT(GuildScript)->OnRemoveMember(guild, player, isDisbanding, isKicked); -} - -void ScriptMgr::OnGuildMOTDChanged(Guild* guild, const std::string& newMotd) -{ - FOREACH_SCRIPT(GuildScript)->OnMOTDChanged(guild, newMotd); -} - -void ScriptMgr::OnGuildInfoChanged(Guild* guild, const std::string& newInfo) -{ - FOREACH_SCRIPT(GuildScript)->OnInfoChanged(guild, newInfo); -} - -void ScriptMgr::OnGuildCreate(Guild* guild, Player* leader, const std::string& name) -{ - FOREACH_SCRIPT(GuildScript)->OnCreate(guild, leader, name); -} - -void ScriptMgr::OnGuildDisband(Guild* guild) -{ - FOREACH_SCRIPT(GuildScript)->OnDisband(guild); -} - -void ScriptMgr::OnGuildMemberWitdrawMoney(Guild* guild, Player* player, uint32& amount, bool isRepair) -{ - FOREACH_SCRIPT(GuildScript)->OnMemberWitdrawMoney(guild, player, amount, isRepair); -} - -void ScriptMgr::OnGuildMemberDepositMoney(Guild* guild, Player* player, uint32& amount) -{ - 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) -{ - 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) -{ - 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) -{ - FOREACH_SCRIPT(GuildScript)->OnBankEvent(guild, eventType, tabId, playerGuid, itemOrMoney, itemStackCount, destTabId); -} - -// Group -void ScriptMgr::OnGroupAddMember(Group* group, ObjectGuid guid) -{ - ASSERT(group); - FOREACH_SCRIPT(GroupScript)->OnAddMember(group, guid); -} - -void ScriptMgr::OnGroupInviteMember(Group* group, ObjectGuid guid) -{ - ASSERT(group); - FOREACH_SCRIPT(GroupScript)->OnInviteMember(group, guid); -} - -void ScriptMgr::OnGroupRemoveMember(Group* group, ObjectGuid guid, RemoveMethod method, ObjectGuid kicker, const char* reason) -{ - ASSERT(group); - FOREACH_SCRIPT(GroupScript)->OnRemoveMember(group, guid, method, kicker, reason); -} - -void ScriptMgr::OnGroupChangeLeader(Group* group, ObjectGuid newLeaderGuid, ObjectGuid oldLeaderGuid) -{ - ASSERT(group); - FOREACH_SCRIPT(GroupScript)->OnChangeLeader(group, newLeaderGuid, oldLeaderGuid); -} - -void ScriptMgr::OnGroupDisband(Group* group) -{ - ASSERT(group); - FOREACH_SCRIPT(GroupScript)->OnDisband(group); -} - -// Global -void ScriptMgr::OnGlobalItemDelFromDB(CharacterDatabaseTransaction trans, ObjectGuid::LowType itemGuid) -{ - ASSERT(trans); - ASSERT(itemGuid); - - FOREACH_SCRIPT(GlobalScript)->OnItemDelFromDB(trans, itemGuid); -} - -void ScriptMgr::OnGlobalMirrorImageDisplayItem(const Item* item, uint32& display) -{ - FOREACH_SCRIPT(GlobalScript)->OnMirrorImageDisplayItem(item, display); -} - -void ScriptMgr::OnBeforeUpdateArenaPoints(ArenaTeam* at, std::map& ap) -{ - FOREACH_SCRIPT(GlobalScript)->OnBeforeUpdateArenaPoints(at, ap); -} - -void ScriptMgr::OnAfterRefCount(Player const* player, Loot& loot, bool canRate, uint16 lootMode, LootStoreItem* LootStoreItem, uint32& maxcount, LootStore const& store) -{ - FOREACH_SCRIPT(GlobalScript)->OnAfterRefCount(player, LootStoreItem, loot, canRate, lootMode, maxcount, store); -} - -void ScriptMgr::OnBeforeDropAddItem(Player const* player, Loot& loot, bool canRate, uint16 lootMode, LootStoreItem* LootStoreItem, LootStore const& store) -{ - FOREACH_SCRIPT(GlobalScript)->OnBeforeDropAddItem(player, loot, canRate, lootMode, LootStoreItem, store); -} - -bool ScriptMgr::OnItemRoll(Player const* player, LootStoreItem const* LootStoreItem, float& chance, Loot& loot, LootStore const& store) -{ - bool ret = true; // return true by default - - FOR_SCRIPTS_RET(GlobalScript, itr, end, ret) - if (!itr->second->OnItemRoll(player, LootStoreItem, chance, loot, store)) - ret = false; // we change ret value only when a script returns false - - return ret; -} - -bool ScriptMgr::OnBeforeLootEqualChanced(Player const* player, LootStoreItemList EqualChanced, Loot& loot, LootStore const& store) { - bool ret = true; // return true by default - - FOR_SCRIPTS_RET(GlobalScript, itr, end, ret) - if (!itr->second->OnBeforeLootEqualChanced(player, EqualChanced, loot, store)) - ret = false; // we change ret value only when a script returns false - - return ret; -} - -void ScriptMgr::OnInitializeLockedDungeons(Player* player, uint8& level, uint32& lockData, lfg::LFGDungeonData const* dungeon) -{ - FOREACH_SCRIPT(GlobalScript)->OnInitializeLockedDungeons(player, level, lockData, dungeon); -} - -void ScriptMgr::OnAfterInitializeLockedDungeons(Player* player) -{ - FOREACH_SCRIPT(GlobalScript)->OnAfterInitializeLockedDungeons(player); -} - -void ScriptMgr::OnAfterUpdateEncounterState(Map* map, EncounterCreditType type, uint32 creditEntry, Unit* source, Difficulty difficulty_fixed, DungeonEncounterList const* encounters, uint32 dungeonCompleted, bool updated) -{ - FOREACH_SCRIPT(GlobalScript)->OnAfterUpdateEncounterState(map, type, creditEntry, source, difficulty_fixed, encounters, dungeonCompleted, updated); -} - -void ScriptMgr::OnBeforeWorldObjectSetPhaseMask(WorldObject const* worldObject, uint32& oldPhaseMask, uint32& newPhaseMask, bool& useCombinedPhases, bool& update) -{ - FOREACH_SCRIPT(GlobalScript)->OnBeforeWorldObjectSetPhaseMask(worldObject, oldPhaseMask, newPhaseMask, useCombinedPhases, update); -} - -// Unit -uint32 ScriptMgr::DealDamage(Unit* AttackerUnit, Unit* pVictim, uint32 damage, DamageEffectType damagetype) -{ - FOR_SCRIPTS_RET(UnitScript, itr, end, damage) - damage = itr->second->DealDamage(AttackerUnit, pVictim, damage, damagetype); - return damage; -} -void ScriptMgr::Creature_SelectLevel(const CreatureTemplate* cinfo, Creature* creature) -{ - FOREACH_SCRIPT(AllCreatureScript)->Creature_SelectLevel(cinfo, creature); -} -void ScriptMgr::OnHeal(Unit* healer, Unit* reciever, uint32& gain) -{ - FOREACH_SCRIPT(UnitScript)->OnHeal(healer, reciever, gain); -} - -void ScriptMgr::OnDamage(Unit* attacker, Unit* victim, uint32& damage) -{ - FOREACH_SCRIPT(UnitScript)->OnDamage(attacker, victim, damage); -} - -void ScriptMgr::ModifyPeriodicDamageAurasTick(Unit* target, Unit* attacker, uint32& damage) -{ - FOREACH_SCRIPT(UnitScript)->ModifyPeriodicDamageAurasTick(target, attacker, damage); -} - -void ScriptMgr::ModifyMeleeDamage(Unit* target, Unit* attacker, uint32& damage) -{ - FOREACH_SCRIPT(UnitScript)->ModifyMeleeDamage(target, attacker, damage); -} - -void ScriptMgr::ModifySpellDamageTaken(Unit* target, Unit* attacker, int32& damage) -{ - FOREACH_SCRIPT(UnitScript)->ModifySpellDamageTaken(target, attacker, damage); -} - -void ScriptMgr::ModifyHealRecieved(Unit* target, Unit* attacker, uint32& damage) -{ - FOREACH_SCRIPT(UnitScript)->ModifyHealRecieved(target, attacker, damage); -} - -void ScriptMgr::OnBeforeRollMeleeOutcomeAgainst(const Unit* attacker, const Unit* victim, WeaponAttackType attType, int32& attackerMaxSkillValueForLevel, int32& victimMaxSkillValueForLevel, int32& attackerWeaponSkill, int32& victimDefenseSkill, int32& crit_chance, int32& miss_chance, int32& dodge_chance, int32& parry_chance, int32& block_chance) -{ - FOREACH_SCRIPT(UnitScript)->OnBeforeRollMeleeOutcomeAgainst(attacker, victim, attType, attackerMaxSkillValueForLevel, victimMaxSkillValueForLevel, attackerWeaponSkill, victimDefenseSkill, crit_chance, miss_chance, dodge_chance, parry_chance, block_chance); -} - -void ScriptMgr::OnPlayerMove(Player* player, MovementInfo movementInfo, uint32 opcode) -{ - FOREACH_SCRIPT(MovementHandlerScript)->OnPlayerMove(player, movementInfo, opcode); -} - -void ScriptMgr::OnBeforeBuyItemFromVendor(Player* player, ObjectGuid vendorguid, uint32 vendorslot, uint32& item, uint8 count, uint8 bag, uint8 slot) -{ - FOREACH_SCRIPT(PlayerScript)->OnBeforeBuyItemFromVendor(player, vendorguid, vendorslot, item, count, bag, slot); -} - -void ScriptMgr::OnAfterStoreOrEquipNewItem(Player* player, uint32 vendorslot, Item* item, uint8 count, uint8 bag, uint8 slot, ItemTemplate const* pProto, Creature* pVendor, VendorItem const* crItem, bool bStore) -{ - FOREACH_SCRIPT(PlayerScript)->OnAfterStoreOrEquipNewItem(player, vendorslot, item, count, bag, slot, pProto, pVendor, crItem, bStore); -} - -void ScriptMgr::OnAfterUpdateMaxPower(Player* player, Powers& power, float& value) -{ - FOREACH_SCRIPT(PlayerScript)->OnAfterUpdateMaxPower(player, power, value); -} - -void ScriptMgr::OnAfterUpdateMaxHealth(Player* player, float& value) -{ - FOREACH_SCRIPT(PlayerScript)->OnAfterUpdateMaxHealth(player, value); -} - -void ScriptMgr::OnBeforeUpdateAttackPowerAndDamage(Player* player, float& level, float& val2, bool ranged) -{ - FOREACH_SCRIPT(PlayerScript)->OnBeforeUpdateAttackPowerAndDamage(player, level, val2, ranged); -} - -void ScriptMgr::OnAfterUpdateAttackPowerAndDamage(Player* player, float& level, float& base_attPower, float& attPowerMod, float& attPowerMultiplier, bool ranged) -{ - FOREACH_SCRIPT(PlayerScript)->OnAfterUpdateAttackPowerAndDamage(player, level, base_attPower, attPowerMod, attPowerMultiplier, ranged); -} - -void ScriptMgr::OnBeforeInitTalentForLevel(Player* player, uint8& level, uint32& talentPointsForLevel) -{ - FOREACH_SCRIPT(PlayerScript)->OnBeforeInitTalentForLevel(player, level, talentPointsForLevel); -} - -void ScriptMgr::OnAfterArenaRatingCalculation(Battleground* const bg, int32& winnerMatchmakerChange, int32& loserMatchmakerChange, int32& winnerChange, int32& loserChange) -{ - FOREACH_SCRIPT(FormulaScript)->OnAfterArenaRatingCalculation(bg, winnerMatchmakerChange, loserMatchmakerChange, winnerChange, loserChange); -} - -// BGScript -void ScriptMgr::OnBattlegroundStart(Battleground* bg) -{ - FOREACH_SCRIPT(BGScript)->OnBattlegroundStart(bg); -} - -void ScriptMgr::OnBattlegroundEndReward(Battleground* bg, Player* player, TeamId winnerTeamId) -{ - FOREACH_SCRIPT(BGScript)->OnBattlegroundEndReward(bg, player, winnerTeamId); -} - -void ScriptMgr::OnBattlegroundUpdate(Battleground* bg, uint32 diff) -{ - FOREACH_SCRIPT(BGScript)->OnBattlegroundUpdate(bg, diff); -} - -void ScriptMgr::OnBattlegroundAddPlayer(Battleground* bg, Player* player) -{ - FOREACH_SCRIPT(BGScript)->OnBattlegroundAddPlayer(bg, player); -} - -void ScriptMgr::OnBattlegroundBeforeAddPlayer(Battleground* bg, Player* player) -{ - FOREACH_SCRIPT(BGScript)->OnBattlegroundBeforeAddPlayer(bg, player); -} - -void ScriptMgr::OnBattlegroundRemovePlayerAtLeave(Battleground* bg, Player* player) -{ - FOREACH_SCRIPT(BGScript)->OnBattlegroundRemovePlayerAtLeave(bg, player); -} - -void ScriptMgr::OnAddGroup(BattlegroundQueue* queue, GroupQueueInfo* ginfo, uint32& index, Player* leader, Group* grp, PvPDifficultyEntry const* bracketEntry, bool isPremade) -{ - FOREACH_SCRIPT(BGScript)->OnAddGroup(queue, ginfo, index, leader, grp, bracketEntry, isPremade); -} - -bool ScriptMgr::CanFillPlayersToBG(BattlegroundQueue* queue, Battleground* bg, const int32 aliFree, const int32 hordeFree, BattlegroundBracketId bracket_id) -{ - bool ret = true; - - FOR_SCRIPTS_RET(BGScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->CanFillPlayersToBG(queue, bg, aliFree, hordeFree, bracket_id)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -bool ScriptMgr::CanFillPlayersToBGWithSpecific(BattlegroundQueue* queue, Battleground* bg, const int32 aliFree, const int32 hordeFree, - BattlegroundBracketId thisBracketId, BattlegroundQueue* specificQueue, BattlegroundBracketId specificBracketId) -{ - bool ret = true; - - FOR_SCRIPTS_RET(BGScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->CanFillPlayersToBGWithSpecific(queue, bg, aliFree, hordeFree, thisBracketId, specificQueue, specificBracketId)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -void ScriptMgr::OnCheckNormalMatch(BattlegroundQueue* queue, uint32& Coef, Battleground* bgTemplate, BattlegroundBracketId bracket_id, uint32& minPlayers, uint32& maxPlayers) -{ - FOREACH_SCRIPT(BGScript)->OnCheckNormalMatch(queue, Coef, bgTemplate, bracket_id, minPlayers, maxPlayers); -} - -void ScriptMgr::OnGetSlotByType(const uint32 type, uint8& slot) -{ - FOREACH_SCRIPT(ArenaTeamScript)->OnGetSlotByType(type, slot); -} - -void ScriptMgr::OnGetArenaPoints(ArenaTeam* at, float& points) -{ - FOREACH_SCRIPT(ArenaTeamScript)->OnGetArenaPoints(at, points); -} - -void ScriptMgr::OnArenaTypeIDToQueueID(const BattlegroundTypeId bgTypeId, const uint8 arenaType, uint32& queueTypeID) -{ - FOREACH_SCRIPT(ArenaTeamScript)->OnTypeIDToQueueID(bgTypeId, arenaType, queueTypeID); -} - -void ScriptMgr::OnArenaQueueIdToArenaType(const BattlegroundQueueTypeId bgQueueTypeId, uint8& ArenaType) -{ - FOREACH_SCRIPT(ArenaTeamScript)->OnQueueIdToArenaType(bgQueueTypeId, ArenaType); -} - -void ScriptMgr::OnSetArenaMaxPlayersPerTeam(const uint8 arenaType, uint32& maxPlayerPerTeam) -{ - FOREACH_SCRIPT(ArenaTeamScript)->OnSetArenaMaxPlayersPerTeam(arenaType, maxPlayerPerTeam); -} - -// SpellSC -void ScriptMgr::OnCalcMaxDuration(Aura const* aura, int32& maxDuration) -{ - FOREACH_SCRIPT(SpellSC)->OnCalcMaxDuration(aura, maxDuration); -} - -void ScriptMgr::OnGameEventStart(uint16 EventID) -{ - FOREACH_SCRIPT(GameEventScript)->OnStart(EventID); -} - -void ScriptMgr::OnGameEventStop(uint16 EventID) -{ - FOREACH_SCRIPT(GameEventScript)->OnStop(EventID); -} - -// Mail -void ScriptMgr::OnBeforeMailDraftSendMailTo(MailDraft* mailDraft, MailReceiver const& receiver, MailSender const& sender, MailCheckMask& checked, uint32& deliver_delay, uint32& custom_expiration, bool& deleteMailItemsFromDB, bool& sendMail) -{ - FOREACH_SCRIPT(MailScript)->OnBeforeMailDraftSendMailTo(mailDraft, receiver, sender, checked, deliver_delay, custom_expiration, deleteMailItemsFromDB, sendMail); -} - -void ScriptMgr::OnBeforeUpdatingPersonalRating(int32& mod, uint32 type) -{ - FOREACH_SCRIPT(FormulaScript)->OnBeforeUpdatingPersonalRating(mod, type); -} - -bool ScriptMgr::OnBeforePlayerQuestComplete(Player* player, uint32 quest_id) -{ - bool ret=true; - FOR_SCRIPTS_RET(PlayerScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->OnBeforeQuestComplete(player, quest_id)) - ret=false; // we change ret value only when scripts return false - - return ret; -} - -void ScriptMgr::OnBeforeStoreOrEquipNewItem(Player* player, uint32 vendorslot, uint32& item, uint8 count, uint8 bag, uint8 slot, ItemTemplate const* pProto, Creature* pVendor, VendorItem const* crItem, bool bStore) -{ - FOREACH_SCRIPT(PlayerScript)->OnBeforeStoreOrEquipNewItem(player, vendorslot, item, count, bag, slot, pProto, pVendor, crItem, bStore); -} - -bool ScriptMgr::CanJoinInArenaQueue(Player* player, ObjectGuid BattlemasterGuid, uint8 arenaslot, BattlegroundTypeId BGTypeID, uint8 joinAsGroup, uint8 IsRated, GroupJoinBattlegroundResult& err) -{ - bool ret = true; - - FOR_SCRIPTS_RET(PlayerScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->CanJoinInArenaQueue(player, BattlemasterGuid, arenaslot, BGTypeID, joinAsGroup, IsRated, err)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -bool ScriptMgr::CanBattleFieldPort(Player* player, uint8 arenaType, BattlegroundTypeId BGTypeID, uint8 action) -{ - bool ret = true; - - FOR_SCRIPTS_RET(PlayerScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->CanBattleFieldPort(player, arenaType, BGTypeID, action)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -bool ScriptMgr::CanGroupInvite(Player* player, std::string& membername) -{ - bool ret = true; - - FOR_SCRIPTS_RET(PlayerScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->CanGroupInvite(player, membername)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -bool ScriptMgr::CanGroupAccept(Player* player, Group* group) -{ - bool ret = true; - - FOR_SCRIPTS_RET(PlayerScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->CanGroupAccept(player, group)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -bool ScriptMgr::CanSellItem(Player* player, Item* item, Creature* creature) -{ - bool ret = true; - - FOR_SCRIPTS_RET(PlayerScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->CanSellItem(player, item, creature)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -bool ScriptMgr::CanSendMail(Player* player, ObjectGuid receiverGuid, ObjectGuid mailbox, std::string& subject, std::string& body, uint32 money, uint32 COD, Item* item) -{ - bool ret = true; - - FOR_SCRIPTS_RET(PlayerScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->CanSendMail(player, receiverGuid, mailbox, subject, body, money, COD, item)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -void ScriptMgr::PetitionBuy(Player* player, Creature* creature, uint32& charterid, uint32& cost, uint32& type) -{ - FOREACH_SCRIPT(PlayerScript)->PetitionBuy(player, creature, charterid, cost, type); -} - -void ScriptMgr::PetitionShowList(Player* player, Creature* creature, uint32& CharterEntry, uint32& CharterDispayID, uint32& CharterCost) -{ - FOREACH_SCRIPT(PlayerScript)->PetitionShowList(player, creature, CharterEntry, CharterDispayID, CharterCost); -} - -void ScriptMgr::OnRewardKillRewarder(Player* player, bool isDungeon, float& rate) -{ - FOREACH_SCRIPT(PlayerScript)->OnRewardKillRewarder(player, isDungeon, rate); -} - -bool ScriptMgr::CanGiveMailRewardAtGiveLevel(Player* player, uint8 level) -{ - bool ret = true; - - FOR_SCRIPTS_RET(PlayerScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->CanGiveMailRewardAtGiveLevel(player, level)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -void ScriptMgr::OnDeleteFromDB(CharacterDatabaseTransaction trans, uint32 guid) -{ - FOREACH_SCRIPT(PlayerScript)->OnDeleteFromDB(trans, guid); -} - -bool ScriptMgr::CanRepopAtGraveyard(Player* player) -{ - bool ret = true; - - FOR_SCRIPTS_RET(PlayerScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->CanRepopAtGraveyard(player)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -void ScriptMgr::OnGetMaxSkillValue(Player* player, uint32 skill, int32& result, bool IsPure) -{ - FOREACH_SCRIPT(PlayerScript)->OnGetMaxSkillValue(player, skill, result, IsPure); -} - -bool ScriptMgr::CanAreaExploreAndOutdoor(Player* player) -{ - bool ret = true; - - FOR_SCRIPTS_RET(PlayerScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->CanAreaExploreAndOutdoor(player)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -void ScriptMgr::OnVictimRewardBefore(Player* player, Player* victim, uint32& killer_title, uint32& victim_title) -{ - FOREACH_SCRIPT(PlayerScript)->OnVictimRewardBefore(player, victim, killer_title, victim_title); -} - -void ScriptMgr::OnVictimRewardAfter(Player* player, Player* victim, uint32& killer_title, uint32& victim_rank, float& honor_f) -{ - FOREACH_SCRIPT(PlayerScript)->OnVictimRewardAfter(player, victim, killer_title, victim_rank, honor_f); -} - -void ScriptMgr::OnCustomScalingStatValueBefore(Player* player, ItemTemplate const* proto, uint8 slot, bool apply, uint32& CustomScalingStatValue) -{ - FOREACH_SCRIPT(PlayerScript)->OnCustomScalingStatValueBefore(player, proto, slot, apply, CustomScalingStatValue); -} - -void ScriptMgr::OnCustomScalingStatValue(Player* player, ItemTemplate const* proto, uint32& statType, int32& val, uint8 itemProtoStatNumber, uint32 ScalingStatValue, ScalingStatValuesEntry const* ssv) -{ - FOREACH_SCRIPT(PlayerScript)->OnCustomScalingStatValue(player, proto, statType, val, itemProtoStatNumber, ScalingStatValue, ssv); -} - -bool ScriptMgr::CanArmorDamageModifier(Player* player) -{ - bool ret = true; - - FOR_SCRIPTS_RET(PlayerScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->CanArmorDamageModifier(player)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -void ScriptMgr::OnGetFeralApBonus(Player* player, int32& feral_bonus, int32 dpsMod, ItemTemplate const* proto, ScalingStatValuesEntry const* ssv) -{ - FOREACH_SCRIPT(PlayerScript)->OnGetFeralApBonus(player, feral_bonus, dpsMod, proto, ssv); -} - -bool ScriptMgr::CanApplyWeaponDependentAuraDamageMod(Player* player, Item* item, WeaponAttackType attackType, AuraEffect const* aura, bool apply) -{ - bool ret = true; - - FOR_SCRIPTS_RET(PlayerScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->CanApplyWeaponDependentAuraDamageMod(player, item, attackType, aura, apply)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -bool ScriptMgr::CanApplyEquipSpell(Player* player, SpellInfo const* spellInfo, Item* item, bool apply, bool form_change) -{ - bool ret = true; - - FOR_SCRIPTS_RET(PlayerScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->CanApplyEquipSpell(player, spellInfo, item, apply, form_change)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -bool ScriptMgr::CanApplyEquipSpellsItemSet(Player* player, ItemSetEffect* eff) -{ - bool ret = true; - - FOR_SCRIPTS_RET(PlayerScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->CanApplyEquipSpellsItemSet(player, eff)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -bool ScriptMgr::CanCastItemCombatSpell(Player* player, Unit* target, WeaponAttackType attType, uint32 procVictim, uint32 procEx, Item* item, ItemTemplate const* proto) -{ - bool ret = true; - - FOR_SCRIPTS_RET(PlayerScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->CanCastItemCombatSpell(player, target, attType, procVictim, procEx, item, proto)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -bool ScriptMgr::CanCastItemUseSpell(Player* player, Item* item, SpellCastTargets const& targets, uint8 cast_count, uint32 glyphIndex) -{ - bool ret = true; - - FOR_SCRIPTS_RET(PlayerScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->CanCastItemUseSpell(player, item, targets, cast_count, glyphIndex)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -void ScriptMgr::OnApplyAmmoBonuses(Player* player, ItemTemplate const* proto, float& currentAmmoDPS) -{ - FOREACH_SCRIPT(PlayerScript)->OnApplyAmmoBonuses(player, proto, currentAmmoDPS); -} - -bool ScriptMgr::CanEquipItem(Player* player, uint8 slot, uint16& dest, Item* pItem, bool swap, bool not_loading) -{ - bool ret = true; - - FOR_SCRIPTS_RET(PlayerScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->CanEquipItem(player, slot, dest, pItem, swap, not_loading)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -bool ScriptMgr::CanUnequipItem(Player* player, uint16 pos, bool swap) -{ - bool ret = true; - - FOR_SCRIPTS_RET(PlayerScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->CanUnequipItem(player, pos, swap)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -bool ScriptMgr::CanUseItem(Player* player, ItemTemplate const* proto, InventoryResult& result) -{ - bool ret = true; - - FOR_SCRIPTS_RET(PlayerScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->CanUseItem(player, proto, result)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -bool ScriptMgr::CanSaveEquipNewItem(Player* player, Item* item, uint16 pos, bool update) -{ - bool ret = true; - - FOR_SCRIPTS_RET(PlayerScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->CanSaveEquipNewItem(player, item, pos, update)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -bool ScriptMgr::CanApplyEnchantment(Player* player, Item* item, EnchantmentSlot slot, bool apply, bool apply_dur, bool ignore_condition) -{ - bool ret = true; - - FOR_SCRIPTS_RET(PlayerScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->CanApplyEnchantment(player, item, slot, apply, apply_dur, ignore_condition)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -void ScriptMgr::OnGetQuestRate(Player* player, float& result) -{ - FOREACH_SCRIPT(PlayerScript)->OnGetQuestRate(player, result); -} - -bool ScriptMgr::PassedQuestKilledMonsterCredit(Player* player, Quest const* qinfo, uint32 entry, uint32 real_entry, ObjectGuid guid) -{ - bool ret = true; - - FOR_SCRIPTS_RET(PlayerScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->PassedQuestKilledMonsterCredit(player, qinfo, entry, real_entry, guid)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -bool ScriptMgr::CheckItemInSlotAtLoadInventory(Player* player, Item* item, uint8 slot, uint8& err, uint16& dest) -{ - bool ret = true; - - FOR_SCRIPTS_RET(PlayerScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->CheckItemInSlotAtLoadInventory(player, item, slot, err, dest)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -bool ScriptMgr::NotAvoidSatisfy(Player* player, DungeonProgressionRequirements const* ar, uint32 target_map, bool report) -{ - bool ret = true; - - FOR_SCRIPTS_RET(PlayerScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->NotAvoidSatisfy(player, ar, target_map, report)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -bool ScriptMgr::NotVisibleGloballyFor(Player* player, Player const* u) -{ - bool ret = true; - - FOR_SCRIPTS_RET(PlayerScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->NotVisibleGloballyFor(player, u)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -void ScriptMgr::OnGetArenaPersonalRating(Player* player, uint8 slot, uint32& result) -{ - FOREACH_SCRIPT(PlayerScript)->OnGetArenaPersonalRating(player, slot, result); -} - -void ScriptMgr::OnGetArenaTeamId(Player* player, uint8 slot, uint32& result) -{ - FOREACH_SCRIPT(PlayerScript)->OnGetArenaTeamId(player, slot, result); -} - -void ScriptMgr::OnIsFFAPvP(Player* player, bool& result) -{ - FOREACH_SCRIPT(PlayerScript)->OnIsFFAPvP(player, result); -} - -void ScriptMgr::OnIsPvP(Player* player, bool& result) -{ - FOREACH_SCRIPT(PlayerScript)->OnIsPvP(player, result); -} - -void ScriptMgr::OnGetMaxSkillValueForLevel(Player* player, uint16& result) -{ - FOREACH_SCRIPT(PlayerScript)->OnGetMaxSkillValueForLevel(player, result); -} - -bool ScriptMgr::NotSetArenaTeamInfoField(Player* player, uint8 slot, ArenaTeamInfoType type, uint32 value) -{ - bool ret = true; - - FOR_SCRIPTS_RET(PlayerScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->NotSetArenaTeamInfoField(player, slot, type, value)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -bool ScriptMgr::CanJoinLfg(Player* player, uint8 roles, lfg::LfgDungeonSet& dungeons, const std::string& comment) -{ - bool ret = true; - - FOR_SCRIPTS_RET(PlayerScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->CanJoinLfg(player, roles, dungeons, comment)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -bool ScriptMgr::CanEnterMap(Player* player, MapEntry const* entry, InstanceTemplate const* instance, MapDifficulty const* mapDiff, bool loginCheck) -{ - bool ret = true; - - FOR_SCRIPTS_RET(PlayerScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->CanEnterMap(player, entry, instance, mapDiff, loginCheck)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -bool ScriptMgr::CanInitTrade(Player* player, Player* target) -{ - bool ret = true; - - FOR_SCRIPTS_RET(PlayerScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->CanInitTrade(player, target)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -void ScriptMgr::OnSetServerSideVisibility(Player* player, ServerSideVisibilityType& type, AccountTypes& sec) -{ - FOREACH_SCRIPT(PlayerScript)->OnSetServerSideVisibility(player, type, sec); -} - -void ScriptMgr::OnSetServerSideVisibilityDetect(Player* player, ServerSideVisibilityType& type, AccountTypes& sec) -{ - 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); -} - -void ScriptMgr::AnticheatSetCanFlybyServer(Player* player, bool apply) -{ - FOREACH_SCRIPT(PlayerScript)->AnticheatSetCanFlybyServer(player, apply); -} - -void ScriptMgr::AnticheatSetUnderACKmount(Player* player) -{ - FOREACH_SCRIPT(PlayerScript)->AnticheatSetUnderACKmount(player); -} - -void ScriptMgr::AnticheatSetRootACKUpd(Player* player) -{ - FOREACH_SCRIPT(PlayerScript)->AnticheatSetRootACKUpd(player); -} - -void ScriptMgr::AnticheatSetJumpingbyOpcode(Player* player, bool jump) -{ - FOREACH_SCRIPT(PlayerScript)->AnticheatSetJumpingbyOpcode(player, jump); -} - -void ScriptMgr::AnticheatUpdateMovementInfo(Player* player, MovementInfo const& movementInfo) -{ - FOREACH_SCRIPT(PlayerScript)->AnticheatUpdateMovementInfo(player, movementInfo); -} - -bool ScriptMgr::AnticheatHandleDoubleJump(Player* player, Unit* mover) -{ - bool ret = true; - - FOR_SCRIPTS_RET(PlayerScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->AnticheatHandleDoubleJump(player, mover)) - ret = false; // we change ret value only when scripts return true - - return ret; -} - -bool ScriptMgr::AnticheatCheckMovementInfo(Player* player, MovementInfo const& movementInfo, Unit* mover, bool jump) -{ - bool ret = true; - - FOR_SCRIPTS_RET(PlayerScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->AnticheatCheckMovementInfo(player, movementInfo, mover, jump)) - ret = false; // we change ret value only when scripts return true - - return ret; -} - -bool ScriptMgr::CanGuildSendBankList(Guild const* guild, WorldSession* session, uint8 tabId, bool sendAllSlots) -{ - bool ret = true; - - FOR_SCRIPTS_RET(GuildScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->CanGuildSendBankList(guild, session, tabId, sendAllSlots)) - ret = false; // we change ret value only when scripts return true - - return ret; -} - -bool ScriptMgr::CanGroupJoinBattlegroundQueue(Group const* group, Player* member, Battleground const* bgTemplate, uint32 MinPlayerCount, bool isRated, uint32 arenaSlot) -{ - bool ret = true; - - FOR_SCRIPTS_RET(GroupScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->CanGroupJoinBattlegroundQueue(group, member, bgTemplate, MinPlayerCount, isRated, arenaSlot)) - ret = false; // we change ret value only when scripts return true - - return ret; -} - -void ScriptMgr::OnCreate(Group* group, Player* leader) -{ - FOREACH_SCRIPT(GroupScript)->OnCreate(group, leader); -} - -void ScriptMgr::OnAuraRemove(Unit* unit, AuraApplication* aurApp, AuraRemoveMode mode) -{ - FOREACH_SCRIPT(UnitScript)->OnAuraRemove(unit, aurApp, mode); -} - -bool ScriptMgr::IfNormalReaction(Unit const* unit, Unit const* target, ReputationRank& repRank) -{ - bool ret = true; - - FOR_SCRIPTS_RET(UnitScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->IfNormalReaction(unit, target, repRank)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -bool ScriptMgr::IsNeedModSpellDamagePercent(Unit const* unit, AuraEffect* auraEff, float& doneTotalMod, SpellInfo const* spellProto) -{ - bool ret = true; - - FOR_SCRIPTS_RET(UnitScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->IsNeedModSpellDamagePercent(unit, auraEff, doneTotalMod, spellProto)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -bool ScriptMgr::IsNeedModMeleeDamagePercent(Unit const* unit, AuraEffect* auraEff, float& doneTotalMod, SpellInfo const* spellProto) -{ - bool ret = true; - - FOR_SCRIPTS_RET(UnitScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->IsNeedModMeleeDamagePercent(unit, auraEff, doneTotalMod, spellProto)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -bool ScriptMgr::IsNeedModHealPercent(Unit const* unit, AuraEffect* auraEff, float& doneTotalMod, SpellInfo const* spellProto) -{ - bool ret = true; - - FOR_SCRIPTS_RET(UnitScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->IsNeedModHealPercent(unit, auraEff, doneTotalMod, spellProto)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -bool ScriptMgr::CanSetPhaseMask(Unit const* unit, uint32 newPhaseMask, bool update) -{ - bool ret = true; - - FOR_SCRIPTS_RET(UnitScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->CanSetPhaseMask(unit, newPhaseMask, update)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -bool ScriptMgr::IsCustomBuildValuesUpdate(Unit const* unit, uint8 updateType, ByteBuffer& fieldBuffer, Player const* target, uint16 index) -{ - bool ret = false; - - FOR_SCRIPTS_RET(UnitScript, itr, end, ret) // return true by default if not scripts - if (itr->second->IsCustomBuildValuesUpdate(unit, updateType, fieldBuffer, target, index)) - ret = true; // we change ret value only when scripts return true - - 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); -} - -bool ScriptMgr::CanSendMessageBGQueue(BattlegroundQueue* queue, Player* leader, Battleground* bg, PvPDifficultyEntry const* bracketEntry) -{ - bool ret = true; - - FOR_SCRIPTS_RET(BGScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->CanSendMessageBGQueue(queue, leader, bg, bracketEntry)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -bool ScriptMgr::OnBeforeSendJoinMessageArenaQueue(BattlegroundQueue* queue, Player* leader, GroupQueueInfo* ginfo, PvPDifficultyEntry const* bracketEntry, bool isRated) -{ - bool ret = true; - - FOR_SCRIPTS_RET(BGScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->OnBeforeSendJoinMessageArenaQueue(queue, leader, ginfo, bracketEntry, isRated)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -bool ScriptMgr::OnBeforeSendExitMessageArenaQueue(BattlegroundQueue* queue, GroupQueueInfo* ginfo) -{ - bool ret = true; - - FOR_SCRIPTS_RET(BGScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->OnBeforeSendExitMessageArenaQueue(queue, ginfo)) - ret = false; // we change ret value only when scripts return false - - 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; - - FOR_SCRIPTS_RET(SpellSC, itr, end, ret) // return true by default if not scripts - if (!itr->second->CanModAuraEffectDamageDone(auraEff, target, aurApp, mode, apply)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -bool ScriptMgr::CanModAuraEffectModDamagePercentDone(AuraEffect const* auraEff, Unit* target, AuraApplication const* aurApp, uint8 mode, bool apply) -{ - bool ret = true; - - FOR_SCRIPTS_RET(SpellSC, itr, end, ret) // return true by default if not scripts - if (!itr->second->CanModAuraEffectModDamagePercentDone(auraEff, target, aurApp, mode, apply)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -void ScriptMgr::OnSpellCheckCast(Spell* spell, bool strict, SpellCastResult& res) -{ - FOREACH_SCRIPT(SpellSC)->OnSpellCheckCast(spell, strict, res); -} - -bool ScriptMgr::CanPrepare(Spell* spell, SpellCastTargets const* targets, AuraEffect const* triggeredByAura) -{ - bool ret = true; - - FOR_SCRIPTS_RET(SpellSC, itr, end, ret) // return true by default if not scripts - if (!itr->second->CanPrepare(spell, targets, triggeredByAura)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -bool ScriptMgr::CanScalingEverything(Spell* spell) -{ - bool ret = false; - - FOR_SCRIPTS_RET(SpellSC, itr, end, ret) // return true by default if not scripts - if (itr->second->CanScalingEverything(spell)) - ret = true; // we change ret value only when scripts return false - - return ret; -} - -bool ScriptMgr::CanSelectSpecTalent(Spell* spell) -{ - bool ret = true; - - FOR_SCRIPTS_RET(SpellSC, itr, end, ret) // return true by default if not scripts - if (!itr->second->CanSelectSpecTalent(spell)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -void ScriptMgr::OnScaleAuraUnitAdd(Spell* spell, Unit* target, uint32 effectMask, bool checkIfValid, bool implicit, uint8 auraScaleMask, TargetInfo& targetInfo) -{ - FOREACH_SCRIPT(SpellSC)->OnScaleAuraUnitAdd(spell, target, effectMask, checkIfValid, implicit, auraScaleMask, targetInfo); -} - -void ScriptMgr::OnRemoveAuraScaleTargets(Spell* spell, TargetInfo& targetInfo, uint8 auraScaleMask, bool& needErase) -{ - FOREACH_SCRIPT(SpellSC)->OnRemoveAuraScaleTargets(spell, targetInfo, auraScaleMask, needErase); -} - -void ScriptMgr::OnBeforeAuraRankForLevel(SpellInfo const* spellInfo, SpellInfo const* latestSpellInfo, uint8 level) -{ - 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); -} - -bool ScriptMgr::IsCompletedCriteria(AchievementMgr* mgr, AchievementCriteriaEntry const* achievementCriteria, AchievementEntry const* achievement, CriteriaProgress const* progress) -{ - bool ret = true; - - FOR_SCRIPTS_RET(AchievementScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->IsCompletedCriteria(mgr, achievementCriteria, achievement, progress)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -bool ScriptMgr::IsRealmCompleted(AchievementGlobalMgr const* globalmgr, AchievementEntry const* achievement, std::chrono::system_clock::time_point completionTime) -{ - bool ret = true; - - FOR_SCRIPTS_RET(AchievementScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->IsRealmCompleted(globalmgr, achievement, completionTime)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -void ScriptMgr::OnBeforeCheckCriteria(AchievementMgr* mgr, AchievementCriteriaEntryList const* achievementCriteriaList) -{ - FOREACH_SCRIPT(AchievementScript)->OnBeforeCheckCriteria(mgr, achievementCriteriaList); -} - -bool ScriptMgr::CanCheckCriteria(AchievementMgr* mgr, AchievementCriteriaEntry const* achievementCriteria) -{ - bool ret = true; - - FOR_SCRIPTS_RET(AchievementScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->CanCheckCriteria(mgr, achievementCriteria)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -void ScriptMgr::OnInitStatsForLevel(Guardian* guardian, uint8 petlevel) -{ - FOREACH_SCRIPT(PetScript)->OnInitStatsForLevel(guardian, petlevel); -} - -void ScriptMgr::OnCalculateMaxTalentPointsForLevel(Pet* pet, uint8 level, uint8& points) -{ - FOREACH_SCRIPT(PetScript)->OnCalculateMaxTalentPointsForLevel(pet, level, points); -} - -bool ScriptMgr::CanUnlearnSpellSet(Pet* pet, uint32 level, uint32 spell) -{ - bool ret = true; - - FOR_SCRIPTS_RET(PetScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->CanUnlearnSpellSet(pet, level, spell)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -bool ScriptMgr::CanUnlearnSpellDefault(Pet* pet, SpellInfo const* spellEntry) -{ - bool ret = true; - - FOR_SCRIPTS_RET(PetScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->CanUnlearnSpellDefault(pet, spellEntry)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -bool ScriptMgr::CanResetTalents(Pet* pet) -{ - bool ret = true; - - FOR_SCRIPTS_RET(PetScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->CanResetTalents(pet)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -bool ScriptMgr::CanAddMember(ArenaTeam* team, ObjectGuid PlayerGuid) -{ - bool ret = true; - - FOR_SCRIPTS_RET(ArenaScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->CanAddMember(team, PlayerGuid)) - ret = false; // we change ret value only when scripts return true - - return ret; -} - -void ScriptMgr::OnGetPoints(ArenaTeam* team, uint32 memberRating, float& points) -{ - FOREACH_SCRIPT(ArenaScript)->OnGetPoints(team, memberRating, points); -} - -bool ScriptMgr::CanSaveToDB(ArenaTeam* team) -{ - bool ret = true; - - FOR_SCRIPTS_RET(ArenaScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->CanSaveToDB(team)) - ret = false; // we change ret value only when scripts return true - - return ret; -} - -void ScriptMgr::OnItemCreate(Item* item, ItemTemplate const* itemProto, Player const* owner) -{ - FOREACH_SCRIPT(MiscScript)->OnItemCreate(item, itemProto, owner); -} - -bool ScriptMgr::CanApplySoulboundFlag(Item* item, ItemTemplate const* proto) -{ - bool ret = true; - - FOR_SCRIPTS_RET(MiscScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->CanApplySoulboundFlag(item, proto)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -void ScriptMgr::OnConstructObject(Object* origin) -{ - FOREACH_SCRIPT(MiscScript)->OnConstructObject(origin); -} - -void ScriptMgr::OnDestructObject(Object* origin) -{ - FOREACH_SCRIPT(MiscScript)->OnDestructObject(origin); -} - -void ScriptMgr::OnConstructPlayer(Player* origin) -{ - FOREACH_SCRIPT(MiscScript)->OnConstructPlayer(origin); -} - -void ScriptMgr::OnDestructPlayer(Player* origin) -{ - FOREACH_SCRIPT(MiscScript)->OnDestructPlayer(origin); -} - -void ScriptMgr::OnConstructGroup(Group* origin) -{ - FOREACH_SCRIPT(MiscScript)->OnConstructGroup(origin); -} - -void ScriptMgr::OnDestructGroup(Group* origin) -{ - FOREACH_SCRIPT(MiscScript)->OnDestructGroup(origin); -} - -void ScriptMgr::OnConstructInstanceSave(InstanceSave* origin) -{ - FOREACH_SCRIPT(MiscScript)->OnConstructInstanceSave(origin); -} - -void ScriptMgr::OnDestructInstanceSave(InstanceSave* origin) -{ - FOREACH_SCRIPT(MiscScript)->OnDestructInstanceSave(origin); -} - -bool ScriptMgr::CanItemApplyEquipSpell(Player* player, Item* item) -{ - bool ret = true; - - FOR_SCRIPTS_RET(MiscScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->CanItemApplyEquipSpell(player, item)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -bool ScriptMgr::CanSendAuctionHello(WorldSession const* session, ObjectGuid guid, Creature* creature) -{ - bool ret = true; - - FOR_SCRIPTS_RET(MiscScript, itr, end, ret) // return true by default if not scripts - if (!itr->second->CanSendAuctionHello(session, guid, creature)) - ret = false; // we change ret value only when scripts return false - - return ret; -} - -void ScriptMgr::ValidateSpellAtCastSpell(Player* player, uint32& oldSpellId, uint32& spellId, uint8& castCount, uint8& castFlags) -{ - FOREACH_SCRIPT(MiscScript)->ValidateSpellAtCastSpell(player, oldSpellId, spellId, castCount, castFlags); -} - -void ScriptMgr::ValidateSpellAtCastSpellResult(Player* player, Unit* mover, Spell* spell, uint32 oldSpellId, uint32 spellId) -{ - FOREACH_SCRIPT(MiscScript)->ValidateSpellAtCastSpellResult(player, mover, spell, oldSpellId, spellId); -} - -void ScriptMgr::OnAfterLootTemplateProcess(Loot* loot, LootTemplate const* tab, LootStore const& store, Player* lootOwner, bool personal, bool noEmptyError, uint16 lootMode) -{ - FOREACH_SCRIPT(MiscScript)->OnAfterLootTemplateProcess(loot, tab, store, lootOwner, personal, noEmptyError, lootMode); -} - -void ScriptMgr::OnInstanceSave(InstanceSave* instanceSave) -{ - FOREACH_SCRIPT(MiscScript)->OnInstanceSave(instanceSave); -} - -void ScriptMgr::OnPlayerSetPhase(const AuraEffect* auraEff, AuraApplication const* aurApp, uint8 mode, bool apply, uint32& newPhase) -{ - FOREACH_SCRIPT(MiscScript)->OnPlayerSetPhase(auraEff, aurApp, mode, apply, newPhase); -} - -void ScriptMgr::GetDialogStatus(Player* player, Object* questgiver) -{ - FOREACH_SCRIPT(MiscScript)->GetDialogStatus(player, questgiver); -} - -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) @@ -3612,49 +597,49 @@ AllGameObjectScript::AllGameObjectScript(const char* name) : ScriptObject(name) } // Specialize for each script type class like so: -template class ScriptRegistry; -template class ScriptRegistry; -template class ScriptRegistry; -template class ScriptRegistry; -template class ScriptRegistry; -template class ScriptRegistry; -template class ScriptRegistry; -template class ScriptRegistry; -template class ScriptRegistry; -template class ScriptRegistry; -template class ScriptRegistry; -template class ScriptRegistry; -template class ScriptRegistry; -template class ScriptRegistry; -template class ScriptRegistry; -template class ScriptRegistry; -template class ScriptRegistry; -template class ScriptRegistry; -template class ScriptRegistry; -template class ScriptRegistry; -template class ScriptRegistry; -template class ScriptRegistry; -template class ScriptRegistry; -template class ScriptRegistry; -template class ScriptRegistry; -template class ScriptRegistry; -template class ScriptRegistry; -template class ScriptRegistry; -template class ScriptRegistry; -template class ScriptRegistry; -template class ScriptRegistry; -template class ScriptRegistry; -template class ScriptRegistry; -template class ScriptRegistry; -template class ScriptRegistry; -template class ScriptRegistry; -template class ScriptRegistry; -template class ScriptRegistry; -template class ScriptRegistry; -template class ScriptRegistry; -template class ScriptRegistry; -template class ScriptRegistry; -template class ScriptRegistry; -template class ScriptRegistry; -template class ScriptRegistry; -template class ScriptRegistry; +template class AC_GAME_API ScriptRegistry; +template class AC_GAME_API ScriptRegistry; +template class AC_GAME_API ScriptRegistry; +template class AC_GAME_API ScriptRegistry; +template class AC_GAME_API ScriptRegistry; +template class AC_GAME_API ScriptRegistry; +template class AC_GAME_API ScriptRegistry; +template class AC_GAME_API ScriptRegistry; +template class AC_GAME_API ScriptRegistry; +template class AC_GAME_API ScriptRegistry; +template class AC_GAME_API ScriptRegistry; +template class AC_GAME_API ScriptRegistry; +template class AC_GAME_API ScriptRegistry; +template class AC_GAME_API ScriptRegistry; +template class AC_GAME_API ScriptRegistry; +template class AC_GAME_API ScriptRegistry; +template class AC_GAME_API ScriptRegistry; +template class AC_GAME_API ScriptRegistry; +template class AC_GAME_API ScriptRegistry; +template class AC_GAME_API ScriptRegistry; +template class AC_GAME_API ScriptRegistry; +template class AC_GAME_API ScriptRegistry; +template class AC_GAME_API ScriptRegistry; +template class AC_GAME_API ScriptRegistry; +template class AC_GAME_API ScriptRegistry; +template class AC_GAME_API ScriptRegistry; +template class AC_GAME_API ScriptRegistry; +template class AC_GAME_API ScriptRegistry; +template class AC_GAME_API ScriptRegistry; +template class AC_GAME_API ScriptRegistry; +template class AC_GAME_API ScriptRegistry; +template class AC_GAME_API ScriptRegistry; +template class AC_GAME_API ScriptRegistry; +template class AC_GAME_API ScriptRegistry; +template class AC_GAME_API ScriptRegistry; +template class AC_GAME_API ScriptRegistry; +template class AC_GAME_API ScriptRegistry; +template class AC_GAME_API ScriptRegistry; +template class AC_GAME_API ScriptRegistry; +template class AC_GAME_API ScriptRegistry; +template class AC_GAME_API ScriptRegistry; +template class AC_GAME_API ScriptRegistry; +template class AC_GAME_API ScriptRegistry; +template class AC_GAME_API ScriptRegistry; +template class AC_GAME_API ScriptRegistry; +template class AC_GAME_API ScriptRegistry; diff --git a/src/server/game/Scripting/ScriptMgrMacros.h b/src/server/game/Scripting/ScriptMgrMacros.h index 1ac730548..82fef5168 100644 --- a/src/server/game/Scripting/ScriptMgrMacros.h +++ b/src/server/game/Scripting/ScriptMgrMacros.h @@ -20,67 +20,48 @@ #include "ScriptMgr.h" -template -inline Optional IsValidBoolScript(TCallBack&& callback) +template +inline Optional IsValidBoolScript(std::function executeHook) { if (ScriptRegistry::ScriptPointerList.empty()) return {}; for (auto const& [scriptID, script] : ScriptRegistry::ScriptPointerList) { - if (callback(script)) + if (executeHook(script)) return true; } return false; } -template -inline void GetReturnIndexScripts([[maybe_unused]] T* ret, TCallBack&& callback) +template +inline T* GetReturnAIScript(std::function executeHook) +{ + if (ScriptRegistry::ScriptPointerList.empty()) + return nullptr; + + for (auto const& [scriptID, script] : ScriptRegistry::ScriptPointerList) + { + if (T* scriptAI = executeHook(script)) + { + return scriptAI; + } + } + + return nullptr; +} + +template +inline void ExecuteScript(std::function executeHook) { if (ScriptRegistry::ScriptPointerList.empty()) return; for (auto const& [scriptID, script] : ScriptRegistry::ScriptPointerList) { - if (T* scriptAI = callback(script)) - { - ret = scriptAI; - break; - } + executeHook(script); } } -// Utility macros to refer to the script registry. -#define SCR_REG_MAP(T) ScriptRegistry::ScriptMap -#define SCR_REG_ITR(T) ScriptRegistry::ScriptMapIterator -#define SCR_REG_LST(T) ScriptRegistry::ScriptPointerList - -// Utility macros for looping over scripts. -#define FOR_SCRIPTS(T, C, E) \ - if (!SCR_REG_LST(T).empty()) \ - for (SCR_REG_ITR(T) C = SCR_REG_LST(T).begin(); \ - C != SCR_REG_LST(T).end(); ++C) - -#define FOR_SCRIPTS_RET(T, C, E, R) \ - if (SCR_REG_LST(T).empty()) \ - return R; \ - for (SCR_REG_ITR(T) C = SCR_REG_LST(T).begin(); \ - C != SCR_REG_LST(T).end(); ++C) - -#define FOREACH_SCRIPT(T) \ - FOR_SCRIPTS(T, itr, end) \ - itr->second - -// Utility macros for finding specific scripts. -#define GET_SCRIPT(T, I, V) \ - T* V = ScriptRegistry::GetScriptById(I); \ - if (!V) \ - return; - -#define GET_SCRIPT_RET(T, I, V, R) \ - T* V = ScriptRegistry::GetScriptById(I); \ - if (!V) \ - return R; - #endif // _SCRIPT_MGR_MACRO_H_