I am new to sjyrim scripting. I am trying to add a cooldown for a passive ability that is always active on the player. I have come to understand that OnUpdate is something to be avoided to reduce the load. I saw something about using RegisterForSingleUpdate to create an update chain but I dont fully understand how that works.
Here's what I have so far utilising OnUpdate (note: this doesnt work either)
Scriptname DamageGate extends ActiveMagicEffect Spell Property HealSpell Auto float timer = 1float Property PercentHealth = 100.0 Auto Function SomeFunction() RegisterForUpdate(5.0)EndFunctionEvent OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked ) PercentHealth = GetTargetActor().GetAVPercentage("Health") If timer = 1 If PercentHealth < 0.8 HealSpell.Cast(GetTargetActor()) ;Utility.Wait(15.0) ;RegisterForUpdate(5.0) timer = 0 EndIf EndIfendEvent Event OnUpdate() ; This event occurs every five seconds timer = 1 ;UnregisterForUpdate()EndEvent
I'm pretty sure I'm missing a few basics, but I can't seem to figure it out.