Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
SkillHandler.cpp
Go to the documentation of this file.
1/*
2* This file is part of Project SkyFire https://www.projectskyfire.org.
3* See LICENSE.md file for Copyright information
4*/
5
6#include "Common.h"
7#include "DatabaseEnv.h"
8#include "Log.h"
9#include "ObjectAccessor.h"
10#include "Opcodes.h"
11#include "Pet.h"
12#include "Player.h"
13#include "UpdateMask.h"
14#include "WorldPacket.h"
15#include "WorldSession.h"
16
18{
19 uint32 specializationTabId;
20 recvData >> specializationTabId;
21
22 if (specializationTabId > MAX_TALENT_TABS)
23 return;
24
25 if (_player->GetTalentSpecialization(_player->GetActiveSpec()))
26 return;
27
28 uint32 specializationId = GetClassSpecializations(_player->getClass())[specializationTabId];
29
30 _player->SetTalentSpecialization(_player->GetActiveSpec(), specializationId);
31 _player->SetUInt32Value(PLAYER_FIELD_CURRENT_SPEC_ID, specializationId);
32 _player->UpdateTalentSpecializationManaBonus();
33 _player->SendTalentsInfoData();
34
35 std::list<uint32> learnList = GetSpellsForLevels(0, _player->getRaceMask(), _player->GetTalentSpecialization(_player->GetActiveSpec()), 0, _player->getLevel());
36 for (std::list<uint32>::const_iterator iter = learnList.begin(); iter != learnList.end(); ++iter)
37 {
38 if (!_player->HasSpell(*iter))
39 _player->learnSpell(*iter, true);
40 }
41
42 _player->SaveToDB();
43}
44
46{
47 uint32 talentCount = recvData.ReadBits(23);
48 uint16 talentId;
49 bool anythingLearned = false;
50
51 for (uint32 i = 0; i != talentCount; i++)
52 {
53 recvData >> talentId;
54 if (_player->LearnTalent(talentId))
55 anythingLearned = true;
56 }
57
58 if (anythingLearned)
59 _player->SendTalentsInfoData();
60}
61
63{
64 SF_LOG_DEBUG("network", "CMSG_LEARN_PREVIEW_TALENTS");
65}
66
68{
69 SF_LOG_DEBUG("network", "CMSG_CONFIRM_RESPEC_WIPE");
70 ObjectGuid guid;
71 uint8 RespecType = 0;
72 uint32 Cost = 0;
73
74 recvPacket >> RespecType;
75 recvPacket.ReadGuidMask(guid, 7, 2, 6, 1, 4, 0, 3, 5);
76 recvPacket.ReadGuidBytes(guid, 2, 4, 1, 3, 0, 5, 7, 6);
77
78 // remove fake death
79 if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
81
82 if (!RespecType)
83 {
84 if (!_player->ResetTalents(Cost, true, false))
85 {
86 GetPlayer()->SendTalentWipeConfirm(guid, false);
87 return;
88 }
89 }
90 else
91 {
92 _player->ResetTalents(Cost, false, true);
93 }
94
95 _player->SendTalentsInfoData();
96
97 if (Unit* unit = _player->GetSelectedUnit())
98 unit->CastSpell(_player, 14867, true); //spell: "Untalent Visual Effect"
99}
100
102{
103 uint32 skillId;
104 recvData >> skillId;
105
106 if (!IsPrimaryProfessionSkill(skillId))
107 return;
108
109 GetPlayer()->SetSkill(skillId, 0, 0, 0);
110}
111
113{
114 if (!_player)
115 return;
116
117 _player->SendResearchHistory();
118}
uint32 const * GetClassSpecializations(uint8 classId)
std::list< uint32 > GetSpellsForLevels(uint32 classId, uint32 raceMask, uint32 specializationId, uint32 minLevel, uint32 maxLevel)
#define MAX_TALENT_TABS
std::uint8_t uint8
Definition Define.h:79
std::uint32_t uint32
Definition Define.h:77
std::uint16_t uint16
Definition Define.h:78
#define SF_LOG_DEBUG(filterType__,...)
Definition Log.h:134
@ SPELL_AURA_FEIGN_DEATH
bool IsPrimaryProfessionSkill(uint32 skill)
Definition SpellMgr.cpp:23
@ UNIT_STATE_DIED
Definition Unit.h:512
@ PLAYER_FIELD_CURRENT_SPEC_ID
uint32 ReadBits(size_t bits)
Definition ByteBuffer.h:198
void ReadGuidBytes(ObjectGuid &guid, Offsets... offsets)
Definition ByteBuffer.h:256
void ReadGuidMask(ObjectGuid &guid, Offsets... offsets)
Definition ByteBuffer.h:240
void SendTalentWipeConfirm(ObjectGuid guid, bool resetType)
Definition Player.cpp:10409
void SetSkill(uint16 id, uint16 step, uint16 currVal, uint16 maxVal)
Definition Player.cpp:6377
Definition Unit.h:1367
void RemoveAurasByType(AuraType auraType, uint64 casterGUID=0, Aura *except=NULL, bool negative=true, bool positive=true)
void HandleRespecWipeConfirmOpcode(WorldPacket &recvPacket)
Player * GetPlayer() const
void HandleLearnPreviewTalents(WorldPacket &recvPacket)
Player * _player
void HandleUnlearnSkillOpcode(WorldPacket &recvPacket)
void HandleLearnTalentOpcode(WorldPacket &recvPacket)
void HandleRequestResearchHistory(WorldPacket &recvPacket)
void HandeSetTalentSpecialization(WorldPacket &recvData)