Core/Auras: Proc flag updates

Port From (https://github.com/TrinityCore/TrinityCore/commit/02979daf761a5122efa7b8fa3e70509ecd69789e)
This commit is contained in:
hondacrx
2022-05-07 22:41:24 -04:00
parent 655a4f9857
commit f67434306f
10 changed files with 164 additions and 129 deletions
+13 -13
View File
@@ -5065,14 +5065,14 @@ namespace Game.Spells
Unit.DealDamageMods(caster, target, ref damage, ref absorb);
// Set trigger flag
ProcFlagsInit procAttacker = new ProcFlagsInit(ProcFlags.DonePeriodic);
ProcFlagsInit procVictim = new ProcFlagsInit(ProcFlags.TakenPeriodic);
ProcFlagsInit procAttacker = new ProcFlagsInit(ProcFlags.DealHarmfulPeriodic);
ProcFlagsInit procVictim = new ProcFlagsInit(ProcFlags.TakeHarmfulPeriodic);
ProcFlagsHit hitMask = damageInfo.GetHitMask();
if (damage != 0)
{
hitMask |= crit ? ProcFlagsHit.Critical : ProcFlagsHit.Normal;
procVictim.Or(ProcFlags.TakenDamage);
procVictim.Or(ProcFlags.TakeAnyDamage);
}
int overkill = (int)(damage - target.GetHealth());
@@ -5156,14 +5156,14 @@ namespace Game.Spells
log.HitInfo |= HitInfo.CriticalHit;
// Set trigger flag
ProcFlagsInit procAttacker = new ProcFlagsInit(ProcFlags.DonePeriodic);
ProcFlagsInit procVictim = new ProcFlagsInit(ProcFlags.TakenPeriodic);
ProcFlagsInit procAttacker = new ProcFlagsInit(ProcFlags.DealHarmfulPeriodic);
ProcFlagsInit procVictim = new ProcFlagsInit(ProcFlags.TakeHarmfulPeriodic);
ProcFlagsHit hitMask = damageInfo.GetHitMask();
if (damage != 0)
{
hitMask |= crit ? ProcFlagsHit.Critical : ProcFlagsHit.Normal;
procVictim.Or(ProcFlags.TakenDamage);
procVictim.Or(ProcFlags.TakeAnyDamage);
}
int new_damage = (int)Unit.DealDamage(caster, target, damage, cleanDamage, DamageEffectType.DOT, GetSpellInfo().GetSchoolMask(), GetSpellInfo(), false);
@@ -5182,7 +5182,7 @@ namespace Game.Spells
caster.HealBySpell(healInfo);
caster.GetThreatManager().ForwardThreatForAssistingMe(caster, healInfo.GetEffectiveHeal() * 0.5f, GetSpellInfo());
Unit.ProcSkillsAndAuras(caster, caster, new ProcFlagsInit(ProcFlags.DonePeriodic), new ProcFlagsInit(ProcFlags.TakenPeriodic), ProcFlagsSpellType.Heal, ProcFlagsSpellPhase.Hit, hitMask, null, null, healInfo);
Unit.ProcSkillsAndAuras(caster, caster, new ProcFlagsInit(ProcFlags.DealHarmfulPeriodic), new ProcFlagsInit(ProcFlags.TakeHarmfulPeriodic), ProcFlagsSpellType.Heal, ProcFlagsSpellPhase.Hit, hitMask, null, null, healInfo);
caster.SendSpellNonMeleeDamageLog(log);
}
@@ -5214,7 +5214,7 @@ namespace Game.Spells
HealInfo healInfo = new(caster, target, damage, GetSpellInfo(), GetSpellInfo().GetSchoolMask());
caster.HealBySpell(healInfo);
Unit.ProcSkillsAndAuras(caster, target, new ProcFlagsInit(ProcFlags.DonePeriodic), new ProcFlagsInit(ProcFlags.TakenPeriodic), ProcFlagsSpellType.Heal, ProcFlagsSpellPhase.Hit, ProcFlagsHit.Normal, null, null, healInfo);
Unit.ProcSkillsAndAuras(caster, target, new ProcFlagsInit(ProcFlags.DealHarmfulPeriodic), new ProcFlagsInit(ProcFlags.TakeHarmfulPeriodic), ProcFlagsSpellType.Heal, ProcFlagsSpellPhase.Hit, ProcFlagsHit.Normal, null, null, healInfo);
}
void HandlePeriodicHealAurasTick(Unit target, Unit caster)
@@ -5271,8 +5271,8 @@ namespace Game.Spells
if (GetAuraType() == AuraType.ObsModHealth)
return;
ProcFlagsInit procAttacker = new ProcFlagsInit(ProcFlags.DonePeriodic);
ProcFlagsInit procVictim = new ProcFlagsInit(ProcFlags.TakenPeriodic);
ProcFlagsInit procAttacker = new ProcFlagsInit(ProcFlags.DealHarmfulPeriodic);
ProcFlagsInit procVictim = new ProcFlagsInit(ProcFlags.TakeHarmfulPeriodic);
ProcFlagsHit hitMask = crit ? ProcFlagsHit.Critical : ProcFlagsHit.Normal;
// ignore item heals
if (GetBase().GetCastItemGUID().IsEmpty())
@@ -5426,13 +5426,13 @@ namespace Game.Spells
Unit.DealDamageMods(damageInfo.attacker, damageInfo.target, ref damageInfo.damage, ref damageInfo.absorb);
// Set trigger flag
ProcFlagsInit procAttacker = new ProcFlagsInit(ProcFlags.DonePeriodic);
ProcFlagsInit procVictim = new ProcFlagsInit(ProcFlags.TakenPeriodic);
ProcFlagsInit procAttacker = new ProcFlagsInit(ProcFlags.DealHarmfulPeriodic);
ProcFlagsInit procVictim = new ProcFlagsInit(ProcFlags.TakeHarmfulPeriodic);
ProcFlagsHit hitMask = Unit.CreateProcHitMask(damageInfo, SpellMissInfo.None);
ProcFlagsSpellType spellTypeMask = ProcFlagsSpellType.NoDmgHeal;
if (damageInfo.damage != 0)
{
procVictim.Or(ProcFlags.TakenDamage);
procVictim.Or(ProcFlags.TakeAnyDamage);
spellTypeMask |= ProcFlagsSpellType.Damage;
}
+89 -54
View File
@@ -1703,24 +1703,24 @@ namespace Game.Spells
switch (m_spellInfo.DmgClass)
{
case SpellDmgClass.Melee:
m_procAttacker = new ProcFlagsInit(ProcFlags.DoneSpellMeleeDmgClass);
m_procAttacker = new ProcFlagsInit(ProcFlags.DealMeleeAbility);
if (m_attackType == WeaponAttackType.OffAttack)
m_procAttacker.Or(ProcFlags.DoneOffHandAttack);
m_procAttacker.Or(ProcFlags.OffHandWeaponSwing);
else
m_procAttacker.Or(ProcFlags.DoneMainHandAttack);
m_procVictim = new ProcFlagsInit(ProcFlags.TakenSpellMeleeDmgClass);
m_procAttacker.Or(ProcFlags.MainHandWeaponSwing);
m_procVictim = new ProcFlagsInit(ProcFlags.TakeMeleeAbility);
break;
case SpellDmgClass.Ranged:
// Auto attack
if (m_spellInfo.HasAttribute(SpellAttr2.AutorepeatFlag))
{
m_procAttacker = new ProcFlagsInit(ProcFlags.DoneRangedAutoAttack);
m_procVictim = new ProcFlagsInit(ProcFlags.TakenRangedAutoAttack);
m_procAttacker = new ProcFlagsInit(ProcFlags.DealRangedAttack);
m_procVictim = new ProcFlagsInit(ProcFlags.TakeRangedAttack);
}
else // Ranged spell attack
{
m_procAttacker = new ProcFlagsInit(ProcFlags.DoneSpellRangedDmgClass);
m_procVictim = new ProcFlagsInit(ProcFlags.TakenSpellRangedDmgClass);
m_procAttacker = new ProcFlagsInit(ProcFlags.DealRangedAbility);
m_procVictim = new ProcFlagsInit(ProcFlags.TakeRangedAbility);
}
break;
default:
@@ -1728,32 +1728,13 @@ namespace Game.Spells
Convert.ToBoolean(m_spellInfo.EquippedItemSubClassMask & (1 << (int)ItemSubClassWeapon.Wand))
&& m_spellInfo.HasAttribute(SpellAttr2.AutorepeatFlag)) // Wands auto attack
{
m_procAttacker = new ProcFlagsInit(ProcFlags.DoneRangedAutoAttack);
m_procVictim = new ProcFlagsInit(ProcFlags.TakenRangedAutoAttack);
m_procAttacker = new ProcFlagsInit(ProcFlags.DealRangedAttack);
m_procVictim = new ProcFlagsInit(ProcFlags.TakeRangedAttack);
}
break;
// For other spells trigger procflags are set in Spell::TargetInfo::DoDamageAndTriggers
// Because spell positivity is dependant on target
}
// Hunter trap spells - activation proc for Lock and Load, Entrapment and Misdirection
if (m_spellInfo.SpellFamilyName == SpellFamilyNames.Hunter && (m_spellInfo.SpellFamilyFlags[0].HasAnyFlag(0x18u) || // Freezing and Frost Trap, Freezing Arrow
m_spellInfo.Id == 57879 || // Snake Trap - done this way to avoid double proc
m_spellInfo.SpellFamilyFlags[2].HasAnyFlag(0x00024000u))) // Explosive and Immolation Trap
{
m_procAttacker.Or(ProcFlags.DoneTrapActivation);
// also fill up other flags (TargetInfo::DoDamageAndTriggers only fills up flag if both are not set)
m_procAttacker.Or(ProcFlags.DoneSpellMagicDmgClassNeg);
m_procVictim.Or(ProcFlags.TakenSpellMagicDmgClassNeg);
}
// Hellfire Effect - trigger as DOT
if (m_spellInfo.SpellFamilyName == SpellFamilyNames.Warlock && m_spellInfo.SpellFamilyFlags[0].HasAnyFlag(0x00000040u))
{
m_procAttacker = new ProcFlagsInit(ProcFlags.DonePeriodic);
m_procVictim = new ProcFlagsInit(ProcFlags.TakenPeriodic);
}
}
public void CleanupTargetList()
@@ -2885,10 +2866,27 @@ namespace Game.Spells
ProcFlagsInit procAttacker = m_procAttacker;
if (!procAttacker)
{
if (m_spellInfo.DmgClass == SpellDmgClass.Magic)
procAttacker = new ProcFlagsInit(IsPositive() ? ProcFlags.DoneSpellMagicDmgClassPos : ProcFlags.DoneSpellMagicDmgClassNeg);
if (m_spellInfo.HasAttribute(SpellAttr3.TreatAsPeriodic))
{
if (IsPositive())
procAttacker.Or(ProcFlags.DealHelpfulPeriodic);
else
procAttacker.Or(ProcFlags.DealHarmfulPeriodic);
}
else if (m_spellInfo.HasAttribute(SpellAttr0.Ability))
{
if (IsPositive())
procAttacker.Or(ProcFlags.DealHelpfulAbility);
else
procAttacker.Or(ProcFlags.DealHarmfulSpell);
}
else
procAttacker = new ProcFlagsInit(IsPositive() ? ProcFlags.DoneSpellNoneDmgClassPos : ProcFlags.DoneSpellNoneDmgClassNeg);
{
if (IsPositive())
procAttacker.Or(ProcFlags.DealHelpfulSpell);
else
procAttacker.Or(ProcFlags.DealHarmfulSpell);
}
}
procAttacker.Or(ProcFlags2.CastSuccessful);
@@ -3149,10 +3147,27 @@ namespace Game.Spells
ProcFlagsInit procAttacker = m_procAttacker;
if (!procAttacker)
{
if (m_spellInfo.DmgClass == SpellDmgClass.Magic)
procAttacker = new ProcFlagsInit(IsPositive() ? ProcFlags.DoneSpellMagicDmgClassPos : ProcFlags.DoneSpellMagicDmgClassNeg);
if (m_spellInfo.HasAttribute(SpellAttr3.TreatAsPeriodic))
{
if (IsPositive())
procAttacker.Or(ProcFlags.DealHelpfulPeriodic);
else
procAttacker.Or(ProcFlags.DealHarmfulPeriodic);
}
else if (m_spellInfo.HasAttribute(SpellAttr0.Ability))
{
if (IsPositive())
procAttacker.Or(ProcFlags.DealHelpfulAbility);
else
procAttacker.Or(ProcFlags.DealHarmfulAbility);
}
else
procAttacker = new ProcFlagsInit(IsPositive() ? ProcFlags.DoneSpellNoneDmgClassPos : ProcFlags.DoneSpellNoneDmgClassNeg);
{
if (IsPositive())
procAttacker.Or(ProcFlags.DealHelpfulSpell);
else
procAttacker.Or(ProcFlags.DealHarmfulSpell);
}
}
Unit.ProcSkillsAndAuras(m_originalCaster, null, procAttacker, new ProcFlagsInit(ProcFlags.None), ProcFlagsSpellType.MaskAll, ProcFlagsSpellPhase.Finish, m_hitMask, this, null, null);
@@ -3294,6 +3309,8 @@ namespace Game.Spells
if (creatureCaster != null)
creatureCaster.ReleaseSpellFocus(this);
Unit.ProcSkillsAndAuras(unitCaster, null, new ProcFlagsInit(ProcFlags.CastEnded), new ProcFlagsInit(), ProcFlagsSpellType.MaskAll, ProcFlagsSpellPhase.None, ProcFlagsHit.None, this, null, null);
if (!ok)
return;
@@ -8225,28 +8242,46 @@ namespace Game.Spells
switch (spell.m_spellInfo.DmgClass)
{
case SpellDmgClass.Magic:
if (positive)
{
procAttacker.Or(ProcFlags.DoneSpellMagicDmgClassPos);
procVictim.Or(ProcFlags.TakenSpellMagicDmgClassPos);
}
else
{
procAttacker.Or(ProcFlags.DoneSpellMagicDmgClassNeg);
procVictim.Or(ProcFlags.TakenSpellMagicDmgClassNeg);
}
break;
case SpellDmgClass.None:
if (positive)
case SpellDmgClass.Magic:
if (spell.m_spellInfo.HasAttribute(SpellAttr3.TreatAsPeriodic))
{
procAttacker.Or(ProcFlags.DoneSpellNoneDmgClassPos);
procVictim.Or(ProcFlags.TakenSpellNoneDmgClassPos);
if (positive)
{
procAttacker.Or(ProcFlags.DealHelpfulPeriodic);
procVictim.Or(ProcFlags.TakeHelpfulPeriodic);
}
else
{
procAttacker.Or(ProcFlags.DealHarmfulPeriodic);
procVictim.Or(ProcFlags.TakeHarmfulPeriodic);
}
}
else if (spell.m_spellInfo.HasAttribute(SpellAttr0.Ability))
{
if (positive)
{
procAttacker.Or(ProcFlags.DealHelpfulAbility);
procVictim.Or(ProcFlags.TakeHelpfulAbility);
}
else
{
procAttacker.Or(ProcFlags.DealHarmfulAbility);
procVictim.Or(ProcFlags.TakeHarmfulAbility);
}
}
else
{
procAttacker.Or(ProcFlags.DoneSpellNoneDmgClassNeg);
procVictim.Or(ProcFlags.TakenSpellNoneDmgClassNeg);
if (positive)
{
procAttacker.Or(ProcFlags.DealHelpfulSpell);
procVictim.Or(ProcFlags.TakeHelpfulSpell);
}
else
{
procAttacker.Or(ProcFlags.DealHarmfulSpell);
procVictim.Or(ProcFlags.TakeHarmfulSpell);
}
}
break;
}
@@ -8299,7 +8334,7 @@ namespace Game.Spells
Unit.DealDamageMods(damageInfo.attacker, damageInfo.target, ref damageInfo.damage, ref damageInfo.absorb);
hitMask |= Unit.CreateProcHitMask(damageInfo, MissCondition);
procVictim.Or(ProcFlags.TakenDamage);
procVictim.Or(ProcFlags.TakeAnyDamage);
spell.m_damage = (int)damageInfo.damage;
@@ -8931,7 +8966,7 @@ namespace Game.Spells
return true;
ProcFlags typeMaskActor = ProcFlags.None;
ProcFlags typeMaskActionTarget = ProcFlags.TakenSpellMagicDmgClassNeg | ProcFlags.TakenSpellNoneDmgClassNeg;
ProcFlags typeMaskActionTarget = ProcFlags.TakeHarmfulSpell | ProcFlags.TakeHarmfulAbility;
ProcFlagsSpellType spellTypeMask = ProcFlagsSpellType.Damage | ProcFlagsSpellType.NoDmgHeal;
ProcFlagsSpellPhase spellPhaseMask = ProcFlagsSpellPhase.None;
ProcFlagsHit hitMask = ProcFlagsHit.Reflect;
+4 -11
View File
@@ -2620,17 +2620,10 @@ namespace Game.Spells
|| (spell.GetState() == SpellState.Preparing && spell.GetCastTime() > 0.0f))
&& curSpellInfo.CanBeInterrupted(m_caster, unitTarget))
{
Unit unitCaster = GetUnitCasterForEffectHandlers();
if (unitCaster != null)
{
int duration = m_spellInfo.GetDuration();
duration = unitTarget.ModSpellDuration(m_spellInfo, unitTarget, duration, false, 1u << (int)effectInfo.EffectIndex);
unitTarget.GetSpellHistory().LockSpellSchool(curSpellInfo.GetSchoolMask(), TimeSpan.FromMilliseconds(duration));
if (m_spellInfo.DmgClass == SpellDmgClass.Magic)
Unit.ProcSkillsAndAuras(unitCaster, unitTarget, new ProcFlagsInit(ProcFlags.DoneSpellMagicDmgClassNeg), new ProcFlagsInit(ProcFlags.TakenSpellMagicDmgClassNeg), ProcFlagsSpellType.MaskAll, ProcFlagsSpellPhase.Hit, ProcFlagsHit.Interrupt, null, null, null);
else if (m_spellInfo.DmgClass == SpellDmgClass.Melee)
Unit.ProcSkillsAndAuras(unitCaster, unitTarget, new ProcFlagsInit(ProcFlags.DoneSpellMeleeDmgClass), new ProcFlagsInit(ProcFlags.TakenSpellMeleeDmgClass), ProcFlagsSpellType.MaskAll, ProcFlagsSpellPhase.Hit, ProcFlagsHit.Interrupt, null, null, null);
}
int duration = m_spellInfo.GetDuration();
duration = unitTarget.ModSpellDuration(m_spellInfo, unitTarget, duration, false, 1u << (int)effectInfo.EffectIndex);
unitTarget.GetSpellHistory().LockSpellSchool(curSpellInfo.GetSchoolMask(), TimeSpan.FromMilliseconds(duration));
m_hitMask |= ProcFlagsHit.Interrupt;
SendSpellInterruptLog(unitTarget, curSpellInfo.Id);
unitTarget.InterruptSpell(i, false);
}
+1 -1
View File
@@ -484,7 +484,7 @@ namespace Game.Entities
}
// always trigger for these types
if (eventInfo.GetTypeMask().HasFlag(ProcFlags.Killed | ProcFlags.Kill | ProcFlags.Death))
if (eventInfo.GetTypeMask().HasFlag(ProcFlags.Heartbeat | ProcFlags.Kill | ProcFlags.Death))
return true;
// check school mask (if set) for other trigger types