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
-13
View File
@@ -355,19 +355,6 @@ namespace Game.Spells
_effects[effect.EffectIndex] = new AuraEffect(this, effect, baseAmount != null ? baseAmount[effect.EffectIndex] : (int?)null, caster);
}
}
public float CalcPeriodicCritChance(Unit caster)
{
if (!caster)
return 0.0f;
Player modOwner = caster.GetSpellModOwner();
if (modOwner == null)
return 0.0f;
float critChance = modOwner.SpellCritChanceDone(GetSpellInfo(), GetSpellInfo().GetSchoolMask(), GetSpellInfo().GetAttackType());
return Math.Max(0.0f, critChance);
}
public Unit GetCaster()
{
+27 -1
View File
@@ -446,7 +446,7 @@ namespace Game.Spells
public float GetCritChanceFor(Unit caster, Unit target)
{
return target.SpellCritChanceTaken(caster, null, this, GetSpellInfo().GetSchoolMask(), GetBase().CalcPeriodicCritChance(caster), GetSpellInfo().GetAttackType());
return target.SpellCritChanceTaken(caster, null, this, GetSpellInfo().GetSchoolMask(), CalcPeriodicCritChance(caster), GetSpellInfo().GetAttackType());
}
public bool IsAffectingSpell(SpellInfo spell)
@@ -595,6 +595,11 @@ namespace Game.Spells
return false;
break;
}
case AuraType.ModSpellCritChance:
// skip spells that can't crit
if (spellInfo == null || !spellInfo.HasAttribute(SpellCustomAttributes.CanCrit))
return false;
break;
default:
break;
}
@@ -5380,6 +5385,27 @@ namespace Game.Spells
caster.SendSpellNonMeleeDamageLog(damageInfo);
}
bool CanPeriodicTickCrit()
{
if (GetSpellInfo().HasAttribute(SpellAttr2.CantCrit))
return false;
return true;
}
float CalcPeriodicCritChance(Unit caster)
{
if (!caster || !CanPeriodicTickCrit())
return 0.0f;
Player modOwner = caster.GetSpellModOwner();
if (!modOwner)
return 0.0f;
float critChance = modOwner.SpellCritChanceDone(null, this, GetSpellInfo().GetSchoolMask(), GetSpellInfo().GetAttackType());
return Math.Max(0.0f, critChance);
}
void HandleBreakableCCAuraProc(AuraApplication aurApp, ProcEventInfo eventInfo)
{
int damageLeft = (int)(GetAmount() - eventInfo.GetDamageInfo().GetDamage());