Strange none-values for variables

Post » Sat Nov 17, 2012 6:36 pm

So, I've been getting some strange errors in papyrus logs produced by my mod and I've tried all kinds of workarounds to get rid of them but can't figure it out. I've also seen many other mods producing similar kinds of errors by the way.

First of all, one of the errors I'm getting most often is the following:

[08/03/2012 - 11:58:54AM] error: Unable to call RegisterForAnimationEvent - no native object bound to the script object, or object is of incorrect typestack:    [None].DCAbEnemyMagEffLocDamScript.RegisterForAnimationEvent() - "" Line ?    [None].DCAbEnemyMagEffLocDamScript.OnEffectStart() - "DCAbEnemyMagEffLocDamScript.psc" Line ?

and also sometimes other kinds of errors related to null-pointers (variables holding ''None'' as a value)

Now, obviously, the error in the above example is caused by a RegisterForAnimationEvent call in my script's OnEffectStart() event. The script in question extends activeMagicEffect and is a script on a magic effect on a spell which I add to all actors around the world (this specific magic effect has a condition checking for the keyword ActorTypeNPC, so this specific script should only end up on humanoid NPCs). Now, this is the specific code of the OnEffectStart() event:

    If(self == None)        Dispel()        return    EndIf    If(akTarget == None)        Dispel()        return    EndIf    selfActor = akTarget    If(selfActor == None)        Dispel()        return    EndIf    RegisterForAnimationEvent(selfActor, "RemoveCharacterControllerFromWorld")    randomInts = new int[2]    randomInts[0] = Utility.RandomInt()    randomInts[1] = Utility.RandomInt()

Now, the first 3 If() - blocks are simply attempts to get rid of these errors. In the first condition I check if the magic effect exists, in the second if the target actors exists, and in the third if the target actor got set correctly to a selfActor variable which I use in various other events and functions throughout the script as well. These all have return statements, so obviously none of these values pointed at ''None'' when the errors in papyrus logs were produced since the RegisterForAnimationEvent() call causing errors follows after these conditional blocks and therefore the return statements cannot have executed.

So, immediately after I have checked and made sure that none of those variables are None, I call RegisterForAnimationEvent() and that specific call prints errors in my logs about None-variables. Does anyone have any idea at all what could be happening here?
User avatar
Laura-Lee Gerwing
 
Posts: 3363
Joined: Fri Jan 12, 2007 12:46 am

Post » Sat Nov 17, 2012 4:06 pm

I have run into similar problems with a script propagating spell. The problem was caused when I saved a game where some actors had the script attached; upon reloading with an updated mod, things wouldn't work as expected. Loading a clean save would get things working again (the new scripts would get applied to the actors). I am too ignorant of what exactly gets included in the save file in regards to scripts and stacks so I can't pinpoint the exact problem.
User avatar
Kelly James
 
Posts: 3266
Joined: Wed Oct 04, 2006 7:33 pm

Post » Sun Nov 18, 2012 1:33 am

well that's not the case here.. I started an entirely new fresh game and this is what happened. Also, the errors in the log obviously say they come from the OnEffectStart() event, which only runs when the spell is added anyway and not later on when a saved game is loaded.

Also, it should be noted that the scripts generally do work fine. I only get some of these errors and on most actors they work fine, but I can not find any pattern indicating what kind of NPCs would cause issues and why some of them produce these errors.
User avatar
Alyesha Neufeld
 
Posts: 3421
Joined: Fri Jan 19, 2007 10:45 am

Post » Sat Nov 17, 2012 4:36 pm

The wiki has an explanation of http://www.creationkit.com/Papyrus_Runtime_Errors#.22Unable_to_call_X_-_no_native_object_bound_to_the_script_object.2C_or_object_is_of_incorrect_type.22 :)

What is most likely happening in your case is your magic effect has been deleted by the game out from under Papyrus, so when you try to call a native function (which requires a valid in-game object) the error is thrown.

You'll want to make sure your magic effect is lasting long enough for your script to run and isn't getting removed or dispelled.
User avatar
ImmaTakeYour
 
Posts: 3383
Joined: Mon Sep 03, 2007 12:45 pm

Post » Sun Nov 18, 2012 2:05 am

The wiki has an explanation of http://www.creationkit.com/Papyrus_Runtime_Errors#.22Unable_to_call_X_-_no_native_object_bound_to_the_script_object.2C_or_object_is_of_incorrect_type.22 :smile:

What is most likely happening in your case is your magic effect has been deleted by the game out from under Papyrus, so when you try to call a native function (which requires a valid in-game object) the error is thrown.

You'll want to make sure your magic effect is lasting long enough for your script to run and isn't getting removed or dispelled.

Hmm ok... so it's probably either NPCs dying or getting disabled (not sure if disabling removes magic effects?) while that event is running then. The spell I'm adding is a constant effect ability, so there's no duration which can run out. Guess there's no way to get rid of those errors then.

Got another question then which you may be able to answer related to this issue: I took a look at the OP of this thread: http://www.gamesas.com/topic/1370110-impact-of-system-stress-scripting-errors-on-game-performance/

and I read the following (obviously not 100% confirmed, but I believe it is tested or at least based on something and not just random speculation)

Seemingly benign, these errors are potentially LETHAL to the Skyrim experience, sometimes even causing CTD or corrupting saveGame data.

and this error I'm seeing is also one of the examples. Could this be true? The reason I ask is that users of my mod have been experiencing CTDs confirmed to be related to this specific mod (disabling this mod allowed them to play for hours in a row without CTD), but the CTDs always occur entirely randomly and are not reproducable (doing the exact same thing/going to the exact same place after reloading the last saved game did not result in a CTD again), and I am suspecting these errors may be the cause (obviously not every time such an error shows up it causes a CTD, but maybe large amounts of them do?)
User avatar
Jessica Phoenix
 
Posts: 3420
Joined: Sat Jun 24, 2006 8:49 am


Return to V - Skyrim