diff options
author | myran2 <henrytgordon@gmail.com> | 2016-01-22 20:27:48 +0100 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2016-01-22 20:27:48 +0100 |
commit | 2652d700e1a40f90b3d219a3cc807ad2efb2b739 (patch) | |
tree | 47d873b15a7fad76dd4a3b435ef0b86b3f8cfe3e | |
parent | d3be63d0c8dc9444c1edd649bad6193bf065a25d (diff) |
Core/Spells: Updated combo point handing
Closes #15996
9 files changed, 27 insertions, 116 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 03d1d6a386b..a26c1f3c841 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -152,8 +152,6 @@ Player::Player(WorldSession* session) : Unit(true) if (!GetSession()->HasPermission(rbac::RBAC_PERM_CAN_FILTER_WHISPERS)) SetAcceptWhispers(true); - m_comboPoints = 0; - m_regenTimer = 0; m_regenTimerCount = 0; m_holyPowerRegenTimerCount = 0; @@ -7124,15 +7122,8 @@ void Player::DuelComplete(DuelCompleteType type) } // cleanup combo points - if (GetComboTarget() == duel->opponent->GetGUID()) - ClearComboPoints(); - else if (GetComboTarget() == duel->opponent->GetPetGUID()) - ClearComboPoints(); - - if (duel->opponent->GetComboTarget() == GetGUID()) - duel->opponent->ClearComboPoints(); - else if (duel->opponent->GetComboTarget() == GetPetGUID()) - duel->opponent->ClearComboPoints(); + ClearComboPoints(); + duel->opponent->ClearComboPoints(); //cleanups SetGuidValue(PLAYER_DUEL_ARBITER, ObjectGuid::Empty); @@ -22134,61 +22125,27 @@ Player* Player::GetSelectedPlayer() const return nullptr; } -void Player::SendComboPoints() -{ - Unit* combotarget = ObjectAccessor::GetUnit(*this, m_comboTarget); - if (combotarget) - { - // Combo points are now a power - //WorldPacket data; - //if (m_mover != this) - //{ - // data.Initialize(SMSG_PET_UPDATE_COMBO_POINTS, m_mover->GetPackGUID().size()+combotarget->GetPackGUID().size()+1); - // data << m_mover->GetPackGUID(); - //} - //else - // data.Initialize(SMSG_UPDATE_COMBO_POINTS, combotarget->GetPackGUID().size()+1); - //data << combotarget->GetPackGUID(); - //data << uint8(m_comboPoints); - //GetSession()->SendPacket(&data); - } -} - -void Player::AddComboPoints(Unit* target, int8 count, Spell* spell) +void Player::AddComboPoints(int8 count, Spell* spell) { if (!count) return; - int8 * comboPoints = spell ? &spell->m_comboPointGain : &m_comboPoints; + int8 comboPoints = spell ? spell->m_comboPointGain : GetPower(POWER_COMBO_POINTS); // without combo points lost (duration checked in aura) RemoveAurasByType(SPELL_AURA_RETAIN_COMBO_POINTS); - if (target->GetGUID() == m_comboTarget) - *comboPoints += count; - else - { - if (!m_comboTarget.IsEmpty()) - if (Unit* target2 = ObjectAccessor::GetUnit(*this, m_comboTarget)) - target2->RemoveComboPointHolder(GetGUID()); - - // Spells will always add value to m_comboPoints eventualy, so it must be cleared first - if (spell) - m_comboPoints = 0; - - m_comboTarget = target->GetGUID(); - *comboPoints = count; + comboPoints += count; - target->AddComboPointHolder(GetGUID()); - } - - if (*comboPoints > 5) - *comboPoints = 5; - else if (*comboPoints < 0) - *comboPoints = 0; + if (comboPoints > 5) + comboPoints = 5; + else if (comboPoints < 0) + comboPoints = 0; if (!spell) - SendComboPoints(); + SetPower(POWER_COMBO_POINTS, comboPoints); + else + spell->m_comboPointGain = comboPoints; } void Player::GainSpellComboPoints(int8 count) @@ -22196,29 +22153,21 @@ void Player::GainSpellComboPoints(int8 count) if (!count) return; - m_comboPoints += count; - if (m_comboPoints > 5) m_comboPoints = 5; - else if (m_comboPoints < 0) m_comboPoints = 0; + int8 cp = GetPower(POWER_COMBO_POINTS); - SendComboPoints(); + cp += count; + if (cp > 5) cp = 5; + else if (cp < 0) cp = 0; + + SetPower(POWER_COMBO_POINTS, cp); } void Player::ClearComboPoints() { - if (!m_comboTarget) - return; - // without combopoints lost (duration checked in aura) RemoveAurasByType(SPELL_AURA_RETAIN_COMBO_POINTS); - m_comboPoints = 0; - - SendComboPoints(); - - if (Unit* target = ObjectAccessor::GetUnit(*this, m_comboTarget)) - target->RemoveComboPointHolder(GetGUID()); - - m_comboTarget.Clear(); + SetPower(POWER_COMBO_POINTS, 0); } void Player::SetGroup(Group* group, int8 subgroup) @@ -25238,7 +25187,6 @@ void Player::ActivateTalentGroup(uint8 spec) if (Pet* pet = GetPet()) RemovePet(pet, PET_SAVE_NOT_IN_SLOT); - ClearComboPointHolders(); ClearAllReactives(); UnsummonAllTotems(); ExitVehicle(); diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index c4f9ad3e05f..6b235a3d0e0 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -1662,13 +1662,10 @@ class Player : public Unit, public GridObject<Player> void SetTarget(ObjectGuid const& /*guid*/) override { } /// Used for serverside target changes, does not apply to players void SetSelection(ObjectGuid const& guid) { SetGuidValue(UNIT_FIELD_TARGET, guid); } - uint8 GetComboPoints() const { return m_comboPoints; } - ObjectGuid GetComboTarget() const { return m_comboTarget; } - - void AddComboPoints(Unit* target, int8 count, Spell* spell = nullptr); + uint8 GetComboPoints() const { return GetPower(POWER_COMBO_POINTS); } + void AddComboPoints(int8 count, Spell* spell = nullptr); void GainSpellComboPoints(int8 count); void ClearComboPoints(); - void SendComboPoints(); void SendMailResult(uint32 mailId, MailResponseType mailAction, MailResponseResult mailError, uint32 equipError = 0, ObjectGuid::LowType item_guid = UI64LIT(0), uint32 item_count = 0) const; void SendNewMail() const; @@ -2642,9 +2639,6 @@ class Player : public Unit, public GridObject<Player> uint32 m_ExtraFlags; - ObjectGuid m_comboTarget; - int8 m_comboPoints; - QuestStatusMap m_QuestStatus; QuestStatusSaveMap m_QuestStatusSave; diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 4f2d0326d7d..8b26988726d 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -10590,7 +10590,6 @@ void Unit::setDeathState(DeathState s) CombatStop(); DeleteThreatList(); getHostileRefManager().deleteReferences(); - ClearComboPointHolders(); // any combo points pointed to unit lost at it death if (IsNonMeleeSpellCast(false)) InterruptNonMeleeSpells(false); @@ -11776,7 +11775,6 @@ void Unit::CleanupBeforeRemoveFromMap(bool finalCleanup) m_Events.KillAllEvents(false); // non-delatable (currently cast spells) will not deleted now but it will deleted at call in Map::RemoveAllObjectsInRemoveList CombatStop(); - ClearComboPointHolders(); DeleteThreatList(); getHostileRefManager().setOnlineOfflineState(false); GetMotionMaster()->Clear(false); // remove different non-standard movement generators. @@ -12263,7 +12261,7 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* target, uint32 procFlag, u // Overpower on victim dodge if (procExtra & PROC_EX_DODGE && GetTypeId() == TYPEID_PLAYER && getClass() == CLASS_WARRIOR) { - ToPlayer()->AddComboPoints(target, 1); + ToPlayer()->AddComboPoints(1); StartReactiveTimer(REACTIVE_OVERPOWER); } } @@ -12821,20 +12819,6 @@ void Unit::RestoreDisplayId() SetDisplayId(GetNativeDisplayId()); } -void Unit::ClearComboPointHolders() -{ - while (!m_ComboPointHolders.empty()) - { - ObjectGuid guid = *m_ComboPointHolders.begin(); - - Player* player = ObjectAccessor::FindPlayer(guid); - if (player && player->GetComboTarget() == GetGUID()) // recheck for safe - player->ClearComboPoints(); // remove also guid from m_ComboPointHolders; - else - m_ComboPointHolders.erase(guid); // or remove manually - } -} - void Unit::ClearAllReactives() { for (uint8 i = 0; i < MAX_REACTIVE; ++i) diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 0782f0bd809..3ef6800c7e7 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -2119,10 +2119,6 @@ class Unit : public WorldObject void SetControlled(bool apply, UnitState state); - void AddComboPointHolder(ObjectGuid lowguid) { m_ComboPointHolders.insert(lowguid); } - void RemoveComboPointHolder(ObjectGuid lowguid) { m_ComboPointHolders.erase(lowguid); } - void ClearComboPointHolders(); - ///----------Pet responses methods----------------- void SendPetActionFeedback (uint8 msg); void SendPetTalk (uint32 pettalk); @@ -2348,8 +2344,6 @@ class Unit : public WorldObject FollowerRefManager m_FollowingRefManager; - GuidSet m_ComboPointHolders; - RedirectThreatInfo _redirectThreadInfo; bool m_cleanupDone; // lock made to not add stuff after cleanup before delete diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index 90156acbe73..dceef48a275 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -4787,9 +4787,8 @@ void AuraEffect::HandleAuraRetainComboPoints(AuraApplication const* aurApp, uint // combo points was added in SPELL_EFFECT_ADD_COMBO_POINTS handler // remove only if aura expire by time (in case combo points amount change aura removed without combo points lost) - if (!(apply) && GetBase()->GetDuration() == 0 && !target->ToPlayer()->GetComboTarget().IsEmpty()) - if (Unit* unit = ObjectAccessor::GetUnit(*target, target->ToPlayer()->GetComboTarget())) - target->ToPlayer()->AddComboPoints(unit, -GetAmount()); + if (!apply && aurApp->GetRemoveMode() == AURA_REMOVE_BY_EXPIRE) + target->ToPlayer()->AddComboPoints(-GetAmount()); } /*********************************************************/ @@ -4887,11 +4886,6 @@ void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool if (caster) target->GetMotionMaster()->MoveFall(); break; - case 52916: // Honor Among Thieves - if (target->GetTypeId() == TYPEID_PLAYER) - if (Unit* spellTarget = ObjectAccessor::GetUnit(*target, target->ToPlayer()->GetComboTarget())) - target->CastSpell(spellTarget, 51699, true); - break; case 71563: if (Aura* newAura = target->AddAura(71564, target)) newAura->SetStackAmount(newAura->GetSpellInfo()->StackAmount); diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index b993951db55..be996e566e0 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -3011,7 +3011,7 @@ void Spell::EffectWeaponDmg(SpellEffIndex effIndex) if (m_spellInfo->SpellFamilyFlags[0] & 0x2000000) { if (m_caster->GetTypeId() == TYPEID_PLAYER) - m_caster->ToPlayer()->AddComboPoints(unitTarget, 1, this); + m_caster->ToPlayer()->AddComboPoints(1, this); // 50% more damage with daggers if (m_caster->GetTypeId() == TYPEID_PLAYER) if (Item* item = m_caster->ToPlayer()->GetWeaponForAttack(m_attackType, true)) @@ -3034,7 +3034,7 @@ void Spell::EffectWeaponDmg(SpellEffIndex effIndex) if (m_spellInfo->SpellFamilyFlags[1] & 0x400) { if (m_caster->GetTypeId() == TYPEID_PLAYER) - m_caster->ToPlayer()->AddComboPoints(unitTarget, 1, this); + m_caster->ToPlayer()->AddComboPoints(1, this); } // Shred, Maul - Rend and Tear else if (m_spellInfo->SpellFamilyFlags[0] & 0x00008800 && unitTarget->HasAuraState(AURA_STATE_BLEEDING)) @@ -3857,7 +3857,7 @@ void Spell::EffectAddComboPoints(SpellEffIndex /*effIndex*/) if (damage <= 0) return; - m_caster->m_movedPlayer->AddComboPoints(unitTarget, damage, this); + m_caster->m_movedPlayer->AddComboPoints(damage, this); } void Spell::EffectDuel(SpellEffIndex effIndex) diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_felblood_kaelthas.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_felblood_kaelthas.cpp index b809128e731..155c7144deb 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_felblood_kaelthas.cpp +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_felblood_kaelthas.cpp @@ -542,7 +542,6 @@ public: me->InterruptNonMeleeSpells(false); me->SetHealth(0); me->StopMoving(); - me->ClearComboPointHolders(); me->RemoveAllAurasOnDeath(); me->ModifyAuraState(AURA_STATE_HEALTHLESS_20_PERCENT, false); me->ModifyAuraState(AURA_STATE_HEALTHLESS_35_PERCENT, false); diff --git a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_mograine_and_whitemane.cpp b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_mograine_and_whitemane.cpp index bab5a02cc90..1f4ac4356b7 100644 --- a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_mograine_and_whitemane.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_mograine_and_whitemane.cpp @@ -146,7 +146,6 @@ public: if (me->IsNonMeleeSpellCast(false)) me->InterruptNonMeleeSpells(false); - me->ClearComboPointHolders(); me->RemoveAllAuras(); me->ClearAllReactives(); diff --git a/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp b/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp index 85737740b13..66cd00489f8 100644 --- a/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp +++ b/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp @@ -374,7 +374,6 @@ struct advisorbase_ai : public ScriptedAI me->InterruptNonMeleeSpells(false); me->SetHealth(0); - me->ClearComboPointHolders(); me->RemoveAllAurasOnDeath(); me->ModifyAuraState(AURA_STATE_HEALTHLESS_20_PERCENT, false); me->ModifyAuraState(AURA_STATE_HEALTHLESS_35_PERCENT, false); |