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...

Owned items mingled in one container


syscrusher
 Share

Recommended Posts

In a mod I am developing, one stage of the quest has the PC recovering property that belongs to several NPCs, from an intermingled container. I plan to have a message box when the PC activates the container which asks if they want to return the items to the NPCs. If the PC says no, then the container thereafter behaves normally, and the items within are available for looting as usual. If the player says yes, however, I need to distribute the items to the NPCs that I have previously defined as the owners.

I'm an experienced programmer in other languages (Java, PHP, SQL, etc.), but relatively new to TES scripting. So I'm not asking for detailed syntax advice here, just a guideline on what general *approach* to take with "tagging" the items in the common container.

My initial thinking is that the items need to exist outside the container at stage 1 of my quest, because I don't *think* you can set ownership on an item added directly to the container in the CS, right? So I'll put them all on a table or something and then have a script move them into the container (once) at the first step of the quest, and set their ownership just before doing so. I assume I can set owner on a reference, without having to make a custom object, right? I would hate for every instance of "torch" and "iron dagger" to have to be a custom object.

Is there a better way to do this? Will what I propose even work?

Thanks!

Link to comment
Share on other sites

If you know what each NPC owns, then there is no need to look at 'ownership' or anything else.

The CS WIKI is a good place to look for functions and syntax on them. It will give you a good idea of what you can do.

If you know what each NPC gets, you simply RemoveAllItems from the chest and AddItem the known items to each NPC.

If you script an OnActivate block of code on the chest, you will 'override' the normal chest open inventory action. So, until the player says then want to keep it all, you would then and only then code the Activate function which would then allow the player to open the chest normally.

Link to comment
Share on other sites

If you know what each NPC owns, then there is no need to look at 'ownership' or anything else.

The CS WIKI is a good place to look for functions and syntax on them. It will give you a good idea of what you can do.

Did that. :-) The issue isn't function syntax, but rather what general approach is best. Adding the known items is a brute-force method that I can use if I must, but there will be multiple NPCs' belongings represented, so it will become very tedious to hand-code the list into my script. Also, AddItem doesn't really move the existing item, but rather adds new references to an object ID, which is not what I want.

I really need a scripted way to iterate over the contents of a container. I found an OBSE tutorial at http://cs.elderscrolls.com/constwiki/index.php/Walking_through_Items_in_an_Inventory that seems to give me the basics of what I need. The goal is to do this programmatically, rather than by an explicit item list, so that I can adjust the NPCs' inventory in character creation without having to remember to update a quest script item-by-item.

I don't see any decent way to iterate a container that doesn't require OBSE, but my mod already has that as a dependency elsewhere, so might as well use it here, too.

If you script an OnActivate block of code on the chest, you will 'override' the normal chest open inventory action. So, until the player says then want to keep it all, you would then and only then code the Activate function which would then allow the player to open the chest normally.

That sounds workable, and I believe some of the COBL activators do things like this. I'll go hunting for an example script.

Thanks!

Link to comment
Share on other sites

begin OnActivate
if myChestGBL == 0
messagebox "You cannot open this chest"
else
messagebox "Take a look at this stuff"
activate
endif
end[/code]

You could also have one chest for each NPC, and place that stuff in each chest. Then you could 'removeallitems' the contents of that chest to the NPC that it belongs to. That way you don't have to move each item individually.

Link to comment
Share on other sites

begin OnActivate

   if myChestGBL == 0

      messagebox "You cannot open this chest"

   else

      messagebox "Take a look at this stuff"

      activate

   endif

end

You could also have one chest for each NPC, and place that stuff in each chest. Then you could 'removeallitems' the contents of that chest to the NPC that it belongs to. That way you don't have to move each item individually.

That's an interesting idea. It would be more persistent objects, but OTOH the scripting would be really simplified. I'll consider this as one of the alternatives; thanks.

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...