Jump to content

DOWNLOAD MODS

Are you looking for something shiny for your load order? We have many exclusive mods and resources you won't find anywhere else. Start your search now...

LEARN MODDING

Ready to try your hand at making your own mod creations? Visit the Enclave, the original ES/FO modding school, and learn the tricks of the trade from veteran modders...

JOIN THE ALLIANCE

Membership is free and registering unlocks image galleries, project hosting, live chat, unlimited downloads, & more...

[SKY] Problem with DropObject/AddItem and Ownership


Ghaunadaur
 Share

Recommended Posts

Hello all,

 

I encountered a strange problem today. This is the scenario:

 

I have an activator, when activated, an item is removed from the player inventory and transferred to an invisible container. Using this function:

 

PlayerRef.RemoveItem(ItemRef, 1, false, ContainerRef)

 

Activated for the second time, the item is dropped out of the container and added to the inventory again. This is the code to make this happen:

 

ObjectReference myRef = ContainerRef.DropObject(ItemRef)
PlayerRef.AddItem(myRef)

 

This works fine, but the problem is that the item now is marked as stolen :blink: and I have no idea why. The container is actually a duplicate of the PlayerBookshelfContainer. The ownership is set to 'None' so it should inherit the ownership of the cell, which is 'PlayerFaction'. I also tried

 

ContainerRef.RemoveItem(ItemRef, 1, false, PlayerRef)

 

This works correctly. The downside of this, there's no notification that the item is added to player again. I really would like to use the DropObject/AddItem method, so if someone has an idea why the ownership of the item gets messed up and how to prevent this, I'd be very thankful. :smile:

Link to comment
Share on other sites

If this works, but you want notification, you need to turn it on.

 

ContainerRef.RemoveItem(ItemRef, 1, true, PlayerRef)

 

Ownership comes from the item, the container or the cell. Use a clean save game and make sure ownership on the three items is default.

Link to comment
Share on other sites

Thanks for the reply. Normally the parameter abSilent needs to be set to 'false' to give a notification, but I don't think it matters in this case. RemoveItem will only show a notification if used on the player anyway. I would have to make a notification message for each item that I want to be removed from the container. That would be a bit tedious, so I will leave it without notification, maybe make a single message for all.

 

The main problem is with the DropObject function. Of course I'm testing with a clean save, without any mods activated. I also tested with different items, some found in game, some added via console command. The ownership of the container and the cell are as described above. It's always the same, when dropped out of the container, the items are flagged as stolen. Maybe DropObject is supposed to work this way, but I couldn't find any information about it. Or maybe it's just a bug?

Link to comment
Share on other sites

Ghan:  When you are using any of the scripts to pick up the items, does it change the ownership at that time? 

 

Sort of hard knowing if the invisible container is showing 'red' or 'white' in its inventory; however,

I am wondering if  the invisible container is somehow taking ownership.

Link to comment
Share on other sites

If nothing works, you should use Function SetActorOwner(ActorBase Game.GetPlayer().GetActorBase()) but it will also clear the stolen flag from items.... Well, unless you make an if condition to check it first.

Edited by bleakraven
  • Upvote 1
Link to comment
Share on other sites

There is nothing in the WIKI about DropObject giving ownership.

I suspect the cell has ownership, or the chest does. It has to acquire it from somewhere.

I was assuming this too. Since it's a cell from the vanilla game there may be several factors influencing the ownership. The cell has a default ownership of 'None' and it gets changed to 'PlayerFaction' by a script of the quest 'HousePurchase'. That's what I know, but there may be other things. To check this, I put a small debug script on the container to show me the ownership of container and cell in game.

faction contowner = self.GetFactionOwner()
faction cellowner = self.GetParentCell().GetFactionOwner()
debug.messagebox("CONT: "+contowner+ " - CELL: "+cellowner)

 Result:

tesv2013-06-0912.jpg

 

00000DB1 = PlayerFaction, so this seems to be correct. I also made a new cell to test in a non-vanilla environment, but it's the same. If I leave the cell's ownership to 'None', it works.

 

 

Ghan: When you are using any of the scripts to pick up the items, does it change the ownership at that time?

Sort of hard knowing if the invisible container is showing 'red' or 'white' in its inventory; however,

I am wondering if the invisible container is somehow taking ownership.

The ownership changes as soon as the item is dropped out of the container, not before and not after. So I'm quite sure it has something to do with that function.

 

 

If nothing works, you should use Function SetActorOwner(ActorBase Game.GetPlayer().GetActorBase()) but it will also clear the stolen flag from items.... Well, unless you make an if condition to check it first.

Yes, that would be a possible workaround, but as you stated, it will cause the opposite problem. Maybe I could use GetActorOwner() and GetFactionOwner() to check the ownership. Sadly, the CK Wiki says that GetActorOwner function is possibly broken and always returns 'None'. I'll need to test it. Thank you for the suggestion.

 

 

EDIT

This seems to be a known issue: http://forums.bethsoft.com/topic/1424878-problem-scripped-dropped-item-changes-ownership/ :confused:

Edited by Ghaunadaur
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...