Jump to content

Dispelling a spell from an Actor that has been unloaded.


TheDriedFinger

Recommended Posts

One of my mods involves adding a spell to all nearby Actors to the player character. However, I'm seeing a bunch of errors in my Papyrus log about being unable to run functions in the script in the spell on None objects. I'm assuming that the issue is that these Actors are being unloaded and then the script is still trying to run functions on them, resulting in the error. Is there a way that I can prevent this? I've tried (rather stupidly) to just run "Dispel()" under Event OnUnload(). Of course, because they're unloaded, Dispel() would be run on a None object, which doesn't work.

 

Thanks for any help you can give me.

Link to comment

Not an expert but, AFAIK, active effects on unloaded actors just dissipate. If there is an update event registered and pending on an attached script this can cause errors when the script tries to do something with the unloaded actor.

 

First thing to do is to never use RegisterForUpdate. Instead chain repeated calls to RegisterForSingleUpdate. Use a condition in the OnUpdate event to make sure the required references are returning usable data and then perform the necessary functions. if everything is good and all conditions are met you can register for the next single update. Otherwise the script can be allowed to detach and get cleaned up.

 

I'm sure more knowledgeable folks can correct me on any of this.

 

Does the effect really need to last long enough for unloading to become an issue? Is there an opportunity to apply the spell, do the deed and immediately dispel?

Link to comment

If that's true then I've essentially been trying to fix something that's not even an issue. LOL The script is for my poise mod so it has to be applied to an actor pretty much all the time. Based on what you've said I think I can just revert to previous versions of my script, with some modifications. Thanks!

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...