From 232e631390a504b51d82a7b678b7cf26d49d182a Mon Sep 17 00:00:00 2001 From: ariel- Date: Thu, 13 Apr 2017 03:18:20 -0300 Subject: Core/Spell: check aura positivity per effect on spell hit - Fixes applying DR to positive effects, and changing duration of whole aura Closes #19447 --- src/server/game/Spells/Spell.cpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 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 302579da128..e14fc60e78e 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -2568,7 +2568,7 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask, bool scaleA // Select rank for aura with level requirements only in specific cases // Unit has to be target only of aura effect, both caster and target have to be players, target has to be other than unit target SpellInfo const* aurSpellInfo = m_spellInfo; - int32 basePoints[3]; + int32 basePoints[MAX_SPELL_EFFECTS]; if (scaleAura) { aurSpellInfo = m_spellInfo->GetAuraRankForLevel(unitTarget->getLevel()); @@ -2602,11 +2602,24 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask, bool scaleA } // Now Reduce spell duration using data received at spell hit + // check whatever effects we're going to apply, diminishing returns only apply to negative aura effects + bool positive = true; + if (m_originalCaster == unit || !m_originalCaster->IsFriendlyTo(unit)) + { + for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) + { + if ((effectMask & (1 << i)) && !aurSpellInfo->IsPositiveEffect(i)) + { + positive = false; + break; + } + } + } + int32 duration = m_spellAura->GetMaxDuration(); - float diminishMod = unit->ApplyDiminishingToDuration(aurSpellInfo, triggered, duration, m_originalCaster, diminishLevel); // unit is immune to aura if it was diminished to 0 duration - if (diminishMod == 0.0f) + if (!positive && !unit->ApplyDiminishingToDuration(aurSpellInfo, triggered, duration, m_originalCaster, diminishLevel)) { m_spellAura->Remove(); bool found = false; @@ -2618,11 +2631,7 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask, bool scaleA } else { - ((UnitAura*)m_spellAura)->SetDiminishGroup(diminishGroup); - - bool positive = m_spellAura->GetSpellInfo()->IsPositive(); - if (AuraApplication* aurApp = m_spellAura->GetApplicationOfTarget(m_originalCaster->GetGUID())) - positive = aurApp->IsPositive(); + static_cast(m_spellAura)->SetDiminishGroup(diminishGroup); duration = m_originalCaster->ModSpellDuration(aurSpellInfo, unit, duration, positive, effectMask); -- cgit v1.2.3