Jump to content

Best Practice For Scripts Attached To Magic Effects: Oneffectfinish Or Registerforsingleupdate ?


Recommended Posts

Poking around other people's mods I've noticed at least in one case the eschewment of using OnEffectFinish. Instead they declare some quest variables in the script to capture akTarget and akCaster coming into the EffectStart event, and then setup an RegisterForSingleUpdate and do their processing in OnUpdate() event handler. I've noticed some problems with timing getting my magic effects to properly call OnEffectFinish when I expect them do, so I wonder if using RegisterForSingleUpdate(...) is more reliable?

 

Thanks

Link to comment

On NPCs magic effects sometimes just vanish without a trace. They do stick while NPC is near Player (in same cell), but once they are not, Skyrim will drop all not-set-in-CK spells/abilities/magic stuff.

 

I use RegisterForSingleUpdate because it alows me to have variable duration. For SexlabUtil1 I use magic effects, because I know Skyrim will drop them at one point and I want that.
 

Avoid using magic effects for something that is very important or something that can break quest/game/character. Its OK for temporary, less important things. For things thats OK if they work or not.

 

 

Most realiable way to track things would be Quest Alias.

 

Link to comment

Hi Fotogen. Funny I was looking through your code last night and saw your commented out OnEffectFinish lines so I wondered. The only npcs that matter in my case are followers of the PC. If the player can tell the follower to wait here or go separate ways then the magic effects might still disappear then? I'm trying to improve an existing effect that can get cast on an NPC for degrading wear and tear. If the player were to dismiss the follower and that follower were to head back home I would want the degrade to continue. What's the best way to make this reliably happen?

Link to comment

Hi Fotogen. Funny I was looking through your code last night and saw your commented out OnEffectFinish lines so I wondered. The only npcs that matter in my case are followers of the PC. If the player can tell the follower to wait here or go separate ways then the magic effects might still disappear then? I'm trying to improve an existing effect that can get cast on an NPC for degrading wear and tear. If the player were to dismiss the follower and that follower were to head back home I would want the degrade to continue. What's the best way to make this reliably happen?

 

When NPC is not close to Player, magic effect may disapear. This can happen even if you just enter (or exit) a house or inn.

 

If you just need to track a small number or counter, you could use faction (rank) or give NPC a token (some item). You could also use StorageUtil functions. You'd also need an array (container) of NPCs. You would need some sort of OnUpdate event, someting to count down(or up) numbers.

 

Best way (but also most work) would be a separate, dedicated quest. Quest can be always active, can have script (and other things). NPC(s) would be quest aliases. And quest alias can also have script attached (and other things).

Link to comment

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use