aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Spells/Spell.cpp
diff options
context:
space:
mode:
authorariel- <ariel-@users.noreply.github.com>2018-03-10 19:40:05 -0300
committerShauren <shauren.trinity@gmail.com>2021-09-05 22:43:48 +0200
commita2ea26816e19224484377697311f3de1f4cc8f55 (patch)
treeb3f69306a4693f87fbf8fb909e7ba82ca69d8b7c /src/server/game/Spells/Spell.cpp
parent7c63a99babe3331d82353467a58d8a3c7cf25099 (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 (cherry picked from commit d6b9f148a772d07b9353a0db95a6f05c9c848a63)
Diffstat (limited to 'src/server/game/Spells/Spell.cpp')
-rw-r--r--src/server/game/Spells/Spell.cpp38
1 files changed, 20 insertions, 18 deletions
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index 45b53f6f93b..ceca13fdfdf 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -2382,6 +2382,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;
}
}
@@ -2645,6 +2646,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)
+ uint32 effMask = EffectMask & aurApp->GetEffectsToApply();
+ for (uint8 i = 0; i < spell->m_spellInfo->GetEffects().size(); ++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);
@@ -2733,7 +2748,7 @@ SpellMissInfo Spell::PreprocessSpellHit(Unit* unit, TargetInfo& hitInfo)
else if (m_caster->IsFriendlyTo(unit))
{
// for delayed spells ignore negative spells (after duel end) for friendly targets
- if (m_spellInfo->HasHitDelay() && unit->GetTypeId() == TYPEID_PLAYER && !IsPositive() && !m_caster->IsValidSpellAttackTarget(unit, m_spellInfo))
+ if (m_spellInfo->HasHitDelay() && unit->GetTypeId() == TYPEID_PLAYER && !IsPositive() && !m_caster->IsValidAssistTarget(unit, m_spellInfo))
return SPELL_MISS_EVADE;
// assisting case, healing and resurrection
@@ -8170,13 +8185,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:
@@ -8184,7 +8199,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;
@@ -8200,7 +8215,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;
@@ -8235,19 +8250,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)