greatgiginthesky Posted August 10, 2010 Share Posted August 10, 2010 Hello everyone,I'm brand new to scripting Oblivion, but I've got a good handle on scripting and programming in general. I need help finding a way to achieve the following effect: SetOwnership of all items in player inventory to 'Player'. That way, once you steal something and it's in your inventory, you can remove the red-hand icon and flag it as belonging to you for selling or keeping without fear of losing it when caught. The article Walking Through Items in Inventory uses the OBSE function GetInventoryObject, and seemed like the perfect thing. However, it states that "GetInventoryObject returns the base object FormID. It can't be used when a reference should be used." I need a reference to the object, not the base object, to call SetOwnership, correct? Does anyone have any ideas about alternative ways to SetOwnership of every item in the player's current inventory? I'm not familiar enough with the functions of the scripting language to know what this situation calls for. If it matters, I was attempting to create a Spell with this as a Script Effect. I'd certainly accept alternatives to this method also. Thank you for any help you can provide! :) Link to comment Share on other sites More sharing options...
Hickory Posted August 10, 2010 Share Posted August 10, 2010 An alternative would be to identify each item in the inventory, remove it and replace it -- inefficient, perhaps, but most scripts that I have seen, including vanilla quests, use this method. Link to comment Share on other sites More sharing options...
greatgiginthesky Posted August 10, 2010 Author Share Posted August 10, 2010 That certainly could work. A lot of times what's actually going on behind the scenes in games isn't at all what you expect, after all. How could I make it skip items created in-game, like player-made enchanted items, potions, etc? Could that crash the game if it tried to duplicate such an item using its FormID? Such a thing wouldn't have one, would it? I'll have to investigate this some more. Thanks for the idea! Further suggestions welcome. Link to comment Share on other sites More sharing options...
Hickory Posted August 11, 2010 Share Posted August 11, 2010 An item created in-game,summoned item/creature etc. will have an ID beginning FFxxxxxx -- you won't be able to replace them, except with a standard equivelent where possible, as the IDs are created on-the-fly. So yes, it's likely to be a ticket to a swift exit, or refusal to load, should you attempt it. Link to comment Share on other sites More sharing options...
greatgiginthesky Posted August 11, 2010 Author Share Posted August 11, 2010 I don't know enough yet to know whether I can set up a conditional to check for FormIDs not beginning with FF - would this be possible? I'd consider a mod broken if it could crash the game without dumping all player-made items before use. Could I do something like, upon casting a spell, a container dialog opens - Then add items to that container which you know have non-FF id's, and then setownership or replace by formID and give them back when you close the dialog? That still has a high chance for accidents but wouldn't be as annoying as dumping items. More food for thought, thank you for your help! Link to comment Share on other sites More sharing options...
Hickory Posted August 11, 2010 Share Posted August 11, 2010 It would be complicated, to say the least, and most likely very unweildy. I wouldn't advise going down that road. Is this project purely for removing the stolen item flag on items? If so, and you're not in the Thieves Guild, there are mods out there, even DLC that add fences to the game. Link to comment Share on other sites More sharing options...
greatgiginthesky Posted August 11, 2010 Author Share Posted August 11, 2010 It's just a realism issue, I guess, and yes, that's all the plugin would be for is adding a spell to SetOwnership on your inventory. I don't mind the unrealistic aspect of selling something back to the victim as much as the other side of the coin where everyone else knows it's stolen too. Plus I just find the red-hand icon unappealing and don't wanna use SetOwnership from the console. I'm not exactly devastated that I may not be able to execute the idea, but it was certainly worth a shot. Maybe I'll come back to it when I know more about the scripting system. Thanks for your time, and if anyone else reads and has anything to offer, please feel free. :) Link to comment Share on other sites More sharing options...
Ranokoa Posted August 11, 2010 Share Posted August 11, 2010 I read a bit of each post but not completely. Here's an idea. Create and place a chest, somewhere hidden and inaccessible. Then create two spells associated with that chest. RemoveAllItems to the chest for the first spell, the second spell would set the ownership, or clear the ownership, of every item in that chest, then after a .1 second delay (To let a frame or two go by) RemoveAllItems from the chest to the player. Clear Ownership: http://cs.elderscrolls.com/constwiki/index.php/ClearOwnershipGetBaseItems: http://cs.elderscrolls.com/constwiki/index.php/GetBaseItemsGetContainer: http://cs.elderscrolls.com/constwiki/index.php/GetContainerGetOwner: http://cs.elderscrolls.com/constwiki/index.php/GetOwnerGetItems:http://cs.elderscrolls.com/constwiki/index.php/GetItems A couple of pages which may help you in this process. You can also just make a quest that starts initially that is also hidden so whenever the player adds an item to his inventory it reads it, references it, clears the ownership, then clears the reference. There are a variety of ways to do what you want. Hell, you could even do a spell to only clear the ownership of the player's inventory. Be creative, with scripting there are almost always 10 ways or more, some complicated, some really complex, and others simple, to do the very same thing. A lot of times if you know what you're doing going the complex way can make it much more efficient and ensure it works properly under only certain circumstances and avoids clashes. Other times doing the same thing can just create a lot of problems. It's a swing-and-a-miss situation with a lot of scripting. Anyways, just try to think outside the box, and come up with various ways you can do the very same thing. Try em out, and eventually one will hit home exactly how you want. If this has helped you in any way feel free to Kudos me to show your appreciation, otherwise if you feel it not worth a Kudos then I implore you to still... Be well, sleep well, fight well, live long.~Ranokoa Link to comment Share on other sites More sharing options...
Argomirr Posted August 11, 2010 Share Posted August 11, 2010 The article Walking Through Items in Inventory uses the OBSE function GetInventoryObject, and seemed like the perfect thing. However, it states that "GetInventoryObject returns the base object FormID. It can't be used when a reference should be used."Inventory walking is outdated. You can use GetItems, which will return an array of all items (base objects, not refs) in an container/inventory. I need a reference to the object, not the base object, to call SetOwnership, correct?Indeed, but it's impossible in this context. Items in containers do not have references. You will have to use a workaround, like Hickory suggested. Link to comment Share on other sites More sharing options...
greatgiginthesky Posted August 11, 2010 Author Share Posted August 11, 2010 Thank you all for this very valuable information. I doubt I would have discovered it without a helping hand, considering how much I read without learning that it's dated, and container items have no references. Like so many things in scripting and programming, there are generally several ways to arrive at the same destination, and it's often not the straight line you imagined it would be. I will invest more time into learning these concepts before I trouble the kind users here again. Maybe I'll work on the transmute spell i want or something else more basic before proceeding with this. Thank you all for your help, kudos for everyone! Link to comment Share on other sites More sharing options...
Recommended Posts