From c7bf2e5e28a87a658237750473a92458d9b89b24 Mon Sep 17 00:00:00 2001 From: veserine Date: Wed, 25 Jan 2023 10:59:19 +0800 Subject: [PATCH 1/6] feat: add PLAYER_EVENT_ON_QUEST_REWARD_ITEM add PLAYER_EVENT_ON_CREATE_ITEM add PLAYER_EVENT_ON_STORE_NEW_ITEM --- src/ElunaLuaEngine_SC.cpp | 13 +++++++++++++ src/LuaEngine/Hooks.h | 3 +++ src/LuaEngine/LuaEngine.h | 3 +++ src/LuaEngine/PlayerHooks.cpp | 26 ++++++++++++++++++++++++++ 4 files changed, 45 insertions(+) diff --git a/src/ElunaLuaEngine_SC.cpp b/src/ElunaLuaEngine_SC.cpp index 962a988a68..443a0f7257 100644 --- a/src/ElunaLuaEngine_SC.cpp +++ b/src/ElunaLuaEngine_SC.cpp @@ -771,6 +771,19 @@ class Eluna_PlayerScript : public PlayerScript { return sEluna->OnCanJoinLfg(player, roles, dungeons, comment); } + void OnQuestRewardItem(Player* player, Item* item, uint32 count) override + { + sEluna->OnQuestRewardItem(player, item, count); + } + void OnCreateItem(Player* player, Item* item, uint32 count) override + { + sEluna->OnCreateItem(player, item, count); + } + + void OnStoreNewItem(Player* player, Item* item, uint32 count) override + { + sEluna->OnStoreNewItem(player, item, count); + } }; class Eluna_ServerScript : public ServerScript diff --git a/src/LuaEngine/Hooks.h b/src/LuaEngine/Hooks.h index 192f5d59ba..ac46fa5703 100644 --- a/src/LuaEngine/Hooks.h +++ b/src/LuaEngine/Hooks.h @@ -212,6 +212,9 @@ namespace Hooks 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_COUNT }; diff --git a/src/LuaEngine/LuaEngine.h b/src/LuaEngine/LuaEngine.h index 8ff9f27b00..a8d3e3326d 100644 --- a/src/LuaEngine/LuaEngine.h +++ b/src/LuaEngine/LuaEngine.h @@ -370,6 +370,9 @@ class ELUNA_GAME_API Eluna void OnLuaStateOpen(); bool OnAddonMessage(Player* sender, uint32 type, std::string& msg, Player* receiver, Guild* guild, Group* group, Channel* channel); void OnPetAddedToWorld(Player* player, Creature* pet); + void OnQuestRewardItem(Player* player, Item* item, uint32 count); + void OnCreateItem(Player* player, Item* item, uint32 count); + void OnStoreNewItem(Player* player, Item* item, uint32 count); /* Item */ void OnDummyEffect(WorldObject* pCaster, uint32 spellId, SpellEffIndex effIndex, Item* pTarget); diff --git a/src/LuaEngine/PlayerHooks.cpp b/src/LuaEngine/PlayerHooks.cpp index 8abdddbdd3..81bc35322b 100644 --- a/src/LuaEngine/PlayerHooks.cpp +++ b/src/LuaEngine/PlayerHooks.cpp @@ -635,3 +635,29 @@ bool Eluna::OnCanJoinLfg(Player* player, uint8 roles, lfg::LfgDungeonSet& dungeo Push(comment); return CallAllFunctionsBool(PlayerEventBindings, key); } + +void Eluna::OnQuestRewardItem(Player* player, Item* item, uint32 count) +{ + START_HOOK(PLAYER_EVENT_ON_QUEST_REWARD_ITEM); + Push(player); + Push(item); + Push(count); + CallAllFunctions(PlayerEventBindings, key); +} + +void Eluna::OnCreateItem(Player* player, Item* item, uint32 count) +{ + START_HOOK(PLAYER_EVENT_ON_CREATE_ITEM); + Push(player); + Push(item); + Push(count); + CallAllFunctions(PlayerEventBindings, key); +} +void Eluna::OnStoreNewItem(Player* player, Item* item, uint32 count) +{ + START_HOOK(PLAYER_EVENT_ON_STORE_NEW_ITEM); + Push(player); + Push(item); + Push(count); + CallAllFunctions(PlayerEventBindings, key); +} From 471930708360917bd84873889505954b32814fb1 Mon Sep 17 00:00:00 2001 From: veserine <42183187+veserine@users.noreply.github.com> Date: Sat, 28 Jan 2023 06:15:55 +0800 Subject: [PATCH 2/6] Update src/ElunaLuaEngine_SC.cpp Co-authored-by: Axel Cocat --- src/ElunaLuaEngine_SC.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ElunaLuaEngine_SC.cpp b/src/ElunaLuaEngine_SC.cpp index 443a0f7257..015de207b0 100644 --- a/src/ElunaLuaEngine_SC.cpp +++ b/src/ElunaLuaEngine_SC.cpp @@ -771,6 +771,7 @@ class Eluna_PlayerScript : public PlayerScript { return sEluna->OnCanJoinLfg(player, roles, dungeons, comment); } + void OnQuestRewardItem(Player* player, Item* item, uint32 count) override { sEluna->OnQuestRewardItem(player, item, count); From bddc4c28834ffd65798a02183ed33f457f64c3d2 Mon Sep 17 00:00:00 2001 From: veserine <42183187+veserine@users.noreply.github.com> Date: Sat, 28 Jan 2023 06:16:02 +0800 Subject: [PATCH 3/6] Update src/ElunaLuaEngine_SC.cpp Co-authored-by: Axel Cocat --- src/ElunaLuaEngine_SC.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ElunaLuaEngine_SC.cpp b/src/ElunaLuaEngine_SC.cpp index 015de207b0..5d43f5c80c 100644 --- a/src/ElunaLuaEngine_SC.cpp +++ b/src/ElunaLuaEngine_SC.cpp @@ -776,6 +776,7 @@ class Eluna_PlayerScript : public PlayerScript { sEluna->OnQuestRewardItem(player, item, count); } + void OnCreateItem(Player* player, Item* item, uint32 count) override { sEluna->OnCreateItem(player, item, count); From 6bb445d04b59ee57a57af45877760bc60e2b2efb Mon Sep 17 00:00:00 2001 From: veserine <42183187+veserine@users.noreply.github.com> Date: Sat, 28 Jan 2023 06:16:13 +0800 Subject: [PATCH 4/6] Update src/LuaEngine/PlayerHooks.cpp Co-authored-by: Axel Cocat --- src/LuaEngine/PlayerHooks.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/LuaEngine/PlayerHooks.cpp b/src/LuaEngine/PlayerHooks.cpp index 81bc35322b..c42a5c9238 100644 --- a/src/LuaEngine/PlayerHooks.cpp +++ b/src/LuaEngine/PlayerHooks.cpp @@ -653,6 +653,7 @@ void Eluna::OnCreateItem(Player* player, Item* item, uint32 count) Push(count); CallAllFunctions(PlayerEventBindings, key); } + void Eluna::OnStoreNewItem(Player* player, Item* item, uint32 count) { START_HOOK(PLAYER_EVENT_ON_STORE_NEW_ITEM); From 578cca0dde9525f5ec0c075ee278c3237960416b Mon Sep 17 00:00:00 2001 From: veserine Date: Sat, 28 Jan 2023 10:46:51 +0800 Subject: [PATCH 5/6] 2023-01-29 1046 update README.md under the pulling rule. --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 2cab782720..c7bb224049 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,9 @@ Eluna API for AC: - Added `RegisterPlayerEvent` `48` (`PLAYER_EVENT_ON_CAN_INIT_TRADE`): https://github.com/azerothcore/mod-eluna/pull/83 - Added `RegisterPlayerEvent` `49` (`PLAYER_EVENT_ON_CAN_SEND_MAIL`): https://github.com/azerothcore/mod-eluna/pull/85 - Added `RegisterPlayerEvent` `50` (`PLAYER_EVENT_ON_CAN_JOIN_LFG`): https://github.com/azerothcore/mod-eluna/pull/86 +- 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 `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 From 62a13c0d633248c9ccb7b2bbf1d29a7f6586de54 Mon Sep 17 00:00:00 2001 From: veserine Date: Sat, 28 Jan 2023 11:04:37 +0800 Subject: [PATCH 6/6] 20230128-1104 updated README_CN.md and GLOBALMETHODS_H under the pulling rule. --- README_CN.md | 3 +++ src/LuaEngine/GlobalMethods.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/README_CN.md b/README_CN.md index 64d2a7b373..e0bf1fd358 100644 --- a/README_CN.md +++ b/README_CN.md @@ -84,5 +84,8 @@ AC版的Eluna API: - 暴露方法 `Object:IsPlayer()`. https://github.com/azerothcore/Eluna/pull/42 - 添加玩家注册事件44(当玩家学习技能时): `PLAYER_EVENT_ON_LEARN_SPELL`. https://github.com/azerothcore/mod-eluna/pull/46 - 添加玩家注册事件45(当玩家完成成就时): `PLAYER_ON_ACHIEVEMENT_COMPLETE`。 https://github.com/azerothcore/mod-eluna/pull/47 +- 添加玩家注册事件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 - 新增参数*商人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/LuaEngine/GlobalMethods.h b/src/LuaEngine/GlobalMethods.h index 3966a2404f..f2a29120f8 100644 --- a/src/LuaEngine/GlobalMethods.h +++ b/src/LuaEngine/GlobalMethods.h @@ -723,6 +723,9 @@ 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) * }; * *