Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add PLAYER_EVENT_ON_QUEST_REWARD_ITEM, add PLAYER_EVENT_ON_CREATE_ITEM, add PLAYER_EVENT_ON_STORE_NEW_ITEM #88

Merged
merged 6 commits into from
Jan 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/ElunaLuaEngine_SC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,19 @@ class Eluna_PlayerScript : public PlayerScript
{
return sEluna->OnCanJoinLfg(player, roles, dungeons, comment);
}
veserine marked this conversation as resolved.
Show resolved Hide resolved
void OnQuestRewardItem(Player* player, Item* item, uint32 count) override
{
sEluna->OnQuestRewardItem(player, item, count);
}
veserine marked this conversation as resolved.
Show resolved Hide resolved
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
Expand Down
3 changes: 3 additions & 0 deletions src/LuaEngine/Hooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand Down
3 changes: 3 additions & 0 deletions src/LuaEngine/LuaEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
26 changes: 26 additions & 0 deletions src/LuaEngine/PlayerHooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
veserine marked this conversation as resolved.
Show resolved Hide resolved
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);
}