Is OnEffecFinish always played ?

Post » Wed Jun 20, 2012 3:36 pm

I want to create my own frost slow effect, through a script instead of the usual archetype.

So, let's say I put this on my script (the effect is set to dispel older effects with the MagicSlow keyword):

Event OnEffectStart(Actor Target, Actor Caster)
Target.damageAV("SpeedMult", 50)
EndEvent

Event OnEffectFinish(Actor Target, Actor Caster)
Target.restoreAV("SpeedMult", 50)
EndEvent

The thing is I don't know if I can really trust the end event. Very weird things happen inside the CK from my experience. I mean, I'm decreasing the target speed at start, so I have to be absolutely sure it will go back to normal when the effect fades, otherwise this can permanently cripple the player character.

So, my question is: Can I really trust the OnEffectFinish event will always play and set the target speed back to normal? Can the effect for some reason be removed without triggering this end event?
User avatar
Austin England
 
Posts: 3528
Joined: Thu Oct 11, 2007 7:16 pm

Post » Wed Jun 20, 2012 8:19 am

If you want to make very sure, Do a RegisterForUpdate(N) where N is 10 seconds or so longer than the duration, and also restore the character's speed to normal in the OnUpdate() event.

You could also add a restore command before the damage command in the OnEffectStart to make sure it never stacks.
User avatar
natalie mccormick
 
Posts: 3415
Joined: Fri Aug 18, 2006 8:36 am

Post » Wed Jun 20, 2012 10:20 am

Using register for update, where the update would occur after the effect ends, will never trigger the OnUpdate() event. OnEffectFinish has always fired for me, so I think it's reliable. Just don't do something like this:

Scriptname NoDurationMagicEffectScript extends ActiveMagicEffectEvent OnEffectStart(Actor akTarget, Actor akCaster)    Utility.Wait(5)    Debug.Notification("Displays 5 seconds after the OnEffectFinish message!")EndEventEvent OnEffectFinish(Actor akTarget, Actor akCaster)    Debug.Notification("Displays 5 seconds before the OnEffectStart message!")EndEvent
User avatar
kiss my weasel
 
Posts: 3221
Joined: Tue Feb 20, 2007 9:08 am

Post » Wed Jun 20, 2012 8:53 am

Using register for update, where the update would occur after the effect ends, will never trigger the OnUpdate() event. OnEffectFinish has always fired for me, so I think it's reliable.

Ok. And I set my effect to dispel other effects with the same keyword. So, in this case, when a dispel occurs the old effect automatically runs OnEffectFinish before start running the OnEffectStart of the new effect? I mean, can I trust the dispelled effect will be completely finished before the new effect start?
User avatar
mike
 
Posts: 3432
Joined: Fri Jul 27, 2007 6:51 pm

Post » Wed Jun 20, 2012 8:55 pm

in my experience with OnEffectStart/finish, it's always fired properly

but i would test it thoroughly and try to break it as much as possible while playing.


my personal policy is never trust anything in the CK, there are so many bugs. for example the OnEquip/unequip event is broken when using hotkey/favorites and never fires. who knows if there is a similar condition that could break the event firing for magic effects.
User avatar
Jade Barnes-Mackey
 
Posts: 3418
Joined: Thu Jul 13, 2006 7:29 am

Post » Wed Jun 20, 2012 7:39 pm

Every time I've used it, it works fine.
User avatar
BEl J
 
Posts: 3397
Joined: Tue Feb 13, 2007 8:12 am

Post » Wed Jun 20, 2012 6:30 pm

my personal policy is never trust anything in the CK

Yes, that's exactly my policy too. And that's why I'm asking more oppinions here in the forums. LOL

Anyway, I'll give it a try and trust the events. But as you guys suggest, I'll keep trying to break it every time I test my mod.

Thanks.
User avatar
Kat Stewart
 
Posts: 3355
Joined: Sun Feb 04, 2007 12:30 am

Post » Wed Jun 20, 2012 6:09 pm

If you want to make very sure, Do a RegisterForUpdate(N) where N is 10 seconds or so longer than the duration, and also restore the character's speed to normal in the OnUpdate() event.

You could also add a restore command before the damage command in the OnEffectStart to make sure it never stacks.

All event registrations are cleared from an active magic effect when it ends, so if your update would happen after the effect ends it will never get called (otherwise you have no way to unregister the events yourself, since the magic effect that was registered no longer exists). OnEffectFinish should always be sent, but if your effect duration is short and your effect start event is long then it might get sent before your effect start event finished running.
User avatar
Horror- Puppe
 
Posts: 3376
Joined: Fri Apr 13, 2007 11:09 am

Post » Wed Jun 20, 2012 11:23 am

All event registrations are cleared from an active magic effect when it ends, so if your update would happen after the effect ends it will never get called (otherwise you have no way to unregister the events yourself, since the magic effect that was registered no longer exists). OnEffectFinish should always be sent, but if your effect duration is short and your effect start event is long then it might get sent before your effect start event finished running.

OK, so if you wanted to make 100% sure, you could set a global boolean at the OnEffectStart() event like "OnEffectStartRunning" (Set to true at the start, and false at the end) and then have a little While OnEffectStartRunning Do-Nothing loop at the start of the OnEffectFinish event.
User avatar
Elizabeth Falvey
 
Posts: 3347
Joined: Fri Oct 26, 2007 1:37 am


Return to V - Skyrim