Amugaba Posted September 19, 2015 Share Posted September 19, 2015 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 36This 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 EndEventI 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 More sharing options...
IsharaMeradin Posted September 19, 2015 Share Posted September 19, 2015 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 Scriptname aboDamageScaleNPC extends activemagiceffect Bool IsEffectActive = false Event OnEffectStart(Actor akTarget, Actor akCaster) IsEffectActive = true STUFF RegisterForSingleUpdate(0.25) EndEvent Event OnUpdate() If IsEffectActive == true STUFF RegisterForSingleUpdate(1) EndIf EndEvent Event OnEffectFinish(Actor akTarget, Actor akCaster) IsEffectActive = false STUFF EndEvent Link to comment Share on other sites More sharing options...
Recommended Posts