NNS10 Posted April 28, 2016 Posted April 28, 2016 I'm trying to use the SKSE GetMagnitude() function to grab the magnitude of a potion that is passed into the magic effect. However, the debug trace shows GetMagnitude() is returning 0 (should be 10). Any idea why this is happening? Here is context: Scriptname myScript extends activemagiceffect Event OnEffectStart(Actor akTarget, Actor akCaster) Debug.Trace("Magnitude = " + self.GetMagnitude()) EndEvent I saw someone else with the same issue in this thread, but no answer: http://forums.nexusmods.com/index.php?/topic/3097564-getting-skses-getmagnitude-function-to-work/
darkconsole Posted April 28, 2016 Posted April 28, 2016 i wonder if it could be a race condition. it is very common to have race conditions with OnEffectFinish (the event firing way after the effect has been deleted from memory) so it wouldn't put it past the game to do something dumb like send it before the effect is fully applied. this would test that theory. Scriptname myScript extends activemagiceffect Event OnEffectStart(Actor akTarget, Actor akCaster) self.RegisterForSingleUpdate(1) EndEvent Event OnUpdate() Debug.Trace("Magnitude = " + self.GetMagnitude()) EndEvent
NNS10 Posted April 28, 2016 Author Posted April 28, 2016 i wonder if it could be a race condition. it is very common to have race conditions with OnEffectFinish (the event firing way after the effect has been deleted from memory) so it wouldn't put it past the game to do something dumb like send it before the effect is fully applied. this would test that theory. Scriptname myScript extends activemagiceffect Event OnEffectStart(Actor akTarget, Actor akCaster) self.RegisterForSingleUpdate(1) EndEvent Event OnUpdate() Debug.Trace("Magnitude = " + self.GetMagnitude()) EndEvent Got this error: Error: Unable to call RegisterForSingleUpdate - no native object bound to the script object, or object is of incorrect type stack: [None].nns_IncreaseMaxHealth.RegisterForSingleUpdate() - "<native>" Line ? [None].nns_IncreaseMaxHealth.OnEffectStart() - "nns_IncreaseMaxHealth.psc" Line 10 Does that confirm the race condition? The magic effect has the "No Duration" flag set. If it's a race condition issue, would turning that off and giving the effect item a duration of 1 second fix the issue? Update: Guess it was a race condition... I changed a bunch of things at once though (in the interest of saving time) which fixed it, so now I have to go back and figure out which it was critical to fixing the issue. Update 2: Looks like the critical change was giving the effect item a non-zero duration. Thanks darkconsole! With the barebone CK documentation, I never would've realized a race condition was going on under the hood.
NNS10 Posted April 28, 2016 Author Posted April 28, 2016 Double-posting to mark this as a solution w/o all the other testing content. This was a race condition as darkconsole suggested. This was addressed by giving the effect item a non-zero duration.
darkconsole Posted April 28, 2016 Posted April 28, 2016 The magic effect has the "No Duration" flag set. indeed. that means the effect was destroyed even before the start event could fire.
NNS10 Posted April 28, 2016 Author Posted April 28, 2016 The magic effect has the "No Duration" flag set. indeed. that means the effect was destroyed even before the start event could fire. It's actually interesting you were the one to respond to this. I'm making a small mod that complements Soul Gem Oven.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.