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:
@@ -1094,6 +1094,7 @@ namespace Game.Scripting
|
||||
// DO NOT OVERRIDE THESE IN SCRIPTS
|
||||
public delegate bool AuraCheckAreaTargetDelegate(Unit target);
|
||||
public delegate void AuraDispelDelegate(DispelInfo dispelInfo);
|
||||
public delegate void AuraHeartbeatDelegate();
|
||||
public delegate void AuraEffectDamageAndHealingCalcFnType(AuraEffect aurEff, Unit victim, ref int damageOrHealing, ref int flatMod, ref float pctMod);
|
||||
public delegate void AuraEffectApplicationModeDelegate(AuraEffect aura, AuraEffectHandleModes auraMode);
|
||||
public delegate void AuraEffectPeriodicDelegate(AuraEffect aura);
|
||||
@@ -1135,6 +1136,18 @@ namespace Game.Scripting
|
||||
}
|
||||
}
|
||||
|
||||
public class AuraHeartbeatHandler
|
||||
{
|
||||
AuraHeartbeatDelegate _callImpl;
|
||||
|
||||
public AuraHeartbeatHandler(AuraHeartbeatDelegate callImpl) { _callImpl = callImpl; }
|
||||
|
||||
public void Call(AuraScript auraScript)
|
||||
{
|
||||
_callImpl();
|
||||
}
|
||||
}
|
||||
|
||||
public class EffectBase : EffectHook
|
||||
{
|
||||
AuraType _effAurName;
|
||||
@@ -1264,7 +1277,7 @@ namespace Game.Scripting
|
||||
_callImpl(aurEff, victim, ref damageOrHealing, ref flatMod, ref pctMod);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class EffectApplyHandler : EffectBase
|
||||
{
|
||||
AuraEffectApplicationModeDelegate _callImpl;
|
||||
@@ -1601,6 +1614,11 @@ namespace Game.Scripting
|
||||
// where function is: void function (DispelInfo dispelInfo);
|
||||
public List<AuraDispelHandler> AfterDispel = new();
|
||||
|
||||
// executed on every heartbeat of a unit
|
||||
// example: OnHeartbeat += AuraHeartbeatFn(class::function);
|
||||
// where function is: void function ();
|
||||
public List<AuraHeartbeatHandler> OnHeartbeat = new();
|
||||
|
||||
// executed when aura effect is applied with specified mode to target
|
||||
// should be used when effect handler preventing/replacing is needed, do not use this hook for triggering spellcasts/removing auras etc - may be unsafe
|
||||
// example: OnEffectApply += AuraEffectApplyFn(class.function, EffectIndexSpecifier, EffectAuraNameSpecifier, AuraEffectHandleModes);
|
||||
|
||||
Reference in New Issue
Block a user