Files
TCPlayerbotCore/src/game/SkillHandler.cpp
T

96 lines
2.8 KiB
C++
Raw Normal View History

2008-10-02 16:23:55 -05:00
/*
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
2008-10-14 11:57:03 -05:00
*
2010-01-16 20:19:18 +03:00
* Copyright (C) 2008-2010 Trinity <http://www.trinitycore.org/>
2008-10-02 16:23:55 -05:00
*
* 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
2008-10-14 11:57:03 -05:00
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2008-10-02 16:23:55 -05:00
* 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, write to the Free Software
2008-10-14 11:57:03 -05:00
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
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 "Database/DatabaseEnv.h"
#include "Opcodes.h"
#include "Log.h"
#include "Player.h"
#include "WorldPacket.h"
#include "WorldSession.h"
#include "ObjectAccessor.h"
#include "UpdateMask.h"
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
void WorldSession::HandleLearnTalentOpcode( WorldPacket & recv_data )
{
uint32 talent_id, requested_rank;
recv_data >> 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)
{
sLog.outDebug("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
2009-10-17 16:20:24 -07:00
for (uint32 i = 0; i < talentsCount; ++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);
2008-10-02 16:23:55 -05:00
}
2009-10-17 15:51:44 -07:00
2009-05-31 15:56:51 -05:00
void WorldSession::HandleTalentWipeConfirmOpcode( WorldPacket & recv_data )
2008-10-02 16:23:55 -05:00
{
sLog.outDetail("MSG_TALENT_WIPE_CONFIRM");
uint64 guid;
recv_data >> guid;
2009-10-17 15:51:44 -07:00
Creature *unit = GetPlayer()->GetNPCIfCanInteractWith(guid,UNIT_NPC_FLAG_TRAINER);
2008-10-02 16:23:55 -05:00
if (!unit)
{
2009-05-31 15:56:51 -05:00
sLog.outDebug( "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
2008-10-02 16:23:55 -05:00
// remove fake death
if(GetPlayer()->hasUnitState(UNIT_STAT_DIED))
2009-04-06 13:31:14 +02:00
GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
if(!(_player->resetTalents()))
{
WorldPacket data( MSG_TALENT_WIPE_CONFIRM, 8+4); //you have not any talent
data << uint64(0);
data << uint32(0);
SendPacket( &data );
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
2008-10-02 16:23:55 -05:00
void WorldSession::HandleUnlearnSkillOpcode(WorldPacket & recv_data)
{
uint32 skill_id;
recv_data >> skill_id;
GetPlayer()->SetSkill(skill_id, 0, 0);
}
2009-02-17 20:07:49 -06:00