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;
@@ -65,4 +64,4 @@ void Eluna::OnBGDestroy(BattleGround* bg, BattleGroundTypeId bgId, uint32 instan
CallAllFunctions(BGEventBindings, BG_EVENT_ON_PRE_DESTROY);
}
#endif // _BATTLEGROUND_HOOKS_H
#endif // _BATTLEGROUND_HOOKS_H

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;
@@ -484,4 +484,4 @@ bool Eluna::OwnerAttacked(Creature* me, Unit* target)
}
#endif // TRINITY
#endif // _CREATURE_HOOKS_H
#endif // _CREATURE_HOOKS_H

View File

@@ -131,4 +131,4 @@ enum SelectAggroTarget
};
#endif // TRINITY
#endif // _ELUNA_INCLUDES_H
#endif // _ELUNA_INCLUDES_H

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;
@@ -209,4 +209,4 @@ bool Eluna::OnGameObjectUse(Player* pPlayer, GameObject* pGameObject)
return CallAllFunctionsBool(GameObjectEventBindings, GAMEOBJECT_EVENT_ON_USE, pGameObject->GetEntry());
}
#endif // _GAMEOBJECT_HOOKS_H
#endif // _GAMEOBJECT_HOOKS_H

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;
@@ -83,4 +83,4 @@ void Eluna::OnCreate(Group* group, uint64 leaderGuid, GroupType groupType)
CallAllFunctions(GroupEventBindings, GROUP_EVENT_ON_CREATE);
}
#endif // _GROUP_HOOKS_H
#endif // _GROUP_HOOKS_H

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;
@@ -191,4 +191,4 @@ void Eluna::OnBankEvent(Guild* guild, uint8 eventType, uint8 tabId, uint32 playe
CallAllFunctions(GuildEventBindings, GUILD_EVENT_ON_BANK_EVENT);
}
#endif // _GUILD_HOOKS_H
#endif // _GUILD_HOOKS_H

View File

@@ -126,4 +126,4 @@ bool Eluna::CallAllFunctionsBool(EventBind<T>* event_bindings, EntryBind<T>* ent
return result;
}
#endif // _HOOK_HELPERS_H
#endif // _HOOK_HELPERS_H

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
@@ -334,4 +334,4 @@ namespace Hooks
};
};
#endif // _HOOKS_H
#endif // _HOOKS_H

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;
@@ -142,4 +142,4 @@ bool Eluna::OnRemove(Player* pPlayer, Item* item)
return CallAllFunctionsBool(ItemEventBindings, ITEM_EVENT_ON_REMOVE, item->GetEntry());
}
#endif // _ITEM_HOOKS_H
#endif // _ITEM_HOOKS_H

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()))
@@ -717,4 +730,4 @@ bool Eluna::OnChat(Player* pPlayer, uint32 type, uint32 lang, std::string& msg,
return result;
}
#endif // _PLAYER_HOOKS_H
#endif // _PLAYER_HOOKS_H

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;
@@ -404,4 +404,4 @@ void Eluna::OnRemove(Creature* creature)
CallAllFunctions(ServerEventBindings, WORLD_EVENT_ON_DELETE_CREATURE);
}
#endif // _SERVER_HOOKS_H
#endif // _SERVER_HOOKS_H

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;
@@ -75,4 +75,4 @@ void Eluna::OnRemovePassenger(Vehicle* vehicle, Unit* passenger)
#endif // CLASSIC
#endif // TBC
#endif // _VEHICLE_HOOKS_H
#endif // _VEHICLE_HOOKS_H