Core/Spells: Define all spell modifier types and implement ProcCooldown mod and PeriodicHealingAndDamage for melee periodic damage

Port From (https://github.com/TrinityCore/TrinityCore/commit/6585666e6e34ade0333e4c23876acdf847d169c0)
This commit is contained in:
hondacrx
2021-03-17 18:52:59 -04:00
parent f667df1b11
commit 4568cdad48
16 changed files with 168 additions and 158 deletions
+10 -5
View File
@@ -1772,7 +1772,7 @@ namespace Game.Entities
{
Player modOwner = GetSpellModOwner();
if (modOwner != null)
modOwner.ApplySpellMod(spellProto, SpellModOp.ProcPerMinute, ref PPM);
modOwner.ApplySpellMod(spellProto, SpellModOp.ProcFrequency, ref PPM);
}
return (float)Math.Floor((WeaponSpeed * PPM) / 600.0f); // result is chance in percents (probability = Speed_in_sec * (PPM / 60))
@@ -1916,7 +1916,7 @@ namespace Game.Entities
damage += CalculateDamage(damageInfo.attackType, false, true);
// Add melee damage bonus
damage = MeleeDamageBonusDone(damageInfo.target, damage, damageInfo.attackType);
damage = MeleeDamageBonusDone(damageInfo.target, damage, damageInfo.attackType, DamageEffectType.Direct);
damage = damageInfo.target.MeleeDamageBonusTaken(this, damage, damageInfo.attackType, DamageEffectType.Direct);
// Script Hook For CalculateMeleeDamage -- Allow scripts to change the Damage pre class mitigation calculations
@@ -2737,7 +2737,7 @@ namespace Game.Entities
{
Player modOwner = GetSpellModOwner();
if (modOwner != null)
modOwner.ApplySpellMod(spellInfo, SpellModOp.IgnoreArmor, ref armor);
modOwner.ApplySpellMod(spellInfo, SpellModOp.TargetResistance, ref armor);
}
var resIgnoreAuras = GetAuraEffectsByType(AuraType.ModIgnoreTargetResist);
@@ -2780,7 +2780,7 @@ namespace Game.Entities
return Math.Max((uint)(damage * (1.0f - mitigation)), 1);
}
public uint MeleeDamageBonusDone(Unit victim, uint pdamage, WeaponAttackType attType, SpellInfo spellProto = null)
public uint MeleeDamageBonusDone(Unit victim, uint pdamage, WeaponAttackType attType, DamageEffectType damagetype, SpellInfo spellProto = null)
{
if (victim == null || pdamage == 0)
return 0;
@@ -2874,7 +2874,12 @@ namespace Game.Entities
{
Player modOwner = GetSpellModOwner();
if (modOwner != null)
modOwner.ApplySpellMod(spellProto, SpellModOp.Damage, ref tmpDamage);
{
if (damagetype == DamageEffectType.DOT)
modOwner.ApplySpellMod(spellProto, SpellModOp.PeriodicHealingAndDamage, ref tmpDamage);
else
modOwner.ApplySpellMod(spellProto, SpellModOp.HealingAndDamage, ref tmpDamage);
}
}
// bonus result can be negative
+1 -2
View File
@@ -286,6 +286,7 @@ namespace Game.Entities
case MeleeHitOutcome.Evade:
m_hitMask |= ProcFlagsHit.Evade;
break;
case MeleeHitOutcome.Block:
case MeleeHitOutcome.Crushing:
case MeleeHitOutcome.Glancing:
case MeleeHitOutcome.Normal:
@@ -296,8 +297,6 @@ namespace Game.Entities
if (!damageNullified)
m_hitMask |= ProcFlagsHit.Critical;
break;
default:
break;
}
}
+23 -23
View File
@@ -121,7 +121,7 @@ namespace Game.Entities
if (modOwner)
{
ApCoeffMod *= 100.0f;
modOwner.ApplySpellMod(spellProto, SpellModOp.BonusMultiplier, ref ApCoeffMod);
modOwner.ApplySpellMod(spellProto, SpellModOp.BonusCoefficient, ref ApCoeffMod);
ApCoeffMod /= 100.0f;
}
@@ -145,7 +145,7 @@ namespace Game.Entities
if (modOwner)
{
coeff *= 100.0f;
modOwner.ApplySpellMod(spellProto, SpellModOp.BonusMultiplier, ref coeff);
modOwner.ApplySpellMod(spellProto, SpellModOp.BonusCoefficient, ref coeff);
coeff /= 100.0f;
}
DoneTotal += (int)(DoneAdvertisedBenefit * coeff * stack);
@@ -158,9 +158,9 @@ namespace Game.Entities
if (_modOwner)
{
if (damagetype == DamageEffectType.DOT)
_modOwner.ApplySpellMod(spellProto, SpellModOp.Dot, ref tmpDamage);
_modOwner.ApplySpellMod(spellProto, SpellModOp.PeriodicHealingAndDamage, ref tmpDamage);
else
_modOwner.ApplySpellMod(spellProto, SpellModOp.Damage, ref tmpDamage);
_modOwner.ApplySpellMod(spellProto, SpellModOp.HealingAndDamage, ref tmpDamage);
}
return (uint)Math.Max(tmpDamage, 0.0f);
@@ -321,7 +321,7 @@ namespace Game.Entities
if (modOwner)
{
coeff *= 100.0f;
modOwner.ApplySpellMod(spellProto, SpellModOp.BonusMultiplier, ref coeff);
modOwner.ApplySpellMod(spellProto, SpellModOp.BonusCoefficient, ref coeff);
coeff /= 100.0f;
}
TakenTotal += (int)(TakenAdvertisedBenefit * coeff * stack);
@@ -400,7 +400,7 @@ namespace Game.Entities
// adds additional damage to critBonus (from talents)
Player modOwner = GetSpellModOwner();
if (modOwner != null)
modOwner.ApplySpellMod(spellProto, SpellModOp.CritDamageBonus, ref crit_bonus);
modOwner.ApplySpellMod(spellProto, SpellModOp.CritDamageAndHealing, ref crit_bonus);
damage += crit_bonus;
@@ -467,7 +467,7 @@ namespace Game.Entities
if (modOwner)
{
coeff *= 100.0f;
modOwner.ApplySpellMod(spellProto, SpellModOp.BonusMultiplier, ref coeff);
modOwner.ApplySpellMod(spellProto, SpellModOp.BonusCoefficient, ref coeff);
coeff /= 100.0f;
}
@@ -498,9 +498,9 @@ namespace Game.Entities
if (_modOwner)
{
if (damagetype == DamageEffectType.DOT)
_modOwner.ApplySpellMod(spellProto, SpellModOp.Dot, ref heal);
_modOwner.ApplySpellMod(spellProto, SpellModOp.PeriodicHealingAndDamage, ref heal);
else
_modOwner.ApplySpellMod(spellProto, SpellModOp.Damage, ref heal);
_modOwner.ApplySpellMod(spellProto, SpellModOp.HealingAndDamage, ref heal);
}
return (uint)Math.Max(heal, 0.0f);
@@ -599,7 +599,7 @@ namespace Game.Entities
if (modOwner)
{
coeff *= 100.0f;
modOwner.ApplySpellMod(spellProto, SpellModOp.BonusMultiplier, ref coeff);
modOwner.ApplySpellMod(spellProto, SpellModOp.BonusCoefficient, ref coeff);
coeff /= 100.0f;
}
@@ -763,7 +763,7 @@ namespace Game.Entities
// only players use intelligence for critical chance computations
Player modOwner = GetSpellModOwner();
if (modOwner != null)
modOwner.ApplySpellMod(spellProto, SpellModOp.CriticalChance, ref crit_chance);
modOwner.ApplySpellMod(spellProto, SpellModOp.CritChance, ref crit_chance);
// for this types the bonus was already added in GetUnitCriticalChance, do not add twice
if (spellProto.DmgClass != SpellDmgClass.Melee && spellProto.DmgClass != SpellDmgClass.Ranged)
@@ -1012,10 +1012,10 @@ namespace Game.Entities
else
modHitChance = 97 - levelBasedHitDiff;
// Spellmod from SPELLMOD_RESIST_MISS_CHANCE
// Spellmod from SpellModOp.HitChance
Player modOwner = GetSpellModOwner();
if (modOwner != null)
modOwner.ApplySpellMod(spell, SpellModOp.ResistMissChance, ref modHitChance);
modOwner.ApplySpellMod(spell, SpellModOp.HitChance, ref modHitChance);
// Spells with SPELL_ATTR3_IGNORE_HIT_RESULT will ignore target's avoidance effects
if (!spell.HasAttribute(SpellAttr3.IgnoreHitResult))
@@ -2021,7 +2021,7 @@ namespace Game.Entities
// called from caster
Player modOwner = GetSpellModOwner();
if (modOwner != null)
modOwner.ApplySpellMod(spellInfo, SpellModOp.CastingTime, ref castTime, spell);
modOwner.ApplySpellMod(spellInfo, SpellModOp.ChangeCastTime, ref castTime, spell);
if (!(spellInfo.HasAttribute(SpellAttr0.Ability | SpellAttr0.Tradespell) || spellInfo.HasAttribute(SpellAttr3.NoDoneBonus))
&& (IsTypeId(TypeId.Player) && spellInfo.SpellFamilyName != 0) || IsTypeId(TypeId.Unit))
@@ -2042,7 +2042,7 @@ namespace Game.Entities
// called from caster
Player modOwner = GetSpellModOwner();
if (modOwner)
modOwner.ApplySpellMod(spellInfo, SpellModOp.CastingTime, ref duration, spell);
modOwner.ApplySpellMod(spellInfo, SpellModOp.ChangeCastTime, ref duration, spell);
if (!(spellInfo.HasAttribute(SpellAttr0.Ability) || spellInfo.HasAttribute(SpellAttr0.Tradespell) || spellInfo.HasAttribute(SpellAttr3.NoDoneBonus)) &&
(IsTypeId(TypeId.Player) && spellInfo.SpellFamilyName != 0) || IsTypeId(TypeId.Unit))
@@ -2055,23 +2055,23 @@ namespace Game.Entities
Player modOwner = GetSpellModOwner();
if (modOwner != null)
{
modOwner.ApplySpellMod(spellProto, SpellModOp.AllEffects, ref value);
modOwner.ApplySpellMod(spellProto, SpellModOp.Points, ref value);
switch (effect_index)
{
case 0:
modOwner.ApplySpellMod(spellProto, SpellModOp.Effect1, ref value);
modOwner.ApplySpellMod(spellProto, SpellModOp.PointsIndex0, ref value);
break;
case 1:
modOwner.ApplySpellMod(spellProto, SpellModOp.Effect2, ref value);
modOwner.ApplySpellMod(spellProto, SpellModOp.PointsIndex1, ref value);
break;
case 2:
modOwner.ApplySpellMod(spellProto, SpellModOp.Effect3, ref value);
modOwner.ApplySpellMod(spellProto, SpellModOp.PointsIndex2, ref value);
break;
case 3:
modOwner.ApplySpellMod(spellProto, SpellModOp.Effect4, ref value);
modOwner.ApplySpellMod(spellProto, SpellModOp.PointsIndex3, ref value);
break;
case 4:
modOwner.ApplySpellMod(spellProto, SpellModOp.Effect5, ref value);
modOwner.ApplySpellMod(spellProto, SpellModOp.PointsIndex4, ref value);
break;
}
}
@@ -2230,7 +2230,7 @@ namespace Game.Entities
// adds additional damage to critBonus (from talents)
Player modOwner = GetSpellModOwner();
if (modOwner != null)
modOwner.ApplySpellMod(spellProto, SpellModOp.CritDamageBonus, ref crit_bonus);
modOwner.ApplySpellMod(spellProto, SpellModOp.CritDamageAndHealing, ref crit_bonus);
crit_bonus += (int)damage;
@@ -2444,7 +2444,7 @@ namespace Game.Entities
// Apply crit_damage bonus for melee spells
Player modOwner = GetSpellModOwner();
if (modOwner != null)
modOwner.ApplySpellMod(spellInfo, SpellModOp.CritDamageBonus, ref crit_bonus);
modOwner.ApplySpellMod(spellInfo, SpellModOp.CritDamageAndHealing, ref crit_bonus);
damage += (int)crit_bonus;
// Increase crit damage from SPELL_AURA_MOD_CRIT_DAMAGE_BONUS