Adding items to Vendor lists - safe?

Post » Wed Jun 20, 2012 10:31 pm

Is there a "safe" way to add items to a vendor?

I'm worried that if I modify their Levelled Lists (eg LItemApothecaryIngredienstRare75) it will block other mods from adding similar items.

Is there a bette way to do this? Will my changes clobber other mods?
User avatar
JUan Martinez
 
Posts: 3552
Joined: Tue Oct 16, 2007 7:12 am

Post » Wed Jun 20, 2012 11:42 pm

editing level lists for vendor inventory will indeed overwrite any other mod below yours in load order (if it modifies the same list)

an easy way to do it (with limited success) is to place your items physically into the world (remember, it doesn't necessarily have to be visible to the player unless you want it to be), and set ownership to the merchant's vendor faction. most of the time this will automatically add it into their sellable inventory without actually using any lists or containers.
User avatar
Lifee Mccaslin
 
Posts: 3369
Joined: Fri Jun 01, 2007 1:03 am

Post » Thu Jun 21, 2012 3:21 am

Is it possible to use a script to remove/add items to a vendors inventory? Perhaps a quest that runs when the game starts up and adds the items?
User avatar
Emily Shackleton
 
Posts: 3535
Joined: Sun Feb 11, 2007 12:36 am

Post » Thu Jun 21, 2012 10:47 am

Is it possible to use a script to remove/add items to a vendors inventory? Perhaps a quest that runs when the game starts up and adds the items?
http://www.creationkit.com/AddForm_-_LeveledItem will do what you're after. The forms added to LVLIs, however, don't stick in one's saves. The problem in this case is also the solution.
Event OnInit()	RegisterForSingleUpdate(1)EndEventEvent OnUpdate()	If bGetGameLoaded(EmptyLeveledItemWithUseAllFlagTicked, UnplayableArmor, Game.GetPlayer())		; Code in here will iterate once per save load		VanillaLeveledItem.AddForm(YourFormProperty)		; etc.	EndIf	RegisterForSingleUpdate(15)EndEventBool Function bGetGameLoaded(LeveledItem akLeveledItem = None, Form akForm = None, ObjectReference akContainer = None)	akContainer.AddItem(akLeveledItem, 1, True)	If akContainer.GetItemCount(akForm)		akContainer.RemoveItem(akForm, akContainer.GetItemCount(akForm), True)		Return False	Else		akLeveledItem.AddForm(akForm, 1, 1)		Return True	 EndIfEndFunction 
User avatar
Janette Segura
 
Posts: 3512
Joined: Wed Aug 22, 2007 12:36 am

Post » Thu Jun 21, 2012 5:55 am

Thanks for the info. It's a pity the vendor lists and loot lists aren't based on keywords, which makes much more sense to me... e.g. just add 10-50 items where keyword = "VendorItemIngredientCommon" to the vendors (or monsters) inventory... mods with items that included the keywords would automatically be picked up and sold by vendors with the same keyword.

Hmmm... (grabs CK)...
User avatar
JLG
 
Posts: 3364
Joined: Fri Oct 19, 2007 7:42 pm

Post » Thu Jun 21, 2012 6:25 am

There's always more than one way to skin a cat, but LeveledItems are lists of particular forms or other LVLIS. You could add items to leveled items according to keywords...
User avatar
Sarah Bishop
 
Posts: 3387
Joined: Wed Oct 04, 2006 9:59 pm

Post » Thu Jun 21, 2012 10:55 am

thats a great script.

i'm wondering if it is possible to make bookshelves by just using dummy books and custom addform level lists (using a hidden chest to store and control the add and removal from the lists). only thing is i don't know if a dummy book will populate itself in real time once you add the form to the list.

if this can actually work, you can easily make custom display shelves for basically anything (i kind of despise the way bookshelves are set up in the vanilla game)
User avatar
Rude Gurl
 
Posts: 3425
Joined: Wed Aug 08, 2007 9:17 am

Post » Thu Jun 21, 2012 11:04 am

Ok it took a while, and I get the general logic of the script, but doesn't it start an endless loop?

Help me here if I'm misssing something:

So on init, you try to add an item from an empty levelled list to the players inventory. Since the list starts out empty, it fails, so we add a useless item to the list and return TRUE, telling us the game just loaded... I then go ahead and do whatever my startup code was. (eg adding stuff to my vendors list).

The useless item is a stopgap in case the init somehow fires again, such as if the item the script is attached to gets duplicated, correct? So since the list has the item, it gets added after all and the test fails... and I leave my vendors alone. Gotcha.

It's the recursive call RegisterForSingleUpdate(15) that gets me. Whats the purpose here? If I'm reading this right, it now loops forever, does it not?
User avatar
Hilm Music
 
Posts: 3357
Joined: Wed Jun 06, 2007 9:36 pm

Post » Thu Jun 21, 2012 3:32 am

thats a great script.
Thanks :) Not sure about the bookshelves.
Ok it took a while, and I get the general logic of the script, but doesn't it start an endless loop?
Yes, and necessarily that it will maintain the changes after saving/reloading via reapplication in the bGetGameLoaded block. Without the RegisterForUpdate, the OnUpdate event wouldn't run and, in turn, neither would the maintenance code within the bGetGameLoaded block.
User avatar
teeny
 
Posts: 3423
Joined: Sun Feb 25, 2007 1:51 am

Post » Thu Jun 21, 2012 6:03 am

*thunks head* because OnInit only fires once -ever. I was thinking like a Flash programmer and was expecting the little devil to fire on every game load.

OK now it makes total sense. Amethyst was right - great script!
User avatar
maya papps
 
Posts: 3468
Joined: Mon Aug 07, 2006 3:44 pm

Post » Wed Jun 20, 2012 9:15 pm

OK I tried the scripted method above... it works great until you actually use the AddForm, causing a CTD if you load the module for the first time, modify any form in the "onload" block, save, and then immediately reload the saved game.

Curiously you can load the saved games just fine once you recover from the CTD. And since most folks wont save and immediately reload, I'm not sure its a real problem, except that it worries me about what else is going on under the hood.

Any idea what's going on?
User avatar
Robert
 
Posts: 3394
Joined: Sun Sep 02, 2007 5:58 am

Post » Thu Jun 21, 2012 8:18 am

 ; A SCRIPT THAT RUNS ON EACH GAME LOAD:; Apparently we cannot save changes to formLists across saves. Therefore a little trickery is required to force-feed the levelledItems; we want our vendors to sell into their levelled lists. This script is attached to any item in any cell in the game.; At OnInit (only happens once, ever), we try to add an item from an empty list to the players inventory. Since the list starts out; empty, the call fails - telling us the game just loaded for the very first time since our mod was installed. We can now do any special startup; routines. However, we also add a bogus item to the empty list, and set up a timer to recursively check this "on load" command every 15 seconds; for the rest of the game (this timer persists through savegames).; During subsequent calls to the Update, the list is no longer empty and the player ends up with a boot in his backpack, which tells us he has not just; loaded the game. The boot is removed and the script ends until the next recursion.; From now on, whenever we load the game, the recursive event fires within 1-15 seconds. Since lists are not saved, the very first time this is called; after loading, the list will be empty, and again we know to fire off our "onLoad" routines. Wash rinse repeat.     Form Property FishingNetUnplayableArmor Auto    LeveledItem Property FishingNetEmptyLeveledItemWithUseAllFlagTicked Auto    LeveledItem Property LItemMiscVendorMiscItems75 Auto    LeveledItem Property LItemFishingNet Auto Event OnInit()    RegisterForSingleUpdate(1)EndEvent  Event OnUpdate()    If bGetGameLoaded(FishingNetEmptyLeveledItemWithUseAllFlagTicked, FishingNetUnplayableArmor, Game.GetPlayer())	    ; Lets add a net to each vendor selling generic junk items:	    LItemMiscVendorMiscItems75.AddForm(LItemFishingNet, 1, 1 )    EndIf    RegisterForSingleUpdate(15)EndEvent Bool Function bGetGameLoaded(LeveledItem akLeveledItem = None, Form akForm = None, ObjectReference akContainer = None)    akContainer.AddItem(akLeveledItem, 1, True)    If akContainer.GetItemCount(akForm)	    akContainer.RemoveItem(akForm, akContainer.GetItemCount(akForm), True)	    Return False    Else	    akLeveledItem.AddForm(akForm, 1, 1)	    Return True    EndIfEndFunction 
User avatar
Matthew Aaron Evans
 
Posts: 3361
Joined: Wed Jul 25, 2007 2:59 am

Post » Wed Jun 20, 2012 11:48 pm

Be sure to tick the "Use All" flag for the empty LeveledItem. I've never had a crash using that method to detect game loading, but evidently that flag is integral.
User avatar
Sophie Morrell
 
Posts: 3364
Joined: Sat Aug 12, 2006 11:13 am

Post » Wed Jun 20, 2012 11:31 pm

Hi,

I don't get all of it - so please excuse my dumb questions. How do I attach a script "to any item in any cell in the game"? I want to add something into the leveleditemlist of a vendor. Where I have to put that script from above, so that it works?
User avatar
CYCO JO-NATE
 
Posts: 3431
Joined: Fri Sep 21, 2007 12:41 pm

Post » Wed Jun 20, 2012 10:39 pm

Basically it means that you can pick any single MISC item in any cell in the world, and attach that script to it. In my case I simply made a new interior cell, and dropped a random MISC object into it (I think it was a frying pan), and attached that script to the instance (aka ref) of the pan.

And bam, it just works.... kinda. I found that modifying formlists using this technique creates instability in the game. If you do this, it works just fine - unless you try to reload the same savegame. Then it CTDs. Curiously, it only happens when you modify formlists - i use his technique to do other stuff just fine. This has something to do with the fact that the formlists need to be cleared before you reload... Beth even provides revert methods for this bug, but I got tired of tryimg top fix it and just went to a different approach:


I know it's very late to confirm, but the quest-alias thing definitely WORKS.

So I'll repeat the steps:

1. Create a new Quest
2. Go to the Quest Aliases tab
3. Add new Quest Alias: Specific Reference, which in this case is the container you want to add items to
4. Add the items you want to be in the container to the inventory tab.

That's it! It will be re-added at reset as well! Thank you all for your help!

I'm doing this in all my mods now. Works like a charm. Also make sure the quest is "Start Game Enabled" and it will fire as soon as the game starts.
User avatar
Thomas LEON
 
Posts: 3420
Joined: Mon Nov 26, 2007 8:01 am

Post » Thu Jun 21, 2012 3:16 am

Aliases are just brilliant ;)

A couple of points (I use the Alias trick for lots of things):
  • If you setup a controller quest for all this type of stuff, then you know exactly where all your similar script routines are
  • Just remember to never end the quest ... and your stuff will always be there ... Or, end the quest and watch all of your stuff disappear (very useful, so I have sub-quests from my main controller quest to do just this)
  • If you set the Quest Priority stupidly high your stuff will always take priority over vanilla stuff (if you can, shove it in a Scene, and you'll have the highest priority of all)
  • Aliases do this for anything .... from NPC clothes/weapons to container contents (inc NPC and player inventory) to the appearance of particular NPCs in particular cells. Indeed, everything should almost always be an Alias of a Quest ... It seems ... Then (almost) everything is put back to vanilla when you end your quest

Really, more should be made of this trick in the wiki ... The tutorials only get around to aliases halfway through and I think quite a few people will have moved on from the tutorials before they get to understand them

:)
User avatar
sam smith
 
Posts: 3386
Joined: Sun Aug 05, 2007 3:55 am

Post » Thu Jun 21, 2012 2:36 am

just keep in mind, forced aliases are persistent forever, even after the quest has ended. you cant get something for "free", there's always a cost. just make sure you can afford it (not just your own mod, but considering multiple mods installed)
User avatar
Amber Ably
 
Posts: 3372
Joined: Wed Aug 29, 2007 4:39 pm

Post » Wed Jun 20, 2012 9:08 pm

Yeah, good point. I try to avoid forced aliases if at all possible (and if not possible, I try to figure out another way of doing the same thing). But I agree, Amethyst, nothing is perfect ;)
User avatar
Evaa
 
Posts: 3502
Joined: Mon Dec 18, 2006 9:11 am


Return to V - Skyrim