Jump to content

Laundering Stolen Items Script


Recommended Posts

Hey everyone.

 

I'm looking for a way to make a script that will remove the "Stolen" flag from any items that I add to a chest.

 

So far experimented with trying to change ownership of items added to the chest, that doesn't seem to do anything though -- at least, not how I implemented it. For example, something like this:

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)

	akItemReference.SetActorOwner(Game.GetPlayer().GetActorBase())

endEvent

Any ideas how this might be done?

 

Link to comment
Share on other sites

Maybe something like

 

Event OnItemAdded(Form akBaseItem, int aiItemCount, objectReference akItemReference, objectReference akSourceContainer)

If akSourceContainer==PlayerRef

self.RemoveItem(akItemReference)

self.AddItem(akBaseItem)

EndIf

EndEvent

 

I have no idea if this would work but the idea is to remove the stolen item reference and add a base item of the same type, that doesn't have the stolen flag..

Link to comment
Share on other sites

Instead of using akItemReference, use the akBaseItem. Why? Only persistent objects will have a valid value for akItemReference. But every item has a base form. Thus every item passing into the container can be grabbed with the akBaseItem parameter.

 

(akBaseItem as ObjectReference).SetActorOwner(NONE)

 

I would avoid removing an item and adding a new instance on the chance that there might be quest items involved. If a quest item gets removed by script and doesn't get put into a container, it will be lost forever and potentially break the quest that relies on it.

Link to comment
Share on other sites

Appreciate the responses here guys.

 

Sadly the second method does not seem to work for whatever reason. I see the risk being brought up, but I can't seem to get that approach to work.

 

The first method kinda works, with one big issue - it won't remove the stolen item for some reason. So if I place a stolen soul gem for example in the chest, then open it again, I see the stolen one still there and also a second non-stolen one.

 

This MIGHT be why? Notes in the CreationKit.com wiki: "The function does not work on object references that have only existed inside containers, for example an item the player has crafted. Even if you use the Self reference."

 

Still trying to find a workaround here.

Link to comment
Share on other sites

OK, here is what worked -- with the caveat that any quest items allowed to be removed from inventory would have the problem that Ishara mentioned above. I added a "temp" chest out of view for use below.

ObjectReference Property TempChest auto

Event OnClose(ObjectReference akActionRef)

 	 if (akActionRef == Game.GetPlayer())
		Int iFormIndex = self.GetNumItems()
		While iFormIndex > 0
			iFormIndex -= 1
			Form ItemToTest = self.GetNthForm(iFormIndex)
			Int MyRefCount = self.GetItemCount(ItemToTest)
			TempChest.AddItem(ItemToTest,MyRefCount)
		EndWhile
 	else
		;Do Nothing
 	 endIf
	self.RemoveAllItems()
	TempChest.RemoveAllItems(MyChest)
endEvent

If anyone knows any way to check items to see if they are quest items, then I can add that simple check before removing them. Sadly I can't find a way to do that so far.

Edited by bluemarvin
Link to comment
Share on other sites

  • Recently Browsing   0 members

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