eluna OnLearnTalents hook and player:LearnTalent function

Signed-off-by: Salja <salja8840@gmail.com>
This commit is contained in:
Salja
2015-01-15 10:29:27 +01:00
committed by Rochet2
parent 3f9251fef9
commit ed0d7dd415
15 changed files with 52 additions and 23 deletions

View File

@@ -9,10 +9,9 @@
#include "Hooks.h"
#include "HookHelpers.h"
#include "ElunaTemplate.h"
#include "LuaEngine.h"
#include "ElunaTemplate.h" // Needed to be able to push BattleGround objects.
#include "ElunaBinding.h"
#include "ElunaTemplate.h"
using namespace Hooks;

View File

@@ -9,10 +9,10 @@
#include "Hooks.h"
#include "HookHelpers.h"
#include "ElunaTemplate.h"
#include "LuaEngine.h"
#include "ElunaBinding.h"
#include "ElunaIncludes.h"
#include "ElunaTemplate.h"
using namespace Hooks;

View File

@@ -9,11 +9,11 @@
#include "Hooks.h"
#include "HookHelpers.h"
#include "ElunaTemplate.h"
#include "LuaEngine.h"
#include "ElunaBinding.h"
#include "ElunaIncludes.h"
#include "ElunaEventMgr.h"
#include "ElunaTemplate.h"
using namespace Hooks;

View File

@@ -9,9 +9,9 @@
#include "Hooks.h"
#include "HookHelpers.h"
#include "ElunaTemplate.h"
#include "LuaEngine.h"
#include "ElunaBinding.h"
#include "ElunaTemplate.h"
using namespace Hooks;

View File

@@ -9,9 +9,9 @@
#include "Hooks.h"
#include "HookHelpers.h"
#include "ElunaTemplate.h"
#include "LuaEngine.h"
#include "ElunaBinding.h"
#include "ElunaTemplate.h"
using namespace Hooks;

View File

@@ -195,7 +195,7 @@ namespace Hooks
PLAYER_EVENT_ON_RESURRECT = 36, // (event, player)
PLAYER_EVENT_ON_LOOT_MONEY = 37, // (event, player, amount)
PLAYER_EVENT_ON_QUEST_ABANDON = 38, // (event, player, questId)
// UNUSED = 39, // (event, player)
PLAYER_EVENT_ON_LEARN_TALENTS = 39, // (event, player, talentId, talentRank, spellid)
// UNUSED = 40, // (event, player)
// UNUSED = 41, // (event, player)
PLAYER_EVENT_ON_COMMAND = 42, // (event, player, command) - player is nil if command used from console. Can return false

View File

@@ -9,10 +9,10 @@
#include "Hooks.h"
#include "HookHelpers.h"
#include "ElunaTemplate.h"
#include "LuaEngine.h"
#include "ElunaBinding.h"
#include "ElunaIncludes.h"
#include "ElunaTemplate.h"
using namespace Hooks;

View File

@@ -314,6 +314,7 @@ public:
void OnRepop(Player* pPlayer);
void OnResurrect(Player* pPlayer);
void OnQuestAbandon(Player* pPlayer, uint32 questId);
void OnLearnTalents(Player* pPlayer, uint32 talentId, uint32 talentRank, uint32 spellid);
InventoryResult OnCanUseItem(const Player* pPlayer, uint32 itemEntry);
void OnLuaStateClose();
void OnLuaStateOpen();

View File

@@ -649,6 +649,7 @@ ElunaRegister<Player> PlayerMethods[] =
{ "SendVendorWindow", &LuaPlayer::SendVendorWindow }, // :SendVendorWindow(unit) - Sends the unit's vendor window to the player
{ "ModifyMoney", &LuaPlayer::ModifyMoney }, // :ModifyMoney(amount[, sendError]) - Modifies (does not set) money (copper count) of the player. Amount can be negative to remove copper
{ "LearnSpell", &LuaPlayer::LearnSpell }, // :LearnSpell(id) - learns the given spell
{ "LearnTalent", &LuaPlayer::LearnTalent },
{ "RemoveItem", &LuaPlayer::RemoveItem }, // :RemoveItem(item/entry, amount) - Removes amount of item from player
{ "RemoveLifetimeKills", &LuaPlayer::RemoveLifetimeKills }, // :RemoveLifetimeKills(val) - Removes a specified amount(val) of the player's lifetime (honorable) kills
{ "ResurrectPlayer", &LuaPlayer::ResurrectPlayer }, // :ResurrectPlayer([percent[, sickness(bool)]]) - Resurrects the player at percentage, player gets resurrection sickness if sickness set to true

View File

@@ -9,13 +9,26 @@
#include "Hooks.h"
#include "HookHelpers.h"
#include "ElunaTemplate.h"
#include "LuaEngine.h"
#include "ElunaBinding.h"
#include "ElunaIncludes.h"
#include "ElunaTemplate.h"
using namespace Hooks;
void Eluna::OnLearnTalents(Player* pPlayer, uint32 talentId, uint32 talentRank, uint32 spellid)
{
if (!PlayerEventBindings->HasEvents(PLAYER_EVENT_ON_LEARN_TALENTS))
return;
LOCK_ELUNA;
Push(pPlayer);
Push(talentId);
Push(talentRank);
Push(spellid);
CallAllFunctions(PlayerEventBindings, PLAYER_EVENT_ON_LEARN_TALENTS);
}
void Eluna::HandleGossipSelectOption(Player* pPlayer, Item* item, uint32 sender, uint32 action, const std::string& code)
{
if (!ItemGossipBindings->HasEvents(GOSSIP_EVENT_ON_SELECT, item->GetEntry()))

View File

@@ -2924,6 +2924,21 @@ namespace LuaPlayer
return 0;
}
/**
* Learn the [Player] the [Talent] specified by talent_id and talentRank
*
* @param uint32 talent_id
* @param uint32 talentRank
*/
int LearnTalent(Eluna* /*E*/, lua_State* L, Player* player)
{
uint32 id = Eluna::CHECKVAL<uint32>(L, 2);
uint32 rank = Eluna::CHECKVAL<uint32>(L, 3);
player->LearnTalent(id, rank);
return 0;
}
/**
* Resurrects the [Player]
*

View File

@@ -11,9 +11,9 @@
#include "HookHelpers.h"
#include "LuaEngine.h"
#include "ElunaBinding.h"
#include "ElunaTemplate.h"
#include "ElunaEventMgr.h"
#include "ElunaIncludes.h"
#include "ElunaTemplate.h"
using namespace Hooks;

View File

@@ -12,9 +12,9 @@
#include "Hooks.h"
#include "HookHelpers.h"
#include "ElunaTemplate.h"
#include "LuaEngine.h"
#include "ElunaBinding.h"
#include "ElunaTemplate.h"
using namespace Hooks;