From 7511f38eab824dbb2392a81337d55e44d0698fc4 Mon Sep 17 00:00:00 2001 From: iThorgrim <125808072+iThorgrim@users.noreply.github.com> Date: Sat, 8 Feb 2025 07:33:43 +0100 Subject: [PATCH] Feat(LuaEngine/PlayerHooks): Add OnCanPlayerResurrect (#236) --- src/ElunaLuaEngine_SC.cpp | 5 +++++ src/LuaEngine/Hooks.h | 1 + src/LuaEngine/LuaEngine.h | 1 + src/LuaEngine/hooks/PlayerHooks.cpp | 8 ++++++++ src/LuaEngine/methods/GlobalMethods.h | 2 ++ 5 files changed, 17 insertions(+) diff --git a/src/ElunaLuaEngine_SC.cpp b/src/ElunaLuaEngine_SC.cpp index 9016ab8..decd6de 100644 --- a/src/ElunaLuaEngine_SC.cpp +++ b/src/ElunaLuaEngine_SC.cpp @@ -812,6 +812,11 @@ public: { sEluna->OnCreatureKilledByPet(player, killed); } + + bool CanPlayerResurrect(Player* player) override + { + return sEluna->CanPlayerResurrect(player); + } }; class Eluna_ServerScript : public ServerScript diff --git a/src/LuaEngine/Hooks.h b/src/LuaEngine/Hooks.h index fb537a8..70e668e 100644 --- a/src/LuaEngine/Hooks.h +++ b/src/LuaEngine/Hooks.h @@ -221,6 +221,7 @@ namespace Hooks PLAYER_EVENT_ON_GROUP_ROLL_REWARD_ITEM = 56, // (event, player, item, count, voteType, roll) PLAYER_EVENT_ON_BG_DESERTION = 57, // (event, player, type) PLAYER_EVENT_ON_PET_KILL = 58, // (event, player, killer) + PLAYER_EVENT_ON_CAN_RESURRECT = 59, // (event, player) PLAYER_EVENT_COUNT }; diff --git a/src/LuaEngine/LuaEngine.h b/src/LuaEngine/LuaEngine.h index 11aad10..ffce5e8 100644 --- a/src/LuaEngine/LuaEngine.h +++ b/src/LuaEngine/LuaEngine.h @@ -451,6 +451,7 @@ public: void OnGroupRollRewardItem(Player* player, Item* item, uint32 count, RollVote voteType, Roll* roll); void OnBattlegroundDesertion(Player* player, const BattlegroundDesertionType type); void OnCreatureKilledByPet(Player* player, Creature* killed); + bool CanPlayerResurrect(Player* player); /* Vehicle */ void OnInstall(Vehicle* vehicle); diff --git a/src/LuaEngine/hooks/PlayerHooks.cpp b/src/LuaEngine/hooks/PlayerHooks.cpp index 62a5d63..f8ff479 100644 --- a/src/LuaEngine/hooks/PlayerHooks.cpp +++ b/src/LuaEngine/hooks/PlayerHooks.cpp @@ -706,3 +706,11 @@ void Eluna::OnCreatureKilledByPet(Player* player, Creature* killed) Push(killed); CallAllFunctions(PlayerEventBindings, key); } + +bool Eluna::CanPlayerResurrect(Player* player) +{ + START_HOOK_WITH_RETVAL(PLAYER_EVENT_ON_CAN_RESURRECT, true); + Push(player); + return CallAllFunctionsBool(PlayerEventBindings, key); +} + diff --git a/src/LuaEngine/methods/GlobalMethods.h b/src/LuaEngine/methods/GlobalMethods.h index fef9e06..e4c2f3c 100644 --- a/src/LuaEngine/methods/GlobalMethods.h +++ b/src/LuaEngine/methods/GlobalMethods.h @@ -716,6 +716,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_BG_DESERTION = 57, // (event, player, type) + * PLAYER_EVENT_ON_PET_KILL = 58, // (event, player, killer) + * PLAYER_EVENT_ON_CAN_RESURRECT = 59, // (event, player) * }; * *