From 94877fed77de04884f1bf8f6a493bd3f10348d40 Mon Sep 17 00:00:00 2001 From: Hondacrx Date: Mon, 19 May 2025 11:01:52 -0400 Subject: [PATCH] Core/Scripts: Added SpellEffectInfo argument to CalcDamage and CalcHealing spell script hooks Port From (https://github.com/TrinityCore/TrinityCore/commit/884662a75a901af6f61cab9efc171d052e8042f4) --- Source/Game/Entities/Unit/Unit.Combat.cs | 2 +- Source/Game/Entities/Unit/Unit.Spells.cs | 4 ++-- Source/Game/Entities/Unit/Unit.cs | 4 ++-- Source/Game/Scripting/SpellScript.cs | 6 +++--- Source/Game/Spells/Auras/AuraEffect.cs | 2 +- Source/Game/Spells/Spell.cs | 8 ++++---- Source/Game/Spells/SpellEffects.cs | 2 +- .../Shadowlands/Torghast/SpellTorghast.cs | 2 +- Source/Scripts/Spells/Azerite.cs | 2 +- Source/Scripts/Spells/Evoker.cs | 2 +- Source/Scripts/Spells/Generic.cs | 4 ++-- Source/Scripts/Spells/Priest.cs | 16 ++++++++-------- Source/Scripts/Spells/Rogue.cs | 4 ++-- 13 files changed, 29 insertions(+), 29 deletions(-) diff --git a/Source/Game/Entities/Unit/Unit.Combat.cs b/Source/Game/Entities/Unit/Unit.Combat.cs index d7f93958f..b91bcc635 100644 --- a/Source/Game/Entities/Unit/Unit.Combat.cs +++ b/Source/Game/Entities/Unit/Unit.Combat.cs @@ -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 diff --git a/Source/Game/Entities/Unit/Unit.Spells.cs b/Source/Game/Entities/Unit/Unit.Spells.cs index c4d2e49c3..5b37766b2 100644 --- a/Source/Game/Entities/Unit/Unit.Spells.cs +++ b/Source/Game/Entities/Unit/Unit.Spells.cs @@ -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); diff --git a/Source/Game/Entities/Unit/Unit.cs b/Source/Game/Entities/Unit/Unit.cs index c1abe64e7..3c6089e1d 100644 --- a/Source/Game/Entities/Unit/Unit.cs +++ b/Source/Game/Entities/Unit/Unit.cs @@ -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); diff --git a/Source/Game/Scripting/SpellScript.cs b/Source/Game/Scripting/SpellScript.cs index f50f75317..15187031e 100644 --- a/Source/Game/Scripting/SpellScript.cs +++ b/Source/Game/Scripting/SpellScript.cs @@ -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); } } diff --git a/Source/Game/Spells/Auras/AuraEffect.cs b/Source/Game/Spells/Auras/AuraEffect.cs index 112d2e766..9827536f9 100644 --- a/Source/Game/Spells/Auras/AuraEffect.cs +++ b/Source/Game/Spells/Auras/AuraEffect.cs @@ -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; diff --git a/Source/Game/Spells/Spell.cs b/Source/Game/Spells/Spell.cs index 5e43f11fd..0e602968b 100644 --- a/Source/Game/Spells/Spell.cs +++ b/Source/Game/Spells/Spell.cs @@ -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(); } diff --git a/Source/Game/Spells/SpellEffects.cs b/Source/Game/Spells/SpellEffects.cs index 845718ab7..e4b38dc12 100644 --- a/Source/Game/Spells/SpellEffects.cs +++ b/Source/Game/Spells/SpellEffects.cs @@ -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); } diff --git a/Source/Scripts/Shadowlands/Torghast/SpellTorghast.cs b/Source/Scripts/Shadowlands/Torghast/SpellTorghast.cs index 65e01a874..ad65b7984 100644 --- a/Source/Scripts/Shadowlands/Torghast/SpellTorghast.cs +++ b/Source/Scripts/Shadowlands/Torghast/SpellTorghast.cs @@ -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) diff --git a/Source/Scripts/Spells/Azerite.cs b/Source/Scripts/Spells/Azerite.cs index 70e6464ad..8e82d34f9 100644 --- a/Source/Scripts/Spells/Azerite.cs +++ b/Source/Scripts/Spells/Azerite.cs @@ -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) diff --git a/Source/Scripts/Spells/Evoker.cs b/Source/Scripts/Spells/Evoker.cs index 97a22233a..f33c77220 100644 --- a/Source/Scripts/Spells/Evoker.cs +++ b/Source/Scripts/Spells/Evoker.cs @@ -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) diff --git a/Source/Scripts/Spells/Generic.cs b/Source/Scripts/Spells/Generic.cs index 3e7f53a48..6731a3724 100644 --- a/Source/Scripts/Spells/Generic.cs +++ b/Source/Scripts/Spells/Generic.cs @@ -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)); } diff --git a/Source/Scripts/Spells/Priest.cs b/Source/Scripts/Spells/Priest.cs index 98e8c06f3..8fb0f74e5 100644 --- a/Source/Scripts/Spells/Priest.cs +++ b/Source/Scripts/Spells/Priest.cs @@ -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())); diff --git a/Source/Scripts/Spells/Rogue.cs b/Source/Scripts/Spells/Rogue.cs index e9084d62d..f8238c2e2 100644 --- a/Source/Scripts/Spells/Rogue.cs +++ b/Source/Scripts/Spells/Rogue.cs @@ -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);