Jump to content

Recommended Posts

Posted (edited)

A player has found a bug in my Breezehome Store mod where persistent references, such as quest items, will not get sold by the Store script.

 

Right now, the script drops items out of the container before running some SKSE functions on them to determine their value. In this case, persistent references will pile up outside the chest.

 

I've figured out a way to run the Store script without dropping items from the container, which solves the problem of persistent references piling up, but it creates a new problem where important quest items can get permanently deleted from the game. This could irreversibly break important quests or prevent achievements from unlocking.

 

I'm using GetNthForm() to pick out items in the container. I need help figuring out some sort of equivalent to a non-existent IsPersistent() function. Is there any function I can run on a form that will work on persistent references but not on non-persistent objects? Or will work on non-persistent but won't work on persistent?

 

Here's the relevant excerpt from my script:

int Function GetPrice(form item, int iCount)
;..... a bunch of unrelated code

	;This line will leave a pile of persistent references by the container!
	;This is annoying!!!!
	;I need some kind of isPersistent() function
	;For example:
	;If (item.IsPersistent())
	;RemoveItem(item, iCount, true, PlayerRef)
	;else
	ObjectReference oItem = pppBHStoreChestRef.dropObject(item,1)
	oItem.Disable()
	oItem.Delete()
	oItem = NONE

;..... more unrelated code
endFunction
int Function GetPrice(form item, int iCount)
;..... lots of unrelated code

	;This line will permanently remove quest items from the game.
	;This is bad!!!! I need some kind of IsPersistent() function.
	;For example:
	;If (item.IsPersistent())
	;RemoveItem(item, iCount, true, PlayerRef)
	;else
	pppBHStoreChestRef.RemoveItem(item,iCount)

;..... some other unrelated code
endFunction
Edited by pufthemajicdragon
Posted

Only crude way I can suggest would be use OnItemAdded() event on your shop container script and when items are being added check the akItemReference parameter for a reference.

If akItemReference is any value other then None then you can consider the added item to be persistent.

Posted

Well nobody else has made any other suggestions.

I'm hesitant about OnItemAdded() since it could queue up a few hundred or more calls and I don't know what the engine's limit is before it starts dumping. However, I might be able to get it to work with OnItemRemoved(), which would only be called a handful of times for each "sale" in the script. Thanks :smile:

  • Recently Browsing   0 members

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