Jump to content

UnregisterForUpdate error in MagicEffect script


Amugaba

Recommended Posts

This forum's been a huge help so far, so let's try another question...Is it necessary to unregisterForUpdate when a magic effect finishes?

My mod is working fine, but when I look at the Papyrus log after it's been running, there is a repeating error:

[09/18/2015 - 10:34:41PM] Error: Unable to call UnregisterForUpdate - no native object bound to the script object, or object is of incorrect type
stack:
    [None].aboDamageScaleNPC.UnregisterForUpdate() - "<native>" Line ?
    [None].aboDamageScaleNPC.OnEffectFinish() - "aboDamageScaleNPC.psc" Line 36

This script is a MagicEffect script that looks basically like:

Scriptname aboDamageScaleNPC extends activemagiceffect 

Event OnEffectStart(Actor akTarget, Actor akCaster)
    STUFF
    RegisterForSingleUpdate(0.25)
EndEvent

Event OnUpdate()
    STUFF
    RegisterForSingleUpdate(1)
EndEvent

Event OnEffectFinish(Actor akTarget, Actor akCaster)
    STUFF
    if self != none
        UnregisterForUpdate()
    endif
EndEvent

I tried it with and without the self != none, but neither made a difference.

 

Should I just leave the unregister out? After the effect is finished, will the script not execute the next time single update is called?

 

Link to comment
Share on other sites

Single updates do not need to be unregistered. They fire once and do not repeat. This is why you have to call RegisterForSingleUpdate again inside the OnUpdate event itself in order to keep it going.

 

I would, however, consider some sort of sanity check to prevent the registration and/or OnUpdate event as a whole from parsing in the event that the effect is no longer active.

 

Example:

  Reveal hidden contents

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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