Files
TCPlayerbotCore/src/server/game/Handlers/SkillHandler.cpp
T

106 lines
3.0 KiB
C++
Raw Normal View History

/*
2014-01-01 00:07:53 +01:00
* Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
2008-10-02 16:23:55 -05:00
*/
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
#include "Common.h"
#include "DatabaseEnv.h"
2008-10-02 16:23:55 -05:00
#include "Log.h"
#include "ObjectAccessor.h"
#include "Opcodes.h"
2008-10-02 16:23:55 -05:00
#include "Player.h"
#include "Pet.h"
#include "UpdateMask.h"
2008-10-02 16:23:55 -05:00
#include "WorldPacket.h"
#include "WorldSession.h"
2009-10-17 15:51:44 -07:00
void WorldSession::HandleLearnTalentOpcode(WorldPacket& recvData)
2008-10-02 16:23:55 -05:00
{
uint32 talent_id, requested_rank;
2012-11-02 22:23:14 +01:00
recvData >> talent_id >> requested_rank;
2009-10-17 15:51:44 -07:00
_player->LearnTalent(talent_id, requested_rank);
2009-06-11 00:45:59 -05:00
_player->SendTalentsInfoData(false);
}
2009-10-17 15:51:44 -07:00
2009-06-11 00:45:59 -05:00
void WorldSession::HandleLearnPreviewTalents(WorldPacket& recvPacket)
{
TC_LOG_DEBUG("network", "CMSG_LEARN_PREVIEW_TALENTS");
2009-10-17 15:51:44 -07:00
2009-06-11 00:45:59 -05:00
uint32 talentsCount;
recvPacket >> talentsCount;
2009-10-17 15:51:44 -07:00
2009-06-11 00:45:59 -05:00
uint32 talentId, talentRank;
2009-10-17 15:51:44 -07:00
// Client has max 44 talents for tree for 3 trees, rounded up : 150
uint32 const MaxTalentsCount = 150;
for (uint32 i = 0; i < talentsCount && i < MaxTalentsCount; ++i)
2009-06-11 00:45:59 -05:00
{
recvPacket >> talentId >> talentRank;
2009-10-17 15:51:44 -07:00
2009-06-11 00:45:59 -05:00
_player->LearnTalent(talentId, talentRank);
}
2009-10-17 15:51:44 -07:00
2009-06-11 00:45:59 -05:00
_player->SendTalentsInfoData(false);
recvPacket.rfinish();
2008-10-02 16:23:55 -05:00
}
2009-10-17 15:51:44 -07:00
void WorldSession::HandleTalentWipeConfirmOpcode(WorldPacket& recvData)
2008-10-02 16:23:55 -05:00
{
TC_LOG_DEBUG("network", "MSG_TALENT_WIPE_CONFIRM");
2008-10-02 16:23:55 -05:00
uint64 guid;
2012-11-02 22:23:14 +01:00
recvData >> guid;
2009-10-17 15:51:44 -07:00
2011-06-12 01:47:45 +02:00
Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_TRAINER);
2008-10-02 16:23:55 -05:00
if (!unit)
{
TC_LOG_DEBUG("network", "WORLD: HandleTalentWipeConfirmOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)));
2008-10-02 16:23:55 -05:00
return;
}
2009-10-17 15:51:44 -07:00
if (!unit->isCanTrainingAndResetTalentsOf(_player))
return;
2008-10-02 16:23:55 -05:00
// remove fake death
if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
2009-04-06 13:31:14 +02:00
GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if (!(_player->resetTalents()))
2008-10-02 16:23:55 -05:00
{
2010-04-07 22:59:46 +02:00
WorldPacket data(MSG_TALENT_WIPE_CONFIRM, 8+4); //you have not any talent
2008-10-02 16:23:55 -05:00
data << uint64(0);
data << uint32(0);
2010-04-07 22:59:46 +02:00
SendPacket(&data);
2008-10-02 16:23:55 -05:00
return;
}
2009-10-17 15:51:44 -07:00
2009-06-11 00:45:59 -05:00
_player->SendTalentsInfoData(false);
2008-10-02 16:23:55 -05:00
unit->CastSpell(_player, 14867, true); //spell: "Untalent Visual Effect"
}
2009-10-17 15:51:44 -07:00
void WorldSession::HandleUnlearnSkillOpcode(WorldPacket& recvData)
2008-10-02 16:23:55 -05:00
{
uint32 skillId;
recvData >> skillId;
if (!IsPrimaryProfessionSkill(skillId))
return;
GetPlayer()->SetSkill(skillId, 0, 0, 0);
2008-10-02 16:23:55 -05:00
}