diff options
-rw-r--r-- | src/server/game/Spells/Auras/SpellAuras.cpp | 10 | ||||
-rw-r--r-- | src/server/game/Spells/Auras/SpellAuras.h | 3 | ||||
-rw-r--r-- | src/server/game/Spells/Spell.cpp | 61 |
3 files changed, 38 insertions, 36 deletions
diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp index fa1087b52be..91f6cdeae49 100644 --- a/src/server/game/Spells/Auras/SpellAuras.cpp +++ b/src/server/game/Spells/Auras/SpellAuras.cpp @@ -853,7 +853,7 @@ void Aura::Update(uint32 diff, Unit* caster) } } -int32 Aura::CalcMaxDuration(Unit* caster) const +/*static*/ int32 Aura::CalcMaxDuration(SpellInfo const* spellInfo, WorldObject* caster) { Player* modOwner = nullptr; int32 maxDuration; @@ -861,17 +861,17 @@ int32 Aura::CalcMaxDuration(Unit* caster) const if (caster) { modOwner = caster->GetSpellModOwner(); - maxDuration = caster->CalcSpellDuration(m_spellInfo); + maxDuration = caster->CalcSpellDuration(spellInfo); } else - maxDuration = m_spellInfo->GetDuration(); + maxDuration = spellInfo->GetDuration(); - if (IsPassive() && !m_spellInfo->DurationEntry) + if (spellInfo->IsPassive() && !spellInfo->DurationEntry) maxDuration = -1; // IsPermanent() checks max duration (which we are supposed to calculate here) if (maxDuration != -1 && modOwner) - modOwner->ApplySpellMod(GetId(), SPELLMOD_DURATION, maxDuration); + modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_DURATION, maxDuration); return maxDuration; } diff --git a/src/server/game/Spells/Auras/SpellAuras.h b/src/server/game/Spells/Auras/SpellAuras.h index fcaad1cae8d..39eadf52443 100644 --- a/src/server/game/Spells/Auras/SpellAuras.h +++ b/src/server/game/Spells/Auras/SpellAuras.h @@ -141,7 +141,8 @@ class TC_GAME_API Aura int32 GetMaxDuration() const { return m_maxDuration; } void SetMaxDuration(int32 duration) { m_maxDuration = duration; } int32 CalcMaxDuration() const { return CalcMaxDuration(GetCaster()); } - int32 CalcMaxDuration(Unit* caster) const; + int32 CalcMaxDuration(Unit* caster) const { return Aura::CalcMaxDuration(GetSpellInfo(), caster); } + static int32 CalcMaxDuration(SpellInfo const* spellInfo, WorldObject* caster); 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 9f49c556baf..f6f8bf1db35 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -2739,7 +2739,7 @@ SpellMissInfo Spell::PreprocessSpellHit(Unit* unit, bool scaleAura, TargetInfo& } } - hitInfo.AuraDuration = hitInfo.AuraSpellInfo->GetMaxDuration(); + hitInfo.AuraDuration = Aura::CalcMaxDuration(hitInfo.AuraSpellInfo, origCaster); // unit is immune to aura if it was diminished to 0 duration if (!hitInfo.Positive && !unit->ApplyDiminishingToDuration(hitInfo.AuraSpellInfo, triggered, hitInfo.AuraDuration, origCaster, diminishLevel)) @@ -2780,39 +2780,38 @@ void Spell::DoSpellEffectHit(Unit* unit, uint8 effIndex, TargetInfo& hitInfo) .IsRefresh = &refresh; if (Aura* aura = Aura::TryRefreshStackOrCreate(createInfo)) + { _spellAura = aura->ToUnitAura(); - } - else - _spellAura->AddStaticApplication(unit, aura_effmask); - if (_spellAura) - { - // Set aura stack amount to desired value - if (m_spellValue->AuraStackAmount > 1) - { - if (!refresh) - _spellAura->SetStackAmount(m_spellValue->AuraStackAmount); - else - _spellAura->ModStackAmount(m_spellValue->AuraStackAmount); - } + // Set aura stack amount to desired value + if (m_spellValue->AuraStackAmount > 1) + { + if (!refresh) + _spellAura->SetStackAmount(m_spellValue->AuraStackAmount); + else + _spellAura->ModStackAmount(m_spellValue->AuraStackAmount); + } - _spellAura->SetDiminishGroup(hitInfo.DRGroup); + _spellAura->SetDiminishGroup(hitInfo.DRGroup); - hitInfo.AuraDuration = caster->ModSpellDuration(hitInfo.AuraSpellInfo, unit, hitInfo.AuraDuration, hitInfo.Positive, _spellAura->GetEffectMask()); + hitInfo.AuraDuration = caster->ModSpellDuration(hitInfo.AuraSpellInfo, unit, hitInfo.AuraDuration, hitInfo.Positive, _spellAura->GetEffectMask()); - // Haste modifies duration of channeled spells - if (m_spellInfo->IsChanneled()) - caster->ModSpellDurationTime(hitInfo.AuraSpellInfo, hitInfo.AuraDuration, this); - // and duration of auras affected by SPELL_AURA_PERIODIC_HASTE - else if (m_originalCaster && (m_originalCaster->HasAuraTypeWithAffectMask(SPELL_AURA_PERIODIC_HASTE, hitInfo.AuraSpellInfo) || m_spellInfo->HasAttribute(SPELL_ATTR5_HASTE_AFFECT_DURATION))) - hitInfo.AuraDuration = int32(hitInfo.AuraDuration * m_originalCaster->GetFloatValue(UNIT_MOD_CAST_SPEED)); + // Haste modifies duration of channeled spells + if (m_spellInfo->IsChanneled()) + caster->ModSpellDurationTime(hitInfo.AuraSpellInfo, hitInfo.AuraDuration, this); + // and duration of auras affected by SPELL_AURA_PERIODIC_HASTE + else if (m_originalCaster && (m_originalCaster->HasAuraTypeWithAffectMask(SPELL_AURA_PERIODIC_HASTE, hitInfo.AuraSpellInfo) || m_spellInfo->HasAttribute(SPELL_ATTR5_HASTE_AFFECT_DURATION))) + hitInfo.AuraDuration = int32(hitInfo.AuraDuration * m_originalCaster->GetFloatValue(UNIT_MOD_CAST_SPEED)); - if (hitInfo.AuraDuration != _spellAura->GetMaxDuration()) - { - _spellAura->SetMaxDuration(hitInfo.AuraDuration); - _spellAura->SetDuration(hitInfo.AuraDuration); + if (hitInfo.AuraDuration != _spellAura->GetMaxDuration()) + { + _spellAura->SetMaxDuration(hitInfo.AuraDuration); + _spellAura->SetDuration(hitInfo.AuraDuration); + } } } + else + _spellAura->AddStaticApplication(unit, aura_effmask); } } @@ -3481,10 +3480,12 @@ void Spell::handle_immediate() else if (duration == -1) SendChannelStart(duration); - m_spellState = SPELL_STATE_CASTING; - - // GameObjects shouldn't cast channeled spells - ASSERT_NOTNULL(m_caster->ToUnit())->AddInterruptMask(m_spellInfo->ChannelInterruptFlags); + if (duration != 0) + { + m_spellState = SPELL_STATE_CASTING; + // GameObjects shouldn't cast channeled spells + ASSERT_NOTNULL(m_caster->ToUnit())->AddInterruptMask(m_spellInfo->ChannelInterruptFlags); + } } PrepareTargetProcessing(); |