TrinityCore
Loading...
Searching...
No Matches
SkillHandler.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "WorldSession.h"
19#include "Common.h"
20#include "DBCStores.h"
21#include "Log.h"
22#include "ObjectAccessor.h"
23#include "Pet.h"
24#include "Player.h"
25#include "TalentPackets.h"
26#include "WorldPacket.h"
27
33
35{
36 bool anythingLearned = false;
37 for (WorldPackets::Talent::LearnTalentEntry const& learnTalentEntry : learnPreviewTalents.Talents)
38 {
39 if (_player->LearnTalent(learnTalentEntry.TalentID, learnTalentEntry.Rank))
40 anythingLearned = true;
41 else
42 break;
43 }
44
45 if (anythingLearned)
47}
48
50{
51 TC_LOG_DEBUG("network", "MSG_TALENT_WIPE_CONFIRM");
52
54 if (!trainer)
55 {
56 TC_LOG_DEBUG("network", "WORLD: HandleTalentWipeConfirmOpcode - {} not found or you can't interact with him.", confirmRespecWipe.RespecMaster);
57 return;
58 }
59
60 if (!trainer->CanResetTalents(_player, false))
61 return;
62
64 if (!_player->HasEnoughMoney(cost))
65 return; // // silently return, client should display the error by itself
66
67 // remove fake death
68 if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
70
71 if (!_player->ResetTalents())
72 {
74 return;
75 }
76
77 _player->ModifyMoney(-(int32)cost);
80
81 trainer->CastSpell(_player, 14867 /*SPELL_UNTALENT_VISUAL_EFFECT*/, true);
82}
83
85{
86 uint32 skillId;
87 recvData >> skillId;
88
89 SkillRaceClassInfoEntry const* rcEntry = GetSkillRaceClassInfo(skillId, GetPlayer()->GetRace(), GetPlayer()->GetClass());
90 if (!rcEntry || !(rcEntry->Flags & SKILL_FLAG_UNLEARNABLE))
91 return;
92
93 GetPlayer()->SetSkill(skillId, 0, 0, 0);
94}
@ SKILL_FLAG_UNLEARNABLE
Definition DBCEnums.h:374
SkillRaceClassInfoEntry const * GetSkillRaceClassInfo(uint32 skill, uint8 race, uint8 class_)
int32_t int32
Definition Define.h:129
uint32_t uint32
Definition Define.h:133
#define TC_LOG_DEBUG(filterType__,...)
Definition Log.h:156
@ SPELL_AURA_FEIGN_DEATH
@ UNIT_NPC_FLAG_TRAINER
@ UNIT_STATE_DIED
Definition Unit.h:234
bool CanResetTalents(Player *player, bool pet) const
static ObjectGuid const Empty
Definition ObjectGuid.h:140
void SendTalentsInfoData(bool pet)
Definition Player.cpp:25337
uint32 GetNextResetTalentsCost() const
Definition Player.cpp:3688
bool LearnTalent(uint32 talentId, uint32 talentRank)
Definition Player.cpp:24924
bool ModifyMoney(int32 amount, bool sendError=true)
Definition Player.cpp:22336
void SetSkill(uint32 id, uint16 step, uint16 newVal, uint16 maxVal)
Definition Player.cpp:5773
bool HasEnoughMoney(uint32 amount) const
Definition Player.h:1394
Creature * GetNPCIfCanInteractWith(ObjectGuid const &guid, NPCFlags npcFlags) const
Definition Player.cpp:2126
bool ResetTalents(bool involuntarily=false)
Definition Player.cpp:3735
void IncreaseResetTalentsCostAndCounters(uint32 lastResetTalentsCost)
Definition Player.cpp:3724
void SendRespecWipeConfirm(ObjectGuid const &guid, uint32 cost) const
Definition Player.cpp:9153
void RemoveAurasByType(AuraType auraType, std::function< bool(AuraApplication const *)> const &check, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3788
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2833
Array< LearnTalentEntry, 150 > Talents
void HandleLearnPreviewTalents(WorldPackets::Talent::LearnPreviewTalents &learnPreviewTalents)
Player * GetPlayer() const
void HandleLearnTalentOpcode(WorldPackets::Talent::LearnTalent &packet)
Player * _player
void HandleTalentWipeConfirmOpcode(WorldPackets::Talent::ConfirmRespecWipe &confirmRespecWipe)
void HandleUnlearnSkillOpcode(WorldPacket &recvPacket)