diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Entities/Object/Object.cpp | 7 | ||||
-rw-r--r-- | src/server/game/Entities/Object/Object.h | 2 | ||||
-rw-r--r-- | src/server/game/Spells/Auras/SpellAuras.cpp | 4 | ||||
-rw-r--r-- | src/server/game/Spells/Auras/SpellAuras.h | 2 | ||||
-rw-r--r-- | src/server/game/Spells/Spell.cpp | 34 | ||||
-rw-r--r-- | src/server/game/Spells/Spell.h | 3 | ||||
-rw-r--r-- | src/server/scripts/Spells/spell_rogue.cpp | 2 |
7 files changed, 29 insertions, 25 deletions
diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index 893435e274d..b0f098e5975 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -2428,7 +2428,7 @@ double WorldObject::ApplyEffectModifiers(SpellInfo const* spellInfo, uint8 effIn return value; } -int32 WorldObject::CalcSpellDuration(SpellInfo const* spellInfo) const +int32 WorldObject::CalcSpellDuration(SpellInfo const* spellInfo, int32 spentComboPoints /*= 0*/) const { int32 minduration = spellInfo->GetDuration(); if (minduration <= 0) @@ -2442,8 +2442,7 @@ int32 WorldObject::CalcSpellDuration(SpellInfo const* spellInfo) const if (!unit) return minduration; - int32 comboPoints = unit->GetPower(POWER_COMBO_POINTS); - if (!comboPoints || !spellInfo->IsFinishingMove()) + if (!spentComboPoints || !spellInfo->IsFinishingMove()) return minduration; // Combo Points increase an aura's duration per consumed point @@ -2455,7 +2454,7 @@ int32 WorldObject::CalcSpellDuration(SpellInfo const* spellInfo) const return minduration; float durationPerComboPoint = float(maxduration - minduration) / baseComboCost; - return minduration + int32(durationPerComboPoint * comboPoints); + return minduration + int32(durationPerComboPoint * spentComboPoints); } int32 WorldObject::ModSpellDuration(SpellInfo const* spellInfo, WorldObject const* target, int32 duration, bool positive, uint32 effectMask) const diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h index f60d04e63bd..d6d4cf85d9b 100644 --- a/src/server/game/Entities/Object/Object.h +++ b/src/server/game/Entities/Object/Object.h @@ -667,7 +667,7 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation float GetSpellMinRangeForTarget(Unit const* target, SpellInfo const* spellInfo) const; double ApplyEffectModifiers(SpellInfo const* spellInfo, uint8 effIndex, double value) const; - int32 CalcSpellDuration(SpellInfo const* spellInfo) const; + int32 CalcSpellDuration(SpellInfo const* spellInfo, int32 spentComboPoints = 0) const; int32 ModSpellDuration(SpellInfo const* spellInfo, WorldObject const* target, int32 duration, bool positive, uint32 effectMask) const; void ModSpellCastTime(SpellInfo const* spellInfo, int32& castTime, Spell* spell = nullptr) const; void ModSpellDurationTime(SpellInfo const* spellInfo, int32& durationTime, Spell* spell = nullptr) const; diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp index 7d50f3f82b3..9b1843a83fb 100644 --- a/src/server/game/Spells/Auras/SpellAuras.cpp +++ b/src/server/game/Spells/Auras/SpellAuras.cpp @@ -873,7 +873,7 @@ int32 Aura::CalcMaxDuration(Unit* caster) const return Aura::CalcMaxDuration(GetSpellInfo(), caster); } -/*static*/ int32 Aura::CalcMaxDuration(SpellInfo const* spellInfo, WorldObject const* caster) +/*static*/ int32 Aura::CalcMaxDuration(SpellInfo const* spellInfo, WorldObject const* caster, int32 spentComboPoints /*= 0*/) { Player* modOwner = nullptr; int32 maxDuration; @@ -881,7 +881,7 @@ int32 Aura::CalcMaxDuration(Unit* caster) const if (caster) { modOwner = caster->GetSpellModOwner(); - maxDuration = caster->CalcSpellDuration(spellInfo); + maxDuration = caster->CalcSpellDuration(spellInfo, spentComboPoints); } else maxDuration = spellInfo->GetDuration(); diff --git a/src/server/game/Spells/Auras/SpellAuras.h b/src/server/game/Spells/Auras/SpellAuras.h index 40abaed8787..b677d32cf15 100644 --- a/src/server/game/Spells/Auras/SpellAuras.h +++ b/src/server/game/Spells/Auras/SpellAuras.h @@ -169,7 +169,7 @@ class TC_GAME_API Aura void SetMaxDuration(int32 duration) { m_maxDuration = duration; } int32 CalcMaxDuration() const { return CalcMaxDuration(GetCaster()); } int32 CalcMaxDuration(Unit* caster) const; - static int32 CalcMaxDuration(SpellInfo const* spellInfo, WorldObject const* caster); + static int32 CalcMaxDuration(SpellInfo const* spellInfo, WorldObject const* caster, int32 spentComboPoints = 0); int32 GetDuration() const { return m_duration; } void SetDuration(int32 duration, bool withMods = false); void RefreshDuration(bool withMods = false); diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 5ce6154fb6a..8cfb0dec3fa 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -565,6 +565,8 @@ m_spellValue(new SpellValue(m_spellInfo, caster)), _spellEvent(nullptr) if (IsIgnoringCooldowns()) m_castFlagsEx |= CAST_FLAG_EX_IGNORE_COOLDOWN; + m_spentComboPoints = 0; + unitTarget = nullptr; itemTarget = nullptr; gameObjTarget = nullptr; @@ -608,7 +610,7 @@ m_spellValue(new SpellValue(m_spellInfo, caster)), _spellEvent(nullptr) && !m_spellInfo->HasAttribute(SPELL_ATTR1_NO_REFLECTION) && !m_spellInfo->HasAttribute(SPELL_ATTR0_NO_IMMUNITIES) && !m_spellInfo->IsPassive(); - m_consumeAllComboPoints = m_spellInfo->IsFinishingMove(); + m_spendComboPoints = m_spellInfo->IsFinishingMove(); CleanupTargetList(); @@ -2999,10 +3001,6 @@ void Spell::TargetInfo::DoDamageAndTriggers(Spell* spell) spell->m_hitMask |= hitMask; spell->m_procSpellType |= procSpellType; - // Don't consume combo points from finishing moves when missing the target and having SPELL_ATTR1_DISCOUNT_POWER_ON_MISS - if (spell->m_consumeAllComboPoints && MissCondition != SPELL_MISS_NONE && spell->m_spellInfo->HasAttribute(SPELL_ATTR1_DISCOUNT_POWER_ON_MISS)) - spell->m_consumeAllComboPoints = false; - // _spellHitTarget can be null if spell is missed in DoSpellHitOnUnit if (MissCondition != SPELL_MISS_EVADE && _spellHitTarget && !spell->m_caster->IsFriendlyTo(unit) && (!spell->IsPositive() || spell->m_spellInfo->HasEffect(SPELL_EFFECT_DISPEL))) { @@ -3220,7 +3218,7 @@ SpellMissInfo Spell::PreprocessSpellHit(Unit* unit, TargetInfo& hitInfo) } } - hitInfo.AuraDuration = Aura::CalcMaxDuration(m_spellInfo, origCaster); + hitInfo.AuraDuration = Aura::CalcMaxDuration(m_spellInfo, origCaster, m_spentComboPoints); // unit is immune to aura if it was diminished to 0 duration if (!hitInfo.Positive && !unit->ApplyDiminishingToDuration(m_spellInfo, hitInfo.AuraDuration, origCaster, diminishLevel)) @@ -3498,6 +3496,9 @@ SpellCastResult Spell::prepare(SpellCastTargets const& targets, AuraEffect const if (!m_CastItem) m_powerCost = m_spellInfo->CalcPowerCost(m_caster, m_spellSchoolMask, this); + if (m_spendComboPoints && m_caster->IsUnit()) + m_spentComboPoints = m_caster->ToUnit()->GetPower(POWER_COMBO_POINTS); + int32 param1 = 0, param2 = 0; SpellCastResult result = CheckCast(true, ¶m1, ¶m2); // target is checked in too many locations and with different results to handle each of them @@ -4211,17 +4212,10 @@ void Spell::_handle_immediate_phase() void Spell::_handle_finish_phase() { - Unit* unitCaster = m_caster->ToUnit(); - if (unitCaster) - { + if (Unit* unitCaster = m_caster->ToUnit()) if (m_spellInfo->HasEffect(SPELL_EFFECT_ADD_EXTRA_ATTACKS)) unitCaster->SetLastExtraAttackSpell(m_spellInfo->Id); - // Finishing moves use up all their combo points after cast and reset their combo target - if (m_consumeAllComboPoints) - unitCaster->ClearComboTarget(); - } - // Handle procs on finish if (!m_originalCaster) return; @@ -5455,6 +5449,9 @@ void Spell::TakePower() //lower spell cost on fail (by talent aura) if (Player* modOwner = unitCaster->GetSpellModOwner()) modOwner->ApplySpellMod(m_spellInfo, SpellModOp::PowerCostOnMiss, cost.Amount); + + if (m_spendComboPoints) + m_spentComboPoints = 0; } } } @@ -5484,6 +5481,13 @@ void Spell::TakePower() unitCaster->ModifyPower(powerType, -cost.Amount); } + + if (m_spendComboPoints && m_spentComboPoints) + { + unitCaster->ModifyPower(POWER_COMBO_POINTS, -m_spentComboPoints); + if (!unitCaster->GetPower(POWER_COMBO_POINTS)) + unitCaster->SetComboTarget(ObjectGuid::Empty); + } } SpellCastResult Spell::CheckRuneCost() const @@ -5871,7 +5875,7 @@ SpellCastResult Spell::CheckCast(bool strict, int32* param1 /*= nullptr*/, int32 return SPELL_FAILED_ONLY_STEALTHED; } - if (m_consumeAllComboPoints && !unitCaster->GetPower(POWER_COMBO_POINTS)) + if (m_spendComboPoints && !m_spentComboPoints) return SPELL_FAILED_NO_COMBO_POINTS; } diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h index 6d2db462efa..c9ca742f96a 100644 --- a/src/server/game/Spells/Spell.h +++ b/src/server/game/Spells/Spell.h @@ -567,6 +567,7 @@ class TC_GAME_API Spell ObjectGuid m_originalCastId; bool m_fromClient; uint32 m_castFlagsEx; + int32 m_spentComboPoints; union { // Alternate names for this value @@ -708,7 +709,7 @@ class TC_GAME_API Spell int32 m_channeledDuration; // Calculated channeled spell duration in order to calculate correct pushback. bool m_canReflect; // can reflect this spell? bool m_autoRepeat; - bool m_consumeAllComboPoints; // For finishing moves that should consume all combo points after cast + bool m_spendComboPoints; // For finishing moves that should consume all combo points after cast uint8 m_runesState; uint8 m_delayAtDamageCount; diff --git a/src/server/scripts/Spells/spell_rogue.cpp b/src/server/scripts/Spells/spell_rogue.cpp index f63117299f5..45474c7135c 100644 --- a/src/server/scripts/Spells/spell_rogue.cpp +++ b/src/server/scripts/Spells/spell_rogue.cpp @@ -37,7 +37,7 @@ class spell_rog_eviscerate : public SpellScript // Damage: effectValue + (basePoints * Combo) + (AP * 0.091 * Combo) void CalculateDamage(Unit* /*victim*/, int32& /*damage*/, int32& flatMod, float& /*pctMod*/) const { - int32 combo = GetCaster()->GetPower(POWER_COMBO_POINTS); + uint32 combo = GetSpell()->m_spentComboPoints; flatMod += (GetSpellInfo()->GetEffect(EFFECT_0).BasePoints * combo) + (GetCaster()->GetTotalAttackPowerValue(BASE_ATTACK) * 0.091f * combo); } |