From 067f78091162dac5d6922b99e2e7b539f3a7ccb8 Mon Sep 17 00:00:00 2001 From: veserine <42183187+veserine@users.noreply.github.com> Date: Sun, 5 Feb 2023 21:49:51 +0800 Subject: [PATCH] feat: add PLAYER_EVENT_ON_COMPLETE_QUEST (#90) --- README.md | 1 + README_CN.md | 1 + src/ElunaLuaEngine_SC.cpp | 5 +++++ src/LuaEngine/GlobalMethods.h | 7 ++++--- src/LuaEngine/Hooks.h | 1 + src/LuaEngine/LuaEngine.h | 1 + src/LuaEngine/PlayerHooks.cpp | 8 ++++++++ 7 files changed, 21 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c7bb224..8b6cc54 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,7 @@ Eluna API for AC: - Added `RegisterPlayerEvent` `51` (`PLAYER_EVENT_ON_QUEST_REWARD_ITEM`): https://github.com/azerothcore/mod-eluna/pull/88 - Added `RegisterPlayerEvent` `52` (`PLAYER_EVENT_ON_CREATE_ITEM`): https://github.com/azerothcore/mod-eluna/pull/88 - Added `RegisterPlayerEvent` `53` (`PLAYER_EVENT_ON_STORE_NEW_ITEM`): https://github.com/azerothcore/mod-eluna/pull/88 +- Added `RegisterPlayerEvent` `54` (`PLAYER_EVENT_ON_COMPLETE_QUEST`): https://github.com/azerothcore/mod-eluna/pull/90 - 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/README_CN.md b/README_CN.md index e0bf1fd..1789c31 100644 --- a/README_CN.md +++ b/README_CN.md @@ -87,5 +87,6 @@ AC版的Eluna API: - 添加玩家注册事件51(当玩家获得任务奖励时) `PLAYER_EVENT_ON_QUEST_REWARD_ITEM`。https://github.com/azerothcore/mod-eluna/pull/88 - 添加玩家注册事件52(当玩家创建物品时) `PLAYER_EVENT_ON_CREATE_ITEM`。https://github.com/azerothcore/mod-eluna/pull/88 - 添加玩家注册事件53(当玩家创建物品实例时) `PLAYER_EVENT_ON_STORE_NEW_ITEM`。https://github.com/azerothcore/mod-eluna/pull/88 +- 添加玩家注册事件54(当玩家完成任务时) `PLAYER_EVENT_ON_COMPLETE_QUEST`。https://github.com/azerothcore/mod-eluna/pull/90 - 新增参数*商人Id*到方法player:SendListInventory(object, vendorentry)中。 https://github.com/azerothcore/mod-eluna/pull/48 - 添加方法`gameobject:AddLoot()`, 可以在线给**空**的容器中添加战利品。 https://github.com/azerothcore/mod-eluna/pull/52 diff --git a/src/ElunaLuaEngine_SC.cpp b/src/ElunaLuaEngine_SC.cpp index 5d43f5c..2816ed4 100644 --- a/src/ElunaLuaEngine_SC.cpp +++ b/src/ElunaLuaEngine_SC.cpp @@ -786,6 +786,11 @@ public: { sEluna->OnStoreNewItem(player, item, count); } + + void OnPlayerCompleteQuest(Player* player, Quest const* quest) override + { + sEluna->OnPlayerCompleteQuest(player, quest); + } }; class Eluna_ServerScript : public ServerScript diff --git a/src/LuaEngine/GlobalMethods.h b/src/LuaEngine/GlobalMethods.h index 4c15aa9..7cc8d79 100644 --- a/src/LuaEngine/GlobalMethods.h +++ b/src/LuaEngine/GlobalMethods.h @@ -723,9 +723,10 @@ namespace LuaGlobalFunctions * PLAYER_EVENT_ON_CAN_INIT_TRADE = 48, // (event, player, target) - Can return false to prevent the trade * PLAYER_EVENT_ON_CAN_SEND_MAIL = 49, // (event, player, receiverGuid, mailbox, subject, body, money, cod, item) - Can return false to prevent sending the mail * PLAYER_EVENT_ON_CAN_JOIN_LFG = 50, // (event, player, roles, dungeons, comment) - Can return false to prevent queueing - * PLAYER_EVENT_ON_QUEST_REWARD_ITEM = 51, // (event, player, item, count) - * PLAYER_EVENT_ON_CREATE_ITEM = 52, // (event, player, item, count) - * PLAYER_EVENT_ON_STORE_NEW_ITEM = 53, // (event, player, item, count) + * PLAYER_EVENT_ON_QUEST_REWARD_ITEM = 51, // (event, player, item, count) + * PLAYER_EVENT_ON_CREATE_ITEM = 52, // (event, player, item, count) + * PLAYER_EVENT_ON_STORE_NEW_ITEM = 53, // (event, player, item, count) + * PLAYER_EVENT_ON_COMPLETE_QUEST = 54, // (event, player, quest) * }; * * diff --git a/src/LuaEngine/Hooks.h b/src/LuaEngine/Hooks.h index ac46fa5..0d91636 100644 --- a/src/LuaEngine/Hooks.h +++ b/src/LuaEngine/Hooks.h @@ -215,6 +215,7 @@ namespace Hooks PLAYER_EVENT_ON_QUEST_REWARD_ITEM = 51, // (event, player, item, count) PLAYER_EVENT_ON_CREATE_ITEM = 52, // (event, player, item, count) PLAYER_EVENT_ON_STORE_NEW_ITEM = 53, // (event, player, item, count) + PLAYER_EVENT_ON_COMPLETE_QUEST = 54, // (event, player, quest) PLAYER_EVENT_COUNT }; diff --git a/src/LuaEngine/LuaEngine.h b/src/LuaEngine/LuaEngine.h index a8d3e33..31e9755 100644 --- a/src/LuaEngine/LuaEngine.h +++ b/src/LuaEngine/LuaEngine.h @@ -373,6 +373,7 @@ public: void OnQuestRewardItem(Player* player, Item* item, uint32 count); void OnCreateItem(Player* player, Item* item, uint32 count); void OnStoreNewItem(Player* player, Item* item, uint32 count); + void OnPlayerCompleteQuest(Player* player, Quest const* quest); /* Item */ void OnDummyEffect(WorldObject* pCaster, uint32 spellId, SpellEffIndex effIndex, Item* pTarget); diff --git a/src/LuaEngine/PlayerHooks.cpp b/src/LuaEngine/PlayerHooks.cpp index c42a5c9..ed68b8a 100644 --- a/src/LuaEngine/PlayerHooks.cpp +++ b/src/LuaEngine/PlayerHooks.cpp @@ -662,3 +662,11 @@ void Eluna::OnStoreNewItem(Player* player, Item* item, uint32 count) Push(count); CallAllFunctions(PlayerEventBindings, key); } + +void Eluna::OnPlayerCompleteQuest(Player* player, Quest const* quest) +{ + START_HOOK(PLAYER_EVENT_ON_COMPLETE_QUEST); + Push(player); + Push(quest); + CallAllFunctions(PlayerEventBindings, key); +}