RegisterForAnimationEvent Unregistering on ActiveMagiceffect

Post » Tue Feb 16, 2016 5:20 am

Solved. This will automatically unregister on the death of the actor when the Magic Effect dispels.



It is amazing what you forget after 6 months.



Scriptname CInvisibility extends ActiveMagicEffect

SPELL Property Invisibility Auto

Event OnEffectStart(Actor akTarget, Actor akCaster)
RegisterForAnimationEvent(GetTargetActor(), "weaponSwing")
RegisterForAnimationEvent(GetTargetActor(), "arrowRelease")
RegisterForAnimationEvent(GetTargetActor(), "weaponDraw")
RegisterForAnimationEvent(GetTargetActor(), "MRh_SpellFire_Event")
RegisterForAnimationEvent(GetTargetActor(), "MLh_SpellFire_Event")

endEvent


Event OnAnimationEvent(ObjectReference akSource, string asEventName)
if (akSource == GetTargetActor())
If (asEventName == "weaponSwing") || (asEventName == "arrowRelease") || (asEventName == "weaponDraw") || (asEventName == "MLh_SpellFire_Event") || (asEventName == "MRh_SpellFire_Event")
Utility.Wait(0.3)
Invisibility.Cast(GetTargetActor(),GetTargetActor())
EndIf
EndIf
endEvent
User avatar
electro_fantics
 
Posts: 3448
Joined: Fri Mar 30, 2007 11:50 pm

Post » Tue Feb 16, 2016 8:55 am

No Death Dispel: If checked, the effect persists even if the target dies.



That suggests if it's checked, constant effect abilities with scripts keep on trucking long after death. I'm not sure how to test that though. Magic effects are so tricky :/. You could unregister it through OnDying(it's faster than OnDeath) to be on the safe side.

User avatar
FoReVeR_Me_N
 
Posts: 3556
Joined: Wed Sep 05, 2007 8:25 pm


Return to V - Skyrim