diff options
author | Mykhailo Redko <ovitnez@gmail.com> | 2024-02-13 16:55:37 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-13 15:55:37 +0100 |
commit | ca1560f043df275d9241055adbf61a393666a533 (patch) | |
tree | 594263c2cce9d067bc9e550e785c355740ecf465 /src/server/game/Handlers/SkillHandler.cpp | |
parent | 1b878209354723138d2f5d969ee53255e6db94d4 (diff) |
Core/Players: Improvements for talent reset logic. (#29580)
* Clean up Player::ResetTalents() from unnecessary logic, such as withdrawing money. Move it to more suitable places.
* Implemented SMSG_TALENTS_INVOLUNTARILY_RESET and use it instead of old trinity_string.
* Do not reset the accumulated talent reset cost if CONFIG_NO_RESET_TALENT_COST is enabled.
Diffstat (limited to 'src/server/game/Handlers/SkillHandler.cpp')
-rw-r--r-- | src/server/game/Handlers/SkillHandler.cpp | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/src/server/game/Handlers/SkillHandler.cpp b/src/server/game/Handlers/SkillHandler.cpp index a43cfdecd13..178237924eb 100644 --- a/src/server/game/Handlers/SkillHandler.cpp +++ b/src/server/game/Handlers/SkillHandler.cpp @@ -22,6 +22,7 @@ #include "ObjectAccessor.h" #include "Pet.h" #include "Player.h" +#include "TalentPackets.h" #include "WorldPacket.h" void WorldSession::HandleLearnTalentOpcode(WorldPacket& recvData) @@ -57,37 +58,39 @@ void WorldSession::HandleLearnPreviewTalents(WorldPacket& recvPacket) recvPacket.rfinish(); } -void WorldSession::HandleTalentWipeConfirmOpcode(WorldPacket& recvData) +void WorldSession::HandleTalentWipeConfirmOpcode(WorldPackets::Talents::ConfirmRespecWipe& confirmRespecWipe) { TC_LOG_DEBUG("network", "MSG_TALENT_WIPE_CONFIRM"); - ObjectGuid guid; - recvData >> guid; - Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_TRAINER); - if (!unit) + Creature* trainer = GetPlayer()->GetNPCIfCanInteractWith(confirmRespecWipe.RespecMaster, UNIT_NPC_FLAG_TRAINER); + if (!trainer) { - TC_LOG_DEBUG("network", "WORLD: HandleTalentWipeConfirmOpcode - {} not found or you can't interact with him.", guid.ToString()); + TC_LOG_DEBUG("network", "WORLD: HandleTalentWipeConfirmOpcode - {} not found or you can't interact with him.", confirmRespecWipe.RespecMaster); return; } - if (!unit->CanResetTalents(_player, false)) + if (!trainer->CanResetTalents(_player, false)) return; + uint32 cost = _player->ResetTalentsCost(); + if (!_player->HasEnoughMoney(cost)) + return; // // silently return, client should display the error by itself + // remove fake death if (GetPlayer()->HasUnitState(UNIT_STATE_DIED)) GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH); - if (!(_player->ResetTalents())) + if (!_player->ResetTalents()) { - WorldPacket data(MSG_TALENT_WIPE_CONFIRM, 8+4); //you have not any talent - data << uint64(0); - data << uint32(0); - SendPacket(&data); + _player->SendTalentWipeConfirm(ObjectGuid::Empty); return; } + _player->ModifyMoney(-(int32)cost); + _player->IncreaseResetTalentsCostAndCounters(cost); _player->SendTalentsInfoData(false); - unit->CastSpell(_player, 14867, true); //spell: "Untalent Visual Effect" + + trainer->CastSpell(_player, 14867 /*SPELL_UNTALENT_VISUAL_EFFECT*/, true); } void WorldSession::HandleUnlearnSkillOpcode(WorldPacket& recvData) |