Core/Scripting: optional modules in src/modules and generic ScriptMgr hooks (#31)
Modules: every folder in src/modules with a CMakeLists.txt is added. A module registers its library, script loader and config files with trinity_add_module(); worldserver links the generated `modules` library, whose AddModuleScripts() runs after AddScripts(). With no module it is empty and the server behaves as before. Module configs are copied to worldserver.conf.d. See src/modules/README.md. New hooks (called where nothing ran before; no cost without scripts): - WorldScript: OnWorldInitialized (world loaded, before the network starts), OnBeforeMapsUpdate (every tick, before the maps), CanCreateBattleground - PlayerScript: OnChatSent (say/yell, whisper, group, guild; after the message was sent), OnAddonMessageSent (whisper, group), OnLootItem, OnBattlegroundQueueJoin, OnBattlegroundInvite, OnBattlegroundPortFailed, OnLfgJoin (only when the join was accepted), OnLfgProposal - UnitScript: OnUnitDeath - GroupScript: OnSubgroupChange
This commit is contained in:
@@ -1541,6 +1541,16 @@ void ScriptMgr::OnWorldUpdate(uint32 diff)
|
||||
FOREACH_SCRIPT(WorldScript)->OnUpdate(diff);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnWorldBeforeMapsUpdate(uint32 diff)
|
||||
{
|
||||
FOREACH_SCRIPT(WorldScript)->OnBeforeMapsUpdate(diff);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnWorldInitialized()
|
||||
{
|
||||
FOREACH_SCRIPT(WorldScript)->OnWorldInitialized();
|
||||
}
|
||||
|
||||
void ScriptMgr::OnHonorCalculation(float& honor, uint8 level, float multiplier)
|
||||
{
|
||||
FOREACH_SCRIPT(FormulaScript)->OnHonorCalculation(honor, level, multiplier);
|
||||
@@ -1973,6 +1983,15 @@ void ScriptMgr::OnShutdown()
|
||||
FOREACH_SCRIPT(WorldScript)->OnShutdown();
|
||||
}
|
||||
|
||||
bool ScriptMgr::CanCreateBattleground(uint32 battlemasterListId, uint8 bracketId)
|
||||
{
|
||||
bool allowed = true;
|
||||
FOR_SCRIPTS_RET(WorldScript, itr, end, true)
|
||||
if (!itr->second->CanCreateBattleground(battlemasterListId, bracketId))
|
||||
allowed = false;
|
||||
return allowed;
|
||||
}
|
||||
|
||||
// Achievement
|
||||
void ScriptMgr::OnAchievementCompleted(Player* player, AchievementEntry const* achievement)
|
||||
{
|
||||
@@ -2083,6 +2102,36 @@ void ScriptMgr::OnPlayerChat(Player* player, uint32 type, uint32 lang, std::stri
|
||||
FOREACH_SCRIPT(PlayerScript)->OnChat(player, type, lang, msg, channel);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnPlayerChatSent(Player* player, uint32 type, uint32 lang, std::string const& msg)
|
||||
{
|
||||
FOREACH_SCRIPT(PlayerScript)->OnChatSent(player, type, lang, msg);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnPlayerChatSent(Player* player, uint32 type, uint32 lang, std::string const& msg, Player* receiver)
|
||||
{
|
||||
FOREACH_SCRIPT(PlayerScript)->OnChatSent(player, type, lang, msg, receiver);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnPlayerChatSent(Player* player, uint32 type, uint32 lang, std::string const& msg, Group* group)
|
||||
{
|
||||
FOREACH_SCRIPT(PlayerScript)->OnChatSent(player, type, lang, msg, group);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnPlayerChatSent(Player* player, uint32 type, uint32 lang, std::string const& msg, Guild* guild)
|
||||
{
|
||||
FOREACH_SCRIPT(PlayerScript)->OnChatSent(player, type, lang, msg, guild);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnPlayerAddonMessageSent(Player* player, uint32 type, std::string const& prefix, std::string const& text, Player* receiver)
|
||||
{
|
||||
FOREACH_SCRIPT(PlayerScript)->OnAddonMessageSent(player, type, prefix, text, receiver);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnPlayerAddonMessageSent(Player* player, uint32 type, std::string const& prefix, std::string const& text, Group* group)
|
||||
{
|
||||
FOREACH_SCRIPT(PlayerScript)->OnAddonMessageSent(player, type, prefix, text, group);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnPlayerClearEmote(Player* player)
|
||||
{
|
||||
FOREACH_SCRIPT(PlayerScript)->OnClearEmote(player);
|
||||
@@ -2153,6 +2202,36 @@ void ScriptMgr::OnMovieComplete(Player* player, uint32 movieId)
|
||||
FOREACH_SCRIPT(PlayerScript)->OnMovieComplete(player, movieId);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnPlayerLootItem(Player* player, Item* item)
|
||||
{
|
||||
FOREACH_SCRIPT(PlayerScript)->OnLootItem(player, item);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnPlayerBattlegroundQueueJoin(Player* player, uint32 bgTypeId, uint8 bracketId)
|
||||
{
|
||||
FOREACH_SCRIPT(PlayerScript)->OnBattlegroundQueueJoin(player, bgTypeId, bracketId);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnPlayerBattlegroundInvite(Player* player, uint32 instanceId, uint32 bgTypeId)
|
||||
{
|
||||
FOREACH_SCRIPT(PlayerScript)->OnBattlegroundInvite(player, instanceId, bgTypeId);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnPlayerBattlegroundPortFailed(Player* player, uint8 reason, uint32 instanceId)
|
||||
{
|
||||
FOREACH_SCRIPT(PlayerScript)->OnBattlegroundPortFailed(player, reason, instanceId);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnPlayerLfgJoin(Player* player, uint32 dungeonId, uint8 roles)
|
||||
{
|
||||
FOREACH_SCRIPT(PlayerScript)->OnLfgJoin(player, dungeonId, roles);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnPlayerLfgProposal(Player* player, uint32 proposalId)
|
||||
{
|
||||
FOREACH_SCRIPT(PlayerScript)->OnLfgProposal(player, proposalId);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnPlayerChoiceResponse(WorldObject* object, Player* player, PlayerChoice const* choice, PlayerChoiceResponse const* response, uint16 clientIdentifier)
|
||||
{
|
||||
ASSERT(choice);
|
||||
@@ -2281,6 +2360,12 @@ void ScriptMgr::OnGroupDisband(Group* group)
|
||||
FOREACH_SCRIPT(GroupScript)->OnDisband(group);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnGroupSubgroupChange(Group* group, ObjectGuid guid, uint8 subgroup)
|
||||
{
|
||||
ASSERT(group);
|
||||
FOREACH_SCRIPT(GroupScript)->OnSubgroupChange(group, guid, subgroup);
|
||||
}
|
||||
|
||||
// Unit
|
||||
void ScriptMgr::OnHeal(Unit* healer, Unit* reciever, uint32& gain)
|
||||
{
|
||||
@@ -2307,6 +2392,11 @@ void ScriptMgr::ModifySpellDamageTaken(Unit* target, Unit* attacker, int32& dama
|
||||
FOREACH_SCRIPT(UnitScript)->ModifySpellDamageTaken(target, attacker, damage, spellInfo);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnUnitDeath(Unit* victim, Unit* killer)
|
||||
{
|
||||
FOREACH_SCRIPT(UnitScript)->OnUnitDeath(victim, killer);
|
||||
}
|
||||
|
||||
// Scene
|
||||
void ScriptMgr::OnSceneStart(Player* player, uint32 sceneInstanceID, SceneTemplate const* sceneTemplate)
|
||||
{
|
||||
@@ -2470,6 +2560,14 @@ void WorldScript::OnUpdate(uint32 /*diff*/)
|
||||
{
|
||||
}
|
||||
|
||||
void WorldScript::OnBeforeMapsUpdate(uint32 /*diff*/)
|
||||
{
|
||||
}
|
||||
|
||||
void WorldScript::OnWorldInitialized()
|
||||
{
|
||||
}
|
||||
|
||||
void WorldScript::OnStartup()
|
||||
{
|
||||
}
|
||||
@@ -2478,6 +2576,11 @@ void WorldScript::OnShutdown()
|
||||
{
|
||||
}
|
||||
|
||||
bool WorldScript::CanCreateBattleground(uint32 /*battlemasterListId*/, uint8 /*bracketId*/)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
FormulaScript::FormulaScript(char const* name) noexcept
|
||||
: ScriptObject(name)
|
||||
{
|
||||
@@ -2667,6 +2770,10 @@ void UnitScript::ModifySpellDamageTaken(Unit* /*target*/, Unit* /*attacker*/, in
|
||||
{
|
||||
}
|
||||
|
||||
void UnitScript::OnUnitDeath(Unit* /*victim*/, Unit* /*killer*/)
|
||||
{
|
||||
}
|
||||
|
||||
CreatureScript::CreatureScript(char const* name) noexcept
|
||||
: ScriptObject(name)
|
||||
{
|
||||
@@ -2967,6 +3074,30 @@ void PlayerScript::OnChat(Player* /*player*/, uint32 /*type*/, uint32 /*lang*/,
|
||||
{
|
||||
}
|
||||
|
||||
void PlayerScript::OnChatSent(Player* /*player*/, uint32 /*type*/, uint32 /*lang*/, std::string const& /*msg*/)
|
||||
{
|
||||
}
|
||||
|
||||
void PlayerScript::OnChatSent(Player* /*player*/, uint32 /*type*/, uint32 /*lang*/, std::string const& /*msg*/, Player* /*receiver*/)
|
||||
{
|
||||
}
|
||||
|
||||
void PlayerScript::OnChatSent(Player* /*player*/, uint32 /*type*/, uint32 /*lang*/, std::string const& /*msg*/, Group* /*group*/)
|
||||
{
|
||||
}
|
||||
|
||||
void PlayerScript::OnChatSent(Player* /*player*/, uint32 /*type*/, uint32 /*lang*/, std::string const& /*msg*/, Guild* /*guild*/)
|
||||
{
|
||||
}
|
||||
|
||||
void PlayerScript::OnAddonMessageSent(Player* /*player*/, uint32 /*type*/, std::string const& /*prefix*/, std::string const& /*text*/, Player* /*receiver*/)
|
||||
{
|
||||
}
|
||||
|
||||
void PlayerScript::OnAddonMessageSent(Player* /*player*/, uint32 /*type*/, std::string const& /*prefix*/, std::string const& /*text*/, Group* /*group*/)
|
||||
{
|
||||
}
|
||||
|
||||
void PlayerScript::OnClearEmote(Player* /*player*/)
|
||||
{
|
||||
}
|
||||
@@ -3027,6 +3158,30 @@ void PlayerScript::OnMovieComplete(Player* /*player*/, uint32 /*movieId*/)
|
||||
{
|
||||
}
|
||||
|
||||
void PlayerScript::OnLootItem(Player* /*player*/, Item* /*item*/)
|
||||
{
|
||||
}
|
||||
|
||||
void PlayerScript::OnBattlegroundQueueJoin(Player* /*player*/, uint32 /*bgTypeId*/, uint8 /*bracketId*/)
|
||||
{
|
||||
}
|
||||
|
||||
void PlayerScript::OnBattlegroundInvite(Player* /*player*/, uint32 /*instanceId*/, uint32 /*bgTypeId*/)
|
||||
{
|
||||
}
|
||||
|
||||
void PlayerScript::OnBattlegroundPortFailed(Player* /*player*/, uint8 /*reason*/, uint32 /*instanceId*/)
|
||||
{
|
||||
}
|
||||
|
||||
void PlayerScript::OnLfgJoin(Player* /*player*/, uint32 /*dungeonId*/, uint8 /*roles*/)
|
||||
{
|
||||
}
|
||||
|
||||
void PlayerScript::OnLfgProposal(Player* /*player*/, uint32 /*proposalId*/)
|
||||
{
|
||||
}
|
||||
|
||||
AccountScript::AccountScript(char const* name) noexcept
|
||||
: ScriptObject(name)
|
||||
{
|
||||
@@ -3141,6 +3296,10 @@ void GroupScript::OnDisband(Group* /*group*/)
|
||||
{
|
||||
}
|
||||
|
||||
void GroupScript::OnSubgroupChange(Group* /*group*/, ObjectGuid /*guid*/, uint8 /*subgroup*/)
|
||||
{
|
||||
}
|
||||
|
||||
AreaTriggerEntityScript::AreaTriggerEntityScript(char const* name) noexcept
|
||||
: ScriptObject(name)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user