diff --git a/src/server/game/DungeonFinding/LFGScripts.cpp b/src/server/game/DungeonFinding/LFGScripts.cpp index cabd4543f..8a34a1478 100644 --- a/src/server/game/DungeonFinding/LFGScripts.cpp +++ b/src/server/game/DungeonFinding/LFGScripts.cpp @@ -29,7 +29,17 @@ namespace lfg { - LFGPlayerScript::LFGPlayerScript() : PlayerScript("LFGPlayerScript") { } + LFGPlayerScript::LFGPlayerScript() : + PlayerScript("LFGPlayerScript", + { + PLAYERHOOK_ON_LEVEL_CHANGED, + PLAYERHOOK_ON_LOGOUT, + PLAYERHOOK_ON_LOGIN, + PLAYERHOOK_ON_BIND_TO_INSTANCE, + PLAYERHOOK_ON_MAP_CHANGED + }) + { + } void LFGPlayerScript::OnLevelChanged(Player* player, uint8 /*oldLevel*/) { diff --git a/src/server/game/Scripting/ScriptDefines/PlayerScript.cpp b/src/server/game/Scripting/ScriptDefines/PlayerScript.cpp index 6f8a05ef5..53e79fd39 100644 --- a/src/server/game/Scripting/ScriptDefines/PlayerScript.cpp +++ b/src/server/game/Scripting/ScriptDefines/PlayerScript.cpp @@ -21,1736 +21,886 @@ void ScriptMgr::OnBeforePlayerDurabilityRepair(Player* player, ObjectGuid npcGUID, ObjectGuid itemGUID, float& discountMod, uint8 guildBank) { - ExecuteScript([&](PlayerScript* script) - { - script->OnBeforeDurabilityRepair(player, npcGUID, itemGUID, discountMod, guildBank); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_BEFORE_DURABILITY_REPAIR, script->OnBeforeDurabilityRepair(player, npcGUID, itemGUID, discountMod, guildBank)); } void ScriptMgr::OnGossipSelect(Player* player, uint32 menu_id, uint32 sender, uint32 action) { - ExecuteScript([&](PlayerScript* script) - { - script->OnGossipSelect(player, menu_id, sender, action); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_GOSSIP_SELECT, script->OnGossipSelect(player, menu_id, sender, action)); } void ScriptMgr::OnGossipSelectCode(Player* player, uint32 menu_id, uint32 sender, uint32 action, const char* code) { - ExecuteScript([&](PlayerScript* script) - { - script->OnGossipSelectCode(player, menu_id, sender, action, code); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_GOSSIP_SELECT_CODE, script->OnGossipSelectCode(player, menu_id, sender, action, code)); } void ScriptMgr::OnPlayerCompleteQuest(Player* player, Quest const* quest) { - ExecuteScript([&](PlayerScript* script) - { - script->OnPlayerCompleteQuest(player, quest); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_PLAYER_COMPLETE_QUEST, script->OnPlayerCompleteQuest(player, quest)); } void ScriptMgr::OnSendInitialPacketsBeforeAddToMap(Player* player, WorldPacket& data) { - ExecuteScript([&](PlayerScript* script) - { + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_SEND_INITIAL_PACKETS_BEFORE_ADD_TO_MAP, { script->OnSendInitialPacketsBeforeAddToMap(player, data); }); } void ScriptMgr::OnBattlegroundDesertion(Player* player, BattlegroundDesertionType const desertionType) { - ExecuteScript([&](PlayerScript* script) - { - script->OnBattlegroundDesertion(player, desertionType); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_BATTLEGROUND_DESERTION, script->OnBattlegroundDesertion(player, desertionType)); } void ScriptMgr::OnPlayerJustDied(Player* player) { - ExecuteScript([&](PlayerScript* script) - { - script->OnPlayerJustDied(player); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_PLAYER_JUST_DIED, script->OnPlayerJustDied(player)); } void ScriptMgr::OnPlayerReleasedGhost(Player* player) { - ExecuteScript([&](PlayerScript* script) - { - script->OnPlayerReleasedGhost(player); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_PLAYER_RELEASED_GHOST, script->OnPlayerReleasedGhost(player)); } bool ScriptMgr::OnCanPlayerFlyInZone(Player* player, uint32 mapId, uint32 zoneId, SpellInfo const* bySpell) { - auto ret = IsValidBoolScript([player, mapId, zoneId, bySpell](PlayerScript* script) - { - return !script->OnCanPlayerFlyInZone(player, mapId, zoneId, bySpell); - }); - - if (ret && *ret) - { - return false; - } - - return true; + CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_ON_CAN_PLAYER_FLY_IN_ZONE, !script->OnCanPlayerFlyInZone(player, mapId, zoneId, bySpell)); } void ScriptMgr::OnPVPKill(Player* killer, Player* killed) { - ExecuteScript([&](PlayerScript* script) - { - script->OnPVPKill(killer, killed); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_PVP_KILL, script->OnPVPKill(killer, killed)); } void ScriptMgr::OnPlayerPVPFlagChange(Player* player, bool state) { - ExecuteScript([&](PlayerScript* script) - { - script->OnPlayerPVPFlagChange(player, state); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_PLAYER_PVP_FLAG_CHANGE,script->OnPlayerPVPFlagChange(player, state)); } void ScriptMgr::OnCreatureKill(Player* killer, Creature* killed) { - ExecuteScript([&](PlayerScript* script) - { - script->OnCreatureKill(killer, killed); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_CREATURE_KILL,script->OnCreatureKill(killer, killed)); } void ScriptMgr::OnCreatureKilledByPet(Player* petOwner, Creature* killed) { - ExecuteScript([&](PlayerScript* script) - { - script->OnCreatureKilledByPet(petOwner, killed); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_CREATURE_KILLED_BY_PET,script->OnCreatureKilledByPet(petOwner, killed)); } void ScriptMgr::OnPlayerKilledByCreature(Creature* killer, Player* killed) { - ExecuteScript([&](PlayerScript* script) - { - script->OnPlayerKilledByCreature(killer, killed); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_PLAYER_KILLED_BY_CREATURE, script->OnPlayerKilledByCreature(killer, killed)); } void ScriptMgr::OnPlayerLevelChanged(Player* player, uint8 oldLevel) { - ExecuteScript([&](PlayerScript* script) - { - script->OnLevelChanged(player, oldLevel); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_LEVEL_CHANGED, script->OnLevelChanged(player, oldLevel)); } void ScriptMgr::OnPlayerFreeTalentPointsChanged(Player* player, uint32 points) { - ExecuteScript([&](PlayerScript* script) - { - script->OnFreeTalentPointsChanged(player, points); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_FREE_TALENT_POINTS_CHANGED, script->OnFreeTalentPointsChanged(player, points)); } void ScriptMgr::OnPlayerTalentsReset(Player* player, bool noCost) { - ExecuteScript([&](PlayerScript* script) - { - script->OnTalentsReset(player, noCost); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_TALENTS_RESET, script->OnTalentsReset(player, noCost)); } void ScriptMgr::OnAfterSpecSlotChanged(Player* player, uint8 newSlot) { - ExecuteScript([=](PlayerScript* script) - { - script->OnAfterSpecSlotChanged(player, newSlot); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_AFTER_SPEC_SLOT_CHANGED, script->OnAfterSpecSlotChanged(player, newSlot)); } void ScriptMgr::OnPlayerMoneyChanged(Player* player, int32& amount) { - ExecuteScript([&](PlayerScript* script) - { - script->OnMoneyChanged(player, amount); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_MONEY_CHANGED, script->OnMoneyChanged(player, amount)); } void ScriptMgr::OnBeforeLootMoney(Player* player, Loot* loot) { - ExecuteScript([&](PlayerScript* script) - { - script->OnBeforeLootMoney(player, loot); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_BEFORE_LOOT_MONEY, script->OnBeforeLootMoney(player, loot)); } void ScriptMgr::OnGivePlayerXP(Player* player, uint32& amount, Unit* victim, uint8 xpSource) { - ExecuteScript([&](PlayerScript* script) - { - script->OnGiveXP(player, amount, victim, xpSource); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_GIVE_EXP, script->OnGiveXP(player, amount, victim, xpSource)); } bool ScriptMgr::OnPlayerReputationChange(Player* player, uint32 factionID, int32& standing, bool incremental) { - auto ret = IsValidBoolScript([&](PlayerScript* script) - { - return !script->OnReputationChange(player, factionID, standing, incremental); - }); - - if (ret && *ret) - { - return false; - } - - return true; + CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_ON_REPUTATION_CHANGE, !script->OnReputationChange(player, factionID, standing, incremental)); } void ScriptMgr::OnPlayerReputationRankChange(Player* player, uint32 factionID, ReputationRank newRank, ReputationRank oldRank, bool increased) { - ExecuteScript([&](PlayerScript* script) - { - script->OnReputationRankChange(player, factionID, newRank, oldRank, increased); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_REPUTATION_RANK_CHANGE, script->OnReputationRankChange(player, factionID, newRank, oldRank, increased)); } void ScriptMgr::OnPlayerLearnSpell(Player* player, uint32 spellID) { - ExecuteScript([&](PlayerScript* script) - { - script->OnLearnSpell(player, spellID); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_PLAYER_LEARN_TALENTS, script->OnLearnSpell(player, spellID)); } void ScriptMgr::OnPlayerForgotSpell(Player* player, uint32 spellID) { - ExecuteScript([&](PlayerScript* script) - { - script->OnForgotSpell(player, spellID); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_FORGOT_SPELL, script->OnForgotSpell(player, spellID)); } void ScriptMgr::OnPlayerDuelRequest(Player* target, Player* challenger) { - ExecuteScript([&](PlayerScript* script) - { - script->OnDuelRequest(target, challenger); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_DUEL_REQUEST, script->OnDuelRequest(target, challenger)); } void ScriptMgr::OnPlayerDuelStart(Player* player1, Player* player2) { - ExecuteScript([&](PlayerScript* script) - { - script->OnDuelStart(player1, player2); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_DUEL_START, script->OnDuelStart(player1, player2)); } void ScriptMgr::OnPlayerDuelEnd(Player* winner, Player* loser, DuelCompleteType type) { - ExecuteScript([&](PlayerScript* script) - { - script->OnDuelEnd(winner, loser, type); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_DUEL_END, script->OnDuelEnd(winner, loser, type)); } void ScriptMgr::OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string& msg) { - ExecuteScript([&](PlayerScript* script) - { - script->OnChat(player, type, lang, msg); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_CHAT, script->OnChat(player, type, lang, msg)); } void ScriptMgr::OnBeforeSendChatMessage(Player* player, uint32& type, uint32& lang, std::string& msg) { - ExecuteScript([&](PlayerScript* script) - { - script->OnBeforeSendChatMessage(player, type, lang, msg); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_BEFORE_SEND_CHAT_MESSAGE, script->OnBeforeSendChatMessage(player, type, lang, msg)); } void ScriptMgr::OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string& msg, Player* receiver) { - ExecuteScript([&](PlayerScript* script) - { - script->OnChat(player, type, lang, msg, receiver); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_CHAT_WITH_RECEIVER, script->OnChat(player, type, lang, msg, receiver)); } void ScriptMgr::OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string& msg, Group* group) { - ExecuteScript([&](PlayerScript* script) - { - script->OnChat(player, type, lang, msg, group); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_CHAT_WITH_GROUP, script->OnChat(player, type, lang, msg, group)); } void ScriptMgr::OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string& msg, Guild* guild) { - ExecuteScript([&](PlayerScript* script) - { - script->OnChat(player, type, lang, msg, guild); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_CHAT_WITH_GUILD, script->OnChat(player, type, lang, msg, guild)); } void ScriptMgr::OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string& msg, Channel* channel) { - ExecuteScript([&](PlayerScript* script) - { - script->OnChat(player, type, lang, msg, channel); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_CHAT_WITH_CHANNEL, script->OnChat(player, type, lang, msg, channel)); } void ScriptMgr::OnPlayerEmote(Player* player, uint32 emote) { - ExecuteScript([&](PlayerScript* script) - { - script->OnEmote(player, emote); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_EMOTE, script->OnEmote(player, emote)); } void ScriptMgr::OnPlayerTextEmote(Player* player, uint32 textEmote, uint32 emoteNum, ObjectGuid guid) { - ExecuteScript([&](PlayerScript* script) - { - script->OnTextEmote(player, textEmote, emoteNum, guid); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_TEXT_EMOTE, + ( + script->OnTextEmote(player, textEmote, emoteNum, guid) + ) + ); } void ScriptMgr::OnPlayerSpellCast(Player* player, Spell* spell, bool skipCheck) { - ExecuteScript([&](PlayerScript* script) - { - script->OnSpellCast(player, spell, skipCheck); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_SPELL_CAST, script->OnSpellCast(player, spell, skipCheck)); } void ScriptMgr::OnBeforePlayerUpdate(Player* player, uint32 p_time) { - ExecuteScript([&](PlayerScript* script) - { - script->OnBeforeUpdate(player, p_time); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_BEFORE_UPDATE, script->OnBeforeUpdate(player, p_time)); } void ScriptMgr::OnPlayerUpdate(Player* player, uint32 p_time) { - ExecuteScript([&](PlayerScript* script) - { - script->OnUpdate(player, p_time); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_BEFORE_UPDATE, script->OnUpdate(player, p_time)); } void ScriptMgr::OnPlayerLogin(Player* player) { - ExecuteScript([&](PlayerScript* script) - { - script->OnLogin(player); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_LOGIN, script->OnLogin(player)); } void ScriptMgr::OnPlayerLoadFromDB(Player* player) { - ExecuteScript([&](PlayerScript* script) - { - script->OnLoadFromDB(player); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_LOAD_FROM_DB, script->OnLoadFromDB(player)); } void ScriptMgr::OnBeforePlayerLogout(Player* player) { - ExecuteScript([&](PlayerScript* script) - { - script->OnBeforeLogout(player); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_BEFORE_LOGOUT, script->OnBeforeLogout(player)); } void ScriptMgr::OnPlayerLogout(Player* player) { - ExecuteScript([&](PlayerScript* script) - { - script->OnLogout(player); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_LOGOUT, script->OnLogout(player)); } void ScriptMgr::OnPlayerCreate(Player* player) { - ExecuteScript([&](PlayerScript* script) - { - script->OnCreate(player); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_CREATE, script->OnCreate(player)); } void ScriptMgr::OnPlayerSave(Player* player) { - ExecuteScript([&](PlayerScript* script) - { - script->OnSave(player); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_SAVE, script->OnSave(player)); } void ScriptMgr::OnPlayerDelete(ObjectGuid guid, uint32 accountId) { - ExecuteScript([&](PlayerScript* script) - { - script->OnDelete(guid, accountId); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_DELETE, script->OnDelete(guid, accountId)); } void ScriptMgr::OnPlayerFailedDelete(ObjectGuid guid, uint32 accountId) { - ExecuteScript([&](PlayerScript* script) - { - script->OnFailedDelete(guid, accountId); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_FAILED_DELETE, script->OnFailedDelete(guid, accountId)); } void ScriptMgr::OnPlayerBindToInstance(Player* player, Difficulty difficulty, uint32 mapid, bool permanent) { - ExecuteScript([&](PlayerScript* script) - { - script->OnBindToInstance(player, difficulty, mapid, permanent); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_BIND_TO_INSTANCE, script->OnBindToInstance(player, difficulty, mapid, permanent)); } void ScriptMgr::OnPlayerUpdateZone(Player* player, uint32 newZone, uint32 newArea) { - ExecuteScript([&](PlayerScript* script) - { - script->OnUpdateZone(player, newZone, newArea); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_UPDATE_ZONE, script->OnUpdateZone(player, newZone, newArea)); } void ScriptMgr::OnPlayerUpdateArea(Player* player, uint32 oldArea, uint32 newArea) { - ExecuteScript([&](PlayerScript* script) - { - script->OnUpdateArea(player, oldArea, newArea); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_UPDATE_AREA, script->OnUpdateArea(player, oldArea, newArea)); } bool ScriptMgr::OnBeforePlayerTeleport(Player* player, uint32 mapid, float x, float y, float z, float orientation, uint32 options, Unit* target) { - auto ret = IsValidBoolScript([&](PlayerScript* script) - { - return !script->OnBeforeTeleport(player, mapid, x, y, z, orientation, options, target); - }); - - if (ret && *ret) - { - return false; - } - - return true; + CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_ON_BEFORE_TELEPORT, !script->OnBeforeTeleport(player, mapid, x, y, z, orientation, options, target)); } void ScriptMgr::OnPlayerUpdateFaction(Player* player) { - ExecuteScript([&](PlayerScript* script) - { - script->OnUpdateFaction(player); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_UPDATE_FACTION, script->OnUpdateFaction(player)); } void ScriptMgr::OnPlayerAddToBattleground(Player* player, Battleground* bg) { - ExecuteScript([&](PlayerScript* script) - { - script->OnAddToBattleground(player, bg); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_ADD_TO_BATTLEGROUND, script->OnAddToBattleground(player, bg)); } void ScriptMgr::OnPlayerQueueRandomDungeon(Player* player, uint32 & rDungeonId) { - ExecuteScript([&](PlayerScript* script) - { - script->OnQueueRandomDungeon(player, rDungeonId); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_QUEUE_RANDOM_DUNGEON, script->OnQueueRandomDungeon(player, rDungeonId)); } void ScriptMgr::OnPlayerRemoveFromBattleground(Player* player, Battleground* bg) { - ExecuteScript([&](PlayerScript* script) - { - script->OnRemoveFromBattleground(player, bg); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_REMOVE_FROM_BATTLEGROUND, script->OnRemoveFromBattleground(player, bg)); } bool ScriptMgr::OnBeforeAchievementComplete(Player* player, AchievementEntry const* achievement) { - auto ret = IsValidBoolScript([&](PlayerScript* script) - { - return !script->OnBeforeAchiComplete(player, achievement); - }); - - if (ret && *ret) - { - return false; - } - - return true; + CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_ON_BEFORE_ACHI_COMPLETE, !script->OnBeforeAchiComplete(player, achievement)); } void ScriptMgr::OnAchievementComplete(Player* player, AchievementEntry const* achievement) { - ExecuteScript([&](PlayerScript* script) - { - script->OnAchiComplete(player, achievement); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_ACHI_COMPLETE, script->OnAchiComplete(player, achievement)); } bool ScriptMgr::OnBeforeCriteriaProgress(Player* player, AchievementCriteriaEntry const* criteria) { - auto ret = IsValidBoolScript([&](PlayerScript* script) - { - return !script->OnBeforeCriteriaProgress(player, criteria); - }); - - if (ret && *ret) - { - return false; - } - - return true; + CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_ON_BEFORE_CRITERIA_PROGRESS, !script->OnBeforeCriteriaProgress(player, criteria)); } void ScriptMgr::OnCriteriaProgress(Player* player, AchievementCriteriaEntry const* criteria) { - ExecuteScript([&](PlayerScript* script) - { - script->OnCriteriaProgress(player, criteria); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_CRITERIA_PROGRESS, script->OnCriteriaProgress(player, criteria)); } void ScriptMgr::OnAchievementSave(CharacterDatabaseTransaction trans, Player* player, uint16 achiId, CompletedAchievementData achiData) { - ExecuteScript([&](PlayerScript* script) - { - script->OnAchiSave(trans, player, achiId, achiData); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_ACHI_SAVE, script->OnAchiSave(trans, player, achiId, achiData)); } void ScriptMgr::OnCriteriaSave(CharacterDatabaseTransaction trans, Player* player, uint16 critId, CriteriaProgress criteriaData) { - ExecuteScript([&](PlayerScript* script) - { - script->OnCriteriaSave(trans, player, critId, criteriaData); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_CRITERIA_SAVE, script->OnCriteriaSave(trans, player, critId, criteriaData)); } void ScriptMgr::OnPlayerBeingCharmed(Player* player, Unit* charmer, uint32 oldFactionId, uint32 newFactionId) { - ExecuteScript([&](PlayerScript* script) - { - script->OnBeingCharmed(player, charmer, oldFactionId, newFactionId); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_BEING_CHARMED, script->OnBeingCharmed(player, charmer, oldFactionId, newFactionId)); } void ScriptMgr::OnAfterPlayerSetVisibleItemSlot(Player* player, uint8 slot, Item* item) { - ExecuteScript([&](PlayerScript* script) - { - script->OnAfterSetVisibleItemSlot(player, slot, item); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_AFTER_SET_VISIBLE_ITEM_SLOT, script->OnAfterSetVisibleItemSlot(player, slot, item)); } void ScriptMgr::OnAfterPlayerMoveItemFromInventory(Player* player, Item* it, uint8 bag, uint8 slot, bool update) { - ExecuteScript([&](PlayerScript* script) - { - script->OnAfterMoveItemFromInventory(player, it, bag, slot, update); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_AFTER_MOVE_ITEM_FROM_INVENTORY, script->OnAfterMoveItemFromInventory(player, it, bag, slot, update)); } void ScriptMgr::OnEquip(Player* player, Item* it, uint8 bag, uint8 slot, bool update) { - ExecuteScript([&](PlayerScript* script) - { - script->OnEquip(player, it, bag, slot, update); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_EQUIP, script->OnEquip(player, it, bag, slot, update)); } void ScriptMgr::OnPlayerJoinBG(Player* player) { - ExecuteScript([&](PlayerScript* script) - { - script->OnPlayerJoinBG(player); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_PLAYER_JOIN_BG, script->OnPlayerJoinBG(player)); } void ScriptMgr::OnPlayerJoinArena(Player* player) { - ExecuteScript([&](PlayerScript* script) - { - script->OnPlayerJoinArena(player); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_PLAYER_JOIN_ARENA, script->OnPlayerJoinArena(player)); } void ScriptMgr::GetCustomGetArenaTeamId(Player const* player, uint8 slot, uint32& teamID) const { - ExecuteScript([&](PlayerScript* script) - { - script->GetCustomGetArenaTeamId(player, slot, teamID); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_GET_CUSTOM_GET_ARENA_TEAM_ID, script->GetCustomGetArenaTeamId(player, slot, teamID)); } void ScriptMgr::GetCustomArenaPersonalRating(Player const* player, uint8 slot, uint32& rating) const { - ExecuteScript([&](PlayerScript* script) - { - script->GetCustomArenaPersonalRating(player, slot, rating); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_GET_CUSTOM_ARENA_PERSONAL_RATING, script->GetCustomArenaPersonalRating(player, slot, rating)); } void ScriptMgr::OnGetMaxPersonalArenaRatingRequirement(Player const* player, uint32 minSlot, uint32& maxArenaRating) const { - ExecuteScript([&](PlayerScript* script) - { - script->OnGetMaxPersonalArenaRatingRequirement(player, minSlot, maxArenaRating); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_GET_MAX_PERSONAL_ARENA_RATING_REQUIREMENT, script->OnGetMaxPersonalArenaRatingRequirement(player, minSlot, maxArenaRating)); } void ScriptMgr::OnLootItem(Player* player, Item* item, uint32 count, ObjectGuid lootguid) { - ExecuteScript([&](PlayerScript* script) - { - script->OnLootItem(player, item, count, lootguid); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_LOOT_ITEM, script->OnLootItem(player, item, count, lootguid)); } void ScriptMgr::OnBeforeFillQuestLootItem(Player* player, LootItem& item) { - ExecuteScript([&](PlayerScript* script) - { - script->OnBeforeFillQuestLootItem(player, item); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_BEFORE_FILL_QUEST_LOOT_ITEM, script->OnBeforeFillQuestLootItem(player, item)); } void ScriptMgr::OnStoreNewItem(Player* player, Item* item, uint32 count) { - ExecuteScript([&](PlayerScript* script) - { - script->OnStoreNewItem(player, item, count); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_STORE_NEW_ITEM, script->OnStoreNewItem(player, item, count)); } void ScriptMgr::OnCreateItem(Player* player, Item* item, uint32 count) { - ExecuteScript([&](PlayerScript* script) - { - script->OnCreateItem(player, item, count); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_CREATE_ITEM, script->OnCreateItem(player, item, count)); } void ScriptMgr::OnQuestRewardItem(Player* player, Item* item, uint32 count) { - ExecuteScript([&](PlayerScript* script) - { - script->OnQuestRewardItem(player, item, count); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_QUEST_REWARD_ITEM, script->OnQuestRewardItem(player, item, count)); } bool ScriptMgr::CanPlaceAuctionBid(Player* player, AuctionEntry* auction) { - auto ret = IsValidBoolScript([&](PlayerScript *script) - { - return !script->CanPlaceAuctionBid(player, auction); - }); - - if (ret && *ret) - { - return false; - } - - return true; + CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_CAN_PLACE_AUCTION_BID, !script->CanPlaceAuctionBid(player, auction)); } void ScriptMgr::OnGroupRollRewardItem(Player* player, Item* item, uint32 count, RollVote voteType, Roll* roll) { - ExecuteScript([&](PlayerScript* script) - { - script->OnGroupRollRewardItem(player, item, count, voteType, roll); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_GROUP_ROLL_REWARD_ITEM, script->OnGroupRollRewardItem(player, item, count, voteType, roll)); } bool ScriptMgr::OnBeforeOpenItem(Player* player, Item* item) { - auto ret = IsValidBoolScript([&](PlayerScript* script) - { - return !script->OnBeforeOpenItem(player, item); - }); - - if (ret && *ret) - { - return false; - } - - return true; + CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_ON_BEFORE_OPEN_ITEM, !script->OnBeforeOpenItem(player, item)); } void ScriptMgr::OnFirstLogin(Player* player) { - ExecuteScript([&](PlayerScript* script) - { - script->OnFirstLogin(player); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_FIRST_LOGIN, script->OnFirstLogin(player)); } void ScriptMgr::OnSetMaxLevel(Player* player, uint32& maxPlayerLevel) { - ExecuteScript([&](PlayerScript* script) - { - script->OnSetMaxLevel(player, maxPlayerLevel); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_SET_MAX_LEVEL, script->OnSetMaxLevel(player, maxPlayerLevel)); } bool ScriptMgr::CanJoinInBattlegroundQueue(Player* player, ObjectGuid BattlemasterGuid, BattlegroundTypeId BGTypeID, uint8 joinAsGroup, GroupJoinBattlegroundResult& err) { - auto ret = IsValidBoolScript([&](PlayerScript* script) - { - return !script->CanJoinInBattlegroundQueue(player, BattlemasterGuid, BGTypeID, joinAsGroup, err); - }); - - if (ret && *ret) - { - return false; - } - - return true; + CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_CAN_JOIN_IN_BATTLEGROUND_QUEUE, !script->CanJoinInBattlegroundQueue(player, BattlemasterGuid, BGTypeID, joinAsGroup, err)); } bool ScriptMgr::ShouldBeRewardedWithMoneyInsteadOfExp(Player* player) { - auto ret = IsValidBoolScript([&](PlayerScript* script) - { - return script->ShouldBeRewardedWithMoneyInsteadOfExp(player); - }); - - if (ret && *ret) - { - return true; - } - - return false; + CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_SHOULD_BE_REWARDED_WITH_MONEY_INSTEAD_OF_EXP, script->ShouldBeRewardedWithMoneyInsteadOfExp(player)); } void ScriptMgr::OnBeforeTempSummonInitStats(Player* player, TempSummon* tempSummon, uint32& duration) { - ExecuteScript([&](PlayerScript* script) - { - script->OnBeforeTempSummonInitStats(player, tempSummon, duration); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_BEFORE_TEMP_SUMMON_INIT_STATS, script->OnBeforeTempSummonInitStats(player, tempSummon, duration)); } void ScriptMgr::OnBeforeGuardianInitStatsForLevel(Player* player, Guardian* guardian, CreatureTemplate const* cinfo, PetType& petType) { - ExecuteScript([&](PlayerScript* script) - { - script->OnBeforeGuardianInitStatsForLevel(player, guardian, cinfo, petType); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_BEFORE_GUARDIAN_INIT_STATS_FOR_LEVEL, script->OnBeforeGuardianInitStatsForLevel(player, guardian, cinfo, petType)); } void ScriptMgr::OnAfterGuardianInitStatsForLevel(Player* player, Guardian* guardian) { - ExecuteScript([&](PlayerScript* script) - { - script->OnAfterGuardianInitStatsForLevel(player, guardian); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_AFTER_GUARDIAN_INIT_STATS_FOR_LEVEL, script->OnAfterGuardianInitStatsForLevel(player, guardian)); } void ScriptMgr::OnBeforeLoadPetFromDB(Player* player, uint32& petentry, uint32& petnumber, bool& current, bool& forceLoadFromDB) { - ExecuteScript([&](PlayerScript* script) - { - script->OnBeforeLoadPetFromDB(player, petentry, petnumber, current, forceLoadFromDB); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_BEFORE_LOAD_PET_FROM_DB, script->OnBeforeLoadPetFromDB(player, petentry, petnumber, current, forceLoadFromDB)); } void ScriptMgr::OnBeforeBuyItemFromVendor(Player* player, ObjectGuid vendorguid, uint32 vendorslot, uint32& item, uint8 count, uint8 bag, uint8 slot) { - ExecuteScript([&](PlayerScript* script) - { - script->OnBeforeBuyItemFromVendor(player, vendorguid, vendorslot, item, count, bag, slot); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_BEFORE_BUY_ITEM_FROM_VENDOR, script->OnBeforeBuyItemFromVendor(player, vendorguid, vendorslot, item, count, bag, slot)); } void ScriptMgr::OnAfterStoreOrEquipNewItem(Player* player, uint32 vendorslot, Item* item, uint8 count, uint8 bag, uint8 slot, ItemTemplate const* pProto, Creature* pVendor, VendorItem const* crItem, bool bStore) { - ExecuteScript([&](PlayerScript* script) - { - script->OnAfterStoreOrEquipNewItem(player, vendorslot, item, count, bag, slot, pProto, pVendor, crItem, bStore); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_AFTER_STORE_OR_EQUIP_NEW_ITEM, script->OnAfterStoreOrEquipNewItem(player, vendorslot, item, count, bag, slot, pProto, pVendor, crItem, bStore)); } void ScriptMgr::OnAfterUpdateMaxPower(Player* player, Powers& power, float& value) { - ExecuteScript([&](PlayerScript* script) - { - script->OnAfterUpdateMaxPower(player, power, value); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_AFTER_UPDATE_MAX_POWER, script->OnAfterUpdateMaxPower(player, power, value)); } void ScriptMgr::OnAfterUpdateMaxHealth(Player* player, float& value) { - ExecuteScript([&](PlayerScript* script) - { - script->OnAfterUpdateMaxHealth(player, value); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_AFTER_UPDATE_MAX_HEALTH, script->OnAfterUpdateMaxHealth(player, value)); } void ScriptMgr::OnBeforeUpdateAttackPowerAndDamage(Player* player, float& level, float& val2, bool ranged) { - ExecuteScript([&](PlayerScript* script) - { - script->OnBeforeUpdateAttackPowerAndDamage(player, level, val2, ranged); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_BEFORE_UPDATE_ATTACK_POWER_AND_DAMAGE, script->OnBeforeUpdateAttackPowerAndDamage(player, level, val2, ranged)); } void ScriptMgr::OnAfterUpdateAttackPowerAndDamage(Player* player, float& level, float& base_attPower, float& attPowerMod, float& attPowerMultiplier, bool ranged) { - ExecuteScript([&](PlayerScript* script) - { - script->OnAfterUpdateAttackPowerAndDamage(player, level, base_attPower, attPowerMod, attPowerMultiplier, ranged); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_AFTER_UPDATE_ATTACK_POWER_AND_DAMAGE, script->OnAfterUpdateAttackPowerAndDamage(player, level, base_attPower, attPowerMod, attPowerMultiplier, ranged)); } void ScriptMgr::OnBeforeInitTalentForLevel(Player* player, uint8& level, uint32& talentPointsForLevel) { - ExecuteScript([&](PlayerScript* script) - { - script->OnBeforeInitTalentForLevel(player, level, talentPointsForLevel); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_BEFORE_INIT_TALENT_FOR_LEVEL, script->OnBeforeInitTalentForLevel(player, level, talentPointsForLevel)); } + bool ScriptMgr::OnBeforePlayerQuestComplete(Player* player, uint32 quest_id) { - auto ret = IsValidBoolScript([&](PlayerScript* script) - { - return !script->OnBeforeQuestComplete(player, quest_id); - }); - - if (ret && *ret) - { - return false; - } - - return true; + CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_ON_BEFORE_QUEST_COMPLETE, !script->OnBeforeQuestComplete(player, quest_id)); } + void ScriptMgr::OnQuestComputeXP(Player* player, Quest const* quest, uint32& xpValue) { - ExecuteScript([&](PlayerScript* script) - { - script->OnQuestComputeXP(player, quest, xpValue); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_QUEST_COMPUTE_EXP, script->OnQuestComputeXP(player, quest, xpValue)); } void ScriptMgr::OnBeforeStoreOrEquipNewItem(Player* player, uint32 vendorslot, uint32& item, uint8 count, uint8 bag, uint8 slot, ItemTemplate const* pProto, Creature* pVendor, VendorItem const* crItem, bool bStore) { - ExecuteScript([&](PlayerScript* script) - { - script->OnBeforeStoreOrEquipNewItem(player, vendorslot, item, count, bag, slot, pProto, pVendor, crItem, bStore); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_BEFORE_STORE_OR_EQUIP_NEW_ITEM, script->OnBeforeStoreOrEquipNewItem(player, vendorslot, item, count, bag, slot, pProto, pVendor, crItem, bStore)); } bool ScriptMgr::CanJoinInArenaQueue(Player* player, ObjectGuid BattlemasterGuid, uint8 arenaslot, BattlegroundTypeId BGTypeID, uint8 joinAsGroup, uint8 IsRated, GroupJoinBattlegroundResult& err) { - auto ret = IsValidBoolScript([&](PlayerScript* script) - { - return !script->CanJoinInArenaQueue(player, BattlemasterGuid, arenaslot, BGTypeID, joinAsGroup, IsRated, err); - }); - - if (ret && *ret) - { - return false; - } - - return true; + CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_CAN_JOIN_IN_ARENA_QUEUE, !script->CanJoinInArenaQueue(player, BattlemasterGuid, arenaslot, BGTypeID, joinAsGroup, IsRated, err)); } bool ScriptMgr::CanBattleFieldPort(Player* player, uint8 arenaType, BattlegroundTypeId BGTypeID, uint8 action) { - auto ret = IsValidBoolScript([&](PlayerScript* script) - { - return !script->CanBattleFieldPort(player, arenaType, BGTypeID, action); - }); - - if (ret && *ret) - { - return false; - } - - return true; + CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_CAN_BATTLEFIELD_PORT, !script->CanBattleFieldPort(player, arenaType, BGTypeID, action)); } bool ScriptMgr::CanGroupInvite(Player* player, std::string& membername) { - auto ret = IsValidBoolScript([&](PlayerScript* script) - { - return !script->CanGroupInvite(player, membername); - }); - - if (ret && *ret) - { - return false; - } - - return true; + CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_CAN_GROUP_INVITE, !script->CanGroupInvite(player, membername)); } bool ScriptMgr::CanGroupAccept(Player* player, Group* group) { - auto ret = IsValidBoolScript([&](PlayerScript* script) - { - return !script->CanGroupAccept(player, group); - }); - - if (ret && *ret) - { - return false; - } - - return true; + CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_CAN_GROUP_ACCEPT, !script->CanGroupAccept(player, group)); } bool ScriptMgr::CanSellItem(Player* player, Item* item, Creature* creature) { - auto ret = IsValidBoolScript([&](PlayerScript* script) - { - return !script->CanSellItem(player, item, creature); - }); - - if (ret && *ret) - { - return false; - } - - return true; + CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_CAN_SELL_ITEM, !script->CanSellItem(player, item, creature)); } bool ScriptMgr::CanSendMail(Player* player, ObjectGuid receiverGuid, ObjectGuid mailbox, std::string& subject, std::string& body, uint32 money, uint32 COD, Item* item) { - auto ret = IsValidBoolScript([&](PlayerScript* script) - { - return !script->CanSendMail(player, receiverGuid, mailbox, subject, body, money, COD, item); - }); - - if (ret && *ret) - { - return false; - } - - return true; + CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_CAN_SEND_MAIL, !script->CanSendMail(player, receiverGuid, mailbox, subject, body, money, COD, item)); } bool ScriptMgr::CanSendErrorAlreadyLooted(Player* player) { - auto ret = IsValidBoolScript([&](PlayerScript* script) - { - return !script->CanSendErrorAlreadyLooted(player); - }); - - if (ret && *ret) - { - return false; - } - - return true; + CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_CAN_SEND_ERROR_ALREADY_LOOTED, !script->CanSendErrorAlreadyLooted(player)); } void ScriptMgr::OnAfterCreatureLoot(Player* player) { - ExecuteScript([&](PlayerScript* script) - { - script->OnAfterCreatureLoot(player); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_AFTER_CREATURE_LOOT, script->OnAfterCreatureLoot(player)); } void ScriptMgr::OnAfterCreatureLootMoney(Player* player) { - ExecuteScript([&](PlayerScript* script) - { - script->OnAfterCreatureLootMoney(player); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_AFTER_CREATURE_LOOT_MONEY, script->OnAfterCreatureLootMoney(player)); } void ScriptMgr::PetitionBuy(Player* player, Creature* creature, uint32& charterid, uint32& cost, uint32& type) { - ExecuteScript([&](PlayerScript* script) - { - script->PetitionBuy(player, creature, charterid, cost, type); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_PETITION_BUY, script->PetitionBuy(player, creature, charterid, cost, type)); } void ScriptMgr::PetitionShowList(Player* player, Creature* creature, uint32& CharterEntry, uint32& CharterDispayID, uint32& CharterCost) { - ExecuteScript([&](PlayerScript* script) - { - script->PetitionShowList(player, creature, CharterEntry, CharterDispayID, CharterCost); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_PETITION_SHOW_LIST, script->PetitionShowList(player, creature, CharterEntry, CharterDispayID, CharterCost)); } void ScriptMgr::OnRewardKillRewarder(Player* player, KillRewarder* rewarder, bool isDungeon, float& rate) { - ExecuteScript([&](PlayerScript* script) - { - script->OnRewardKillRewarder(player, rewarder, isDungeon, rate); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_REWARD_KILL_REWARDER, script->OnRewardKillRewarder(player, rewarder, isDungeon, rate)); } bool ScriptMgr::CanGiveMailRewardAtGiveLevel(Player* player, uint8 level) { - auto ret = IsValidBoolScript([&](PlayerScript* script) - { - return !script->CanGiveMailRewardAtGiveLevel(player, level); - }); - - if (ret && *ret) - { - return false; - } - - return true; + CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_CAN_GIVE_MAIL_REWARD_AT_GIVE_LEVEL, !script->CanGiveMailRewardAtGiveLevel(player, level)); } void ScriptMgr::OnDeleteFromDB(CharacterDatabaseTransaction trans, uint32 guid) { - ExecuteScript([&](PlayerScript* script) - { - script->OnDeleteFromDB(trans, guid); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_DELETE_FROM_DB, script->OnDeleteFromDB(trans, guid)); } bool ScriptMgr::CanRepopAtGraveyard(Player* player) { - auto ret = IsValidBoolScript([&](PlayerScript* script) - { - return !script->CanRepopAtGraveyard(player); - }); - - if (ret && *ret) - { - return false; - } - - return true; + CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_CAN_REPOP_AT_GRAVEYARD, !script->CanRepopAtGraveyard(player)); } Optional ScriptMgr::OnPlayerIsClass(Player const* player, Classes unitClass, ClassContext context) { - if (ScriptRegistry::ScriptPointerList.empty()) + if (ScriptRegistry::EnabledHooks[PLAYERHOOK_ON_PLAYER_IS_CLASS].empty()) return {}; - for (auto const& [scriptID, script] : ScriptRegistry::ScriptPointerList) + + for (auto const& script : ScriptRegistry::EnabledHooks[PLAYERHOOK_ON_PLAYER_IS_CLASS]) { Optional scriptResult = script->OnPlayerIsClass(player, unitClass, context); if (scriptResult) return scriptResult; } + return {}; } void ScriptMgr::OnGetMaxSkillValue(Player* player, uint32 skill, int32& result, bool IsPure) { - ExecuteScript([&](PlayerScript* script) - { - script->OnGetMaxSkillValue(player, skill, result, IsPure); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_GET_MAX_SKILL_VALUE, script->OnGetMaxSkillValue(player, skill, result, IsPure)); } bool ScriptMgr::OnPlayerHasActivePowerType(Player const* player, Powers power) { - auto ret = IsValidBoolScript([&](PlayerScript* script) - { - return script->OnPlayerHasActivePowerType(player, power); - }); - - if (ret && *ret) - { - return true; - } - - return false; + CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_ON_PLAYER_HAS_ACTIVE_POWER_TYPE, !script->OnPlayerHasActivePowerType(player, power)); } void ScriptMgr::OnUpdateGatheringSkill(Player *player, uint32 skillId, uint32 currentLevel, uint32 gray, uint32 green, uint32 yellow, uint32 &gain) { - ExecuteScript([&](PlayerScript* script) - { - script->OnUpdateGatheringSkill(player, skillId, currentLevel, gray, green, yellow, gain); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_UPDATE_GATHERING_SKILL, script->OnUpdateGatheringSkill(player, skillId, currentLevel, gray, green, yellow, gain)); } void ScriptMgr::OnUpdateCraftingSkill(Player *player, SkillLineAbilityEntry const* skill, uint32 currentLevel, uint32& gain) { - ExecuteScript([&](PlayerScript* script) - { - script->OnUpdateCraftingSkill(player, skill, currentLevel, gain); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_UPDATE_CRAFTING_SKILL, script->OnUpdateCraftingSkill(player, skill, currentLevel, gain)); } bool ScriptMgr::OnUpdateFishingSkill(Player* player, int32 skill, int32 zone_skill, int32 chance, int32 roll) { - auto ret = IsValidBoolScript([&](PlayerScript* script) - { - return !script->OnUpdateFishingSkill(player, skill, zone_skill, chance, roll); - }); - - if (ret && *ret) - { - return false; - } - - return true; + CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_ON_UPDATE_FISHING_SKILL, !script->OnUpdateFishingSkill(player, skill, zone_skill, chance, roll)); } bool ScriptMgr::CanAreaExploreAndOutdoor(Player* player) { - auto ret = IsValidBoolScript([&](PlayerScript* script) - { - return !script->CanAreaExploreAndOutdoor(player); - }); - - if (ret && *ret) - { - return false; - } - - return true; + CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_CAN_AREA_EXPLORE_AND_OUTDOOR, !script->CanAreaExploreAndOutdoor(player)); } void ScriptMgr::OnVictimRewardBefore(Player* player, Player* victim, uint32& killer_title, uint32& victim_title) { - ExecuteScript([&](PlayerScript* script) - { - script->OnVictimRewardBefore(player, victim, killer_title, victim_title); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_VICTIM_REWARD_BEFORE, script->OnVictimRewardBefore(player, victim, killer_title, victim_title)); } void ScriptMgr::OnVictimRewardAfter(Player* player, Player* victim, uint32& killer_title, uint32& victim_rank, float& honor_f) { - ExecuteScript([&](PlayerScript* script) - { - script->OnVictimRewardAfter(player, victim, killer_title, victim_rank, honor_f); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_VICTIM_REWARD_AFTER, script->OnVictimRewardAfter(player, victim, killer_title, victim_rank, honor_f)); } void ScriptMgr::OnCustomScalingStatValueBefore(Player* player, ItemTemplate const* proto, uint8 slot, bool apply, uint32& CustomScalingStatValue) { - ExecuteScript([&](PlayerScript* script) - { - script->OnCustomScalingStatValueBefore(player, proto, slot, apply, CustomScalingStatValue); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_CUSTOM_SCALING_STAT_VALUE_BEFORE, script->OnCustomScalingStatValueBefore(player, proto, slot, apply, CustomScalingStatValue)); } void ScriptMgr::OnCustomScalingStatValue(Player* player, ItemTemplate const* proto, uint32& statType, int32& val, uint8 itemProtoStatNumber, uint32 ScalingStatValue, ScalingStatValuesEntry const* ssv) { - ExecuteScript([&](PlayerScript* script) - { - script->OnCustomScalingStatValue(player, proto, statType, val, itemProtoStatNumber, ScalingStatValue, ssv); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_CUSTOM_SCALING_STAT_VALUE, script->OnCustomScalingStatValue(player, proto, statType, val, itemProtoStatNumber, ScalingStatValue, ssv)); } bool ScriptMgr::CanArmorDamageModifier(Player* player) { - auto ret = IsValidBoolScript([&](PlayerScript* script) - { - return !script->CanArmorDamageModifier(player); - }); - - if (ret && *ret) - { - return false; - } - - return true; + CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_CAN_ARMOR_DAMAGE_MODIFIER, !script->CanArmorDamageModifier(player)); } void ScriptMgr::OnGetFeralApBonus(Player* player, int32& feral_bonus, int32 dpsMod, ItemTemplate const* proto, ScalingStatValuesEntry const* ssv) { - ExecuteScript([&](PlayerScript* script) - { - script->OnGetFeralApBonus(player, feral_bonus, dpsMod, proto, ssv); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_GET_FERAL_AP_BONUS, script->OnGetFeralApBonus(player, feral_bonus, dpsMod, proto, ssv)); } bool ScriptMgr::CanApplyWeaponDependentAuraDamageMod(Player* player, Item* item, WeaponAttackType attackType, AuraEffect const* aura, bool apply) { - auto ret = IsValidBoolScript([&](PlayerScript* script) - { - return !script->CanApplyWeaponDependentAuraDamageMod(player, item, attackType, aura, apply); - }); - - if (ret && *ret) - { - return false; - } - - return true; + CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_CAN_APPLY_WEAPON_DEPENDENT_AURA_DAMAGE_MOD, !script->CanApplyWeaponDependentAuraDamageMod(player, item, attackType, aura, apply)); } bool ScriptMgr::CanApplyEquipSpell(Player* player, SpellInfo const* spellInfo, Item* item, bool apply, bool form_change) { - auto ret = IsValidBoolScript([&](PlayerScript* script) - { - return !script->CanApplyEquipSpell(player, spellInfo, item, apply, form_change); - }); - - if (ret && *ret) - { - return false; - } - - return true; + CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_CAN_APPLY_EQUIP_SPELL, !script->CanApplyEquipSpell(player, spellInfo, item, apply, form_change)); } bool ScriptMgr::CanApplyEquipSpellsItemSet(Player* player, ItemSetEffect* eff) { - auto ret = IsValidBoolScript([&](PlayerScript* script) - { - return !script->CanApplyEquipSpellsItemSet(player, eff); - }); - - if (ret && *ret) - { - return false; - } - - return true; + CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_CAN_APPLY_EQUIP_SPELLS_ITEM_SET, !script->CanApplyEquipSpellsItemSet(player, eff)); } bool ScriptMgr::CanCastItemCombatSpell(Player* player, Unit* target, WeaponAttackType attType, uint32 procVictim, uint32 procEx, Item* item, ItemTemplate const* proto) { - auto ret = IsValidBoolScript([&](PlayerScript* script) - { - return !script->CanCastItemCombatSpell(player, target, attType, procVictim, procEx, item, proto); - }); - - if (ret && *ret) - { - return false; - } - - return true; + CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_CAN_CAST_ITEM_COMBAT_SPELL, !script->CanCastItemCombatSpell(player, target, attType, procVictim, procEx, item, proto)); } bool ScriptMgr::CanCastItemUseSpell(Player* player, Item* item, SpellCastTargets const& targets, uint8 cast_count, uint32 glyphIndex) { - auto ret = IsValidBoolScript([&](PlayerScript* script) - { - return !script->CanCastItemUseSpell(player, item, targets, cast_count, glyphIndex); - }); - - if (ret && *ret) - { - return false; - } - - return true; + CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_CAN_CAST_ITEM_USE_SPELL, !script->CanCastItemUseSpell(player, item, targets, cast_count, glyphIndex)); } void ScriptMgr::OnApplyAmmoBonuses(Player* player, ItemTemplate const* proto, float& currentAmmoDPS) { - ExecuteScript([&](PlayerScript* script) - { - script->OnApplyAmmoBonuses(player, proto, currentAmmoDPS); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_APPLY_AMMO_BONUSES, script->OnApplyAmmoBonuses(player, proto, currentAmmoDPS)); } bool ScriptMgr::CanEquipItem(Player* player, uint8 slot, uint16& dest, Item* pItem, bool swap, bool not_loading) { - auto ret = IsValidBoolScript([&](PlayerScript* script) - { - return !script->CanEquipItem(player, slot, dest, pItem, swap, not_loading); - }); - - if (ret && *ret) - { - return false; - } - - return true; + CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_CAN_EQUIP_ITEM, !script->CanEquipItem(player, slot, dest, pItem, swap, not_loading)); } bool ScriptMgr::CanUnequipItem(Player* player, uint16 pos, bool swap) { - auto ret = IsValidBoolScript([&](PlayerScript* script) - { - return !script->CanUnequipItem(player, pos, swap); - }); - - if (ret && *ret) - { - return false; - } - - return true; + CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_CAN_UNEQUIP_ITEM, !script->CanUnequipItem(player, pos, swap)); } bool ScriptMgr::CanUseItem(Player* player, ItemTemplate const* proto, InventoryResult& result) { - auto ret = IsValidBoolScript([&](PlayerScript* script) - { - return !script->CanUseItem(player, proto, result); - }); - - if (ret && *ret) - { - return false; - } - - return true; + CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_CAN_USE_ITEM, !script->CanUseItem(player, proto, result)); } bool ScriptMgr::CanSaveEquipNewItem(Player* player, Item* item, uint16 pos, bool update) { - auto ret = IsValidBoolScript([&](PlayerScript* script) - { - return !script->CanSaveEquipNewItem(player, item, pos, update); - }); - - if (ret && *ret) - { - return false; - } - - return true; + CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_CAN_SAVE_EQUIP_NEW_ITEM, !script->CanSaveEquipNewItem(player, item, pos, update)); } bool ScriptMgr::CanApplyEnchantment(Player* player, Item* item, EnchantmentSlot slot, bool apply, bool apply_dur, bool ignore_condition) { - auto ret = IsValidBoolScript([&](PlayerScript* script) - { - return !script->CanApplyEnchantment(player, item, slot, apply, apply_dur, ignore_condition); - }); - - if (ret && *ret) - { - return false; - } - - return true; + CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_CAN_APPLY_ENCHANTMENT, !script->CanApplyEnchantment(player, item, slot, apply, apply_dur, ignore_condition)); } void ScriptMgr::OnGetQuestRate(Player* player, float& result) { - ExecuteScript([&](PlayerScript* script) - { - script->OnGetQuestRate(player, result); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_GET_QUEST_RATE, script->OnGetQuestRate(player, result)); } bool ScriptMgr::PassedQuestKilledMonsterCredit(Player* player, Quest const* qinfo, uint32 entry, uint32 real_entry, ObjectGuid guid) { - auto ret = IsValidBoolScript([&](PlayerScript* script) - { - return !script->PassedQuestKilledMonsterCredit(player, qinfo, entry, real_entry, guid); - }); - - if (ret && *ret) - { - return false; - } - - return true; + CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_PASSED_QUEST_KILLED_MONSTER_CREDIT, !script->PassedQuestKilledMonsterCredit(player, qinfo, entry, real_entry, guid)); } bool ScriptMgr::CheckItemInSlotAtLoadInventory(Player* player, Item* item, uint8 slot, uint8& err, uint16& dest) { - auto ret = IsValidBoolScript([&](PlayerScript* script) - { - return !script->CheckItemInSlotAtLoadInventory(player, item, slot, err, dest); - }); - - if (ret && *ret) - { - return false; - } - - return true; + CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_CHECK_ITEM_IN_SLOT_AT_LOAD_INVENTORY, !script->CheckItemInSlotAtLoadInventory(player, item, slot, err, dest)); } bool ScriptMgr::NotAvoidSatisfy(Player* player, DungeonProgressionRequirements const* ar, uint32 target_map, bool report) { - auto ret = IsValidBoolScript([&](PlayerScript* script) - { - return !script->NotAvoidSatisfy(player, ar, target_map, report); - }); - - if (ret && *ret) - { - return false; - } - - return true; + CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_NOT_AVOID_SATISFY, !script->NotAvoidSatisfy(player, ar, target_map, report)); } bool ScriptMgr::NotVisibleGloballyFor(Player* player, Player const* u) { - auto ret = IsValidBoolScript([&](PlayerScript* script) - { - return !script->NotVisibleGloballyFor(player, u); - }); - - if (ret && *ret) - { - return false; - } - - return true; + CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_NOT_VISIBLE_GLOBALLY_FOR, !script->NotVisibleGloballyFor(player, u)); } void ScriptMgr::OnGetArenaPersonalRating(Player* player, uint8 slot, uint32& result) { - ExecuteScript([&](PlayerScript* script) - { - script->OnGetArenaPersonalRating(player, slot, result); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_GET_ARENA_PERSONAL_RATING, script->OnGetArenaPersonalRating(player, slot, result)); } void ScriptMgr::OnGetArenaTeamId(Player* player, uint8 slot, uint32& result) { - ExecuteScript([&](PlayerScript* script) - { - script->OnGetArenaTeamId(player, slot, result); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_GET_ARENA_TEAM_ID, script->OnGetArenaTeamId(player, slot, result)); } -//Signifies that IsFfaPvp has been called. void ScriptMgr::OnIsFFAPvP(Player* player, bool& result) { - ExecuteScript([&](PlayerScript* script) - { - script->OnIsFFAPvP(player, result); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_IS_FFA_PVP, script->OnIsFFAPvP(player, result)); } -//Fires whenever the UNIT_BYTE2_FLAG_FFA_PVP bit is Changed + void ScriptMgr::OnFfaPvpStateUpdate(Player* player, bool result) { - ExecuteScript([&](PlayerScript* script) - { - script->OnFfaPvpStateUpdate(player, result); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_FFA_PVP_STATE_UPDATE, script->OnFfaPvpStateUpdate(player, result)); } void ScriptMgr::OnIsPvP(Player* player, bool& result) { - ExecuteScript([&](PlayerScript* script) - { + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_IS_PVP, { script->OnIsPvP(player, result); }); } void ScriptMgr::OnGetMaxSkillValueForLevel(Player* player, uint16& result) { - ExecuteScript([&](PlayerScript* script) - { + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_GET_MAX_SKILL_VALUE_FOR_LEVEL, { script->OnGetMaxSkillValueForLevel(player, result); }); } bool ScriptMgr::NotSetArenaTeamInfoField(Player* player, uint8 slot, ArenaTeamInfoType type, uint32 value) { - auto ret = IsValidBoolScript([&](PlayerScript* script) - { - return !script->NotSetArenaTeamInfoField(player, slot, type, value); - }); - - if (ret && *ret) - { - return false; - } - - return true; + CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_NOT_SET_ARENA_TEAM_INFO_FIELD, !script->NotSetArenaTeamInfoField(player, slot, type, value)); } bool ScriptMgr::CanJoinLfg(Player* player, uint8 roles, lfg::LfgDungeonSet& dungeons, const std::string& comment) { - auto ret = IsValidBoolScript([&](PlayerScript* script) - { - return !script->CanJoinLfg(player, roles, dungeons, comment); - }); - - if (ret && *ret) - { - return false; - } - - return true; + CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_CAN_JOIN_LFG, !script->CanJoinLfg(player, roles, dungeons, comment)); } bool ScriptMgr::CanEnterMap(Player* player, MapEntry const* entry, InstanceTemplate const* instance, MapDifficulty const* mapDiff, bool loginCheck) { - auto ret = IsValidBoolScript([&](PlayerScript* script) - { - return !script->CanEnterMap(player, entry, instance, mapDiff, loginCheck); - }); - - if (ret && *ret) - { - return false; - } - - return true; + CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_CAN_ENTER_MAP, !script->CanEnterMap(player, entry, instance, mapDiff, loginCheck)); } bool ScriptMgr::CanInitTrade(Player* player, Player* target) { - auto ret = IsValidBoolScript([&](PlayerScript* script) - { - return !script->CanInitTrade(player, target); - }); - - if (ret && *ret) - { - return false; - } - - return true; + CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_CAN_INIT_TRADE, !script->CanInitTrade(player, target)); } bool ScriptMgr::CanSetTradeItem(Player* player, Item* tradedItem, uint8 tradeSlot) { - auto ret = IsValidBoolScript([&](PlayerScript* script) - { - return !script->CanSetTradeItem(player, tradedItem, tradeSlot); - }); - - if (ret && *ret) - return false; - - return true; + CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_CAN_SET_TRADE_ITEM, !script->CanSetTradeItem(player, tradedItem, tradeSlot)); } void ScriptMgr::OnSetServerSideVisibility(Player* player, ServerSideVisibilityType& type, AccountTypes& sec) { - ExecuteScript([&](PlayerScript* script) - { - script->OnSetServerSideVisibility(player, type, sec); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_SET_SERVER_SIDE_VISIBILITY, script->OnSetServerSideVisibility(player, type, sec)); } void ScriptMgr::OnSetServerSideVisibilityDetect(Player* player, ServerSideVisibilityType& type, AccountTypes& sec) { - ExecuteScript([&](PlayerScript* script) - { - script->OnSetServerSideVisibilityDetect(player, type, sec); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_SET_SERVER_SIDE_VISIBILITY_DETECT, script->OnSetServerSideVisibilityDetect(player, type, sec)); } -//void ScriptMgr::OnGiveHonorPoints(Player* player, float& honor, Unit* victim) -//{ -// ExecuteScript([&](PlayerScript* script) -// { -// script->OnGiveHonorPoints(player, honor, victim); -// }); -//} -// -//void ScriptMgr::OnAfterResurrect(Player* player, float restore_percent, bool applySickness) -//{ -// ExecuteScript([&](PlayerScript* script) -// { -// script->OnAfterResurrect(player, restore_percent, applySickness); -// }); -//} - void ScriptMgr::OnPlayerResurrect(Player* player, float restore_percent, bool applySickness) { - ExecuteScript([&](PlayerScript* script) - { - script->OnPlayerResurrect(player, restore_percent, applySickness); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_PLAYER_RESURRECT, script->OnPlayerResurrect(player, restore_percent, applySickness)); } void ScriptMgr::OnBeforeChooseGraveyard(Player* player, TeamId teamId, bool nearCorpse, uint32& graveyardOverride) { - ExecuteScript([&](PlayerScript* script) - { - script->OnBeforeChooseGraveyard(player, teamId, nearCorpse, graveyardOverride); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_BEFORE_CHOOSE_GRAVEYARD, script->OnBeforeChooseGraveyard(player, teamId, nearCorpse, graveyardOverride)); } bool ScriptMgr::CanPlayerUseChat(Player* player, uint32 type, uint32 language, std::string& msg) { - auto ret = IsValidBoolScript([&](PlayerScript* script) - { - return !script->CanPlayerUseChat(player, type, language, msg); - }); - - if (ret && *ret) - { - return false; - } - - return true; + CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_CAN_PLAYER_USE_CHAT, !script->CanPlayerUseChat(player, type, language, msg)); } bool ScriptMgr::CanPlayerUseChat(Player* player, uint32 type, uint32 language, std::string& msg, Player* receiver) { - auto ret = IsValidBoolScript([&](PlayerScript* script) - { - return !script->CanPlayerUseChat(player, type, language, msg, receiver); - }); - - if (ret && *ret) - { - return false; - } - - return true; + CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_CAN_PLAYER_USE_PRIVATE_CHAT, !script->CanPlayerUseChat(player, type, language, msg, receiver)); } bool ScriptMgr::CanPlayerUseChat(Player* player, uint32 type, uint32 language, std::string& msg, Group* group) { - auto ret = IsValidBoolScript([&](PlayerScript* script) - { - return !script->CanPlayerUseChat(player, type, language, msg, group); - }); - - if (ret && *ret) - { - return false; - } - - return true; + CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_CAN_PLAYER_USE_GROUP_CHAT, !script->CanPlayerUseChat(player, type, language, msg, group)); } bool ScriptMgr::CanPlayerUseChat(Player* player, uint32 type, uint32 language, std::string& msg, Guild* guild) { - auto ret = IsValidBoolScript([&](PlayerScript* script) - { - return !script->CanPlayerUseChat(player, type, language, msg, guild); - }); - - if (ret && *ret) - { - return false; - } - - return true; + CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_CAN_PLAYER_USE_GUILD_CHAT, !script->CanPlayerUseChat(player, type, language, msg, guild)); } bool ScriptMgr::CanPlayerUseChat(Player* player, uint32 type, uint32 language, std::string& msg, Channel* channel) { - auto ret = IsValidBoolScript([&](PlayerScript* script) - { - return !script->CanPlayerUseChat(player, type, language, msg, channel); - }); - - if (ret && *ret) - { - return false; - } - - return true; + CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_CAN_PLAYER_USE_CHANNEL_CHAT, !script->CanPlayerUseChat(player, type, language, msg, channel)); } void ScriptMgr::OnPlayerLearnTalents(Player* player, uint32 talentId, uint32 talentRank, uint32 spellid) { - ExecuteScript([&](PlayerScript* script) - { - script->OnPlayerLearnTalents(player, talentId, talentRank, spellid); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_PLAYER_LEARN_TALENTS, script->OnPlayerLearnTalents(player, talentId, talentRank, spellid)); } void ScriptMgr::OnPlayerEnterCombat(Player* player, Unit* enemy) { - ExecuteScript([&](PlayerScript* script) - { - script->OnPlayerEnterCombat(player, enemy); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_PLAYER_ENTER_COMBAT, script->OnPlayerEnterCombat(player, enemy)); } void ScriptMgr::OnPlayerLeaveCombat(Player* player) { - ExecuteScript([&](PlayerScript* script) - { - script->OnPlayerLeaveCombat(player); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_PLAYER_LEAVE_COMBAT, script->OnPlayerLeaveCombat(player)); } void ScriptMgr::OnQuestAbandon(Player* player, uint32 questId) { - ExecuteScript([&](PlayerScript* script) - { - script->OnQuestAbandon(player, questId); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_QUEST_ABANDON, script->OnQuestAbandon(player, questId)); } // Player anti cheat void ScriptMgr::AnticheatSetCanFlybyServer(Player* player, bool apply) { - ExecuteScript([&](PlayerScript* script) - { - script->AnticheatSetCanFlybyServer(player, apply); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ANTICHEAT_SET_CAN_FLY_BY_SERVER, script->AnticheatSetCanFlybyServer(player, apply)); } void ScriptMgr::AnticheatSetUnderACKmount(Player* player) { - ExecuteScript([&](PlayerScript* script) - { - script->AnticheatSetUnderACKmount(player); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ANTICHEAT_SET_UNDER_ACK_MOUNT, script->AnticheatSetUnderACKmount(player)); } void ScriptMgr::AnticheatSetRootACKUpd(Player* player) { - ExecuteScript([&](PlayerScript* script) - { - script->AnticheatSetRootACKUpd(player); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ANTICHEAT_SET_ROOT_ACK_UPD, script->AnticheatSetRootACKUpd(player)); } void ScriptMgr::AnticheatSetJumpingbyOpcode(Player* player, bool jump) { - ExecuteScript([&](PlayerScript* script) - { - script->AnticheatSetJumpingbyOpcode(player, jump); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ANTICHEAT_SET_JUMPING_BY_OPCODE, script->AnticheatSetJumpingbyOpcode(player, jump)); } void ScriptMgr::AnticheatUpdateMovementInfo(Player* player, MovementInfo const& movementInfo) { - ExecuteScript([&](PlayerScript* script) - { - script->AnticheatUpdateMovementInfo(player, movementInfo); - }); + CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ANTICHEAT_UPDATE_MOVEMENT_INFO, script->AnticheatUpdateMovementInfo(player, movementInfo)); } - bool ScriptMgr::AnticheatHandleDoubleJump(Player* player, Unit* mover) { - auto ret = IsValidBoolScript([&](PlayerScript* script) - { - return !script->AnticheatHandleDoubleJump(player, mover); - }); - - if (ret && *ret) - { - return false; - } - - return true; + CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_ANTICHEAT_HANDLE_DOUBLE_JUMP, !script->AnticheatHandleDoubleJump(player, mover)); } bool ScriptMgr::AnticheatCheckMovementInfo(Player* player, MovementInfo const& movementInfo, Unit* mover, bool jump) { - auto ret = IsValidBoolScript([&](PlayerScript* script) - { - return !script->AnticheatCheckMovementInfo(player, movementInfo, mover, jump); - }); - - if (ret && *ret) - { - return false; - } - - return true; + CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_ANTICHEAT_CHECK_MOVEMENT_INFO, !script->AnticheatCheckMovementInfo(player, movementInfo, mover, jump)); } -PlayerScript::PlayerScript(const char* name) - : ScriptObject(name) +PlayerScript::PlayerScript(const char* name, std::vector enabledHooks) + : ScriptObject(name, PLAYERHOOK_END) { - ScriptRegistry::AddScript(this); + // If empty - enable all available hooks. + if (enabledHooks.empty()) + for (uint16 i = 0; i < PLAYERHOOK_END; i++) + enabledHooks.emplace_back(i); + + ScriptRegistry::AddScript(this, std::move(enabledHooks)); } template class AC_GAME_API ScriptRegistry; diff --git a/src/server/game/Scripting/ScriptDefines/PlayerScript.h b/src/server/game/Scripting/ScriptDefines/PlayerScript.h index eb0e6753e..a834e82a1 100644 --- a/src/server/game/Scripting/ScriptDefines/PlayerScript.h +++ b/src/server/game/Scripting/ScriptDefines/PlayerScript.h @@ -24,10 +24,186 @@ #include "AchievementMgr.h" #include "KillRewarder.h" +enum PlayerHook { + PLAYERHOOK_ON_PLAYER_JUST_DIED, + PLAYERHOOK_ON_PLAYER_RELEASED_GHOST, + PLAYERHOOK_ON_SEND_INITIAL_PACKETS_BEFORE_ADD_TO_MAP, + PLAYERHOOK_ON_BATTLEGROUND_DESERTION, + PLAYERHOOK_ON_PLAYER_COMPLETE_QUEST, + PLAYERHOOK_ON_PVP_KILL, + PLAYERHOOK_ON_PLAYER_PVP_FLAG_CHANGE, + PLAYERHOOK_ON_CREATURE_KILL, + PLAYERHOOK_ON_CREATURE_KILLED_BY_PET, + PLAYERHOOK_ON_PLAYER_KILLED_BY_CREATURE, + PLAYERHOOK_ON_LEVEL_CHANGED, + PLAYERHOOK_ON_FREE_TALENT_POINTS_CHANGED, + PLAYERHOOK_ON_TALENTS_RESET, + PLAYERHOOK_ON_AFTER_SPEC_SLOT_CHANGED, + PLAYERHOOK_ON_BEFORE_UPDATE, + PLAYERHOOK_ON_UPDATE, + PLAYERHOOK_ON_MONEY_CHANGED, + PLAYERHOOK_ON_BEFORE_LOOT_MONEY, + PLAYERHOOK_ON_GIVE_EXP, + PLAYERHOOK_ON_REPUTATION_CHANGE, + PLAYERHOOK_ON_REPUTATION_RANK_CHANGE, + PLAYERHOOK_ON_LEARN_SPELL, + PLAYERHOOK_ON_FORGOT_SPELL, + PLAYERHOOK_ON_DUEL_REQUEST, + PLAYERHOOK_ON_DUEL_START, + PLAYERHOOK_ON_DUEL_END, + PLAYERHOOK_ON_CHAT, + PLAYERHOOK_ON_BEFORE_SEND_CHAT_MESSAGE, + PLAYERHOOK_ON_CHAT_WITH_RECEIVER, + PLAYERHOOK_ON_CHAT_WITH_GROUP, + PLAYERHOOK_ON_CHAT_WITH_GUILD, + PLAYERHOOK_ON_CHAT_WITH_CHANNEL, + PLAYERHOOK_ON_EMOTE, + PLAYERHOOK_ON_TEXT_EMOTE, + PLAYERHOOK_ON_SPELL_CAST, + PLAYERHOOK_ON_LOAD_FROM_DB, + PLAYERHOOK_ON_LOGIN, + PLAYERHOOK_ON_BEFORE_LOGOUT, + PLAYERHOOK_ON_LOGOUT, + PLAYERHOOK_ON_CREATE, + PLAYERHOOK_ON_DELETE, + PLAYERHOOK_ON_FAILED_DELETE, + PLAYERHOOK_ON_SAVE, + PLAYERHOOK_ON_BIND_TO_INSTANCE, + PLAYERHOOK_ON_UPDATE_ZONE, + PLAYERHOOK_ON_UPDATE_AREA, + PLAYERHOOK_ON_MAP_CHANGED, + PLAYERHOOK_ON_BEFORE_TELEPORT, + PLAYERHOOK_ON_UPDATE_FACTION, + PLAYERHOOK_ON_ADD_TO_BATTLEGROUND, + PLAYERHOOK_ON_QUEUE_RANDOM_DUNGEON, + PLAYERHOOK_ON_REMOVE_FROM_BATTLEGROUND, + PLAYERHOOK_ON_ACHI_COMPLETE, + PLAYERHOOK_ON_BEFORE_ACHI_COMPLETE, + PLAYERHOOK_ON_CRITERIA_PROGRESS, + PLAYERHOOK_ON_BEFORE_CRITERIA_PROGRESS, + PLAYERHOOK_ON_ACHI_SAVE, + PLAYERHOOK_ON_CRITERIA_SAVE, + PLAYERHOOK_ON_GOSSIP_SELECT, + PLAYERHOOK_ON_GOSSIP_SELECT_CODE, + PLAYERHOOK_ON_BEING_CHARMED, + PLAYERHOOK_ON_AFTER_SET_VISIBLE_ITEM_SLOT, + PLAYERHOOK_ON_AFTER_MOVE_ITEM_FROM_INVENTORY, + PLAYERHOOK_ON_EQUIP, + PLAYERHOOK_ON_PLAYER_JOIN_BG, + PLAYERHOOK_ON_PLAYER_JOIN_ARENA, + PLAYERHOOK_GET_CUSTOM_GET_ARENA_TEAM_ID, + PLAYERHOOK_GET_CUSTOM_ARENA_PERSONAL_RATING, + PLAYERHOOK_ON_GET_MAX_PERSONAL_ARENA_RATING_REQUIREMENT, + PLAYERHOOK_ON_LOOT_ITEM, + PLAYERHOOK_ON_BEFORE_FILL_QUEST_LOOT_ITEM, + PLAYERHOOK_ON_STORE_NEW_ITEM, + PLAYERHOOK_ON_CREATE_ITEM, + PLAYERHOOK_ON_QUEST_REWARD_ITEM, + PLAYERHOOK_CAN_PLACE_AUCTION_BID, + PLAYERHOOK_ON_GROUP_ROLL_REWARD_ITEM, + PLAYERHOOK_ON_BEFORE_OPEN_ITEM, + PLAYERHOOK_ON_BEFORE_QUEST_COMPLETE, + PLAYERHOOK_ON_QUEST_COMPUTE_EXP, + PLAYERHOOK_ON_BEFORE_DURABILITY_REPAIR, + PLAYERHOOK_ON_BEFORE_BUY_ITEM_FROM_VENDOR, + PLAYERHOOK_ON_BEFORE_STORE_OR_EQUIP_NEW_ITEM, + PLAYERHOOK_ON_AFTER_STORE_OR_EQUIP_NEW_ITEM, + PLAYERHOOK_ON_AFTER_UPDATE_MAX_POWER, + PLAYERHOOK_ON_AFTER_UPDATE_MAX_HEALTH, + PLAYERHOOK_ON_BEFORE_UPDATE_ATTACK_POWER_AND_DAMAGE, + PLAYERHOOK_ON_AFTER_UPDATE_ATTACK_POWER_AND_DAMAGE, + PLAYERHOOK_ON_BEFORE_INIT_TALENT_FOR_LEVEL, + PLAYERHOOK_ON_FIRST_LOGIN, + PLAYERHOOK_ON_SET_MAX_LEVEL, + PLAYERHOOK_CAN_JOIN_IN_BATTLEGROUND_QUEUE, + PLAYERHOOK_SHOULD_BE_REWARDED_WITH_MONEY_INSTEAD_OF_EXP, + PLAYERHOOK_ON_BEFORE_TEMP_SUMMON_INIT_STATS, + PLAYERHOOK_ON_BEFORE_GUARDIAN_INIT_STATS_FOR_LEVEL, + PLAYERHOOK_ON_AFTER_GUARDIAN_INIT_STATS_FOR_LEVEL, + PLAYERHOOK_ON_BEFORE_LOAD_PET_FROM_DB, + PLAYERHOOK_CAN_JOIN_IN_ARENA_QUEUE, + PLAYERHOOK_CAN_BATTLEFIELD_PORT, + PLAYERHOOK_CAN_GROUP_INVITE, + PLAYERHOOK_CAN_GROUP_ACCEPT, + PLAYERHOOK_CAN_SELL_ITEM, + PLAYERHOOK_CAN_SEND_MAIL, + PLAYERHOOK_PETITION_BUY, + PLAYERHOOK_PETITION_SHOW_LIST, + PLAYERHOOK_ON_REWARD_KILL_REWARDER, + PLAYERHOOK_CAN_GIVE_MAIL_REWARD_AT_GIVE_LEVEL, + PLAYERHOOK_ON_DELETE_FROM_DB, + PLAYERHOOK_CAN_REPOP_AT_GRAVEYARD, + PLAYERHOOK_ON_PLAYER_IS_CLASS, + PLAYERHOOK_ON_GET_MAX_SKILL_VALUE, + PLAYERHOOK_ON_PLAYER_HAS_ACTIVE_POWER_TYPE, + PLAYERHOOK_ON_UPDATE_GATHERING_SKILL, + PLAYERHOOK_ON_UPDATE_CRAFTING_SKILL, + PLAYERHOOK_ON_UPDATE_FISHING_SKILL, + PLAYERHOOK_CAN_AREA_EXPLORE_AND_OUTDOOR, + PLAYERHOOK_ON_VICTIM_REWARD_BEFORE, + PLAYERHOOK_ON_VICTIM_REWARD_AFTER, + PLAYERHOOK_ON_CUSTOM_SCALING_STAT_VALUE_BEFORE, + PLAYERHOOK_ON_CUSTOM_SCALING_STAT_VALUE, + PLAYERHOOK_CAN_ARMOR_DAMAGE_MODIFIER, + PLAYERHOOK_ON_GET_FERAL_AP_BONUS, + PLAYERHOOK_CAN_APPLY_WEAPON_DEPENDENT_AURA_DAMAGE_MOD, + PLAYERHOOK_CAN_APPLY_EQUIP_SPELL, + PLAYERHOOK_CAN_APPLY_EQUIP_SPELLS_ITEM_SET, + PLAYERHOOK_CAN_CAST_ITEM_COMBAT_SPELL, + PLAYERHOOK_CAN_CAST_ITEM_USE_SPELL, + PLAYERHOOK_ON_APPLY_AMMO_BONUSES, + PLAYERHOOK_CAN_EQUIP_ITEM, + PLAYERHOOK_CAN_UNEQUIP_ITEM, + PLAYERHOOK_CAN_USE_ITEM, + PLAYERHOOK_CAN_SAVE_EQUIP_NEW_ITEM, + PLAYERHOOK_CAN_APPLY_ENCHANTMENT, + PLAYERHOOK_PASSED_QUEST_KILLED_MONSTER_CREDIT, + PLAYERHOOK_CHECK_ITEM_IN_SLOT_AT_LOAD_INVENTORY, + PLAYERHOOK_NOT_AVOID_SATISFY, + PLAYERHOOK_NOT_VISIBLE_GLOBALLY_FOR, + PLAYERHOOK_ON_GET_ARENA_PERSONAL_RATING, + PLAYERHOOK_ON_GET_ARENA_TEAM_ID, + PLAYERHOOK_ON_IS_FFA_PVP, + PLAYERHOOK_ON_FFA_PVP_STATE_UPDATE, + PLAYERHOOK_ON_IS_PVP, + PLAYERHOOK_ON_GET_MAX_SKILL_VALUE_FOR_LEVEL, + PLAYERHOOK_NOT_SET_ARENA_TEAM_INFO_FIELD, + PLAYERHOOK_CAN_JOIN_LFG, + PLAYERHOOK_CAN_ENTER_MAP, + PLAYERHOOK_CAN_INIT_TRADE, + PLAYERHOOK_CAN_SET_TRADE_ITEM, + PLAYERHOOK_ON_SET_SERVER_SIDE_VISIBILITY, + PLAYERHOOK_ON_SET_SERVER_SIDE_VISIBILITY_DETECT, + PLAYERHOOK_ON_PLAYER_RESURRECT, + PLAYERHOOK_ON_BEFORE_CHOOSE_GRAVEYARD, + PLAYERHOOK_CAN_PLAYER_USE_CHAT, + PLAYERHOOK_CAN_PLAYER_USE_PRIVATE_CHAT, + PLAYERHOOK_CAN_PLAYER_USE_GROUP_CHAT, + PLAYERHOOK_CAN_PLAYER_USE_GUILD_CHAT, + PLAYERHOOK_CAN_PLAYER_USE_CHANNEL_CHAT, + PLAYERHOOK_ON_PLAYER_LEARN_TALENTS, + PLAYERHOOK_ON_PLAYER_ENTER_COMBAT, + PLAYERHOOK_ON_PLAYER_LEAVE_COMBAT, + PLAYERHOOK_ON_QUEST_ABANDON, + PLAYERHOOK_ON_GET_QUEST_RATE, + PLAYERHOOK_ON_CAN_PLAYER_FLY_IN_ZONE, + PLAYERHOOK_ANTICHEAT_SET_CAN_FLY_BY_SERVER, + PLAYERHOOK_ANTICHEAT_SET_UNDER_ACK_MOUNT, + PLAYERHOOK_ANTICHEAT_SET_ROOT_ACK_UPD, + PLAYERHOOK_ANTICHEAT_SET_JUMPING_BY_OPCODE, + PLAYERHOOK_ANTICHEAT_UPDATE_MOVEMENT_INFO, + PLAYERHOOK_ANTICHEAT_HANDLE_DOUBLE_JUMP, + PLAYERHOOK_ANTICHEAT_CHECK_MOVEMENT_INFO, + PLAYERHOOK_CAN_SEND_ERROR_ALREADY_LOOTED, + PLAYERHOOK_ON_AFTER_CREATURE_LOOT, + PLAYERHOOK_ON_AFTER_CREATURE_LOOT_MONEY, + PLAYERHOOK_END +}; + class PlayerScript : public ScriptObject { protected: - PlayerScript(const char* name); + PlayerScript(const char* name, std::vector enabledHooks = std::vector()); public: // Called when a player dies diff --git a/src/server/game/Scripting/ScriptMgr.h b/src/server/game/Scripting/ScriptMgr.h index a2f1cf5f5..f01ccadd5 100644 --- a/src/server/game/Scripting/ScriptMgr.h +++ b/src/server/game/Scripting/ScriptMgr.h @@ -710,30 +710,42 @@ public: typedef std::map ScriptMap; typedef typename ScriptMap::iterator ScriptMapIterator; - typedef std::vector ScriptVector; + typedef std::vector>> ScriptVector; typedef typename ScriptVector::iterator ScriptVectorIterator; + typedef std::vector> EnabledHooksVector; + typedef typename EnabledHooksVector::iterator EnabledHooksVectorIterator; + // The actual list of scripts. This will be accessed concurrently, so it must not be modified // after server startup. static ScriptMap ScriptPointerList; // After database load scripts static ScriptVector ALScripts; + // The list of hook types with the list of enabled scripts for this specific hook. + // With this approach, we wouldn't call all available hooks in case if we override just one hook. + static EnabledHooksVector EnabledHooks; - static void AddScript(TScript* const script) + static void AddScript(TScript* const script, std::vector enabledHooks = {}) { ASSERT(script); if (!_checkMemory(script)) return; + if (EnabledHooks.empty()) + EnabledHooks.resize(script->GetTotalAvailableHooks()); + if (script->isAfterLoadScript()) { - ALScripts.push_back(script); + ALScripts.emplace_back(script, std::move(enabledHooks)); } else { script->checkValidity(); + for (uint16 v : enabledHooks) + EnabledHooks[v].emplace_back(script); + // We're dealing with a code-only script; just add it. ScriptPointerList[_scriptIdCounter++] = script; sScriptMgr->IncreaseScriptCount(); @@ -742,9 +754,9 @@ public: static void AddALScripts() { - for(ScriptVectorIterator it = ALScripts.begin(); it != ALScripts.end(); ++it) + for (ScriptVectorIterator it = ALScripts.begin(); it != ALScripts.end(); ++it) { - TScript* const script = *it; + TScript* const script = (*it).first; script->checkValidity(); @@ -776,6 +788,14 @@ public: // If the script is already assigned -> delete it! if (oldScript) { + for (auto& vIt : EnabledHooks) + for (size_t i = 0; i < vIt.size(); ++i) + if (vIt[i] == oldScript) + { + vIt.erase(vIt.begin() + i); + break; + } + delete oldScript; } @@ -798,6 +818,9 @@ public: } else { + for (uint16 v : (*it).second) + EnabledHooks[v].emplace_back(script); + // We're dealing with a code-only script; just add it. ScriptPointerList[_scriptIdCounter++] = script; sScriptMgr->IncreaseScriptCount(); @@ -842,7 +865,8 @@ private: // Instantiate static members of ScriptRegistry. template std::map ScriptRegistry::ScriptPointerList; -template std::vector ScriptRegistry::ALScripts; +template std::vector>> ScriptRegistry::ALScripts; +template std::vector> ScriptRegistry::EnabledHooks; template uint32 ScriptRegistry::_scriptIdCounter = 0; #endif diff --git a/src/server/game/Scripting/ScriptMgrMacros.h b/src/server/game/Scripting/ScriptMgrMacros.h index a26c6d71b..fc7895e81 100644 --- a/src/server/game/Scripting/ScriptMgrMacros.h +++ b/src/server/game/Scripting/ScriptMgrMacros.h @@ -69,4 +69,14 @@ inline bool ReturnValidBool(Optional ret, bool need = false) return ret && *ret ? need : !need; } +#define CALL_ENABLED_HOOKS(scriptType, hookType, action) \ + if (!ScriptRegistry::EnabledHooks[hookType].empty()) \ + for (auto const& script : ScriptRegistry::EnabledHooks[hookType]) { action; } + +#define CALL_ENABLED_BOOLEAN_HOOKS(scriptType, hookType, action) \ + if (ScriptRegistry::EnabledHooks[hookType].empty()) \ + return true; \ + for (auto const& script : ScriptRegistry::EnabledHooks[hookType]) { if (action) return false; } \ + return true; + #endif // _SCRIPT_MGR_MACRO_H_ diff --git a/src/server/game/Scripting/ScriptObject.h b/src/server/game/Scripting/ScriptObject.h index c5bb042e5..ea8e0b90b 100644 --- a/src/server/game/Scripting/ScriptObject.h +++ b/src/server/game/Scripting/ScriptObject.h @@ -53,8 +53,10 @@ public: [[nodiscard]] const std::string& GetName() const { return _name; } + [[nodiscard]] uint16 GetTotalAvailableHooks() { return _totalAvailableHooks; } + protected: - ScriptObject(const char* name) : _name(std::string(name)) + ScriptObject(const char* name, uint16 totalAvailableHooks = 0) : _name(std::string(name)), _totalAvailableHooks(totalAvailableHooks) { } @@ -62,6 +64,7 @@ protected: private: const std::string _name; + const uint16 _totalAvailableHooks; }; template diff --git a/src/server/scripts/Events/midsummer.cpp b/src/server/scripts/Events/midsummer.cpp index c450e0576..33106da38 100644 --- a/src/server/scripts/Events/midsummer.cpp +++ b/src/server/scripts/Events/midsummer.cpp @@ -153,7 +153,7 @@ uint32 const GoBonfireCity[COUNT_GO_BONFIRE_CITY] = { 181332, 181333, 181334, 18 class MidsummerPlayerScript : public PlayerScript { public: - MidsummerPlayerScript() : PlayerScript("MidsummerPlayerScript") + MidsummerPlayerScript() : PlayerScript("MidsummerPlayerScript", {PLAYERHOOK_ON_UPDATE_ZONE}) { } diff --git a/src/server/scripts/World/action_ip_logger.cpp b/src/server/scripts/World/action_ip_logger.cpp index c99639974..1d219476f 100644 --- a/src/server/scripts/World/action_ip_logger.cpp +++ b/src/server/scripts/World/action_ip_logger.cpp @@ -169,7 +169,15 @@ public: class CharacterActionIpLogger : public PlayerScript { public: - CharacterActionIpLogger() : PlayerScript("CharacterActionIpLogger") { } + CharacterActionIpLogger() : + PlayerScript("CharacterActionIpLogger", + { + PLAYERHOOK_ON_CREATE, + PLAYERHOOK_ON_LOGIN, + PLAYERHOOK_ON_LOGOUT + }) + { + } // CHARACTER_CREATE = 7 void OnCreate(Player* player) override @@ -256,7 +264,14 @@ public: class CharacterDeleteActionIpLogger : public PlayerScript { public: - CharacterDeleteActionIpLogger() : PlayerScript("CharacterDeleteActionIpLogger") { } + CharacterDeleteActionIpLogger() : + PlayerScript("CharacterDeleteActionIpLogger", + { + PLAYERHOOK_ON_DELETE, + PLAYERHOOK_ON_FAILED_DELETE + }) + { + } // CHARACTER_DELETE = 10 void OnDelete(ObjectGuid guid, uint32 accountId) override diff --git a/src/server/scripts/World/chat_log.cpp b/src/server/scripts/World/chat_log.cpp index f2ef910e4..caafbca83 100644 --- a/src/server/scripts/World/chat_log.cpp +++ b/src/server/scripts/World/chat_log.cpp @@ -25,7 +25,17 @@ class ChatLogScript : public PlayerScript { public: - ChatLogScript() : PlayerScript("ChatLogScript") { } + ChatLogScript() : + PlayerScript("ChatLogScript", + { + PLAYERHOOK_ON_CHAT, + PLAYERHOOK_ON_CHAT_WITH_GROUP, + PLAYERHOOK_ON_CHAT_WITH_GUILD, + PLAYERHOOK_ON_CHAT_WITH_CHANNEL, + PLAYERHOOK_ON_CHAT_WITH_RECEIVER + }) + { + } void OnChat(Player* player, uint32 type, uint32 lang, std::string& msg) override { diff --git a/src/server/scripts/World/player_scripts.cpp b/src/server/scripts/World/player_scripts.cpp index 0ec18509b..89e62c023 100644 --- a/src/server/scripts/World/player_scripts.cpp +++ b/src/server/scripts/World/player_scripts.cpp @@ -27,7 +27,7 @@ enum ApprenticeAnglerQuestEnum class QuestApprenticeAnglerPlayerScript : public PlayerScript { public: - QuestApprenticeAnglerPlayerScript() : PlayerScript("QuestApprenticeAnglerPlayerScript") + QuestApprenticeAnglerPlayerScript() : PlayerScript("QuestApprenticeAnglerPlayerScript", {PLAYERHOOK_ON_PLAYER_COMPLETE_QUEST}) { } diff --git a/src/server/scripts/World/server_mail.cpp b/src/server/scripts/World/server_mail.cpp index 12e4b44ac..d8f1a2ac1 100644 --- a/src/server/scripts/World/server_mail.cpp +++ b/src/server/scripts/World/server_mail.cpp @@ -24,7 +24,7 @@ class ServerMailReward : public PlayerScript { public: - ServerMailReward() : PlayerScript("ServerMailReward") { } + ServerMailReward() : PlayerScript("ServerMailReward", {PLAYERHOOK_ON_LOGIN}) { } // CHARACTER_LOGIN = 8 void OnLogin(Player* player) override