diff options
| author | ariel- <ariel-@users.noreply.github.com> | 2018-03-10 19:40:05 -0300 | 
|---|---|---|
| committer | ariel- <ariel-@users.noreply.github.com> | 2018-03-10 19:40:19 -0300 | 
| commit | d6b9f148a772d07b9353a0db95a6f05c9c848a63 (patch) | |
| tree | 57b08bafa579a066de8206310dc9574720fbb5b9 /src/server/game/Spells/Spell.cpp | |
| parent | e7e46b2a822cd0179b30ba5b0fa7c6fe7cea8774 (diff) | |
Core/Spell: fix target checks
- Aura will be applied at last moment possible (after damage) to prevent regressions on #18395
- Partial revert of 9b38a6352c0fe2499de54fd769aa1c721a410bda as it wasnt handling correctly checks without spells
Closes #21578
Closes #21579
Closes #21581
Diffstat (limited to 'src/server/game/Spells/Spell.cpp')
| -rw-r--r-- | src/server/game/Spells/Spell.cpp | 38 | 
1 files changed, 20 insertions, 18 deletions
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index bbd290df5a4..4293ee5e268 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -2293,6 +2293,7 @@ void Spell::TargetInfo::PreprocessTarget(Spell* spell)              if (missInfo != SPELL_MISS_MISS)                  spell->m_caster->ToUnit()->SendSpellMiss(unit, spell->m_spellInfo->Id, missInfo);              spell->m_damage = 0; +            spell->m_healing = 0;              _spellHitTarget = nullptr;          }      } @@ -2555,6 +2556,20 @@ void Spell::TargetInfo::DoDamageAndTriggers(Spell* spell)          else if (spell->m_caster->GetTypeId() == TYPEID_GAMEOBJECT && spell->m_caster->ToGameObject()->AI())              spell->m_caster->ToGameObject()->AI()->SpellHitTarget(_spellHitTarget, spell->m_spellInfo); +        if (spell->_spellAura) +        { +            if (AuraApplication* aurApp = spell->_spellAura->GetApplicationOfTarget(_spellHitTarget->GetGUID())) +            { +                // only apply unapplied effects (for reapply case) +                uint8 effMask = EffectMask & aurApp->GetEffectsToApply(); +                for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) +                    if ((effMask & (1 << i)) && aurApp->HasEffect(i)) +                        effMask &= ~(1 << i); + +                _spellHitTarget->_ApplyAura(aurApp, effMask); +            } +        } +          // Needs to be called after dealing damage/healing to not remove breaking on damage auras          spell->DoTriggersOnSpellHit(_spellHitTarget, EffectMask); @@ -2643,7 +2658,7 @@ SpellMissInfo Spell::PreprocessSpellHit(Unit* unit, bool scaleAura, TargetInfo&          else if (m_caster->IsFriendlyTo(unit))          {              // for delayed spells ignore negative spells (after duel end) for friendly targets -            if (m_spellInfo->Speed > 0.0f && unit->GetTypeId() == TYPEID_PLAYER && !IsPositive() && !m_caster->IsValidSpellAttackTarget(unit, m_spellInfo)) +            if (m_spellInfo->Speed > 0.0f && unit->GetTypeId() == TYPEID_PLAYER && !IsPositive() && !m_caster->IsValidAssistTarget(unit, m_spellInfo))                  return SPELL_MISS_EVADE;              // assisting case, healing and resurrection @@ -8005,13 +8020,13 @@ bool WorldObjectSpellTargetCheck::operator()(WorldObject* target) const              case TARGET_CHECK_ENEMY:                  if (unitTarget->IsTotem())                      return false; -                if (!_caster->IsValidAttackTarget(unitTarget, _spellInfo, false)) +                if (!_caster->IsValidAttackTarget(unitTarget, _spellInfo))                      return false;                  break;              case TARGET_CHECK_ALLY:                  if (unitTarget->IsTotem())                      return false; -                if (!_caster->IsValidAssistTarget(unitTarget, _spellInfo, false)) +                if (!_caster->IsValidAssistTarget(unitTarget, _spellInfo))                      return false;                  break;              case TARGET_CHECK_PARTY: @@ -8019,7 +8034,7 @@ bool WorldObjectSpellTargetCheck::operator()(WorldObject* target) const                      return false;                  if (unitTarget->IsTotem())                      return false; -                if (!_caster->IsValidAssistTarget(unitTarget, _spellInfo, false)) +                if (!_caster->IsValidAssistTarget(unitTarget, _spellInfo))                      return false;                  if (!refUnit->IsInPartyWith(unitTarget))                      return false; @@ -8035,7 +8050,7 @@ bool WorldObjectSpellTargetCheck::operator()(WorldObject* target) const                      return false;                  if (unitTarget->IsTotem())                      return false; -                if (!_caster->IsValidAssistTarget(unitTarget, _spellInfo, false)) +                if (!_caster->IsValidAssistTarget(unitTarget, _spellInfo))                      return false;                  if (!refUnit->IsInRaidWith(unitTarget))                      return false; @@ -8043,19 +8058,6 @@ bool WorldObjectSpellTargetCheck::operator()(WorldObject* target) const              default:                  break;          } - -        // then check actual spell positivity to determine if the target is valid -        // (negative spells may be targeted on allies) -        if (_spellInfo->IsPositive()) -        { -            if (!_caster->IsValidSpellAssistTarget(unitTarget, _spellInfo)) -                return false; -        } -        else -        { -            if (!_caster->IsValidSpellAttackTarget(unitTarget, _spellInfo)) -                return false; -        }      }      if (!_condSrcInfo)  | 
