Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion Hooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ namespace Hooks
PLAYER_EVENT_ON_LOOT_MONEY = 37, // (event, player, amount)
PLAYER_EVENT_ON_QUEST_ABANDON = 38, // (event, player, questId)
PLAYER_EVENT_ON_LEARN_TALENTS = 39, // (event, player, talentId, talentRank, spellid)
// UNUSED = 40, // (event, player)
PLAYER_EVENT_ON_CRAFT_SKILL_CHANGE = 40, // (event, player, craftSpellId, craftSkillAmount) - Can return new skill amount
// UNUSED = 41, // (event, player)
PLAYER_EVENT_ON_COMMAND = 42, // (event, player, command) - player is nil if command used from console. Can return false

Expand Down
1 change: 1 addition & 0 deletions LuaEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ class TC_GAME_API Eluna
void OnResurrect(Player* pPlayer);
void OnQuestAbandon(Player* pPlayer, uint32 questId);
void OnLearnTalents(Player* pPlayer, uint32 talentId, uint32 talentRank, uint32 spellid);
void OnCraftSkillChange(Player* pPlayer, uint32 spellid, uint32& skillAmount);
InventoryResult OnCanUseItem(const Player* pPlayer, uint32 itemEntry);
void OnLuaStateClose();
void OnLuaStateOpen();
Expand Down
26 changes: 26 additions & 0 deletions PlayerHooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,32 @@ void Eluna::OnLearnTalents(Player* pPlayer, uint32 talentId, uint32 talentRank,
CallAllFunctions(PlayerEventBindings, key);
}

void Eluna::OnCraftSkillChange(Player* pPlayer, uint32 spellid, uint32& skillAmount)
{
START_HOOK(PLAYER_EVENT_ON_CRAFT_SKILL_CHANGE);
Push(pPlayer);
Push(spellid);
Push(skillAmount);
int amountIndex = lua_gettop(L) - 1;
int n = SetupStack(PlayerEventBindings, key, 3);

while (n > 0)
{
int r = CallOneFunction(n--, 3, 1);

if (lua_isnumber(L, r))
{
skillAmount = CHECKVAL<uint32>(L, r);
// Update the stack for subsequent calls.
ReplaceArgument(skillAmount, amountIndex);
}

lua_pop(L, 1);
}

CleanUpStack(3);
}

bool Eluna::OnCommand(Player* player, const char* text)
{
// If from console, player is NULL
Expand Down