Scripts/Spells: Converted some damage calculating scripts to use new hooks as examples

Port From (https://github.com/TrinityCore/TrinityCore/commit/8594fcfe8a0085a087bce510e3b4cb14f632434f)
This commit is contained in:
hondacrx
2023-09-13 18:23:20 -04:00
parent d7c2fa52f4
commit f89df8dca8
3 changed files with 12 additions and 36 deletions
+3 -11
View File
@@ -1398,24 +1398,16 @@ namespace Scripts.Spells.Generic
[Script] // 64208 - Consumption
class spell_gen_consumption : SpellScript
{
void HandleDamageCalc(uint effIndex)
void CalculateDamage(Unit victim, ref int damage, ref int flatMod, ref float pctMod)
{
Creature caster = GetCaster().ToCreature();
if (caster == null)
return;
int damage = 0;
SpellInfo createdBySpell = Global.SpellMgr.GetSpellInfo(caster.m_unitData.CreatedBySpell, GetCastDifficulty());
SpellInfo createdBySpell = Global.SpellMgr.GetSpellInfo(GetCaster().m_unitData.CreatedBySpell, GetCastDifficulty());
if (createdBySpell != null)
damage = createdBySpell.GetEffect(2).CalcValue();
if (damage != 0)
SetEffectValue(damage);
}
public override void Register()
{
OnEffectLaunchTarget.Add(new EffectHandler(HandleDamageCalc, 0, SpellEffectName.SchoolDamage));
CalcDamage.Add(new DamageAndHealingCalcHandler(CalculateDamage));
}
}