[9581] Fixed apply damage reduction to melee/ranged damage.
[getmangos.git] / src / game / SkillHandler.cpp
blob8bcef39706ef8698ac0a52e774806650f0173697
1 /*
2 * Copyright (C) 2005-2010 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #include "Common.h"
20 #include "Database/DatabaseEnv.h"
21 #include "Opcodes.h"
22 #include "Log.h"
23 #include "Player.h"
24 #include "WorldPacket.h"
25 #include "WorldSession.h"
26 #include "UpdateMask.h"
28 void WorldSession::HandleLearnTalentOpcode( WorldPacket & recv_data )
30 uint32 talent_id, requested_rank;
31 recv_data >> talent_id >> requested_rank;
33 _player->LearnTalent(talent_id, requested_rank);
34 _player->SendTalentsInfoData(false);
37 void WorldSession::HandleLearnPreviewTalents(WorldPacket& recvPacket)
39 sLog.outDebug("CMSG_LEARN_PREVIEW_TALENTS");
41 uint32 talentsCount;
42 recvPacket >> talentsCount;
44 uint32 talentId, talentRank;
46 for(uint32 i = 0; i < talentsCount; ++i)
48 recvPacket >> talentId >> talentRank;
50 _player->LearnTalent(talentId, talentRank);
53 _player->SendTalentsInfoData(false);
56 void WorldSession::HandleTalentWipeConfirmOpcode( WorldPacket & recv_data )
58 sLog.outDetail("MSG_TALENT_WIPE_CONFIRM");
59 uint64 guid;
60 recv_data >> guid;
62 Creature *unit = GetPlayer()->GetNPCIfCanInteractWith(guid,UNIT_NPC_FLAG_TRAINER);
63 if (!unit)
65 sLog.outDebug( "WORLD: HandleTalentWipeConfirmOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)) );
66 return;
69 // remove fake death
70 if(GetPlayer()->hasUnitState(UNIT_STAT_DIED))
71 GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
73 if(!(_player->resetTalents()))
75 WorldPacket data( MSG_TALENT_WIPE_CONFIRM, 8+4); //you have not any talent
76 data << uint64(0);
77 data << uint32(0);
78 SendPacket( &data );
79 return;
82 _player->SendTalentsInfoData(false);
83 unit->CastSpell(_player, 14867, true); //spell: "Untalent Visual Effect"
86 void WorldSession::HandleUnlearnSkillOpcode(WorldPacket & recv_data)
88 uint32 skill_id;
89 recv_data >> skill_id;
90 GetPlayer()->SetSkill(skill_id, 0, 0);