Combat/Threat rewrite - prep & refactor
Port From (https://github.com/TrinityCore/TrinityCore/commit/8be23fcbbdf26e8169defd761e61765f301bebe0)
This commit is contained in:
@@ -4239,7 +4239,7 @@ namespace Game.Spells
|
||||
case 1515: // Tame beast
|
||||
// FIX_ME: this is 2.0.12 threat effect replaced in 2.1.x by dummy aura, must be checked for correctness
|
||||
if (caster != null && target.CanHaveThreatList())
|
||||
target.AddThreat(caster, 10.0f);
|
||||
target.GetThreatManager().AddThreat(caster, 10.0f);
|
||||
break;
|
||||
case 13139: // net-o-matic
|
||||
// root to self part of (root_target.charge.root_self sequence
|
||||
@@ -5597,7 +5597,7 @@ namespace Game.Spells
|
||||
HealInfo healInfo = new HealInfo(caster, caster, heal, GetSpellInfo(), GetSpellInfo().GetSchoolMask());
|
||||
caster.HealBySpell(healInfo);
|
||||
|
||||
caster.GetHostileRefManager().ThreatAssist(caster, healInfo.GetEffectiveHeal() * 0.5f, GetSpellInfo());
|
||||
caster.GetThreatManager().ForwardThreatForAssistingMe(caster, healInfo.GetEffectiveHeal() * 0.5f, GetSpellInfo());
|
||||
caster.ProcSkillsAndAuras(caster, ProcFlags.DonePeriodic, ProcFlags.TakenPeriodic, ProcFlagsSpellType.Heal, ProcFlagsSpellPhase.None, hitMask, null, null, healInfo);
|
||||
}
|
||||
|
||||
@@ -5707,7 +5707,7 @@ namespace Game.Spells
|
||||
SpellPeriodicAuraLogInfo pInfo = new SpellPeriodicAuraLogInfo(this, heal, (uint)damage, heal - healInfo.GetEffectiveHeal(), healInfo.GetAbsorb(), 0, 0.0f, crit);
|
||||
target.SendPeriodicAuraLog(pInfo);
|
||||
|
||||
target.GetHostileRefManager().ThreatAssist(caster, healInfo.GetEffectiveHeal() * 0.5f, GetSpellInfo());
|
||||
target.GetThreatManager().ForwardThreatForAssistingMe(caster, healInfo.GetEffectiveHeal() * 0.5f, GetSpellInfo());
|
||||
|
||||
// %-based heal - does not proc auras
|
||||
if (GetAuraType() == AuraType.ObsModHealth)
|
||||
@@ -5751,7 +5751,8 @@ namespace Game.Spells
|
||||
if (gainAmount != 0)
|
||||
{
|
||||
gainedAmount = caster.ModifyPower(powerType, gainAmount);
|
||||
target.AddThreat(caster, gainedAmount * 0.5f, GetSpellInfo().GetSchoolMask(), GetSpellInfo());
|
||||
// energize is not modified by threat modifiers
|
||||
target.GetThreatManager().AddThreat(caster, gainedAmount * 0.5f, GetSpellInfo(), true);
|
||||
}
|
||||
|
||||
// Drain Mana
|
||||
@@ -5801,7 +5802,7 @@ namespace Game.Spells
|
||||
int gain = target.ModifyPower(powerType, amount);
|
||||
|
||||
if (caster != null)
|
||||
target.GetHostileRefManager().ThreatAssist(caster, gain * 0.5f, GetSpellInfo());
|
||||
target.GetThreatManager().ForwardThreatForAssistingMe(caster, gain * 0.5f, GetSpellInfo(), true);
|
||||
|
||||
target.SendPeriodicAuraLog(pInfo);
|
||||
}
|
||||
@@ -5829,7 +5830,7 @@ namespace Game.Spells
|
||||
int gain = target.ModifyPower(powerType, amount);
|
||||
|
||||
if (caster != null)
|
||||
target.GetHostileRefManager().ThreatAssist(caster, gain * 0.5f, GetSpellInfo());
|
||||
target.GetThreatManager().ForwardThreatForAssistingMe(caster, gain * 0.5f, GetSpellInfo(), true);
|
||||
|
||||
target.SendPeriodicAuraLog(pInfo);
|
||||
}
|
||||
|
||||
@@ -1938,7 +1938,7 @@ namespace Game.Spells
|
||||
|
||||
HealInfo healInfo = new HealInfo(caster, unitTarget, addhealth, m_spellInfo, m_spellInfo.GetSchoolMask());
|
||||
caster.HealBySpell(healInfo, crit);
|
||||
unitTarget.GetHostileRefManager().ThreatAssist(caster, healInfo.GetEffectiveHeal() * 0.5f, m_spellInfo);
|
||||
unitTarget.GetThreatManager().ForwardThreatForAssistingMe(caster, healInfo.GetEffectiveHeal() * 0.5f, m_spellInfo);
|
||||
m_healing = (int)healInfo.GetEffectiveHeal();
|
||||
|
||||
// Do triggers for unit
|
||||
@@ -2007,8 +2007,7 @@ namespace Game.Spells
|
||||
if (missInfo == SpellMissInfo.Resist && m_spellInfo.HasAttribute(SpellCustomAttributes.PickPocket) && unitTarget.IsTypeId(TypeId.Unit))
|
||||
{
|
||||
m_caster.RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags.Talk);
|
||||
if (unitTarget.ToCreature().IsAIEnabled)
|
||||
unitTarget.ToCreature().GetAI().AttackStart(m_caster);
|
||||
unitTarget.ToCreature().EngageWithTarget(m_caster);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2108,14 +2107,17 @@ namespace Game.Spells
|
||||
// assisting case, healing and resurrection
|
||||
if (unit.HasUnitState(UnitState.AttackPlayer))
|
||||
{
|
||||
m_caster.SetContestedPvP();
|
||||
if (m_caster.IsTypeId(TypeId.Player))
|
||||
m_caster.ToPlayer().UpdatePvP(true);
|
||||
Player playerOwner = m_caster.GetCharmerOrOwnerPlayerOrPlayerItself();
|
||||
if (playerOwner != null)
|
||||
{
|
||||
playerOwner.SetContestedPvP();
|
||||
playerOwner.UpdatePvP(true);
|
||||
}
|
||||
}
|
||||
if (unit.IsInCombat() && m_spellInfo.HasInitialAggro())
|
||||
{
|
||||
m_caster.SetInCombatState(unit.GetCombatTimer() > 0, unit);
|
||||
unit.GetHostileRefManager().ThreatAssist(m_caster, 0.0f);
|
||||
unit.GetThreatManager().ForwardThreatForAssistingMe(m_caster, 0.0f, null, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4377,14 +4379,14 @@ namespace Game.Spells
|
||||
|
||||
// positive spells distribute threat among all units that are in combat with target, like healing
|
||||
if (m_spellInfo.IsPositive())
|
||||
target.GetHostileRefManager().ThreatAssist(m_caster, threatToAdd, m_spellInfo);
|
||||
target.GetThreatManager().ForwardThreatForAssistingMe(m_caster, threatToAdd, m_spellInfo);
|
||||
// for negative spells threat gets distributed among affected targets
|
||||
else
|
||||
{
|
||||
if (!target.CanHaveThreatList())
|
||||
continue;
|
||||
|
||||
target.AddThreat(m_caster, threatToAdd, m_spellInfo.GetSchoolMask(), m_spellInfo);
|
||||
target.GetThreatManager().AddThreat(m_caster, threatToAdd, m_spellInfo, true);
|
||||
}
|
||||
}
|
||||
Log.outDebug(LogFilter.Spells, "Spell {0}, added an additional {1} threat for {2} {3} target(s)", m_spellInfo.Id, threat, m_spellInfo.IsPositive() ? "assisting" : "harming", m_UniqueTargetInfo.Count);
|
||||
|
||||
@@ -1942,7 +1942,7 @@ namespace Game.Spells
|
||||
return;
|
||||
|
||||
// Check for possible target
|
||||
if (unitTarget == null || unitTarget.IsInCombat())
|
||||
if (unitTarget == null || unitTarget.IsEngaged())
|
||||
return;
|
||||
|
||||
// target must be OK to do this
|
||||
@@ -2701,7 +2701,7 @@ namespace Game.Spells
|
||||
if (!unitTarget.CanHaveThreatList())
|
||||
return;
|
||||
|
||||
unitTarget.AddThreat(m_caster, damage);
|
||||
unitTarget.GetThreatManager().AddThreat(m_caster, damage);
|
||||
}
|
||||
|
||||
[SpellEffectHandler(SpellEffectName.HealMaxHealth)]
|
||||
@@ -4408,7 +4408,7 @@ namespace Game.Spells
|
||||
if (unitTarget == null)
|
||||
return;
|
||||
|
||||
unitTarget.GetThreatManager().ModifyThreatPercent(m_caster, damage);
|
||||
unitTarget.GetThreatManager().ModifyThreatByPercent(m_caster, damage);
|
||||
}
|
||||
|
||||
[SpellEffectHandler(SpellEffectName.TransDoor)]
|
||||
|
||||
Reference in New Issue
Block a user