diff --git a/BattleGroundHooks.cpp b/BattleGroundHooks.cpp index c0bb186..5806c54 100644 --- a/BattleGroundHooks.cpp +++ b/BattleGroundHooks.cpp @@ -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 \ No newline at end of file +#endif // _BATTLEGROUND_HOOKS_H diff --git a/CreatureHooks.cpp b/CreatureHooks.cpp index 0fb1ff7..104945e 100644 --- a/CreatureHooks.cpp +++ b/CreatureHooks.cpp @@ -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 \ No newline at end of file +#endif // _CREATURE_HOOKS_H diff --git a/ElunaIncludes.h b/ElunaIncludes.h index fb67c61..eed76b6 100644 --- a/ElunaIncludes.h +++ b/ElunaIncludes.h @@ -131,4 +131,4 @@ enum SelectAggroTarget }; #endif // TRINITY -#endif // _ELUNA_INCLUDES_H \ No newline at end of file +#endif // _ELUNA_INCLUDES_H diff --git a/GameObjectHooks.cpp b/GameObjectHooks.cpp index 7ec12e5..2c6387e 100644 --- a/GameObjectHooks.cpp +++ b/GameObjectHooks.cpp @@ -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 \ No newline at end of file +#endif // _GAMEOBJECT_HOOKS_H diff --git a/GroupHooks.cpp b/GroupHooks.cpp index 0277a61..d36e4ca 100644 --- a/GroupHooks.cpp +++ b/GroupHooks.cpp @@ -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 \ No newline at end of file +#endif // _GROUP_HOOKS_H diff --git a/GuildHooks.cpp b/GuildHooks.cpp index 58f6ed9..4f57bfa 100644 --- a/GuildHooks.cpp +++ b/GuildHooks.cpp @@ -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 \ No newline at end of file +#endif // _GUILD_HOOKS_H diff --git a/HookHelpers.h b/HookHelpers.h index 6ff54a9..e36f1cd 100644 --- a/HookHelpers.h +++ b/HookHelpers.h @@ -126,4 +126,4 @@ bool Eluna::CallAllFunctionsBool(EventBind* event_bindings, EntryBind* ent return result; } -#endif // _HOOK_HELPERS_H \ No newline at end of file +#endif // _HOOK_HELPERS_H diff --git a/Hooks.h b/Hooks.h index 2c8531a..24aeee8 100644 --- a/Hooks.h +++ b/Hooks.h @@ -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 \ No newline at end of file +#endif // _HOOKS_H diff --git a/ItemHooks.cpp b/ItemHooks.cpp index af7046e..196cf2c 100644 --- a/ItemHooks.cpp +++ b/ItemHooks.cpp @@ -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 \ No newline at end of file +#endif // _ITEM_HOOKS_H diff --git a/LuaEngine.h b/LuaEngine.h index 6b2695b..08f1480 100644 --- a/LuaEngine.h +++ b/LuaEngine.h @@ -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(); diff --git a/LuaFunctions.cpp b/LuaFunctions.cpp index 120e2ee..afc807f 100644 --- a/LuaFunctions.cpp +++ b/LuaFunctions.cpp @@ -649,6 +649,7 @@ ElunaRegister 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 diff --git a/PlayerHooks.cpp b/PlayerHooks.cpp index 4e58e32..3569cc4 100644 --- a/PlayerHooks.cpp +++ b/PlayerHooks.cpp @@ -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 \ No newline at end of file +#endif // _PLAYER_HOOKS_H diff --git a/PlayerMethods.h b/PlayerMethods.h index 5ec3daf..0f162db 100644 --- a/PlayerMethods.h +++ b/PlayerMethods.h @@ -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(L, 2); + uint32 rank = Eluna::CHECKVAL(L, 3); + + player->LearnTalent(id, rank); + return 0; + } + /** * Resurrects the [Player] * diff --git a/ServerHooks.cpp b/ServerHooks.cpp index e4c9691..6391556 100644 --- a/ServerHooks.cpp +++ b/ServerHooks.cpp @@ -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 \ No newline at end of file +#endif // _SERVER_HOOKS_H diff --git a/VehicleHooks.cpp b/VehicleHooks.cpp index bf137bc..90892ed 100644 --- a/VehicleHooks.cpp +++ b/VehicleHooks.cpp @@ -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 \ No newline at end of file +#endif // _VEHICLE_HOOKS_H