feat(Core/ScriptMgr): replace macro and cleanup (#9598)

This commit is contained in:
Kargatum
2021-12-11 01:05:28 +07:00
committed by GitHub
parent 6c8ed5b352
commit fad214efe0
44 changed files with 5289 additions and 3167 deletions

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
void ScriptMgr::OnAccountLogin(uint32 accountId)
{
ExecuteScript<AccountScript>([&](AccountScript* script)
{
script->OnAccountLogin(accountId);
});
}
//void ScriptMgr::OnAccountLogout(uint32 accountId)
//{
// ExecuteScript<AccountScript>([&](AccountScript* script)
// {
// script->OnAccountLogout(accountId);
// });
//}
void ScriptMgr::OnLastIpUpdate(uint32 accountId, std::string ip)
{
ExecuteScript<AccountScript>([&](AccountScript* script)
{
script->OnLastIpUpdate(accountId, ip);
});
}
void ScriptMgr::OnFailedAccountLogin(uint32 accountId)
{
ExecuteScript<AccountScript>([&](AccountScript* script)
{
script->OnFailedAccountLogin(accountId);
});
}
void ScriptMgr::OnEmailChange(uint32 accountId)
{
ExecuteScript<AccountScript>([&](AccountScript* script)
{
script->OnEmailChange(accountId);
});
}
void ScriptMgr::OnFailedEmailChange(uint32 accountId)
{
ExecuteScript<AccountScript>([&](AccountScript* script)
{
script->OnFailedEmailChange(accountId);
});
}
void ScriptMgr::OnPasswordChange(uint32 accountId)
{
ExecuteScript<AccountScript>([&](AccountScript* script)
{
script->OnPasswordChange(accountId);
});
}
void ScriptMgr::OnFailedPasswordChange(uint32 accountId)
{
ExecuteScript<AccountScript>([&](AccountScript* script)
{
script->OnFailedPasswordChange(accountId);
});
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#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<AchievementCriteriaScript>::GetScriptById(scriptId);
return tempScript ? tempScript->OnCheck(source, target, criteria_id) : false;
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
void ScriptMgr::SetRealmCompleted(AchievementEntry const* achievement)
{
ExecuteScript<AchievementScript>([&](AchievementScript* script)
{
script->SetRealmCompleted(achievement);
});
}
bool ScriptMgr::IsCompletedCriteria(AchievementMgr* mgr, AchievementCriteriaEntry const* achievementCriteria, AchievementEntry const* achievement, CriteriaProgress const* progress)
{
auto ret = IsValidBoolScript<AchievementScript>([&](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>([&](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>([&](AchievementScript* script)
{
script->OnBeforeCheckCriteria(mgr, achievementCriteriaList);
});
}
bool ScriptMgr::CanCheckCriteria(AchievementMgr* mgr, AchievementCriteriaEntry const* achievementCriteria)
{
auto ret = IsValidBoolScript<AchievementScript>([&](AchievementScript* script)
{
return !script->CanCheckCriteria(mgr, achievementCriteria);
});
if (ret && *ret)
{
return false;
}
return true;
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
void ScriptMgr::OnCreatureAddWorld(Creature* creature)
{
ASSERT(creature);
ExecuteScript<AllCreatureScript>([&](AllCreatureScript* script)
{
script->OnCreatureAddWorld(creature);
});
}
void ScriptMgr::OnCreatureRemoveWorld(Creature* creature)
{
ASSERT(creature);
ExecuteScript<AllCreatureScript>([&](AllCreatureScript* script)
{
script->OnCreatureRemoveWorld(creature);
});
}
void ScriptMgr::Creature_SelectLevel(const CreatureTemplate* cinfo, Creature* creature)
{
ExecuteScript<AllCreatureScript>([&](AllCreatureScript* script)
{
script->Creature_SelectLevel(cinfo, creature);
});
}
//bool ScriptMgr::CanCreatureSendListInventory(Player* player, Creature* creature, uint32 vendorEntry)
//{
// auto ret = IsValidBoolScript<AllCreatureScript>([&](AllCreatureScript* script)
// {
// return !script->CanCreatureSendListInventory(player, creature, vendorEntry);
// });
//
// if (ret && *ret)
// return false;
//
// return true;
//}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
void ScriptMgr::OnGameObjectAddWorld(GameObject* go)
{
ASSERT(go);
ExecuteScript<AllGameObjectScript>([&](AllGameObjectScript* script)
{
script->OnGameObjectAddWorld(go);
});
}
void ScriptMgr::OnGameObjectRemoveWorld(GameObject* go)
{
ASSERT(go);
ExecuteScript<AllGameObjectScript>([&](AllGameObjectScript* script)
{
script->OnGameObjectRemoveWorld(go);
});
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
namespace
{
template<class ScriptName>
inline void ForeachMaps([[maybe_unused]] Map* map, [[maybe_unused]] std::function<void(ScriptName*)> executeHook)
{
static_assert(Acore::dependant_false_v<ScriptName>, "Unsupported type used for ForeachMaps");
}
template<>
inline void ForeachMaps(Map* map, std::function<void(WorldMapScript*)> executeHook)
{
auto mapEntry = map->GetEntry();
if (!mapEntry)
{
return;
}
if (!mapEntry->IsWorldMap())
{
return;
}
if (ScriptRegistry<WorldMapScript>::ScriptPointerList.empty())
{
return;
}
for (auto const& [scriptID, script] : ScriptRegistry<WorldMapScript>::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<void(InstanceMapScript*)> executeHook)
{
auto mapEntry = map->GetEntry();
if (!mapEntry)
{
return;
}
if (!mapEntry->IsDungeon())
{
return;
}
if (ScriptRegistry<InstanceMapScript>::ScriptPointerList.empty())
{
return;
}
for (auto const& [scriptID, script] : ScriptRegistry<InstanceMapScript>::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<void(BattlegroundMapScript*)> executeHook)
{
auto mapEntry = map->GetEntry();
if (!mapEntry)
{
return;
}
if (!mapEntry->IsBattleground())
{
return;
}
if (ScriptRegistry<BattlegroundMapScript>::ScriptPointerList.empty())
{
return;
}
for (auto const& [scriptID, script] : ScriptRegistry<BattlegroundMapScript>::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>([&](AllMapScript* script)
{
script->OnCreateMap(map);
});
ForeachMaps<WorldMapScript>(map,
[&](WorldMapScript* script)
{
script->OnCreate(map);
});
ForeachMaps<InstanceMapScript>(map,
[&](InstanceMapScript* script)
{
script->OnCreate((InstanceMap*)map);
});
ForeachMaps<BattlegroundMapScript>(map,
[&](BattlegroundMapScript* script)
{
script->OnCreate((BattlegroundMap*)map);
});
}
void ScriptMgr::OnDestroyMap(Map* map)
{
ASSERT(map);
ExecuteScript<AllMapScript>([&](AllMapScript* script)
{
script->OnDestroyMap(map);
});
ForeachMaps<WorldMapScript>(map,
[&](WorldMapScript* script)
{
script->OnDestroy(map);
});
ForeachMaps<InstanceMapScript>(map,
[&](InstanceMapScript* script)
{
script->OnDestroy((InstanceMap*)map);
});
ForeachMaps<BattlegroundMapScript>(map,
[&](BattlegroundMapScript* script)
{
script->OnDestroy((BattlegroundMap*)map);
});
}
void ScriptMgr::OnLoadGridMap(Map* map, GridMap* gmap, uint32 gx, uint32 gy)
{
ASSERT(map);
ASSERT(gmap);
ForeachMaps<WorldMapScript>(map,
[&](WorldMapScript* script)
{
script->OnLoadGridMap(map, gmap, gx, gy);
});
ForeachMaps<InstanceMapScript>(map,
[&](InstanceMapScript* script)
{
script->OnLoadGridMap((InstanceMap*)map, gmap, gx, gy);
});
ForeachMaps<BattlegroundMapScript>(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<WorldMapScript>(map,
[&](WorldMapScript* script)
{
script->OnUnloadGridMap(map, gmap, gx, gy);
});
ForeachMaps<InstanceMapScript>(map,
[&](InstanceMapScript* script)
{
script->OnUnloadGridMap((InstanceMap*)map, gmap, gx, gy);
});
ForeachMaps<BattlegroundMapScript>(map,
[&](BattlegroundMapScript* script)
{
script->OnUnloadGridMap((BattlegroundMap*)map, gmap, gx, gy);
});
}
void ScriptMgr::OnPlayerEnterMap(Map* map, Player* player)
{
ASSERT(map);
ASSERT(player);
ExecuteScript<AllMapScript>([&](AllMapScript* script)
{
script->OnPlayerEnterAll(map, player);
});
ExecuteScript<PlayerScript>([&](PlayerScript* script)
{
script->OnMapChanged(player);
});
ForeachMaps<WorldMapScript>(map,
[&](WorldMapScript* script)
{
script->OnPlayerEnter(map, player);
});
ForeachMaps<InstanceMapScript>(map,
[&](InstanceMapScript* script)
{
script->OnPlayerEnter((InstanceMap*)map, player);
});
ForeachMaps<BattlegroundMapScript>(map,
[&](BattlegroundMapScript* script)
{
script->OnPlayerEnter((BattlegroundMap*)map, player);
});
}
void ScriptMgr::OnPlayerLeaveMap(Map* map, Player* player)
{
ASSERT(map);
ASSERT(player);
ExecuteScript<AllMapScript>([&](AllMapScript* script)
{
script->OnPlayerLeaveAll(map, player);
});
ForeachMaps<WorldMapScript>(map,
[&](WorldMapScript* script)
{
script->OnPlayerLeave(map, player);
});
ForeachMaps<InstanceMapScript>(map,
[&](InstanceMapScript* script)
{
script->OnPlayerLeave((InstanceMap*)map, player);
});
ForeachMaps<BattlegroundMapScript>(map,
[&](BattlegroundMapScript* script)
{
script->OnPlayerLeave((BattlegroundMap*)map, player);
});
}
void ScriptMgr::OnMapUpdate(Map* map, uint32 diff)
{
ASSERT(map);
ExecuteScript<AllMapScript>([&](AllMapScript* script)
{
script->OnMapUpdate(map, diff);
});
ForeachMaps<WorldMapScript>(map,
[&](WorldMapScript* script)
{
script->OnUpdate(map, diff);
});
ForeachMaps<InstanceMapScript>(map,
[&](InstanceMapScript* script)
{
script->OnUpdate((InstanceMap*)map, diff);
});
ForeachMaps<BattlegroundMapScript>(map,
[&](BattlegroundMapScript* script)
{
script->OnUpdate((BattlegroundMap*)map, diff);
});
}
void ScriptMgr::OnBeforeCreateInstanceScript(InstanceMap* instanceMap, InstanceScript* instanceData, bool load, std::string data, uint32 completedEncounterMask)
{
ExecuteScript<AllMapScript>([&](AllMapScript* script)
{
script->OnBeforeCreateInstanceScript(instanceMap, instanceData, load, data, completedEncounterMask);
});
}
void ScriptMgr::OnDestroyInstance(MapInstanced* mapInstanced, Map* map)
{
ExecuteScript<AllMapScript>([&](AllMapScript* script)
{
script->OnDestroyInstance(mapInstanced, map);
});
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
bool ScriptMgr::OnAreaTrigger(Player* player, AreaTrigger const* trigger)
{
ASSERT(player);
ASSERT(trigger);
auto ret = IsValidBoolScript<ElunaScript>([&](ElunaScript* script)
{
return script->CanAreaTrigger(player, trigger);
});
if (ret && *ret)
{
return false;
}
auto tempScript = ScriptRegistry<AreaTriggerScript>::GetScriptById(sObjectMgr->GetAreaTriggerScriptId(trigger->entry));
return tempScript ? tempScript->OnTrigger(player, trigger) : false;
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
bool ScriptMgr::CanAddMember(ArenaTeam* team, ObjectGuid PlayerGuid)
{
auto ret = IsValidBoolScript<ArenaScript>([&](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>([&](ArenaScript* script)
{
script->OnGetPoints(team, memberRating, points);
});
}
bool ScriptMgr::CanSaveToDB(ArenaTeam* team)
{
auto ret = IsValidBoolScript<ArenaScript>([&](ArenaScript* script)
{
return !script->CanSaveToDB(team);
});
if (ret && *ret)
{
return false;
}
return true;
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
void ScriptMgr::OnGetSlotByType(const uint32 type, uint8& slot)
{
ExecuteScript<ArenaTeamScript>([&](ArenaTeamScript* script)
{
script->OnGetSlotByType(type, slot);
});
}
void ScriptMgr::OnGetArenaPoints(ArenaTeam* at, float& points)
{
ExecuteScript<ArenaTeamScript>([&](ArenaTeamScript* script)
{
script->OnGetArenaPoints(at, points);
});
}
void ScriptMgr::OnArenaTypeIDToQueueID(const BattlegroundTypeId bgTypeId, const uint8 arenaType, uint32& queueTypeID)
{
ExecuteScript<ArenaTeamScript>([&](ArenaTeamScript* script)
{
script->OnTypeIDToQueueID(bgTypeId, arenaType, queueTypeID);
});
}
void ScriptMgr::OnArenaQueueIdToArenaType(const BattlegroundQueueTypeId bgQueueTypeId, uint8& ArenaType)
{
ExecuteScript<ArenaTeamScript>([&](ArenaTeamScript* script)
{
script->OnQueueIdToArenaType(bgQueueTypeId, ArenaType);
});
}
void ScriptMgr::OnSetArenaMaxPlayersPerTeam(const uint8 arenaType, uint32& maxPlayerPerTeam)
{
ExecuteScript<ArenaTeamScript>([&](ArenaTeamScript* script)
{
script->OnSetArenaMaxPlayersPerTeam(arenaType, maxPlayerPerTeam);
});
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
void ScriptMgr::OnAuctionAdd(AuctionHouseObject* ah, AuctionEntry* entry)
{
ASSERT(ah);
ASSERT(entry);
ExecuteScript<AuctionHouseScript>([&](AuctionHouseScript* script)
{
script->OnAuctionAdd(ah, entry);
});
}
void ScriptMgr::OnAuctionRemove(AuctionHouseObject* ah, AuctionEntry* entry)
{
ASSERT(ah);
ASSERT(entry);
ExecuteScript<AuctionHouseScript>([&](AuctionHouseScript* script)
{
script->OnAuctionRemove(ah, entry);
});
}
void ScriptMgr::OnAuctionSuccessful(AuctionHouseObject* ah, AuctionEntry* entry)
{
ASSERT(ah);
ASSERT(entry);
ExecuteScript<AuctionHouseScript>([&](AuctionHouseScript* script)
{
script->OnAuctionSuccessful(ah, entry);
});
}
void ScriptMgr::OnAuctionExpire(AuctionHouseObject* ah, AuctionEntry* entry)
{
ASSERT(ah);
ASSERT(entry);
ExecuteScript<AuctionHouseScript>([&](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>([&](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>([&](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>([&](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>([&](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>([&](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>([&](AuctionHouseScript* script)
{
script->OnBeforeAuctionHouseMgrSendAuctionCancelledToBidderMail(auctionHouseMgr, auction, bidder, bidder_accId, sendMail);
});
}
void ScriptMgr::OnBeforeAuctionHouseMgrUpdate()
{
ExecuteScript<AuctionHouseScript>([&](AuctionHouseScript* script)
{
script->OnBeforeAuctionHouseMgrUpdate();
});
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
void ScriptMgr::OnBattlegroundStart(Battleground* bg)
{
ExecuteScript<BGScript>([&](BGScript* script)
{
script->OnBattlegroundStart(bg);
});
}
void ScriptMgr::OnBattlegroundEndReward(Battleground* bg, Player* player, TeamId winnerTeamId)
{
ExecuteScript<BGScript>([&](BGScript* script)
{
script->OnBattlegroundEndReward(bg, player, winnerTeamId);
});
}
void ScriptMgr::OnBattlegroundUpdate(Battleground* bg, uint32 diff)
{
ExecuteScript<BGScript>([&](BGScript* script)
{
script->OnBattlegroundUpdate(bg, diff);
});
}
void ScriptMgr::OnBattlegroundAddPlayer(Battleground* bg, Player* player)
{
ExecuteScript<BGScript>([&](BGScript* script)
{
script->OnBattlegroundAddPlayer(bg, player);
});
}
void ScriptMgr::OnBattlegroundBeforeAddPlayer(Battleground* bg, Player* player)
{
ExecuteScript<BGScript>([&](BGScript* script)
{
script->OnBattlegroundBeforeAddPlayer(bg, player);
});
}
void ScriptMgr::OnBattlegroundRemovePlayerAtLeave(Battleground* bg, Player* player)
{
ExecuteScript<BGScript>([&](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>([&](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>([&](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>([&](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>([&](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>([&](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>([&](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>([&](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>([&](BGScript* script)
{
return !script->OnBeforeSendExitMessageArenaQueue(queue, ginfo);
});
if (ret && *ret)
{
return false;
}
return true;
}
void ScriptMgr::OnBattlegroundEnd(Battleground* bg, TeamId winnerTeam)
{
ExecuteScript<BGScript>([&](BGScript* script)
{
script->OnBattlegroundEnd(bg, winnerTeam);
});
}
void ScriptMgr::OnBattlegroundDestroy(Battleground* bg)
{
ExecuteScript<BGScript>([&](BGScript* script)
{
script->OnBattlegroundDestroy(bg);
});
}
void ScriptMgr::OnBattlegroundCreate(Battleground* bg)
{
ExecuteScript<BGScript>([&](BGScript* script)
{
script->OnBattlegroundCreate(bg);
});
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
Battleground* ScriptMgr::CreateBattleground(BattlegroundTypeId /*typeId*/)
{
// TODO: Implement script-side battlegrounds.
ABORT();
return nullptr;
}

View File

@@ -0,0 +1,42 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
void ScriptMgr::OnHandleDevCommand(Player* player, std::string& argstr)
{
ExecuteScript<CommandSC>([&](CommandSC* script)
{
script->OnHandleDevCommand(player, argstr);
});
}
bool ScriptMgr::CanExecuteCommand(ChatHandler& handler, std::string_view cmdStr)
{
auto ret = IsValidBoolScript<CommandSC>([&](CommandSC* script)
{
return !script->CanExecuteCommand(handler, cmdStr);
});
if (ret && *ret)
{
return false;
}
return true;
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
#include "Chat.h"
Acore::ChatCommands::ChatCommandTable ScriptMgr::GetChatCommands()
{
Acore::ChatCommands::ChatCommandTable table;
for (auto const& [scriptID, script] : ScriptRegistry<CommandScript>::ScriptPointerList)
{
Acore::ChatCommands::ChatCommandTable cmds = script->GetCommands();
std::move(cmds.begin(), cmds.end(), std::back_inserter(table));
}
return table;
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
bool ScriptMgr::OnConditionCheck(Condition* condition, ConditionSourceInfo& sourceInfo)
{
ASSERT(condition);
auto tempScript = ScriptRegistry<ConditionScript>::GetScriptById(condition->ScriptId);
return tempScript ? tempScript->OnConditionCheck(condition, sourceInfo) : true;
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
#include "ScriptedGossip.h"
bool ScriptMgr::OnGossipHello(Player* player, Creature* creature)
{
ASSERT(player);
ASSERT(creature);
auto ret = IsValidBoolScript<AllCreatureScript>([&](AllCreatureScript* script)
{
return script->CanCreatureGossipHello(player, creature);
});
if (ret && *ret)
{
return true;
}
auto tempScript = ScriptRegistry<CreatureScript>::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>([&](AllCreatureScript* script)
{
return script->CanCreatureGossipSelect(player, creature, sender, action);
});
if (ret && *ret)
{
return true;
}
auto tempScript = ScriptRegistry<CreatureScript>::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>([&](AllCreatureScript* script)
{
return script->CanCreatureGossipSelectCode(player, creature, sender, action, code);
});
if (ret && *ret)
{
return true;
}
auto tempScript = ScriptRegistry<CreatureScript>::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>([&](AllCreatureScript* script)
{
return script->CanCreatureQuestAccept(player, creature, quest);
});
if (ret && *ret)
{
return true;
}
auto tempScript = ScriptRegistry<CreatureScript>::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<CreatureScript>::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<CreatureScript>::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>([&](AllCreatureScript* script)
{
return script->CanCreatureQuestReward(player, creature, quest, opt);
});
if (ret && *ret)
{
return true;
}
auto tempScript = ScriptRegistry<CreatureScript>::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<CreatureScript>::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<AllCreatureScript, CreatureAI>([creature](AllCreatureScript* script)
{
return script->GetCreatureAI(creature);
});
if (retAI)
{
return retAI;
}
auto tempScript = ScriptRegistry<CreatureScript>::GetScriptById(creature->GetScriptId());
return tempScript ? tempScript->GetAI(creature) : nullptr;
}
void ScriptMgr::OnCreatureUpdate(Creature* creature, uint32 diff)
{
ASSERT(creature);
ExecuteScript<AllCreatureScript>([&](AllCreatureScript* script)
{
script->OnAllCreatureUpdate(creature, diff);
});
if (auto tempScript = ScriptRegistry<CreatureScript>::GetScriptById(creature->GetScriptId()))
{
tempScript->OnUpdate(creature, diff);
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
void ScriptMgr::OnAfterDatabasesLoaded(uint32 updateFlags)
{
ExecuteScript<DatabaseScript>([&](DatabaseScript* script)
{
script->OnAfterDatabasesLoaded(updateFlags);
});
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
void ScriptMgr::OnDynamicObjectUpdate(DynamicObject* dynobj, uint32 diff)
{
ASSERT(dynobj);
for (auto const& [scriptID, script] : ScriptRegistry<DynamicObjectScript>::ScriptPointerList)
{
script->OnUpdate(dynobj, diff);
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
void ScriptMgr::OnHonorCalculation(float& honor, uint8 level, float multiplier)
{
ExecuteScript<FormulaScript>([&](FormulaScript* script)
{
script->OnHonorCalculation(honor, level, multiplier);
});
}
void ScriptMgr::OnGrayLevelCalculation(uint8& grayLevel, uint8 playerLevel)
{
ExecuteScript<FormulaScript>([&](FormulaScript* script)
{
script->OnGrayLevelCalculation(grayLevel, playerLevel);
});
}
void ScriptMgr::OnColorCodeCalculation(XPColorChar& color, uint8 playerLevel, uint8 mobLevel)
{
ExecuteScript<FormulaScript>([&](FormulaScript* script)
{
script->OnColorCodeCalculation(color, playerLevel, mobLevel);
});
}
void ScriptMgr::OnZeroDifferenceCalculation(uint8& diff, uint8 playerLevel)
{
ExecuteScript<FormulaScript>([&](FormulaScript* script)
{
script->OnZeroDifferenceCalculation(diff, playerLevel);
});
}
void ScriptMgr::OnBaseGainCalculation(uint32& gain, uint8 playerLevel, uint8 mobLevel, ContentLevels content)
{
ExecuteScript<FormulaScript>([&](FormulaScript* script)
{
script->OnBaseGainCalculation(gain, playerLevel, mobLevel, content);
});
}
void ScriptMgr::OnGainCalculation(uint32& gain, Player* player, Unit* unit)
{
ASSERT(player);
ASSERT(unit);
ExecuteScript<FormulaScript>([&](FormulaScript* script)
{
script->OnGainCalculation(gain, player, unit);
});
}
void ScriptMgr::OnGroupRateCalculation(float& rate, uint32 count, bool isRaid)
{
ExecuteScript<FormulaScript>([&](FormulaScript* script)
{
script->OnGroupRateCalculation(rate, count, isRaid);
});
}
void ScriptMgr::OnAfterArenaRatingCalculation(Battleground* const bg, int32& winnerMatchmakerChange, int32& loserMatchmakerChange, int32& winnerChange, int32& loserChange)
{
ExecuteScript<FormulaScript>([&](FormulaScript* script)
{
script->OnAfterArenaRatingCalculation(bg, winnerMatchmakerChange, loserMatchmakerChange, winnerChange, loserChange);
});
}
void ScriptMgr::OnBeforeUpdatingPersonalRating(int32& mod, uint32 type)
{
ExecuteScript<FormulaScript>([&](FormulaScript* script)
{
script->OnBeforeUpdatingPersonalRating(mod, type);
});
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
void ScriptMgr::OnGameEventStart(uint16 EventID)
{
ExecuteScript<GameEventScript>([&](GameEventScript* script)
{
script->OnStart(EventID);
});
}
void ScriptMgr::OnGameEventStop(uint16 EventID)
{
ExecuteScript<GameEventScript>([&](GameEventScript* script)
{
script->OnStop(EventID);
});
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
#include "ScriptedGossip.h"
bool ScriptMgr::OnGossipHello(Player* player, GameObject* go)
{
ASSERT(player);
ASSERT(go);
auto ret = IsValidBoolScript<AllGameObjectScript>([&](AllGameObjectScript* script)
{
return script->CanGameObjectGossipHello(player, go);
});
if (ret && *ret)
{
return true;
}
auto tempScript = ScriptRegistry<GameObjectScript>::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>([&](AllGameObjectScript* script)
{
return script->CanGameObjectGossipSelect(player, go, sender, action);
});
if (ret && *ret)
{
return true;
}
auto tempScript = ScriptRegistry<GameObjectScript>::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>([&](AllGameObjectScript* script)
{
return script->CanGameObjectGossipSelectCode(player, go, sender, action, code);
});
if (ret && *ret)
{
return true;
}
auto tempScript = ScriptRegistry<GameObjectScript>::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>([&](AllGameObjectScript* script)
{
return script->CanGameObjectQuestAccept(player, go, quest);
});
if (ret && *ret)
{
return true;
}
auto tempScript = ScriptRegistry<GameObjectScript>::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>([&](AllGameObjectScript* script)
{
return script->CanGameObjectQuestReward(player, go, quest, opt);
});
if (ret && *ret)
{
return true;
}
auto tempScript = ScriptRegistry<GameObjectScript>::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<GameObjectScript>::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>([&](AllGameObjectScript* script)
{
script->OnGameObjectDestroyed(go, player);
});
if (auto tempScript = ScriptRegistry<GameObjectScript>::GetScriptById(go->GetScriptId()))
{
tempScript->OnDestroyed(go, player);
}
}
void ScriptMgr::OnGameObjectDamaged(GameObject* go, Player* player)
{
ASSERT(go);
ExecuteScript<AllGameObjectScript>([&](AllGameObjectScript* script)
{
script->OnGameObjectDamaged(go, player);
});
if (auto tempScript = ScriptRegistry<GameObjectScript>::GetScriptById(go->GetScriptId()))
{
tempScript->OnDamaged(go, player);
}
}
void ScriptMgr::OnGameObjectLootStateChanged(GameObject* go, uint32 state, Unit* unit)
{
ASSERT(go);
ExecuteScript<AllGameObjectScript>([&](AllGameObjectScript* script)
{
script->OnGameObjectLootStateChanged(go, state, unit);
});
if (auto tempScript = ScriptRegistry<GameObjectScript>::GetScriptById(go->GetScriptId()))
{
tempScript->OnLootStateChanged(go, state, unit);
}
}
void ScriptMgr::OnGameObjectStateChanged(GameObject* go, uint32 state)
{
ASSERT(go);
ExecuteScript<AllGameObjectScript>([&](AllGameObjectScript* script)
{
script->OnGameObjectStateChanged(go, state);
});
if (auto tempScript = ScriptRegistry<GameObjectScript>::GetScriptById(go->GetScriptId()))
{
tempScript->OnGameObjectStateChanged(go, state);
}
}
void ScriptMgr::OnGameObjectUpdate(GameObject* go, uint32 diff)
{
ASSERT(go);
ExecuteScript<AllGameObjectScript>([&](AllGameObjectScript* script)
{
script->OnGameObjectUpdate(go, diff);
});
if (auto tempScript = ScriptRegistry<GameObjectScript>::GetScriptById(go->GetScriptId()))
{
tempScript->OnUpdate(go, diff);
}
}
GameObjectAI* ScriptMgr::GetGameObjectAI(GameObject* go)
{
ASSERT(go);
auto retAI = GetReturnAIScript<AllGameObjectScript, GameObjectAI>([go](AllGameObjectScript* script)
{
return script->GetGameObjectAI(go);
});
if (retAI)
{
return retAI;
}
auto tempScript = ScriptRegistry<GameObjectScript>::GetScriptById(go->GetScriptId());
return tempScript ? tempScript->GetAI(go) : nullptr;
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
void ScriptMgr::OnGlobalItemDelFromDB(CharacterDatabaseTransaction trans, ObjectGuid::LowType itemGuid)
{
ASSERT(trans);
ASSERT(itemGuid);
ExecuteScript<GlobalScript>([&](GlobalScript* script)
{
script->OnItemDelFromDB(trans, itemGuid);
});
}
void ScriptMgr::OnGlobalMirrorImageDisplayItem(const Item* item, uint32& display)
{
ExecuteScript<GlobalScript>([&](GlobalScript* script)
{
script->OnMirrorImageDisplayItem(item, display);
});
}
void ScriptMgr::OnBeforeUpdateArenaPoints(ArenaTeam* at, std::map<ObjectGuid, uint32>& ap)
{
ExecuteScript<GlobalScript>([&](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>([&](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>([&](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>([&](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>([&](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>([&](GlobalScript* script)
{
script->OnInitializeLockedDungeons(player, level, lockData, dungeon);
});
}
void ScriptMgr::OnAfterInitializeLockedDungeons(Player* player)
{
ExecuteScript<GlobalScript>([&](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>([&](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>([&](GlobalScript* script)
{
script->OnBeforeWorldObjectSetPhaseMask(worldObject, oldPhaseMask, newPhaseMask, useCombinedPhases, update);
});
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
void ScriptMgr::OnGroupAddMember(Group* group, ObjectGuid guid)
{
ASSERT(group);
ExecuteScript<GroupScript>([&](GroupScript* script)
{
script->OnAddMember(group, guid);
});
}
void ScriptMgr::OnGroupInviteMember(Group* group, ObjectGuid guid)
{
ASSERT(group);
ExecuteScript<GroupScript>([&](GroupScript* script)
{
script->OnInviteMember(group, guid);
});
}
void ScriptMgr::OnGroupRemoveMember(Group* group, ObjectGuid guid, RemoveMethod method, ObjectGuid kicker, const char* reason)
{
ASSERT(group);
ExecuteScript<GroupScript>([&](GroupScript* script)
{
script->OnRemoveMember(group, guid, method, kicker, reason);
});
}
void ScriptMgr::OnGroupChangeLeader(Group* group, ObjectGuid newLeaderGuid, ObjectGuid oldLeaderGuid)
{
ASSERT(group);
ExecuteScript<GroupScript>([&](GroupScript* script)
{
script->OnChangeLeader(group, newLeaderGuid, oldLeaderGuid);
});
}
void ScriptMgr::OnGroupDisband(Group* group)
{
ASSERT(group);
ExecuteScript<GroupScript>([&](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>([&](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>([&](GroupScript* script)
{
script->OnCreate(group, leader);
});
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
void ScriptMgr::OnGuildAddMember(Guild* guild, Player* player, uint8& plRank)
{
ExecuteScript<GuildScript>([&](GuildScript* script)
{
script->OnAddMember(guild, player, plRank);
});
}
void ScriptMgr::OnGuildRemoveMember(Guild* guild, Player* player, bool isDisbanding, bool isKicked)
{
ExecuteScript<GuildScript>([&](GuildScript* script)
{
script->OnRemoveMember(guild, player, isDisbanding, isKicked);
});
}
void ScriptMgr::OnGuildMOTDChanged(Guild* guild, const std::string& newMotd)
{
ExecuteScript<GuildScript>([&](GuildScript* script)
{
script->OnMOTDChanged(guild, newMotd);
});
}
void ScriptMgr::OnGuildInfoChanged(Guild* guild, const std::string& newInfo)
{
ExecuteScript<GuildScript>([&](GuildScript* script)
{
script->OnInfoChanged(guild, newInfo);
});
}
void ScriptMgr::OnGuildCreate(Guild* guild, Player* leader, const std::string& name)
{
ExecuteScript<GuildScript>([&](GuildScript* script)
{
script->OnCreate(guild, leader, name);
});
}
void ScriptMgr::OnGuildDisband(Guild* guild)
{
ExecuteScript<GuildScript>([&](GuildScript* script)
{
script->OnDisband(guild);
});
}
void ScriptMgr::OnGuildMemberWitdrawMoney(Guild* guild, Player* player, uint32& amount, bool isRepair)
{
ExecuteScript<GuildScript>([&](GuildScript* script)
{
script->OnMemberWitdrawMoney(guild, player, amount, isRepair);
});
}
void ScriptMgr::OnGuildMemberDepositMoney(Guild* guild, Player* player, uint32& amount)
{
ExecuteScript<GuildScript>([&](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>([&](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>([&](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>([&](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>([&](GuildScript* script)
{
return !script->CanGuildSendBankList(guild, session, tabId, sendAllSlots);
});
if (ret && *ret)
{
return false;
}
return true;
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
InstanceScript* ScriptMgr::CreateInstanceScript(InstanceMap* map)
{
ASSERT(map);
auto tempScript = ScriptRegistry<InstanceMapScript>::GetScriptById(map->GetScriptId());
return tempScript ? tempScript->GetInstanceScript(map) : nullptr;
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#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>([&](AllItemScript* script)
{
return !script->CanItemQuestAccept(player, item, quest);
});
if (ret && *ret)
{
return false;
}
auto tempScript = ScriptRegistry<ItemScript>::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>([&](AllItemScript* script)
{
return script->CanItemUse(player, item, targets);
});
if (ret && *ret)
{
return true;
}
auto tempScript = ScriptRegistry<ItemScript>::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>([&](AllItemScript* script)
{
return !script->CanItemExpire(player, proto);
});
if (ret && *ret)
{
return false;
}
auto tempScript = ScriptRegistry<ItemScript>::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>([&](AllItemScript* script)
{
return !script->CanItemRemove(player, item);
});
if (ret && *ret)
{
return false;
}
auto tempScript = ScriptRegistry<ItemScript>::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<ItemScript>::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>([&](AllItemScript* script)
{
script->OnItemGossipSelect(player, item, sender, action);
});
if (auto tempScript = ScriptRegistry<ItemScript>::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>([&](AllItemScript* script)
{
script->OnItemGossipSelectCode(player, item, sender, action, code);
});
if (auto tempScript = ScriptRegistry<ItemScript>::GetScriptById(item->GetScriptId()))
{
tempScript->OnGossipSelectCode(player, item, sender, action, code);
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
void ScriptMgr::OnLootMoney(Player* player, uint32 gold)
{
ASSERT(player);
ExecuteScript<LootScript>([&](LootScript* script)
{
script->OnLootMoney(player, gold);
});
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#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>([&](MailScript* script)
{
script->OnBeforeMailDraftSendMailTo(mailDraft, receiver, sender, checked, deliver_delay, custom_expiration, deleteMailItemsFromDB, sendMail);\
});
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
void ScriptMgr::OnItemCreate(Item* item, ItemTemplate const* itemProto, Player const* owner)
{
ExecuteScript<MiscScript>([&](MiscScript* script)
{
script->OnItemCreate(item, itemProto, owner);
});
}
bool ScriptMgr::CanApplySoulboundFlag(Item* item, ItemTemplate const* proto)
{
auto ret = IsValidBoolScript<MiscScript>([&](MiscScript* script)
{
return !script->CanApplySoulboundFlag(item, proto);
});
if (ret && *ret)
{
return false;
}
return true;
}
void ScriptMgr::OnConstructObject(Object* origin)
{
ExecuteScript<MiscScript>([&](MiscScript* script)
{
script->OnConstructObject(origin);
});
}
void ScriptMgr::OnDestructObject(Object* origin)
{
ExecuteScript<MiscScript>([&](MiscScript* script)
{
script->OnDestructObject(origin);
});
}
void ScriptMgr::OnConstructPlayer(Player* origin)
{
ExecuteScript<MiscScript>([&](MiscScript* script)
{
script->OnConstructPlayer(origin);
});
}
void ScriptMgr::OnDestructPlayer(Player* origin)
{
ExecuteScript<MiscScript>([&](MiscScript* script)
{
script->OnDestructPlayer(origin);
});
}
void ScriptMgr::OnConstructGroup(Group* origin)
{
ExecuteScript<MiscScript>([&](MiscScript* script)
{
script->OnConstructGroup(origin);
});
}
void ScriptMgr::OnDestructGroup(Group* origin)
{
ExecuteScript<MiscScript>([&](MiscScript* script)
{
script->OnDestructGroup(origin);
});
}
void ScriptMgr::OnConstructInstanceSave(InstanceSave* origin)
{
ExecuteScript<MiscScript>([&](MiscScript* script)
{
script->OnConstructInstanceSave(origin);
});
}
void ScriptMgr::OnDestructInstanceSave(InstanceSave* origin)
{
ExecuteScript<MiscScript>([&](MiscScript* script)
{
script->OnDestructInstanceSave(origin);
});
}
bool ScriptMgr::CanItemApplyEquipSpell(Player* player, Item* item)
{
auto ret = IsValidBoolScript<MiscScript>([&](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>([&](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>([&](MiscScript* script)
{
script->ValidateSpellAtCastSpell(player, oldSpellId, spellId, castCount, castFlags);
});
}
void ScriptMgr::ValidateSpellAtCastSpellResult(Player* player, Unit* mover, Spell* spell, uint32 oldSpellId, uint32 spellId)
{
ExecuteScript<MiscScript>([&](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>([&](MiscScript* script)
{
script->OnAfterLootTemplateProcess(loot, tab, store, lootOwner, personal, noEmptyError, lootMode);
});
}
void ScriptMgr::OnInstanceSave(InstanceSave* instanceSave)
{
ExecuteScript<MiscScript>([&](MiscScript* script)
{
script->OnInstanceSave(instanceSave);
});
}
void ScriptMgr::OnPlayerSetPhase(const AuraEffect* auraEff, AuraApplication const* aurApp, uint8 mode, bool apply, uint32& newPhase)
{
ExecuteScript<MiscScript>([&](MiscScript* script)
{
script->OnPlayerSetPhase(auraEff, aurApp, mode, apply, newPhase);
});
}
void ScriptMgr::GetDialogStatus(Player* player, Object* questgiver)
{
ExecuteScript<MiscScript>([&](MiscScript* script)
{
script->GetDialogStatus(player, questgiver);
});
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
void ScriptMgr::OnPlayerMove(Player* player, MovementInfo movementInfo, uint32 opcode)
{
ExecuteScript<MovementHandlerScript>([&](MovementHandlerScript* script)
{
script->OnPlayerMove(player, movementInfo, opcode);
});
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
#include "OutdoorPvPMgr.h"
OutdoorPvP* ScriptMgr::CreateOutdoorPvP(OutdoorPvPData const* data)
{
ASSERT(data);
auto tempScript = ScriptRegistry<OutdoorPvPScript>::GetScriptById(data->ScriptId);
return tempScript ? tempScript->GetOutdoorPvP() : nullptr;
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
void ScriptMgr::OnInitStatsForLevel(Guardian* guardian, uint8 petlevel)
{
ExecuteScript<PetScript>([&](PetScript* script)
{
script->OnInitStatsForLevel(guardian, petlevel);
});
}
void ScriptMgr::OnCalculateMaxTalentPointsForLevel(Pet* pet, uint8 level, uint8& points)
{
ExecuteScript<PetScript>([&](PetScript* script)
{
script->OnCalculateMaxTalentPointsForLevel(pet, level, points);
});
}
bool ScriptMgr::CanUnlearnSpellSet(Pet* pet, uint32 level, uint32 spell)
{
auto ret = IsValidBoolScript<PetScript>([&](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>([&](PetScript* script)
{
return !script->CanUnlearnSpellDefault(pet, spellEntry);
});
if (ret && *ret)
{
return false;
}
return true;
}
bool ScriptMgr::CanResetTalents(Pet* pet)
{
auto ret = IsValidBoolScript<PetScript>([&](PetScript* script)
{
return !script->CanResetTalents(pet);
});
if (ret && *ret)
{
return false;
}
return true;
}
void ScriptMgr::OnPetAddToWorld(Pet* pet)
{
ASSERT(pet);
ExecuteScript<PetScript>([&](PetScript* script)
{
script->OnPetAddToWorld(pet);
});
}

File diff suppressed because it is too large Load Diff

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
void ScriptMgr::OnNetworkStart()
{
ExecuteScript<ServerScript>([&](ServerScript* script)
{
script->OnNetworkStart();
});
}
void ScriptMgr::OnNetworkStop()
{
ExecuteScript<ServerScript>([&](ServerScript* script)
{
script->OnNetworkStop();
});
}
void ScriptMgr::OnSocketOpen(std::shared_ptr<WorldSocket> socket)
{
ASSERT(socket);
ExecuteScript<ServerScript>([&](ServerScript* script)
{
script->OnSocketOpen(socket);
});
}
void ScriptMgr::OnSocketClose(std::shared_ptr<WorldSocket> socket)
{
ASSERT(socket);
ExecuteScript<ServerScript>([&](ServerScript* script)
{
script->OnSocketClose(socket);
});
}
bool ScriptMgr::CanPacketReceive(WorldSession* session, WorldPacket const& packet)
{
if (ScriptRegistry<ServerScript>::ScriptPointerList.empty())
return true;
WorldPacket copy(packet);
auto ret = IsValidBoolScript<ServerScript>([&](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<ServerScript>::ScriptPointerList.empty())
return true;
WorldPacket copy(packet);
auto ret = IsValidBoolScript<ServerScript>([&](ServerScript* script)
{
return !script->CanPacketSend(session, copy);
});
if (ret && *ret)
{
return false;
}
return true;
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
void ScriptMgr::OnCalcMaxDuration(Aura const* aura, int32& maxDuration)
{
ExecuteScript<SpellSC>([&](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>([&](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>([&](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>([&](SpellSC* script)
{
script->OnSpellCheckCast(spell, strict, res);
});
}
bool ScriptMgr::CanPrepare(Spell* spell, SpellCastTargets const* targets, AuraEffect const* triggeredByAura)
{
auto ret = IsValidBoolScript<SpellSC>([&](SpellSC* script)
{
return !script->CanPrepare(spell, targets, triggeredByAura);
});
if (ret && *ret)
{
return false;
}
return true;
}
bool ScriptMgr::CanScalingEverything(Spell* spell)
{
auto ret = IsValidBoolScript<SpellSC>([&](SpellSC* script)
{
return script->CanScalingEverything(spell);
});
if (ret && *ret)
{
return true;
}
return false;
}
bool ScriptMgr::CanSelectSpecTalent(Spell* spell)
{
auto ret = IsValidBoolScript<SpellSC>([&](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>([&](SpellSC* script)
{
script->OnScaleAuraUnitAdd(spell, target, effectMask, checkIfValid, implicit, auraScaleMask, targetInfo);
});
}
void ScriptMgr::OnRemoveAuraScaleTargets(Spell* spell, TargetInfo& targetInfo, uint8 auraScaleMask, bool& needErase)
{
ExecuteScript<SpellSC>([&](SpellSC* script)
{
script->OnRemoveAuraScaleTargets(spell, targetInfo, auraScaleMask, needErase);
});
}
void ScriptMgr::OnBeforeAuraRankForLevel(SpellInfo const* spellInfo, SpellInfo const* latestSpellInfo, uint8 level)
{
ExecuteScript<SpellSC>([&](SpellSC* script)
{
script->OnBeforeAuraRankForLevel(spellInfo, latestSpellInfo, level);
});
}
void ScriptMgr::OnDummyEffect(WorldObject* caster, uint32 spellID, SpellEffIndex effIndex, GameObject* gameObjTarget)
{
ExecuteScript<SpellSC>([&](SpellSC* script)
{
script->OnDummyEffect(caster, spellID, effIndex, gameObjTarget);
});
}
void ScriptMgr::OnDummyEffect(WorldObject* caster, uint32 spellID, SpellEffIndex effIndex, Creature* creatureTarget)
{
ExecuteScript<SpellSC>([&](SpellSC* script)
{
script->OnDummyEffect(caster, spellID, effIndex, creatureTarget);
});
}
void ScriptMgr::OnDummyEffect(WorldObject* caster, uint32 spellID, SpellEffIndex effIndex, Item* itemTarget)
{
ExecuteScript<SpellSC>([&](SpellSC* script)
{
script->OnDummyEffect(caster, spellID, effIndex, itemTarget);
});
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
#include "SpellScript.h"
void ScriptMgr::CreateSpellScripts(uint32 spellId, std::list<SpellScript*>& scriptVector)
{
SpellScriptsBounds bounds = sObjectMgr->GetSpellScriptsBounds(spellId);
for (SpellScriptsContainer::iterator itr = bounds.first; itr != bounds.second; ++itr)
{
SpellScriptLoader* tempScript = ScriptRegistry<SpellScriptLoader>::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<AuraScript*>& scriptVector)
{
SpellScriptsBounds bounds = sObjectMgr->GetSpellScriptsBounds(spellId);
for (SpellScriptsContainer::iterator itr = bounds.first; itr != bounds.second; ++itr)
{
SpellScriptLoader* tempScript = ScriptRegistry<SpellScriptLoader>::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<std::pair<SpellScriptLoader*, SpellScriptsContainer::iterator>>& 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<SpellScriptLoader>::GetScriptById(itr->second);
if (!tempScript)
continue;
scriptVector.emplace_back(tempScript, itr);
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
#include "Transport.h"
void ScriptMgr::OnAddPassenger(Transport* transport, Player* player)
{
ASSERT(transport);
ASSERT(player);
if (auto tempScript = ScriptRegistry<TransportScript>::GetScriptById(transport->GetScriptId()))
{
tempScript->OnAddPassenger(transport, player);
}
}
void ScriptMgr::OnAddCreaturePassenger(Transport* transport, Creature* creature)
{
ASSERT(transport);
ASSERT(creature);
if (auto tempScript = ScriptRegistry<TransportScript>::GetScriptById(transport->GetScriptId()))
{
tempScript->OnAddCreaturePassenger(transport, creature);
}
}
void ScriptMgr::OnRemovePassenger(Transport* transport, Player* player)
{
ASSERT(transport);
ASSERT(player);
if (auto tempScript = ScriptRegistry<TransportScript>::GetScriptById(transport->GetScriptId()))
{
tempScript->OnRemovePassenger(transport, player);
}
}
void ScriptMgr::OnTransportUpdate(Transport* transport, uint32 diff)
{
ASSERT(transport);
if (auto tempScript = ScriptRegistry<TransportScript>::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<TransportScript>::GetScriptById(transport->GetScriptId()))
{
tempScript->OnRelocate(transport, waypointId, mapId, x, y, z);
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
uint32 ScriptMgr::DealDamage(Unit* AttackerUnit, Unit* pVictim, uint32 damage, DamageEffectType damagetype)
{
if (ScriptRegistry<UnitScript>::ScriptPointerList.empty())
{
return damage;
}
for (auto const& [scriptID, script] : ScriptRegistry<UnitScript>::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>([&](UnitScript* script)
{
script->OnHeal(healer, reciever, gain);
});
}
void ScriptMgr::OnDamage(Unit* attacker, Unit* victim, uint32& damage)
{
ExecuteScript<UnitScript>([&](UnitScript* script)
{
script->OnDamage(attacker, victim, damage);
});
}
void ScriptMgr::ModifyPeriodicDamageAurasTick(Unit* target, Unit* attacker, uint32& damage)
{
ExecuteScript<UnitScript>([&](UnitScript* script)
{
script->ModifyPeriodicDamageAurasTick(target, attacker, damage);
});
}
void ScriptMgr::ModifyMeleeDamage(Unit* target, Unit* attacker, uint32& damage)
{
ExecuteScript<UnitScript>([&](UnitScript* script)
{
script->ModifyMeleeDamage(target, attacker, damage);
});
}
void ScriptMgr::ModifySpellDamageTaken(Unit* target, Unit* attacker, int32& damage)
{
ExecuteScript<UnitScript>([&](UnitScript* script)
{
script->ModifySpellDamageTaken(target, attacker, damage);
});
}
void ScriptMgr::ModifyHealRecieved(Unit* target, Unit* attacker, uint32& damage)
{
ExecuteScript<UnitScript>([&](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>([&](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>([&](UnitScript* script)
{
script->OnAuraRemove(unit, aurApp, mode);
});
}
bool ScriptMgr::IfNormalReaction(Unit const* unit, Unit const* target, ReputationRank& repRank)
{
auto ret = IsValidBoolScript<UnitScript>([&](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>([&](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>([&](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>([&](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>([&](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>([&](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>([&](UnitScript* script)
{
script->OnUnitUpdate(unit, diff);
});
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#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<VehicleScript>::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<VehicleScript>::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<VehicleScript>::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<VehicleScript>::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<VehicleScript>::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<VehicleScript>::GetScriptById(veh->GetBase()->ToCreature()->GetScriptId()))
{
tempScript->OnRemovePassenger(veh, passenger);
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
void ScriptMgr::OnWeatherChange(Weather* weather, WeatherState state, float grade)
{
ASSERT(weather);
ExecuteScript<ElunaScript>([&](ElunaScript* script)
{
script->OnWeatherChange(weather, state, grade);
});
if (auto tempScript = ScriptRegistry<WeatherScript>::GetScriptById(weather->GetScriptId()))
{
tempScript->OnChange(weather, state, grade);
}
}
void ScriptMgr::OnWeatherUpdate(Weather* weather, uint32 diff)
{
ASSERT(weather);
if (auto tempScript = ScriptRegistry<WeatherScript>::GetScriptById(weather->GetScriptId()))
{
tempScript->OnUpdate(weather, diff);
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
void ScriptMgr::OnWorldObjectDestroy(WorldObject* object)
{
ASSERT(object);
ExecuteScript<WorldObjectScript>([&](WorldObjectScript* script)
{
script->OnWorldObjectDestroy(object);
});
}
void ScriptMgr::OnWorldObjectCreate(WorldObject* object)
{
ASSERT(object);
ExecuteScript<WorldObjectScript>([&](WorldObjectScript* script)
{
script->OnWorldObjectCreate(object);
});
}
void ScriptMgr::OnWorldObjectSetMap(WorldObject* object, Map* map)
{
ASSERT(object);
ExecuteScript<WorldObjectScript>([&](WorldObjectScript* script)
{
script->OnWorldObjectSetMap(object, map);
});
}
void ScriptMgr::OnWorldObjectResetMap(WorldObject* object)
{
ASSERT(object);
ExecuteScript<WorldObjectScript>([&](WorldObjectScript* script)
{
script->OnWorldObjectResetMap(object);
});
}
void ScriptMgr::OnWorldObjectUpdate(WorldObject* object, uint32 diff)
{
ASSERT(object);
ExecuteScript<WorldObjectScript>([&](WorldObjectScript* script)
{
script->OnWorldObjectUpdate(object, diff);
});
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
void ScriptMgr::OnOpenStateChange(bool open)
{
ExecuteScript<WorldScript>([&](WorldScript* script)
{
script->OnOpenStateChange(open);
});
}
void ScriptMgr::OnLoadCustomDatabaseTable()
{
ExecuteScript<WorldScript>([&](WorldScript* script)
{
script->OnLoadCustomDatabaseTable();
});
}
void ScriptMgr::OnBeforeConfigLoad(bool reload)
{
ExecuteScript<WorldScript>([&](WorldScript* script)
{
script->OnBeforeConfigLoad(reload);
});
}
void ScriptMgr::OnAfterConfigLoad(bool reload)
{
ExecuteScript<WorldScript>([&](WorldScript* script)
{
script->OnAfterConfigLoad(reload);
});
}
void ScriptMgr::OnBeforeFinalizePlayerWorldSession(uint32& cacheVersion)
{
ExecuteScript<WorldScript>([&](WorldScript* script)
{
script->OnBeforeFinalizePlayerWorldSession(cacheVersion);
});
}
void ScriptMgr::OnMotdChange(std::string& newMotd)
{
ExecuteScript<WorldScript>([&](WorldScript* script)
{
script->OnMotdChange(newMotd);
});
}
void ScriptMgr::OnShutdownInitiate(ShutdownExitCode code, ShutdownMask mask)
{
ExecuteScript<WorldScript>([&](WorldScript* script)
{
script->OnShutdownInitiate(code, mask);
});
}
void ScriptMgr::OnShutdownCancel()
{
ExecuteScript<WorldScript>([&](WorldScript* script)
{
script->OnShutdownCancel();
});
}
void ScriptMgr::OnWorldUpdate(uint32 diff)
{
ExecuteScript<WorldScript>([&](WorldScript* script)
{
script->OnUpdate(diff);
});
}
void ScriptMgr::OnStartup()
{
ExecuteScript<WorldScript>([&](WorldScript* script)
{
script->OnStartup();
});
}
void ScriptMgr::OnShutdown()
{
ExecuteScript<WorldScript>([&](WorldScript* script)
{
script->OnShutdown();
});
}
void ScriptMgr::OnBeforeWorldInitialized()
{
ExecuteScript<WorldScript>([&](WorldScript* script)
{
script->OnBeforeWorldInitialized();
});
}