From 60c90414d5c7f6d29ba31e59cf941cb460f24787 Mon Sep 17 00:00:00 2001 From: Revision Date: Mon, 20 Jun 2022 07:48:17 +0200 Subject: [PATCH] feat(PlayerHooks): OnLearnSpell(player, spellid) (#46) OnLearnSpell --- src/ElunaLuaEngine_SC.cpp | 5 +++++ src/LuaEngine/GlobalMethods.h | 1 + src/LuaEngine/Hooks.h | 1 + src/LuaEngine/LuaEngine.h | 1 + src/LuaEngine/PlayerHooks.cpp | 8 ++++++++ 5 files changed, 16 insertions(+) diff --git a/src/ElunaLuaEngine_SC.cpp b/src/ElunaLuaEngine_SC.cpp index f9dd6fe40d..8d1d257e76 100644 --- a/src/ElunaLuaEngine_SC.cpp +++ b/src/ElunaLuaEngine_SC.cpp @@ -731,6 +731,11 @@ class Eluna_PlayerScript : public PlayerScript { sEluna->OnFirstLogin(player); } + + void OnLearnSpell(Player* player, uint32 spellId) override + { + sEluna->OnLearnSpell(player, spellId); + } }; class Eluna_ServerScript : public ServerScript diff --git a/src/LuaEngine/GlobalMethods.h b/src/LuaEngine/GlobalMethods.h index 44e0fa59c3..2ec082cd13 100644 --- a/src/LuaEngine/GlobalMethods.h +++ b/src/LuaEngine/GlobalMethods.h @@ -706,6 +706,7 @@ namespace LuaGlobalFunctions * // UNUSED = 41, // (event, player) * PLAYER_EVENT_ON_COMMAND = 42, // (event, player, command, chatHandler) - player is nil if command used from console. Can return false * PLAYER_EVENT_ON_PET_ADDED_TO_WORLD = 43, // (event, player, pet) + * * PLAYER_EVENT_ON_LEARN_SPELL = 44, // (event, player, spellId) * }; * * diff --git a/src/LuaEngine/Hooks.h b/src/LuaEngine/Hooks.h index 7591baf8e7..5beb8cb64b 100644 --- a/src/LuaEngine/Hooks.h +++ b/src/LuaEngine/Hooks.h @@ -205,6 +205,7 @@ namespace Hooks // UNUSED = 41, // (event, player) PLAYER_EVENT_ON_COMMAND = 42, // (event, player, command, chatHandler) - player is nil if command used from console. Can return false PLAYER_EVENT_ON_PET_ADDED_TO_WORLD = 43, // (event, player, pet) + PLAYER_EVENT_ON_LEARN_SPELL = 44, // (event, player, spellId) PLAYER_EVENT_COUNT }; diff --git a/src/LuaEngine/LuaEngine.h b/src/LuaEngine/LuaEngine.h index 63d720bb0e..517c0bdfcf 100644 --- a/src/LuaEngine/LuaEngine.h +++ b/src/LuaEngine/LuaEngine.h @@ -472,6 +472,7 @@ class ELUNA_GAME_API Eluna void OnUpdateZone(Player* pPlayer, uint32 newZone, uint32 newArea); void OnMapChanged(Player* pPlayer); void HandleGossipSelectOption(Player* pPlayer, uint32 menuId, uint32 sender, uint32 action, const std::string& code); + void OnLearnSpell(Player* player, uint32 spellId); #ifndef CLASSIC #ifndef TBC diff --git a/src/LuaEngine/PlayerHooks.cpp b/src/LuaEngine/PlayerHooks.cpp index 3e1d5bb901..f556cb9245 100644 --- a/src/LuaEngine/PlayerHooks.cpp +++ b/src/LuaEngine/PlayerHooks.cpp @@ -558,3 +558,11 @@ void Eluna::OnPetAddedToWorld(Player* player, Creature* pet) Push(pet); CallAllFunctions(PlayerEventBindings, key); } + +void Eluna::OnLearnSpell(Player* player, uint32 spellId) +{ + START_HOOK(PLAYER_EVENT_ON_LEARN_SPELL); + Push(player); + Push(spellId); + CallAllFunctions(PlayerEventBindings, key); +}