Core/Scripts: Added SpellEffectInfo argument to CalcDamage and CalcHealing spell script hooks

Port From (https://github.com/TrinityCore/TrinityCore/commit/884662a75a901af6f61cab9efc171d052e8042f4)
This commit is contained in:
Hondacrx
2025-05-19 11:01:52 -04:00
parent 6097bf92cc
commit 94877fed77
13 changed files with 29 additions and 29 deletions
+1 -1
View File
@@ -1221,7 +1221,7 @@ namespace Game.Entities
uint damage = 0;
damage += CalculateDamage(damageInfo.AttackType, false, true);
// Add melee damage bonus
damage = (uint)MeleeDamageBonusDone(damageInfo.Target, (int)damage, damageInfo.AttackType, DamageEffectType.Direct, null, default, (SpellSchoolMask)damageInfo.DamageSchoolMask);
damage = (uint)MeleeDamageBonusDone(damageInfo.Target, (int)damage, damageInfo.AttackType, DamageEffectType.Direct, null, null, Mechanics.None, (SpellSchoolMask)damageInfo.DamageSchoolMask);
damage = (uint)damageInfo.Target.MeleeDamageBonusTaken(this, (int)damage, damageInfo.AttackType, DamageEffectType.Direct, null, (SpellSchoolMask)damageInfo.DamageSchoolMask);
// Script Hook For CalculateMeleeDamage -- Allow scripts to change the Damage pre class mitigation calculations
+2 -2
View File
@@ -68,7 +68,7 @@ namespace Game.Entities
void callDamageScript(ref int dmg, ref int flatMod, ref float pctMod)
{
if (spell != null)
spell.CallScriptCalcDamageHandlers(victim, ref dmg, ref flatMod, ref pctMod);
spell.CallScriptCalcDamageHandlers(spellEffectInfo, victim, ref dmg, ref flatMod, ref pctMod);
else if (aurEff != null)
aurEff.GetBase().CallScriptCalcDamageAndHealingHandlers(aurEff, aurEff.GetBase().GetApplicationOfTarget(victim.GetGUID()), victim, ref dmg, ref flatMod, ref pctMod);
}
@@ -483,7 +483,7 @@ namespace Game.Entities
}
if (spell != null)
spell.CallScriptCalcHealingHandlers(victim, ref healamount, ref DoneTotal, ref DoneTotalMod);
spell.CallScriptCalcHealingHandlers(spellEffectInfo, victim, ref healamount, ref DoneTotal, ref DoneTotalMod);
else if (aurEff != null)
aurEff.GetBase().CallScriptCalcDamageAndHealingHandlers(aurEff, aurEff.GetBase().GetApplicationOfTarget(victim.GetGUID()), victim, ref healamount, ref DoneTotal, ref DoneTotalMod);
+2 -2
View File
@@ -3876,7 +3876,7 @@ namespace Game.Entities
return (uint)Math.Max(damage * (1.0f - mitigation), 0.0f);
}
public int MeleeDamageBonusDone(Unit victim, int damage, WeaponAttackType attType, DamageEffectType damagetype, SpellInfo spellProto = null, Mechanics mechanic = default, SpellSchoolMask damageSchoolMask = SpellSchoolMask.Normal, Spell spell = null, AuraEffect aurEff = null)
public int MeleeDamageBonusDone(Unit victim, int damage, WeaponAttackType attType, DamageEffectType damagetype, SpellInfo spellProto = null, SpellEffectInfo spellEffectInfo = null, Mechanics mechanic = default, SpellSchoolMask damageSchoolMask = SpellSchoolMask.Normal, Spell spell = null, AuraEffect aurEff = null)
{
if (victim == null || damage == 0)
return 0;
@@ -3976,7 +3976,7 @@ namespace Game.Entities
MathFunctions.AddPct(ref DoneTotalMod, GetTotalAuraModifierByMiscValue(AuraType.ModDamageDoneForMechanic, (int)spellProto.Mechanic));
if (spell != null)
spell.CallScriptCalcDamageHandlers(victim, ref damage, ref DoneFlatBenefit, ref DoneTotalMod);
spell.CallScriptCalcDamageHandlers(spellEffectInfo, victim, ref damage, ref DoneFlatBenefit, ref DoneTotalMod);
else if (aurEff != null)
aurEff.GetBase().CallScriptCalcDamageAndHealingHandlers(aurEff, aurEff.GetBase().GetApplicationOfTarget(victim.GetGUID()), victim, ref damage, ref DoneFlatBenefit, ref DoneTotalMod);
+3 -3
View File
@@ -164,7 +164,7 @@ namespace Game.Scripting
// internal use classes & functions
// DO NOT OVERRIDE THESE IN SCRIPTS
public delegate SpellCastResult SpellCheckCastFnType();
public delegate void DamageAndHealingCalcFnType(Unit victim, ref int damageOrHealing, ref int flatMod, ref float pctMod);
public delegate void DamageAndHealingCalcFnType(SpellEffectInfo spellEffectInfo, Unit victim, ref int damageOrHealing, ref int flatMod, ref float pctMod);
public delegate void SpellOnResistAbsorbCalculateFnType(DamageInfo damageInfo, ref uint resistAmount, ref int absorbAmount);
public delegate void SpellEffectFnType(uint index);
public delegate void SpellBeforeHitFnType(SpellMissInfo missInfo);
@@ -212,9 +212,9 @@ namespace Game.Scripting
_callImpl = handler;
}
public void Call(Unit victim, ref int damageOrHealing, ref int flatMod, ref float pctMod)
public void Call(SpellEffectInfo spellEffectInfo, Unit victim, ref int damageOrHealing, ref int flatMod, ref float pctMod)
{
_callImpl(victim, ref damageOrHealing, ref flatMod, ref pctMod);
_callImpl(spellEffectInfo, victim, ref damageOrHealing, ref flatMod, ref pctMod);
}
}
+1 -1
View File
@@ -5238,7 +5238,7 @@ namespace Game.Spells
// Add melee damage bonuses (also check for negative)
if (caster != null)
damage = (uint)caster.MeleeDamageBonusDone(target, (int)damage, attackType, DamageEffectType.DOT, GetSpellInfo(), GetSpellEffectInfo().Mechanic, GetSpellInfo().GetSchoolMask(), null, this);
damage = (uint)caster.MeleeDamageBonusDone(target, (int)damage, attackType, DamageEffectType.DOT, GetSpellInfo(), GetSpellEffectInfo(), GetSpellEffectInfo().Mechanic, GetSpellInfo().GetSchoolMask(), null, this);
damage = (uint)target.MeleeDamageBonusTaken(caster, (int)damage, attackType, DamageEffectType.DOT, GetSpellInfo());
break;
+4 -4
View File
@@ -8077,25 +8077,25 @@ namespace Game.Spells
}
}
public void CallScriptCalcDamageHandlers(Unit victim, ref int damage, ref int flatMod, ref float pctMod)
public void CallScriptCalcDamageHandlers(SpellEffectInfo spellEffectInfo, Unit victim, ref int damage, ref int flatMod, ref float pctMod)
{
foreach (SpellScript script in m_loadedScripts)
{
script._PrepareScriptCall(SpellScriptHookType.CalcDamage);
foreach (var calcDamage in script.CalcDamage)
calcDamage.Call(victim, ref damage, ref flatMod, ref pctMod);
calcDamage.Call(spellEffectInfo, victim, ref damage, ref flatMod, ref pctMod);
script._FinishScriptCall();
}
}
public void CallScriptCalcHealingHandlers(Unit victim, ref int healing, ref int flatMod, ref float pctMod)
public void CallScriptCalcHealingHandlers(SpellEffectInfo spellEffectInfo, Unit victim, ref int healing, ref int flatMod, ref float pctMod)
{
foreach (SpellScript script in m_loadedScripts)
{
script._PrepareScriptCall(SpellScriptHookType.CalcHealing);
foreach (var calcHealing in script.CalcHealing)
calcHealing.Call(victim, ref healing, ref flatMod, ref pctMod);
calcHealing.Call(spellEffectInfo, victim, ref healing, ref flatMod, ref pctMod);
script._FinishScriptCall();
}
+1 -1
View File
@@ -2498,7 +2498,7 @@ namespace Game.Spells
weaponDamage = Math.Max(weaponDamage, 0);
// Add melee damage bonuses (also check for negative)
weaponDamage = (uint)unitCaster.MeleeDamageBonusDone(unitTarget, (int)weaponDamage, m_attackType, DamageEffectType.SpellDirect, m_spellInfo, mechanic, m_spellSchoolMask, this);
weaponDamage = (uint)unitCaster.MeleeDamageBonusDone(unitTarget, (int)weaponDamage, m_attackType, DamageEffectType.SpellDirect, m_spellInfo, effectInfo, mechanic, m_spellSchoolMask, this);
m_damage += unitTarget.MeleeDamageBonusTaken(unitCaster, (int)weaponDamage, m_attackType, DamageEffectType.SpellDirect, m_spellInfo);
}
@@ -89,7 +89,7 @@ namespace Scripts.Shadowlands.Torghast
[Script] // 305060 - Yel'Shir's Powerglove
class spell_torghast_yelshirs_powerglove : SpellScript
{
void CalculateDamage(Unit victim, ref int damage, ref int flatMod, ref float pctMod)
void CalculateDamage(SpellEffectInfo spellEffectInfo, Unit victim, ref int damage, ref int flatMod, ref float pctMod)
{
SpellInfo triggeringSpell = GetTriggeringSpell();
if (triggeringSpell != null)
+1 -1
View File
@@ -435,7 +435,7 @@ namespace Scripts.Spells.Azerite
return ValidateSpellEffect((SpellEchoingBladesTrait, 2));
}
void CalculateDamage(Unit victim, ref int damage, ref int flatMod, ref float pctMod)
void CalculateDamage(SpellEffectInfo spellEffectInfo, Unit victim, ref int damage, ref int flatMod, ref float pctMod)
{
AuraEffect trait = GetCaster().GetAuraEffect(SpellEchoingBladesTrait, 2);
if (trait != null)
+1 -1
View File
@@ -161,7 +161,7 @@ namespace Scripts.Spells.Evoker
&& spellInfo.GetEffect(2).IsAura(AuraType.ModSilence); // validate we are removing the correct effect
}
void AddBonusUpfrontDamage(Unit victim, ref int damage, ref int flatMod, ref float pctMod)
void AddBonusUpfrontDamage(SpellEffectInfo spellEffectInfo, Unit victim, ref int damage, ref int flatMod, ref float pctMod)
{
int empowerLevel = (int)GetSpell().m_customArg;
if (empowerLevel == 0)
+2 -2
View File
@@ -942,7 +942,7 @@ namespace Scripts.Spells.Generic
[Script] // 64208 - Consumption
class spell_gen_consumption : SpellScript
{
void CalculateDamage(Unit victim, ref int damage, ref int flatMod, ref float pctMod)
void CalculateDamage(SpellEffectInfo spellEffectInfo, Unit victim, ref int damage, ref int flatMod, ref float pctMod)
{
SpellInfo createdBySpell = SpellMgr.GetSpellInfo(GetCaster().m_unitData.CreatedBySpell, GetCastDifficulty());
if (createdBySpell != null)
@@ -5100,7 +5100,7 @@ namespace Scripts.Spells.Generic
);
}
void CalculateHealingBonus(Unit victim, ref int healing, ref int flatMod, ref float pctMod)
void CalculateHealingBonus(SpellEffectInfo spellEffectInfo, Unit victim, ref int healing, ref int flatMod, ref float pctMod)
{
MathFunctions.AddPct(ref pctMod, MajorPlayerHealingCooldownHelpers.GetBonusMultiplier(GetCaster(), GetSpellInfo().Id));
}
+8 -8
View File
@@ -439,7 +439,7 @@ namespace Scripts.Spells.Priest
return ValidateSpellEffect((SpellIds.AbyssalReverie, 0));
}
void CalculateHealingBonus(Unit victim, ref int healing, ref int flatMod, ref float pctMod)
void CalculateHealingBonus(SpellEffectInfo spellEffectInfo, Unit victim, ref int healing, ref int flatMod, ref float pctMod)
{
spell_pri_atonement.TriggerArgs args = (spell_pri_atonement.TriggerArgs)GetSpell().m_customArg;
if (args == null || (args.DamageSchoolMask & SpellSchoolMask.Shadow) == 0)
@@ -919,7 +919,7 @@ namespace Scripts.Spells.Priest
&& ValidateSpellEffect((SpellIds.DivineService, 0));
}
void CalculateHealingBonus(Unit victim, ref int healing, ref int flatMod, ref float pctMod)
void CalculateHealingBonus(SpellEffectInfo spellEffectInfo, Unit victim, ref int healing, ref int flatMod, ref float pctMod)
{
AuraEffect divineServiceEffect = GetCaster().GetAuraEffect(SpellIds.DivineService, 0);
if (divineServiceEffect != null)
@@ -1183,7 +1183,7 @@ namespace Scripts.Spells.Priest
return ValidateSpellEffect((SpellIds.FocusedMending, 0));
}
void CalculateHealingBonus(Unit victim, ref int healing, ref int flatMod, ref float pctMod)
void CalculateHealingBonus(SpellEffectInfo spellEffectInfo, Unit victim, ref int healing, ref int flatMod, ref float pctMod)
{
AuraEffect focusedMendingEffect = GetCaster().GetAuraEffect(SpellIds.FocusedMending, 0);
if (focusedMendingEffect != null)
@@ -1574,7 +1574,7 @@ namespace Scripts.Spells.Priest
}
}
void CalculateDamageBonus(Unit victim, ref int damage, ref int flatMod, ref float pctMod)
void CalculateDamageBonus(SpellEffectInfo spellEffectInfo, Unit victim, ref int damage, ref int flatMod, ref float pctMod)
{
Aura atonement = GetCaster().GetAura(SpellIds.Atonement);
if (atonement == null)
@@ -1680,7 +1680,7 @@ namespace Scripts.Spells.Priest
_damageIncrease = mindDevourer.GetAmount();
}
void CalculateDamage(Unit victim, ref int damage, ref int flatMod, ref float pctMod)
void CalculateDamage(SpellEffectInfo spellEffectInfo, Unit victim, ref int damage, ref int flatMod, ref float pctMod)
{
MathFunctions.AddPct(ref pctMod, _damageIncrease);
}
@@ -1966,7 +1966,7 @@ namespace Scripts.Spells.Priest
return ValidateSpellInfo(SpellIds.PowerOfTheDarkSide);
}
void CalculateDamageBonus(Unit victim, ref int damage, ref int flatMod, ref float pctMod)
void CalculateDamageBonus(SpellEffectInfo spellEffectInfo, Unit victim, ref int damage, ref int flatMod, ref float pctMod)
{
AuraEffect powerOfTheDarkSide = GetCaster().GetAuraEffect(SpellIds.PowerOfTheDarkSide, 0);
if (powerOfTheDarkSide != null)
@@ -1988,7 +1988,7 @@ namespace Scripts.Spells.Priest
return ValidateSpellInfo(SpellIds.PowerOfTheDarkSide);
}
void CalculateHealingBonus(Unit victim, ref int healing, ref int flatMod, ref float pctMod)
void CalculateHealingBonus(SpellEffectInfo spellEffectInfo, Unit victim, ref int healing, ref int flatMod, ref float pctMod)
{
AuraEffect powerOfTheDarkSide = GetCaster().GetAuraEffect(SpellIds.PowerOfTheDarkSide, 0);
if (powerOfTheDarkSide != null)
@@ -3003,7 +3003,7 @@ namespace Scripts.Spells.Priest
&& ValidateSpellEffect((spellInfo.Id, 4));
}
void HandleDamageCalculation(Unit victim, ref int damage, ref int flatMod, ref float pctMod)
void HandleDamageCalculation(SpellEffectInfo spellEffectInfo, Unit victim, ref int damage, ref int flatMod, ref float pctMod)
{
if (victim.HealthBelowPct(GetEffectInfo(1).CalcValue(GetCaster())))
MathFunctions.AddPct(ref pctMod, GetEffectInfo(2).CalcValue(GetCaster()));
+2 -2
View File
@@ -293,7 +293,7 @@ namespace Scripts.Spells.Rogue
[Script] // 32645 - Envenom
class spell_rog_envenom : SpellScript
{
void CalculateDamage(Unit victim, ref int damage, ref int flatMod, ref float pctMod)
void CalculateDamage(SpellEffectInfo spellEffectInfo, Unit victim, ref int damage, ref int flatMod, ref float pctMod)
{
pctMod *= GetSpell().GetPowerTypeCostAmount(PowerType.ComboPoints).GetValueOrDefault(0);
@@ -311,7 +311,7 @@ namespace Scripts.Spells.Rogue
[Script] // 196819 - Eviscerate
class spell_rog_eviscerate : SpellScript
{
void CalculateDamage(Unit victim, ref int damage, ref int flatMod, ref float pctMod)
void CalculateDamage(SpellEffectInfo spellEffectInfo, Unit victim, ref int damage, ref int flatMod, ref float pctMod)
{
pctMod *= GetSpell().GetPowerTypeCostAmount(PowerType.ComboPoints).GetValueOrDefault(0);