bluemarvin Posted April 2, 2023 Share Posted April 2, 2023 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 More sharing options...
greyday01 Posted April 2, 2023 Share Posted April 2, 2023 Maybe something like Event OnItemAdded(Form akBaseItem, int aiItemCount, objectReference akItemReference, objectReference akSourceContainer) If akSourceContainer==PlayerRef self.RemoveItem(akItemReference) self.AddItem(akBaseItem) EndIfEndEvent 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 More sharing options...
IsharaMeradin Posted April 2, 2023 Share Posted April 2, 2023 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 More sharing options...
bluemarvin Posted April 2, 2023 Author Share Posted April 2, 2023 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 More sharing options...
bluemarvin Posted April 2, 2023 Author Share Posted April 2, 2023 Hmm, that note wasn't the issue. Tried dropping the stolen soul gem into the environment, picking it back up THEN adding it, same results. Link to comment Share on other sites More sharing options...
bluemarvin Posted April 2, 2023 Author Share Posted April 2, 2023 (edited) 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 April 3, 2023 by bluemarvin Link to comment Share on other sites More sharing options...
Recommended Posts