vendor container trouble

Post » Sat May 28, 2011 11:45 am

I'm trying to add some stuff to vendor's inventories, but I'm getting sort of tricky. The script below checks to see if their VendorChestBuried (the respawning container that holds their goods) contains a PPAVendorToken - a piece of unplayable armor. If its there, do nothing, if it isn't, add the appropriate leveled item (which contains the PPAVendorToken, and the other stuff). When the container respawns, the PPAVendorToken gets removed, and the next time this script checks it will add the leveled list again - so the leveled list respawns along with the container, effectively.

This should remove the need to merge leveled lists, or wait for the vendor containers to respawn after installing the mod. It also gives me more control over what shows up in the inventory and when.

The only problem is it doesn't seem to work. I've verified that you can add leveled items in scripts via additem. My goods don't seem to be showing up though. Anyone see anything glaringly wrong (am I using the wrong container or somthing)?

begin gamemode	set rChest to VendorChestBuriedCantelliREF	IF rChest.getitemcount PPATokenVendor	ELSE		IF getobjectivecompleted MS03 78 && MS03.MS03C1RCBonus		; player has researched Rivet City's history and received Moira's Rivet City discount bonus			rChest.additem PPAVendorListCantelli1 1		ELSE			rChest.additem PPAVendorListCantelli0 1		ENDif	ENDifend

User avatar
The Time Car
 
Posts: 3435
Joined: Sat Oct 27, 2007 7:13 pm

Post » Sat May 28, 2011 3:48 pm

well for starters, you sould go through cipscis's scripting for begginers here @ http://www.cipscis.com/fallout.
I noticed that you have not declared the rChest variable. you shoul have below the scn
scn waterverscriptshort rChest;


hope this helps

Thanks Persidon
User avatar
Sami Blackburn
 
Posts: 3306
Joined: Tue Jun 20, 2006 7:56 am

Post » Sat May 28, 2011 7:38 pm

very funny.

I guess since I'm asking people to debug, I should mention what I left out. The actual script is a couple of hundred lines of more or less the same stuff for different vendors. I cropped out the "scn PPAVendorChestQuestScript" and the variable declaration for brevity (it compiles, but the stuff doesn't show up when I try things out in game).
User avatar
Katie Pollard
 
Posts: 3460
Joined: Thu Nov 09, 2006 11:23 pm

Post » Sat May 28, 2011 5:16 pm

sorry. What about this one
IFgetobjectivecompletedMS03 78 &&MS03.MS03C1RCBonus; player hasresearched Rivet City'shistory and receivedMoira's Rivet Citydiscount bonus


This is wrong syntax(i think as ive not scripted in a while)

i think this might work
if ( GetObjectiveCompleted MS03 78 && GetObjectiveCompletd MS03C1RCBonus)
hopefully this might help
User avatar
Amber Hubbard
 
Posts: 3537
Joined: Tue Dec 05, 2006 6:59 pm

Post » Sat May 28, 2011 8:41 pm

The "MS03.MS03C1RCBonus" is the syntax for accessing a quest variable - MS03 is the quest (the Wasteland Survival Guide quest) and MS03C1RCBonus is a variable in that quest's script that is 1 if the bonus is applied, 0 if it isn't. I've also used that general syntax for conditionals before, and you can get away with not putting everything in parenthesis.

If that conditional were written wrong, the "ELSE" portion of it should still be executed, so something should be added to the container either way. I'll try messing around with the console to start narrowing down the possible errors- I think this might be a useful way to handle vendors if I can get it to work.
User avatar
Cassie Boyle
 
Posts: 3468
Joined: Sun Nov 05, 2006 9:33 am

Post » Sat May 28, 2011 9:37 pm

ok open up the console and type
player.additem PPAVendorListCantelli0 1


if it adds it to your inventory then the problem is within your script

Thanks Persidon
User avatar
Silvia Gil
 
Posts: 3433
Joined: Mon Nov 20, 2006 9:31 pm

Post » Sat May 28, 2011 7:38 pm

A few things:
1) Did your test character finish the Rivert City history quest as specified?
2) If the answer is yes, you could try to use the VendorContainer*REF instead of the VendorChestBuried*REF.
3) Instead of hardcoding all that for each merchant, you may want to try to use a http://cs.elderscrolls.com/constwiki/index.php/User:Haama/FAR, with the following code on the activator:
ScriptName AddItemsToMerchantScriptref rChestref vendorListBegin OnActivate        IF rChest.getitemcount PPATokenVendor	ELSE		IF getobjectivecompleted MS03 78 && MS03.MS03C1RCBonus		; player has researched Rivet City's history and received Moira's Rivet City discount bonus			rChest.additem vendorList 1		ELSE			rChest.additem vendorList 1		ENDif	ENDifEnd

You can set rChest remotely and activate it like this
set AddItemsToMerchantFAR.rChest to VendorContainerMoiraBrownREFset AddItemsToMerchantFAR.vendorList to YourCustomVenderListForMoireBrownAddItemsToMerchantFAR.Activate player, 1

where AddItemsToMerchantFAR is the Function Activator.
User avatar
Georgine Lee
 
Posts: 3353
Joined: Wed Oct 04, 2006 11:50 am

Post » Sat May 28, 2011 10:25 pm

@ Persidon

I have tried that, and it adds the items to my inventory as expected, so it has to be something in the script.

@ Zumbs

If I understand correctly, both the vendorchestburied and vendorcontainer are drawn from in the same way by the vendor. The difference is that the vendorcontainer doesn't respawn, so it's used to hold things that can only be bought once, like schematics. My mod is going to add schematics and some unique items to some vendors, so I've used both in some cases. The items don't show up in either case.

But wow, many of my scripts are long and incomprehensible with lots of copy/pasting. I will definitely benefit from that FAR suggestion. It'd be interesting to hear from Cipsis on how efficient it is.
User avatar
Charles Mckinna
 
Posts: 3511
Joined: Mon Nov 12, 2007 6:51 am

Post » Sat May 28, 2011 4:33 pm

ok im having a thought. The problem lies within your script right? put it through cipscis's script validator. if the above is valid, it might be within the rest of your script. so you might have to put your hole script in. its available @ cipscis http://www.cipscis.com/fallout/utilities/validator.aspx


Thanks Persidon
User avatar
Solène We
 
Posts: 3470
Joined: Tue Mar 27, 2007 7:04 am

Post » Sat May 28, 2011 2:46 pm

OK, figured it out. The problem was somewhere in the other lines of code (sorry about that).

If you want to use additem with a reference, it has to be an individual instance in the gameworld, not the base object. All of the vendor chests are persistant references, but for some reason the devs forgot to give the Flak and Shrapnel container a name that was distinct from the base object. So my code compiled, because the compiler thought I was referring to the persistent reference (or possibly because I was calling everything via a reference variable), but the script crashed because the game couldn't figure out if I was referring to the base object or the persistent reference.

That script validator looks useful, getting indentation right can be a pain, and I like the way it color codes everything. It also doesn't threaten to exit the program if I make a typo.

On the upside, it looks like this technique works, so if anybody wants to get creative with the way they add stuff to vendors the code I initially posted will do it. It can be used to have a lot of control over when the player gets access to stuff, and also to refresh certain items in the containers more frequently than others.
User avatar
TOYA toys
 
Posts: 3455
Joined: Sat Jan 13, 2007 4:22 am

Post » Sat May 28, 2011 11:00 am

You could also put a new respawning container, owned by the vendor, underground in the same cell as his shop. No scripting required. :)

Only issue is that it could possibly become visible if another mod changes the layout of the cell, but it's not likely and can be fixed easily.

Edit/Addendum: It might respawn differently to the vendor's default container if the player visits too often. Somewhere common like RC or Moira's might be a problem because of this.
User avatar
Dina Boudreau
 
Posts: 3410
Joined: Thu Jan 04, 2007 10:59 pm

Post » Sat May 28, 2011 4:12 pm

I'd still need the script if I wanted to make the inventory dependent upon quest status, so I don't think it would save me much work. I came across the Engineering Guild tutorial on merchants while trying to work out the bug, and it had some great information on how the containers work. As of Fallout 3, each merchant gets one container that can be in any cell and still be accessed. Additional containers can be accessed if their ownership is set to the merchant in question, but only if they're in the same cell. So what you're suggesting works for stationary vendors, but not for any roving merchants, like the four major ones from Canterbury Commons. You have to either add your stuff to their existing VendorChestBuried, or create new containers in all the cells where the player is likely to encounter them (which is quite a few).

What I did was just add a name to Flak and Shrapnel's container, using the same naming convention that Bethesda was using. It doesn't change the form id, so it won't cause conflicts with mods, and it won't conflict with any mod's scripts because without a name, no other script would have been able to reference it. There might be a problem if another modder ran into the same problem and named that container something different, but I'll cross that bridge when I come to it. I've got a hunch that the compiled code references the Form ID rather than the nametag, so there wouldn't be a problem.

I was thinking it would be cool to use this technique to make it so that trading heavily with a single merchant "unlocked" better goods, and maybe higher amounts of caps. Take your business elsewhere for too long, and you lose the bonus goods. Basically, trade in the wastes, especially in out of the way locations, would be very stagnant, no cash flow. But the lone wanderer starts venturing out and killing and looting everything in the area, and suddenly there's a major economy wherever he unloads his goods. That area becomes a trading hub with better inventories and loads of caps (and possibly lower prices, though there's already a mod WIP that will cover that). Major trading hubs, like Rivet City Market and Moira's, probably wouldn't change much.
User avatar
ashleigh bryden
 
Posts: 3446
Joined: Thu Jun 29, 2006 5:43 am

Post » Sat May 28, 2011 10:49 pm

I'd still need the script if I wanted to make the inventory dependent upon quest status, so I don't think it would save me much work.
You could use a global for the 'chance none' field of your LVLI(s).

What I did was just add a name to Flak and Shrapnel's container, using the same naming convention that Bethesda was using. It doesn't change the form id, so it won't cause conflicts with mods, and it won't conflict with any mod's scripts because without a name, no other script would have been able to reference it.
You can actually reference any persistent [00] reference by its Form ID in scripts so, 'B41D9.AddItem F 10' = 'VendorChestBuriedFlakAndShrapnelREF.AddItem Caps001 10' minus the addition of the Editor ID. Then, even if ten mods add ten different editor ID's to that ref, your script will A) always compile and B) always work.

Oh, http://www.mediafire.com/?vp3rmhn4t3ga184's a plugin with all vendor related FO3 stuff for easy reference in FO3Edit.

Good luck with your endeavor :)
User avatar
Catherine Harte
 
Posts: 3379
Joined: Sat Aug 26, 2006 12:58 pm

Post » Sat May 28, 2011 8:47 pm

Thanks, that's a handy resource, and its good to know about the ability to use Form IDs directly.

I think my method of adding the items still has a couple of advantages over creating a new container with pre-added leveled items controlled via chancenone globals (though its good to know how those work now). It works easily with roving traders, the goods can be spawned immediately upon meeting the conditions, as opposed to waiting for a container respawn (though sometimes you might not want that), and goods can be added at shorter intervals - so if you wanted the merchant's supply of bottled water or caps to be refreshed daily while the rest of the goods respawned every 4 days, you could. You can also remove stuff - create a non-"use all" version of the vendor inventory leveled list, and remove it at random intervals. That would simulate random NPC purchases.

I guess if I were to do that economy overhaul, my first step would be to empty out all of the vendor containers in that .esp...
User avatar
cosmo valerga
 
Posts: 3477
Joined: Sat Oct 13, 2007 10:21 am

Post » Sat May 28, 2011 1:00 pm

No prob. :) That was the beginning of FOOK's scripted vendor chain and that Form ID business is great for refs without Editor ID's. There's code in FOOK within each 'link' of said vendor chain to remove all of the *vanilla wares so that the slate(s) are clean and you're welcome to copypasta anything useful. I, also, prefer to script addition/removal of wares to/from vendor chests over adding more chests to cells/editing LVLI's/editing CONT records.

*anything else is left alone
User avatar
noa zarfati
 
Posts: 3410
Joined: Sun Apr 15, 2007 5:54 am

Post » Sat May 28, 2011 7:59 pm

I'll have to take a look.

I think I figured out how to adjust the item prices without going totally insane - keep formlists of items in similar categories, then use listgetformindex and listgetnthform to step through the lists, adjusting the prices by some multiplier that's related to how scarce items in that category are locally. The trick will be to figure out the multipliers. I guess if I have formlists with all of the vanilla items in them, I can step through them, checking to see how many of each item category are in the merchant's inventory. The more there are, the lower the price for buyer and seller (supply and demand). So if you're using IMCN and you start unloading a ton of meat from all the wasteland critters you've killed, the price will be lower every time you go back. I might even want to do away with container respawning entirely, and handle all of the inventory reduction via random item removal.
User avatar
Hayley Bristow
 
Posts: 3467
Joined: Tue Oct 31, 2006 12:24 am


Return to Fallout 3