From 65f65e06753c019813835110fe28705de4bef264 Mon Sep 17 00:00:00 2001 From: 55Honey <71938210+55Honey@users.noreply.github.com> Date: Fri, 16 Sep 2022 22:54:04 +0200 Subject: [PATCH] feat: add player event OnFfaPvpStateUpdate --- src/ElunaLuaEngine_SC.cpp | 5 +++++ src/LuaEngine/GlobalMethods.h | 1 + src/LuaEngine/Hooks.h | 3 ++- src/LuaEngine/LuaEngine.h | 1 + src/LuaEngine/PlayerHooks.cpp | 9 +++++++++ 5 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/ElunaLuaEngine_SC.cpp b/src/ElunaLuaEngine_SC.cpp index bdf9cbb91c..c81cad821e 100644 --- a/src/ElunaLuaEngine_SC.cpp +++ b/src/ElunaLuaEngine_SC.cpp @@ -741,6 +741,11 @@ class Eluna_PlayerScript : public PlayerScript { sEluna->OnAchiComplete(player, achievement); } + + void OnFfaPvpStateUpdate(Player* player, bool IsFlaggedForFfaPvp) override + { + sEluna->OnFfaPvpStateUpdate(player, IsFlaggedForFfaPvp); + } }; class Eluna_ServerScript : public ServerScript diff --git a/src/LuaEngine/GlobalMethods.h b/src/LuaEngine/GlobalMethods.h index 52aceaec21..61a93919be 100644 --- a/src/LuaEngine/GlobalMethods.h +++ b/src/LuaEngine/GlobalMethods.h @@ -708,6 +708,7 @@ namespace LuaGlobalFunctions * PLAYER_EVENT_ON_PET_ADDED_TO_WORLD = 43, // (event, player, pet) * PLAYER_EVENT_ON_LEARN_SPELL = 44, // (event, player, spellId) * PLAYER_EVENT_ON_ACHIEVEMENT_COMPLETE = 45, // (event, player, achievement) + * PLAYER_EVENT_ON_FFAPVP_CHANGE = 46, // (event, player, hasFfaPvp) * }; * * diff --git a/src/LuaEngine/Hooks.h b/src/LuaEngine/Hooks.h index 0079e69d85..bc6b1d89cc 100644 --- a/src/LuaEngine/Hooks.h +++ b/src/LuaEngine/Hooks.h @@ -145,7 +145,7 @@ namespace Hooks // AddOns ADDON_EVENT_ON_MESSAGE = 30, // (event, sender, type, prefix, msg, target) - target can be nil/whisper_target/guild/group/channel. Can return false - + WORLD_EVENT_ON_DELETE_CREATURE = 31, // (event, creature) WORLD_EVENT_ON_DELETE_GAMEOBJECT = 32, // (event, gameobject) @@ -207,6 +207,7 @@ namespace Hooks PLAYER_EVENT_ON_PET_ADDED_TO_WORLD = 43, // (event, player, pet) PLAYER_EVENT_ON_LEARN_SPELL = 44, // (event, player, spellId) PLAYER_EVENT_ON_ACHIEVEMENT_COMPLETE = 45, // (event, player, achievement) + PLAYER_EVENT_ON_FFAPVP_CHANGE = 46, // (event, player, hasFfaPvp) PLAYER_EVENT_COUNT }; diff --git a/src/LuaEngine/LuaEngine.h b/src/LuaEngine/LuaEngine.h index d435a64518..8feef69636 100644 --- a/src/LuaEngine/LuaEngine.h +++ b/src/LuaEngine/LuaEngine.h @@ -474,6 +474,7 @@ class ELUNA_GAME_API Eluna void HandleGossipSelectOption(Player* pPlayer, uint32 menuId, uint32 sender, uint32 action, const std::string& code); void OnLearnSpell(Player* player, uint32 spellId); void OnAchiComplete(Player* player, AchievementEntry const* achievement); + void OnFfaPvpStateUpdate(Player* player, bool hasFfaPvp); #ifndef CLASSIC #ifndef TBC diff --git a/src/LuaEngine/PlayerHooks.cpp b/src/LuaEngine/PlayerHooks.cpp index 005d603314..c1e85fb756 100644 --- a/src/LuaEngine/PlayerHooks.cpp +++ b/src/LuaEngine/PlayerHooks.cpp @@ -574,3 +574,12 @@ void Eluna::OnAchiComplete(Player* player, AchievementEntry const* achievement) Push(achievement); CallAllFunctions(PlayerEventBindings, key); } + + +void Eluna::OnFfaPvpStateUpdate(Player* player, bool hasFfaPvp) +{ + START_HOOK(PLAYER_EVENT_ON_FFAPVP_CHANGE); + Push(player); + Push(hasFfaPvp); + CallAllFunctions(PlayerEventBindings, key); +}