Jump to content

Possible Engine Issue in SSE


Recommended Posts

While I'm sure you're not surprised by the topic title, I believe I've uncovered a strange bug in Skyrim SE (haven't checked old Skyrim because I don't care about it anymore) regarding scripted weapons. I need some help in testing/confirming the theory before I add to the CK WIki about it.

 

The issue

When adding a weapon with at least 1 script on it's base form to an unloaded NPC then checking if that NPC has equipped that weapon the game will crash.

 

How I reproduced this error (and you can try too)

  1. I have a script on a PlayerAlias which detects when you sell certain items to a vendor, it then passed them to another NPC's inventory and runs a script against that NPC to remove items that are relevant to displays in the Dragonborn Gallery.
  2. Grab a weapon with a script (examples include Jyrik's Staff from Saarthaal on Bloodscythe.
  3. Sell it to the vendor and allow the script to move it to the unloaded NPC.
  4. When the follow-up script checks if the NPC has it equipped, the game will CTD with no errors in the log.

 

My theories

 

I can see this being caused by one of a few possible things.

  • The "IsEquipped()" check is bugged when using it on (unloaded?) NPCs. It's possible it's cast the weapon as a type of the script rather than casting it as a weapon during this check (the theory is here, that when you write a weapon to the logs it will print it as [scriptname <formid>] rather than [WEAPON <formid>] so I assume the default cast is the type of script. Without converting it to the correct type the game doesn't know what to do with it and crashes.
  • Actors only decide which weapon they have equipped when loaded - regardless of the default state. If they get a new item while unloaded it doesn't know which item is equipped at all until the actor is loaded, so when querying the data it crashes.
  • The actor's AI package may be set to "Weapons Unequipped" which will cause a strange issue when checking equipped state (doesn't happen for non-scripted weapons).

 

More weirdness

 

When trying to test if this was related to an actor being unloaded, I quickly COC'd into the cell with the actor after starting the operation. This prevented the crash of the game. However, the item never leaves the actor's inventory and doing "inv" on them in the console crashes the game. This leads me to believe the "weapons unequipped" flag is the one at fault here. Perhaps that flag equips the actor with an invalid weapon to block any actual weapons from being added?

 

If anyone has any insight about this please do let me know. If I get something concrete I'll update the CK wiki.

Link to comment
Share on other sites

Have you considered moving the NPC to the player and placing them underneath in the ground? That way they'd be 3D loaded but not viewable by the player. Might have to move a bit of floor for them to stand on first so that they do not keep failing downward. When complete with your work, move them back to their normal location.

 

It does not verify the issue, but it may solve your issue.

Link to comment
Share on other sites

So I added the following debug code to the checks to run through each possible issue:

; TEST 
			if (Disp.IsDisabled())
				DBMDebug.Log(Self, "Display disabled "+Disp)
			endif
			if (akActionRef.GetItemCount(Item))
				DBMDebug.Log(Self, "Container "+akActionRef + " has "+ akActionRef.GetItemCount(Item) +" of item "+ Item.GetName()+Item)
			endif
			if (!oCont.GetItemCount(Item))
				DBMDebug.Log(Self, "Display container "+akActionRef + " has 0 of item "+ Item.GetName()+Item)
			endif
			if (!akActionRef as Actor || !(akActionRef as Actor).IsEquipped(Item))
				DBMDebug.Log(Self, akActionRef+"is not an actor OR does not have equipped item "+ Item.GetName()+Item)
			endif
			if (!DBM_ExcludeList.HasForm(Item))
				DBMDebug.Log(Self, "Exclude list does not contain "+ Item.GetName()+Item)
			endif
			if ((!useSKSE || !Game.IsObjectFavorited(Item)))
				DBMDebug.Log(Self, "SKSE is not loaded OR item not favourited "+ Item.GetName()+Item)
			endif
; TEST

Annoyingly with a container instead of an actor, all the checks pass as shown below:

[01/05/2020 - 11:51:48AM] [DBMDisplayAutoSorter < (062ACE1F)>] - Display disabled [dbm_dynamicdisplayscript < (062ACD3C)>]
[01/05/2020 - 11:51:48AM] [DBMDisplayAutoSorter < (062ACE1F)>] - Container [DBM_AutoSortDropOffScript < (09005905)>] has 1 of item Staff of Jyrik Gauldurson[Form < (000E5F43)>]
[01/05/2020 - 11:51:48AM] [DBMDisplayAutoSorter < (062ACE1F)>] - Display container [DBM_AutoSortDropOffScript < (09005905)>] has 0 of item Staff of Jyrik Gauldurson[Form < (000E5F43)>]
[01/05/2020 - 11:51:48AM] [DBMDisplayAutoSorter < (062ACE1F)>] - [DBM_AutoSortDropOffScript < (09005905)>]is not an actor OR does not have equipped item Staff of Jyrik Gauldurson[Form < (000E5F43)>]
[01/05/2020 - 11:51:48AM] [DBMDisplayAutoSorter < (062ACE1F)>] - Exclude list does not contain Staff of Jyrik Gauldurson[Form < (000E5F43)>]
[01/05/2020 - 11:51:48AM] [DBMDisplayAutoSorter < (062ACE1F)>] - SKSE is not loaded OR item not favourited Staff of Jyrik Gauldurson[Form < (000E5F43)>]

But it still crashes on the combined check:

if Disp.IsDisabled() && (akActionRef.GetItemCount(Item)) && !oCont.GetItemCount(Item) && (!akActionRef as Actor || !(akActionRef as Actor).IsEquipped(Item)) && !DBM_ExcludeList.HasForm(Item) && (!useSKSE || !Game.IsObjectFavorited(Item))
	akActionRef.RemoveItem(Item, 1, true, oCont)
	DBM_DisplayCount.Mod(1)
	Disp.Enable()
	DBMDebug.Log(Self, "Displayed item "+Item.GetName() + Item + " for " + Disp)
	Return 1
endif	
Link to comment
Share on other sites

Ok, so after further testing the crash seems to be on this line AFTER the checks pass:

(akActionRef as ObjectReference).RemoveItem(Item, 1, true, oCont)

I preceded it with a log statement and nothing looks out of place to me:

[01/05/2020 - 12:35:57PM] [DBMDisplayAutoSorter < (062ACE1F)>] - Trying to remove Staff of Jyrik Gauldurson[Form < (000E5F43)>] from container [DBM_AutoSortDropOffScript < (09005905)>] and place in [ObjectReference < (06126087)>]

I'm running out of ideas :/

 

Edit: Here's the same output message for a different item "Froki's bow" - this didn't crash. It has to have something to do with the script attached to the weapon....

[01/05/2020 - 12:52:52PM] [DBMDisplayAutoSorter < (062ACE1F)>] - Trying to remove Froki's Bow[Form < (000C0186)>] from [DBM_AutoSortDropOffScript < (09005905)>] and place in [ObjectReference < (06126087)>]
Edited by Pickysaurus
Link to comment
Share on other sites

What are the script(s) attached to the offending objects? There could be something within that code which could be causing the crash independent of whatever object you are using in order to obtain the forms to pass through your checks. Further, have you tested this scenario on original Skyrim? It may be possible that some of the additions to Papyrus in SSE have affected behavior in unforeseen ways such as this.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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