From 1cb948db3d634ff6ae2b9f945b950c0d536af46f Mon Sep 17 00:00:00 2001 From: 0xCiBeR Date: Mon, 5 Jun 2023 04:36:48 -0300 Subject: [PATCH] feat: add OnBattlegroundDesertion hook --- README.md | 1 + src/ElunaLuaEngine_SC.cpp | 5 +++++ src/LuaEngine/GlobalMethods.h | 3 ++- src/LuaEngine/Hooks.h | 1 + src/LuaEngine/LuaEngine.h | 1 + src/LuaEngine/PlayerHooks.cpp | 8 ++++++++ 6 files changed, 18 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4c89f64650..9cad349e6e 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,7 @@ Eluna API for AC: - Added `RegisterPlayerEvent` `56` (`PLAYER_EVENT_ON_GROUP_ROLL_REWARD_ITEM`): https://github.com/azerothcore/mod-eluna/pull/119 - Added `RegisterPlayerEvent` `57` (`PLAYER_EVENT_ON_APPLY_AURA`): https://github.com/azerothcore/mod-eluna/pull/137 - Added `RegisterPlayerEvent` `58` (`PLAYER_EVENT_ON_REMOVE_AURA`): https://github.com/azerothcore/mod-eluna/pull/137 +- Added `RegisterPlayerEvent` `59` (`PLAYER_EVENT_ON_BG_DESERTION`): https://github.com/azerothcore/mod-eluna/pull/146 - Added `Player:GetMailCount()`: https://github.com/azerothcore/mod-eluna/pull/76 - Added `Player:GetXP()`: https://github.com/azerothcore/mod-eluna/pull/77 - Added `Player:GetAchievementCriteriaProgress()`: https://github.com/azerothcore/mod-eluna/pull/78 diff --git a/src/ElunaLuaEngine_SC.cpp b/src/ElunaLuaEngine_SC.cpp index 05744e51f6..c128bec7ad 100644 --- a/src/ElunaLuaEngine_SC.cpp +++ b/src/ElunaLuaEngine_SC.cpp @@ -811,6 +811,11 @@ class Eluna_PlayerScript : public PlayerScript { return sEluna->OnRemoveAura(player, aura, isExpired); } + + void OnBattlegroundDesertion(Player* player, const BattlegroundDesertionType type) override + { + sEluna->OnBattlegroundDesertion(player, type); + } }; class Eluna_ServerScript : public ServerScript diff --git a/src/LuaEngine/GlobalMethods.h b/src/LuaEngine/GlobalMethods.h index 3003a5ab91..7829ff59c7 100644 --- a/src/LuaEngine/GlobalMethods.h +++ b/src/LuaEngine/GlobalMethods.h @@ -730,7 +730,8 @@ namespace LuaGlobalFunctions * PLAYER_EVENT_ON_CAN_GROUP_INVITE = 55, // (event, player, memberName) - Can return false to prevent inviting * PLAYER_EVENT_ON_GROUP_ROLL_REWARD_ITEM = 56, // (event, player, item, count, voteType, roll) * PLAYER_EVENT_ON_APPLY_AURA = 57, // (event, player, aura, isNewAura) - * PLAYER_EVENT_ON_REMOVE_AURA = 58, // (event, player, aura, isExpired) + * PLAYER_EVENT_ON_REMOVE_AURA = 58, // (event, player, aura, isExpired) + * PLAYER_EVENT_ON_BG_DESERTION = 59, // (event, player, type) * }; * * diff --git a/src/LuaEngine/Hooks.h b/src/LuaEngine/Hooks.h index 6166ce3ddf..ace9f1d931 100644 --- a/src/LuaEngine/Hooks.h +++ b/src/LuaEngine/Hooks.h @@ -220,6 +220,7 @@ namespace Hooks PLAYER_EVENT_ON_GROUP_ROLL_REWARD_ITEM = 56, // (event, player, item, count, voteType, roll) PLAYER_EVENT_ON_APPLY_AURA = 57, // (event, player, aura, isNewAura) PLAYER_EVENT_ON_REMOVE_AURA = 58, // (event, player, aura, isExpired) + PLAYER_EVENT_ON_BG_DESERTION = 59, // (event, player, type) PLAYER_EVENT_COUNT }; diff --git a/src/LuaEngine/LuaEngine.h b/src/LuaEngine/LuaEngine.h index 9d259bd0f3..23c5e73bb0 100644 --- a/src/LuaEngine/LuaEngine.h +++ b/src/LuaEngine/LuaEngine.h @@ -491,6 +491,7 @@ class ELUNA_GAME_API Eluna void OnGroupRollRewardItem(Player* player, Item* item, uint32 count, RollVote voteType, Roll* roll); void OnApplyAura(Player* player, Aura* aura, bool isNewAura); void OnRemoveAura(Player* player, Aura* aura, bool isExpired); + void OnBattlegroundDesertion(Player* player, const BattlegroundDesertionType type); #ifndef CLASSIC #ifndef TBC diff --git a/src/LuaEngine/PlayerHooks.cpp b/src/LuaEngine/PlayerHooks.cpp index 4e7acfdb22..04f38d02ab 100644 --- a/src/LuaEngine/PlayerHooks.cpp +++ b/src/LuaEngine/PlayerHooks.cpp @@ -708,3 +708,11 @@ void Eluna::OnRemoveAura(Player* player, Aura* aura, bool isExpired) Push(isExpired); CallAllFunctions(PlayerEventBindings, key); } + +void Eluna::OnBattlegroundDesertion(Player* player, const BattlegroundDesertionType type) +{ + START_HOOK(PLAYER_EVENT_ON_BG_DESERTION); + Push(player); + Push(type); + CallAllFunctions(PlayerEventBindings, key); +} \ No newline at end of file