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
This commit is contained in:
ariel- authored and Ovahlord committed 2022-09-12 09:15:15 +02:00
1 parent 5e6167ce46
commit c889b81f2c
4 files changed
+101 -138

No files matched your search

+20 -18
View File
@@ -2452,6 +2452,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;
}
}
@@ -2736,6 +2737,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);
@@ -2838,7 +2853,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
@@ -8528,13 +8543,13 @@ bool WorldObjectSpellTargetCheck::operator()(WorldObject* target) const
case TARGET_CHECK_ENEMY:
if (unitTarget->IsTotem())
return false;
if (!target->IsCorpse() && !_caster->IsValidAttackTarget(unitTarget, _spellInfo, false))
if (!target->IsCorpse() && !_caster->IsValidAttackTarget(unitTarget, _spellInfo))
return false;
break;
case TARGET_CHECK_ALLY:
if (unitTarget->IsTotem())
return false;
if (!target->IsCorpse() && !_caster->IsValidAssistTarget(unitTarget, _spellInfo, false))
if (!target->IsCorpse() && !_caster->IsValidAssistTarget(unitTarget, _spellInfo))
return false;
break;
case TARGET_CHECK_PARTY:
@@ -8542,7 +8557,7 @@ bool WorldObjectSpellTargetCheck::operator()(WorldObject* target) const
return false;
if (unitTarget->IsTotem())
return false;
if (!target->IsCorpse() && !_caster->IsValidAssistTarget(unitTarget, _spellInfo, false))
if (!target->IsCorpse() && !_caster->IsValidAssistTarget(unitTarget, _spellInfo))
return false;
if (!refUnit->IsInPartyWith(unitTarget))
return false;
@@ -8558,7 +8573,7 @@ bool WorldObjectSpellTargetCheck::operator()(WorldObject* target) const
return false;
if (unitTarget->IsTotem())
return false;
if (!target->IsCorpse() && !_caster->IsValidAssistTarget(unitTarget, _spellInfo, false))
if (!target->IsCorpse() && !_caster->IsValidAssistTarget(unitTarget, _spellInfo))
return false;
if (!refUnit->IsInRaidWith(unitTarget))
return false;
@@ -8582,19 +8597,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)