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

* Updated Amalgam's Seventh Spine dummy aura script to use the new AuraScript hook

(cherry picked from commit 55ce5b150f)
This commit is contained in:
Ovahlord
2024-04-27 19:04:10 +02:00
parent 4de6799403
commit cbc6aed437
5 changed files with 80 additions and 14 deletions

View File

@@ -4326,17 +4326,9 @@ class spell_item_amalgams_seventh_spine : public AuraScript
});
}
void ForcePeriodic(AuraEffect const* /*aurEff*/, bool& isPeriodic, int32& amplitude)
void UpdateSpecAura()
{
// simulate heartbeat timer
isPeriodic = true;
amplitude = 5000;
}
void UpdateSpecAura(AuraEffect const* aurEff)
{
PreventDefaultAction();
Player* target = GetTarget()->ToPlayer();
Player* target = GetUnitOwner()->ToPlayer();
if (!target)
return;
@@ -4345,7 +4337,7 @@ class spell_item_amalgams_seventh_spine : public AuraScript
if (target->GetPrimarySpecialization() != spec)
target->RemoveAurasDueToSpell(aura);
else if (!target->HasAura(aura))
target->CastSpell(target, aura, aurEff);
target->CastSpell(target, aura, GetEffect(EFFECT_0));
};
switch (target->GetClass())
@@ -4373,8 +4365,7 @@ class spell_item_amalgams_seventh_spine : public AuraScript
void Register() override
{
DoEffectCalcPeriodic += AuraEffectCalcPeriodicFn(spell_item_amalgams_seventh_spine::ForcePeriodic, EFFECT_0, SPELL_AURA_DUMMY);
OnEffectPeriodic += AuraEffectPeriodicFn(spell_item_amalgams_seventh_spine::UpdateSpecAura, EFFECT_0, SPELL_AURA_DUMMY);
OnHeartbeat += AuraHeartbeatFn(spell_item_amalgams_seventh_spine::UpdateSpecAura);
}
};