Core: Combat/threat system rewrite

Port From (https://github.com/TrinityCore/TrinityCore/commit/34c7810fe507eca1b8b9389630db5d5d26d92e77)
This commit is contained in:
hondacrx
2021-05-18 12:25:40 -04:00
parent 891c3b6478
commit 9851142796
37 changed files with 3454 additions and 3345 deletions
+7 -2
View File
@@ -2033,7 +2033,7 @@ namespace Game.Spells
// spellHitTarget can be null if spell is missed in DoSpellHitOnUnit
if (missInfo != SpellMissInfo.Evade && spellHitTarget && !m_caster.IsFriendlyTo(unit) && (!IsPositive() || m_spellInfo.HasEffect(SpellEffectName.Dispel)))
{
m_caster.CombatStart(unit, m_spellInfo.HasInitialAggro());
m_caster.AttackedTarget(unit, m_spellInfo.HasInitialAggro());
if (!unit.IsStandState())
unit.SetStandState(UnitStandStateType.Stand);
@@ -2133,7 +2133,8 @@ namespace Game.Spells
}
if (unit.IsInCombat() && m_spellInfo.HasInitialAggro())
{
m_caster.SetInCombatState(unit.GetCombatTimer() > 0, unit);
if (m_caster.HasUnitFlag(UnitFlags.PvpAttackable)) // only do explicit combat forwarding for PvP enabled units
m_caster.GetCombatManager().InheritCombatStatesFrom(unit); // for creature v creature combat, the threat forward does it for us
unit.GetThreatManager().ForwardThreatForAssistingMe(m_caster, 0.0f, null, true);
}
}
@@ -6849,6 +6850,10 @@ namespace Game.Spells
if (unit == null)
return;
// This will only cause combat - the target will engage once the projectile hits (in DoAllEffectOnTarget)
if (targetInfo.missCondition != SpellMissInfo.Evade && !m_caster.IsFriendlyTo(unit) && (!m_spellInfo.IsPositive() || m_spellInfo.HasEffect(SpellEffectName.Dispel)) && (m_spellInfo.HasInitialAggro() || unit.IsEngaged()))
m_caster.SetInCombatWith(unit);
foreach (SpellEffectInfo effect in m_spellInfo.GetEffects())
{
if (effect != null && Convert.ToBoolean(targetInfo.effectMask & (1 << (int)effect.EffectIndex)))