SevenBlue Posted April 24, 2017 Share Posted April 24, 2017 So I'm juggling a couple of projects each of which requires me to add items to a formlist. So I was wondering what the best way of "throttling" item distribution was? My research tells me not to add them to form lists directly because incompatibilities and that scripting in the solution, but I haven't been able to dig up exact methods. Item 1, A series of specific items to add to a vendor that they will only have one of. Essentially a token to allow the purchase of "upgrades" for a player home. Item 2, adding a new alchemy ingredient (for my simple skooma mod) to leveled lists, merchant lists, and so forth so specific vendors and types of enemies might drop it. Bandits and Khajitt caravans for instance. Link to comment Share on other sites More sharing options...
foamyesque Posted April 24, 2017 Share Posted April 24, 2017 (edited) There's two good ways (and many bad) to do this, as I understand it. 1. To add items to a specific vendor, create a quest, then add their merchant chest to a quest alias. Then add your items into the alias inventory list; these can be either specific items or levelled item lists, as needed. By default these items will not respawn; if respawning is desired, a simple script can be attached to the alias: ChestRespawnAlias extends ReferenceAlias int Property iRespawnGameHours = 48 Auto Event OnInit() RegisterForSingleUpdateGameTime(iRespawnGameHours) EndEvent Event OnUpdateGameTime() ObjectReference myRef = GetRef() Clear() ForceRefTo(myRef) RegisterForSingleUpdateGameTime(iRespawnGameHours) EndEvent This clears the chest from, and readds it to, the alias, whenever the specified number of game hours goes by. 48 is the default merchant container respawn rate. It will re-evaluate the levelled list, and add those results. You'll need to write a custom function to remove anything previously added or you'll get duplicates. If needed or desired, any levelled item lists in the alias can also be script modified, but the inventory passed to the chest won't be modified until a clear/forceref pair triggers a re-evaluation of the levelled list. This method can fairly easily be extended to as many merchants as you'd like, but it requires setting up an alias for each one and it doesn't work great with merchants added by other mods without a bunch of horsing around. 2. For adding items to a broad variety of merchants, including ones you don't know about when you're creating a mod, you want to hijack levelled lists. For example, you want to add an alchemy ingredient. You'd create a quest with a script with properties that target the levelled lists you want to insert your items to, and a blank LevelledItem list for your ingredient to go in. Then, you'd use AddForm in the quest's script to: 1. insert the ingredients into your blank levelled list, and 2. add the (no-longer) blank levelled list to the default game levelled list you want your stuff to appear in. The reason for using scripts to build your added levelled list is that so, if necessary, you can call Revert() on it to clear all your modifications without impacting anyone else, as might happen if someone calls Revert() on a base game levelled list that multiple mods have added forms to. Sadly, there's no equivalent to a FormList's RemoveAddedForm() for levelled lists, so Revert is the only way to clear script-driven changes. If you're absolutely confident you'll never need to clean them, you can build your new levelled list in the editor instead. Edited April 25, 2017 by foamyesque Link to comment Share on other sites More sharing options...
SevenBlue Posted April 25, 2017 Author Share Posted April 25, 2017 Thank you for your guidance, I deeply appreciate it. Testing what you recommended now and will continue to follow the trail you set forth. Link to comment Share on other sites More sharing options...
Recommended Posts