Core/Spells: calculate crit chance only for spells that do damage/healing

Port From (https://github.com/TrinityCore/TrinityCore/commit/85e5509e91a1370b16851d375a26121797870921)
This commit is contained in:
hondacrx
2021-06-23 22:06:49 -04:00
parent 89586e9495
commit 9e23ca4b04
6 changed files with 80 additions and 43 deletions
+47 -25
View File
@@ -2661,6 +2661,23 @@ namespace Game.Entities
break;
}
switch (effect.Effect)
{
case SpellEffectName.SchoolDamage:
case SpellEffectName.HealthLeech:
case SpellEffectName.Heal:
case SpellEffectName.WeaponDamageNoSchool:
case SpellEffectName.WeaponPercentDamage:
case SpellEffectName.WeaponDamage:
case SpellEffectName.PowerBurn:
case SpellEffectName.HealMechanical:
case SpellEffectName.NormalizedWeaponDmg:
case SpellEffectName.HealPct:
case SpellEffectName.DamageFromMaxHealthPCT:
spellInfo.AttributesCu |= SpellCustomAttributes.CanCrit;
break;
}
switch (effect.Effect)
{
case SpellEffectName.SchoolDamage:
@@ -2846,38 +2863,43 @@ namespace Game.Entities
// addition for binary spells, ommit spells triggering other spells
foreach (var spellInfo in mSpellInfoMap.Values)
{
if (spellInfo.HasAttribute(SpellCustomAttributes.BinarySpell))
continue;
bool allNonBinary = true;
bool overrideAttr = false;
foreach (SpellEffectInfo effect in spellInfo.GetEffects())
if (!spellInfo.HasAttribute(SpellCustomAttributes.BinarySpell))
{
if (effect == null)
continue;
if (effect.IsAura() && effect.TriggerSpell != 0)
bool allNonBinary = true;
bool overrideAttr = false;
foreach (SpellEffectInfo effect in spellInfo.GetEffects())
{
switch (effect.ApplyAuraName)
if (effect == null)
continue;
if (effect.IsAura() && effect.TriggerSpell != 0)
{
case AuraType.PeriodicTriggerSpell:
case AuraType.PeriodicTriggerSpellWithValue:
SpellInfo triggerSpell = Global.SpellMgr.GetSpellInfo(effect.TriggerSpell, Difficulty.None);
if (triggerSpell != null)
{
overrideAttr = true;
if (triggerSpell.HasAttribute(SpellCustomAttributes.BinarySpell))
allNonBinary = false;
}
break;
default:
break;
switch (effect.ApplyAuraName)
{
case AuraType.PeriodicTriggerSpell:
case AuraType.PeriodicTriggerSpellWithValue:
SpellInfo triggerSpell = Global.SpellMgr.GetSpellInfo(effect.TriggerSpell, Difficulty.None);
if (triggerSpell != null)
{
overrideAttr = true;
if (triggerSpell.HasAttribute(SpellCustomAttributes.BinarySpell))
allNonBinary = false;
}
break;
default:
break;
}
}
}
if (overrideAttr && allNonBinary)
spellInfo.AttributesCu &= ~SpellCustomAttributes.BinarySpell;
}
if (overrideAttr && allNonBinary)
spellInfo.AttributesCu &= ~SpellCustomAttributes.BinarySpell;
// remove attribute from spells that can't crit
if (spellInfo.HasAttribute(SpellCustomAttributes.CanCrit))
if (spellInfo.HasAttribute(SpellAttr2.CantCrit))
spellInfo.AttributesCu &= ~SpellCustomAttributes.CanCrit;
}
Log.outInfo(LogFilter.ServerLoading, "Loaded spell custom attributes in {0} ms", Time.GetMSTimeDiffToNow(oldMSTime));