Skip to content

Commit

Permalink
Added Trade Init and Accept hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
Foereaper committed Oct 13, 2023
1 parent c403f8d commit 34c27ce
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Hooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,14 @@ namespace Hooks
PLAYER_EVENT_ON_QUEST_ABANDON = 38, // (event, player, questId)
PLAYER_EVENT_ON_LEARN_TALENTS = 39, // (event, player, talentId, talentRank, spellid)
PLAYER_EVENT_ON_ENVIRONMENTAL_DEATH = 40, // (event, player, environmentalDamageType)
// UNUSED = 41, // (event, player)
PLAYER_EVENT_ON_TRADE_ACCEPT = 41, // (event, player, target) - Can return false to interrupt trade
PLAYER_EVENT_ON_COMMAND = 42, // (event, player, command) - player is nil if command used from console. Can return false
// UNUSED = 43, // (event, player)
PLAYER_EVENT_ON_LEARN_SPELL = 44, // (event, player, spellId)
PLAYER_EVENT_ON_ACHIEVEMENT_COMPLETE = 45, // (event, player, achievementId)
// UNUSED = 46, // (event, player)
PLAYER_EVENT_ON_UPDATE_AREA = 47, // (event, player, oldArea, newArea)
// UNUSED = 48, // (event, player)
PLAYER_EVENT_ON_TRADE_INIT = 48, // (event, player, target) - Can return false to interrupt trade
// UNUSED = 49, // (event, player)
// UNUSED = 50, // (event, player)
// UNUSED = 51, // (event, player)
Expand Down
2 changes: 2 additions & 0 deletions LuaEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,8 @@ class ELUNA_GAME_API Eluna
void OnLuaStateClose();
void OnLuaStateOpen();
bool OnAddonMessage(Player* sender, uint32 type, std::string& msg, Player* receiver, Guild* guild, Group* group, Channel* channel);
bool OnTradeInit(Player* trader, Player* tradee);
bool OnTradeAccept(Player* trader, Player* tradee);

/* Item */
void OnDummyEffect(WorldObject* pCaster, uint32 spellId, SpellEffIndex effIndex, Item* pTarget);
Expand Down
16 changes: 16 additions & 0 deletions PlayerHooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,22 @@ void Eluna::OnAchievementComplete(Player* player, uint32 achievementId)
CallAllFunctions(PlayerEventBindings, key);
}

bool Eluna::OnTradeInit(Player* trader, Player* tradee)
{
START_HOOK_WITH_RETVAL(PLAYER_EVENT_ON_TRADE_INIT, true);
Push(trader);
Push(tradee);
return CallAllFunctionsBool(PlayerEventBindings, key, true);
}

bool Eluna::OnTradeAccept(Player* trader, Player* tradee)
{
START_HOOK_WITH_RETVAL(PLAYER_EVENT_ON_TRADE_ACCEPT, true);
Push(trader);
Push(tradee);
return CallAllFunctionsBool(PlayerEventBindings, key, true);
}

bool Eluna::OnChat(Player* pPlayer, uint32 type, uint32 lang, std::string& msg)
{
if (lang == LANG_ADDON)
Expand Down
4 changes: 2 additions & 2 deletions TrinityCore/GlobalMethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -650,14 +650,14 @@ namespace LuaGlobalFunctions
* PLAYER_EVENT_ON_QUEST_ABANDON = 38, // (event, player, questId)
* PLAYER_EVENT_ON_LEARN_TALENTS = 39, // (event, player, talentId, talentRank, spellid)
* PLAYER_EVENT_ON_ENVIRONMENTAL_DEATH = 40, // (event, player, environmentalDamageType)
* // UNUSED = 41, // (event, player)
* PLAYER_EVENT_ON_TRADE_ACCEPT = 41, // (event, player, target) - Can return false to interrupt trade
* PLAYER_EVENT_ON_COMMAND = 42, // (event, player, command) - player is nil if command used from console. Can return false
* // UNUSED = 43, // (event, player)
* PLAYER_EVENT_ON_LEARN_SPELL = 44, // (event, player, spellId)
* PLAYER_EVENT_ON_ACHIEVEMENT_COMPLETE = 45, // (event, player, achievementId)
* // UNUSED = 46, // (event, player)
* PLAYER_EVENT_ON_UPDATE_AREA = 47, // (event, player, oldArea, newArea)
* // UNUSED = 48, // (event, player)
* PLAYER_EVENT_ON_TRADE_INIT = 48, // (event, player, target) - Can return false to interrupt trade
* // UNUSED = 49, // (event, player)
* // UNUSED = 50, // (event, player)
* // UNUSED = 51, // (event, player)
Expand Down

0 comments on commit 34c27ce

Please sign in to comment.