Core/Auras: Implemented OnHeartbeat AuraScript hook and refactored an aurascript to use it as example

Port From (https://github.com/TrinityCore/TrinityCore/commit/55ce5b150f716b6d470af80a9c31adf78e4cc198)
This commit is contained in:
Hondacrx
2024-08-19 12:24:24 -04:00
parent d7130c982d
commit cf42b5e591
5 changed files with 41 additions and 16 deletions
+4 -13
View File
@@ -3883,17 +3883,9 @@ namespace Scripts.Spells.Azerite
return ValidateSpellInfo(SpellFragileEchoesMonk, SpellFragileEchoesShaman, SpellFragileEchoesPriestDiscipline, SpellFragileEchoesPaladin, SpellFragileEchoesDruid, SpellFragileEchoesPriestHoly);
}
void ForcePeriodic(AuraEffect aurEff, ref bool isPeriodic, ref int amplitude)
void UpdateSpecAura()
{
// simulate heartbeat timer
isPeriodic = true;
amplitude = 5000;
}
void UpdateSpecAura(AuraEffect aurEff)
{
PreventDefaultAction();
Player target = GetTarget().ToPlayer();
Player target = GetUnitOwner().ToPlayer();
if (target == null)
return;
@@ -3902,7 +3894,7 @@ namespace Scripts.Spells.Azerite
if (target.GetPrimarySpecialization() != spec)
target.RemoveAurasDueToSpell(aura);
else if (!target.HasAura(aura))
target.CastSpell(target, aura, aurEff);
target.CastSpell(target, aura, GetEffect(0));
}
switch (target.GetClass())
@@ -3930,8 +3922,7 @@ namespace Scripts.Spells.Azerite
public override void Register()
{
DoEffectCalcPeriodic.Add(new(ForcePeriodic, 0, AuraType.Dummy));
OnEffectPeriodic.Add(new(UpdateSpecAura, 0, AuraType.Dummy));
OnHeartbeat.Add(new(UpdateSpecAura));
}
}