From ac976550632f17f5a3ec7eaae354f84faf2656e5 Mon Sep 17 00:00:00 2001 From: ariel- Date: Mon, 12 Mar 2018 02:31:17 -0300 Subject: Core/Spells: Fix some issues with channeled spells and aura duration mods Closes #21584 --- src/server/game/Spells/Spell.cpp | 61 ++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 30 deletions(-) (limited to 'src/server/game/Spells/Spell.cpp') 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(); -- cgit v1.2.3