Unable to call GetReference

Post » Wed Sep 28, 2016 8:41 pm

Unable to call GetReference - no native object bound to the script object, or object is of incorrect type

Does anyone have *any* idea what exactly fires the above error? The script runs in a quest alias and works flawlessly but for some unknown reason the GetReference function periodically fails to run and logs are spammed with the above error. Been banging my head on the wall for hours and still not a clue.
User avatar
NO suckers In Here
 
Posts: 3449
Joined: Thu Jul 13, 2006 2:05 am

Post » Wed Sep 28, 2016 8:10 pm

Could you post the script?


Are you calling get reference on "self" or a reference alias property?

User avatar
Guy Pearce
 
Posts: 3499
Joined: Sun May 20, 2007 3:08 pm

Post » Wed Sep 28, 2016 3:10 pm

Dang, wrong forum, I meant to post this in the CK section. Anyway, here:




Spoiler


; Attached to TEST_LockBashingQuest
Scriptname TEST_LockBashing extends ReferenceAlias
Message Property TEST_ImpossibleLockBashingMSG auto

Message Property TEST_LockBashedOpenMSG auto

Message Property TEST_TooDifficultLockBashingMSG auto

Message Property TEST_LockBashingTwoHandedMSG auto

Message Property TEST_TooDifficultLockMSG auto

Message Property TEST_LockBashingMeleeRequiredMSG auto

Message Property TEST_LockBashingNoDagger auto

Message Property TEST_LockBashingNoMace auto

Message Property TEST_LockBashingNoSword auto

Message Property TEST_LockBashingNoWarAxe auto

MiscObject Property Lockpick auto

Actor Property PlayerREF Auto

ObjectReference TEST_Lock

Quest Property TEST_LockBashingAlertQuest Auto

Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)
TEST_Lock = self.GetReference()
if ( akAggressor == PlayerREF)

if ( akSource as Weapon )

if TEST_Lock.IsLocked()

if ( PlayerREF.GetEquippedWeapon() != NONE )

Weapon BashingWeapon = akSource as weapon

if ( BashingWeapon.IsBattleaxe() || BashingWeapon.IsWarhammer() || BashingWeapon.IsGreatsword() )

if ( TEST_Lock.GetLockLevel() > 75 )

TEST_ImpossibleLockBashingMSG.Show()

else

if ( TEST_Lock.GetLockLevel() < 2 && PlayerREF.GetActorValue("TwoHanded") >= 25 ) || ( TEST_Lock.GetLockLevel() < 26 && PlayerREF.GetActorValue("TwoHanded") >= 50 ) || ( TEST_Lock.GetLockLevel() < 51 && PlayerREF.GetActorValue("TwoHanded") >= 75 ) || ( TEST_Lock.GetLockLevel() < 76 && PlayerREF.GetActorValue("TwoHanded") >= 100 )

TEST_Lock.Lock(false)

TEST_LockBashedOpenMSG.Show()

TEST_LockBashingAlertQuest.Start()

else

TEST_TooDifficultLockBashingMSG.Show()

endif

endif

elseif ( BashingWeapon.IsWaraxe() || BashingWeapon.IsMace() || BashingWeapon.IsSword() )

if ( TEST_Lock.GetLockLevel() > 75 )

TEST_ImpossibleLockBashingMSG.Show()

elseif ( TEST_Lock.GetLockLevel() > 50 )

TEST_LockBashingTwoHandedMSG.Show()

else

if ( TEST_Lock.GetLockLevel() < 2 && PlayerREF.GetActorValue("OneHanded") >= 50 ) || ( TEST_Lock.GetLockLevel() < 26 && PlayerREF.GetActorValue("OneHanded") >= 75 ) || ( TEST_Lock.GetLockLevel() < 51 && PlayerREF.GetActorValue("OneHanded") >= 100 )

TEST_Lock.Lock(false)

TEST_LockBashedOpenMSG.Show()

TEST_LockBashingAlertQuest.Start()

else

if ( BashingWeapon.IsWaraxe() )

TEST_LockBashingNoWarAxe.Show()

elseif ( BashingWeapon.IsMace() )

TEST_LockBashingNoMace.Show()

elseif ( BashingWeapon.IsSword() )

TEST_LockBashingNoSword.Show()

endif

endif

endif

elseif ( BashingWeapon.IsDagger() )

if ( TEST_Lock.GetLockLevel() > 75 )

TEST_ImpossibleLockBashingMSG.Show()

elseif ( TEST_Lock.GetLockLevel() > 25 )

TEST_LockBashingTwoHandedMSG.Show()

else

if ( TEST_Lock.GetLockLevel() < 2 && PlayerREF.GetActorValue("OneHanded") >= 75 ) || ( TEST_Lock.GetLockLevel() < 26 && PlayerREF.GetActorValue("OneHanded") >= 100 )

TEST_Lock.Lock(false)

TEST_LockBashedOpenMSG.Show()

TEST_LockBashingAlertQuest.Start()

else

TEST_LockBashingNoDagger.Show()

endif

endif

else

TEST_LockBashingMeleeRequiredMSG.Show()

endif

endif

endif

endif



endif
EndEvent

Event OnActivate(ObjectReference akActionRef)
TEST_Lock = self.GetReference()



if akActionRef == PlayerREF

if TEST_Lock.IsLocked()

if ( ( TEST_Lock.GetLockLevel() >= 2 && PlayerREF.GetActorValue("Lockpicking") < 25 ) || ( TEST_Lock.GetLockLevel() >= 26 && PlayerREF.GetActorValue("Lockpicking") < 50 ) || ( TEST_Lock.GetLockLevel() >= 51 && PlayerREF.GetActorValue("Lockpicking") < 75 ) || ( TEST_Lock.GetLockLevel() >= 76 && PlayerREF.GetActorValue("Lockpicking") < 100 ) ) && ( TEST_Lock.GetLockLevel() <= 100)

if ( PlayerREF.GetItemCount(Lockpick) > 0 )

TEST_TooDifficultLockMSG.Show()

endif

endif

endif

endif



EndEvent




This is attached to a quest with the Fill Type set to Find Matching Reference / In Loaded Area / Closest with the IsLocked condition. The quest runs and stops every 2 seconds when OnUpdate is triggered in a script attached to another quest that acts as a scheduler.

User avatar
Jason Wolf
 
Posts: 3390
Joined: Sun Jun 17, 2007 7:30 am

Post » Thu Sep 29, 2016 1:58 am

Troubling, for the script to even run at all means the alias has filled successfully.


Do you get different results if you define your "self" alias as a property and refer to it as such?

User avatar
Lyndsey Bird
 
Posts: 3539
Joined: Sun Oct 22, 2006 2:57 am

Post » Wed Sep 28, 2016 7:41 pm

The wiki details http://www.creationkit.com/index.php?title=Papyrus_Runtime_Errors#.22Unable_to_call_X_-_no_native_object_bound_to_the_script_object.2C_or_object_is_of_incorrect_type.22. If, in your case, it's happening with an alias than either the alias no longer exists, or your variable type does not match the alias type.

Whether the alias is filled or not has no bearing on the error.
User avatar
Dragonz Dancer
 
Posts: 3441
Joined: Sat Jun 24, 2006 11:01 am

Post » Wed Sep 28, 2016 1:32 pm

Ha. Found it. It turned out that logs were spammed only when loading a save. No log spamming upon starting a new game. This rang me a *huge* bell.

The previous version of this script [same script name] was directly attached to objects, thus it extended ObjectReference, not ReferenceAlias as in the new version.
I have since then removed the script from those objects, but apparently it's not enough to prevent GetReference to still run on them, and it can't because they are of the wrong type.

Basically I have confused the heck out of Papyrus.

So it has been just a matter of renaming the script. Problem solved.
User avatar
Eve Booker
 
Posts: 3300
Joined: Thu Jul 20, 2006 7:53 pm

Post » Wed Sep 28, 2016 7:23 pm


See above, as usual it was a problem between the chair and the keyboard.

And, if I may.. any chances for AddPerk() to work for NPCs as well in the Special Edition? :)
User avatar
Nathan Hunter
 
Posts: 3464
Joined: Sun Apr 29, 2007 9:58 am


Return to V - Skyrim