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
+16 -1
View File
@@ -1986,6 +1986,18 @@ namespace Game.Spells
}
}
public void CallScriptOnHeartbeat()
{
foreach (var script in m_loadedScripts)
{
script._PrepareScriptCall(AuraScriptHookType.OnHeartbeat);
foreach (var onHeartbeat in script.OnHeartbeat)
onHeartbeat.Call(script);
script._FinishScriptCall();
}
}
public bool CallScriptEffectApplyHandlers(AuraEffect aurEff, AuraApplication aurApp, AuraEffectHandleModes mode)
{
bool preventDefault = false;
@@ -2865,12 +2877,15 @@ namespace Game.Spells
_staticApplications[target.GetGUID()] |= effMask;
}
void Heartbeat()
public override void Heartbeat()
{
base.Heartbeat();
// Periodic food and drink emote animation
HandlePeriodicFoodSpellVisualKit();
// Invoke the OnHeartbeat AuraScript hook
CallScriptOnHeartbeat();
}
void HandlePeriodicFoodSpellVisualKit()