diff options
author | ModoX <moardox@gmail.com> | 2021-10-06 18:31:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-06 18:31:04 +0200 |
commit | a048475cb037a3a3672723c1f2ab32a343142927 (patch) | |
tree | 1c8f7538c80b4ce9a31b3004dab7430365dbea6e /src | |
parent | 73e6cf4d274f3b74d6375adbad6719b5795ec09c (diff) |
Core/Spells: Implemented SpellValueMod duration (#26945)
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Spells/Spell.cpp | 65 | ||||
-rw-r--r-- | src/server/game/Spells/Spell.h | 1 | ||||
-rw-r--r-- | src/server/game/Spells/SpellDefines.h | 3 |
3 files changed, 42 insertions, 27 deletions
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 233a0cdcddf..45afa9a7745 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -2879,29 +2879,34 @@ void Spell::DoSpellEffectHit(Unit* unit, SpellEffectInfo const& spellEffectInfo, _spellAura->SetDiminishGroup(hitInfo.DRGroup); - hitInfo.AuraDuration = caster->ModSpellDuration(m_spellInfo, unit, hitInfo.AuraDuration, hitInfo.Positive, _spellAura->GetEffectMask()); - - if (hitInfo.AuraDuration > 0) + if (!m_spellValue->Duration) { - hitInfo.AuraDuration *= m_spellValue->DurationMul; + hitInfo.AuraDuration = caster->ModSpellDuration(m_spellInfo, unit, hitInfo.AuraDuration, hitInfo.Positive, _spellAura->GetEffectMask()); - // Haste modifies duration of channeled spells - if (m_spellInfo->IsChanneled()) - caster->ModSpellDurationTime(m_spellInfo, hitInfo.AuraDuration, this); - else if (m_spellInfo->HasAttribute(SPELL_ATTR5_HASTE_AFFECT_DURATION)) + if (hitInfo.AuraDuration > 0) { - int32 origDuration = hitInfo.AuraDuration; - hitInfo.AuraDuration = 0; - for (AuraEffect const* auraEff : _spellAura->GetAuraEffects()) - if (auraEff) - if (int32 period = auraEff->GetPeriod()) // period is hastened by UNIT_MOD_CAST_SPEED - hitInfo.AuraDuration = std::max(std::max(origDuration / period, 1) * period, hitInfo.AuraDuration); - - // if there is no periodic effect - if (!hitInfo.AuraDuration) - hitInfo.AuraDuration = int32(origDuration * m_originalCaster->m_unitData->ModCastingSpeed); + hitInfo.AuraDuration *= m_spellValue->DurationMul; + + // Haste modifies duration of channeled spells + if (m_spellInfo->IsChanneled()) + caster->ModSpellDurationTime(m_spellInfo, hitInfo.AuraDuration, this); + else if (m_spellInfo->HasAttribute(SPELL_ATTR5_HASTE_AFFECT_DURATION)) + { + int32 origDuration = hitInfo.AuraDuration; + hitInfo.AuraDuration = 0; + for (AuraEffect const* auraEff : _spellAura->GetAuraEffects()) + if (auraEff) + if (int32 period = auraEff->GetPeriod()) // period is hastened by UNIT_MOD_CAST_SPEED + hitInfo.AuraDuration = std::max(std::max(origDuration / period, 1) * period, hitInfo.AuraDuration); + + // if there is no periodic effect + if (!hitInfo.AuraDuration) + hitInfo.AuraDuration = int32(origDuration * m_originalCaster->m_unitData->ModCastingSpeed); + } } } + else + hitInfo.AuraDuration = m_spellValue->Duration.get(); if (hitInfo.AuraDuration != _spellAura->GetMaxDuration()) { @@ -3583,17 +3588,22 @@ void Spell::handle_immediate() if (m_spellInfo->IsChanneled()) { int32 duration = m_spellInfo->GetDuration(); - if (duration > 0) + if (duration > 0 || m_spellValue->Duration) { - // First mod_duration then haste - see Missile Barrage - // Apply duration mod - if (Player* modOwner = m_caster->GetSpellModOwner()) - modOwner->ApplySpellMod(m_spellInfo, SpellModOp::Duration, duration); + if (!m_spellValue->Duration) + { + // First mod_duration then haste - see Missile Barrage + // Apply duration mod + if (Player* modOwner = m_caster->GetSpellModOwner()) + modOwner->ApplySpellMod(m_spellInfo, SpellModOp::Duration, duration); - duration *= m_spellValue->DurationMul; + duration *= m_spellValue->DurationMul; - // Apply haste mods - m_caster->ModSpellDurationTime(m_spellInfo, duration, this); + // Apply haste mods + m_caster->ModSpellDurationTime(m_spellInfo, duration, this); + } + else + duration = m_spellValue->Duration.get(); m_channeledDuration = duration; SendChannelStart(duration); @@ -7773,6 +7783,9 @@ void Spell::SetSpellValue(SpellValueMod mod, int32 value) case SPELLVALUE_DURATION_PCT: m_spellValue->DurationMul = float(value) / 100.0f; break; + case SPELLVALUE_DURATION: + m_spellValue->Duration = value; + break; default: break; } diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h index 2817944ff8c..55ef3386253 100644 --- a/src/server/game/Spells/Spell.h +++ b/src/server/game/Spells/Spell.h @@ -208,6 +208,7 @@ struct SpellValue int32 AuraStackAmount; float DurationMul; float CriticalChance; + Optional<int32> Duration; }; enum SpellState diff --git a/src/server/game/Spells/SpellDefines.h b/src/server/game/Spells/SpellDefines.h index 337c039e3a1..1b32fd91d52 100644 --- a/src/server/game/Spells/SpellDefines.h +++ b/src/server/game/Spells/SpellDefines.h @@ -222,7 +222,8 @@ enum SpellValueMod : uint8 SPELLVALUE_MAX_TARGETS, SPELLVALUE_AURA_STACK, SPELLVALUE_CRIT_CHANCE, - SPELLVALUE_DURATION_PCT + SPELLVALUE_DURATION_PCT, + SPELLVALUE_DURATION }; enum SpellFacingFlags |