Jump to content

Adding items to existing vendors in a clean way


Merilia

Recommended Posts

So far all of my mods have added items to vendors by simply adding the items to the vendor's chest. Of course, that is not the best way to do it, because if you have 2 mods changing the same vendor chest, they will conflict. Once the CK is released, my plan is to create new vendor chests with just my items. Here's my question where I feel like a total newbie... doing this will make the whole cell dirty, right? Won't that also conflict if somebody else also adds their own chest? Or is the game perfectly ok with loading whatever additional items any mods add (so like, my mod and another mod both add new vendor chests, both of them will get loaded)?

 

Also if there are any other best practices considerations when changing vendor inventories, I would love to know them. I am also curious if there is a preferred way to change leveled lists etc.

Link to comment
Share on other sites

Does that mean that creating new containers is just as bad as adding items to the existing containers?

 

No adding new chests is the way to go -- By adding a new chest there will not be any conflict with other mods since the chest will be specific to your mod and no other mod will touch it and the game is fine with having more than one chest owned by an NPC in the same cell.

 

By uisng the existing vendor chest your mod will conflict with any other mod that also edits that same chest and only the mod that loads last will have its changes show up in game -- so you want to avoid doing that.

Link to comment
Share on other sites

Ok, that's what I thought. So just to be really pedantic and make sure, if Mod A adds an item X to a cell, and Mod B adds item Y to the same cell, if you load both mods, you will get both item X and Y in the cell to show up, right? I guess what I don't get is, if that works as expected, why didn't they make it work the same way for things like leveled lists and container contents and that sort of thing?
Link to comment
Share on other sites

Ok, that's what I thought. So just to be really pedantic and make sure, if Mod A adds an item X to a cell, and Mod B adds item Y to the same cell, if you load both mods, you will get both item X and Y in the cell to show up, right? I guess what I don't get is, if that works as expected, why didn't they make it work the same way for things like leveled lists and container contents and that sort of thing?

 

Correct -- Because the leveled lists are lists of items that exist in the original game - yet when mod A adds items to that list the list changes and once mod B comes along and also changes that list -- since one mod can not edit changes made by another mod it can not change the modified list it winds up creating it's own modified list with the original list and mod B's changes which then means Mod A's changes no longer exist ( They did it this way because if they allowed Mod B to make changes that included Mod A's changes then mod A was removed from the game and Mod B was still used (OR if the load order changed and Mod B was loaded before Mod A it would be trying to modify things that do not exist and the game would crash !)

 

By adding a new container instead of changing an existing container - you remove the possibility that Mod B will delete your changes because as far as Mod B is concerned your container does not exist so it can not modify it. But if you just change the contents of an existing container then Mod B also has that same container and if it changes the contents only the mod that loads last will have it's changes show up in game.

Link to comment
Share on other sites

Create a new, unique, empty container.

 

Add your items to it

 

Move a copy of it to the cell (usually the shop)

 

Make this copy a persistent reference***

 

Move it outside the walls of the shop unless you want players to be able to access it/steal from it

 

Give the NPC ownership of the reference

 

That should be it. Just make sure you add to the right kind of vendor. For instance, don't give weapons to a mage, vice versa.

 

***Don't know if this CK still uses persistent references. If so, recommend going this route. But once you place it and make the ref persistent, and others are using your mod, NEVER MOVE the container ref from the spot. Not even 1cm. Unless Beth changed things, the positions of persistent objects are stored in save game files. Changing the position breaks save games and makes them dependent on your mod, or did in the old Gamebryo.

Link to comment
Share on other sites

You can also create a new quest, give it a script, and make the script AddItem what you want to the vendor container. I've done this and it works fine. You just need to make sure that you have a "Wait" call for a couple of seconds before you add the item, as it doesn't seem to work if it runs right on the game loading.

 

 

 

Scriptname AATestFactionInventorySCRIPT extends Quest

ObjectReference Property WarmChest  Auto  

Armor Property ChefOutfit  Auto  

EVENT OnInit()
Utility.Wait(5)
WarmChest.AddItem(ChefOutfit, 3)
Debug.MessageBox("Items Added")
endEVENT

 

You just need to set up the properties in the CK as well.

 

(obviously the Debug message is just for debugging (making sure the script is working). If it works, you can don't need it there)

 

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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