Jump to content

How Are Vendor Caps Calculated?


user826

Recommended Posts

I'm trying to script a workaround to the glitch where if a vendor has over 32,767 caps, they'll stop paying out for items that you sell them. The scripting itself isn't an issue, but the problem is, I can't seem to figure out how the game calculates the total number of caps each vendor has available. I did a test with Chet. Talking to him and accessing his barter menu showed that he had 811 caps available to trade. Then, using the 'OpenTeammateContainer 1' console command, I found that he had 55 caps on his person. Opening his vendor chest showed 720 caps. Adding those two numbers together only gives me 775 caps, with 36 caps coming from some mystery source.

 

If I'm going to add a script either to him or his vendor chest, I need to know how the game calculates the total so that if it exceeds, say, 30,000 caps then I can tell it to ditch the excess. Does anyone here know the answer?

Link to comment
Share on other sites

At first I thought maybe you were missing a second stack of caps in his vendor container , since he has 2 different leveled items for them in there. But it would take a combination of the 2 to come up with 720.

By the way ... how were you able to look inside his vendor container from in game ?

I attempted by placing a COC marker there ... then toggle clip mode ... but my game froze when pressing "E" to open it.

Thought maybe the collision off might be doing it ... but turning it back on to stand on a container ... then did the same thing.

 

Me checking his total at barter twice from same load , then just crouch to pickpocket ... he had 41 on person both times.

But the remainder was 748 & 838 ... both not being possible from the 2 leveled items in the vendor chest.

 

I can't really say exactly what the un accounted amount ratio was on mine ... but yours is just over 4%

Not really alarming if you leave some buffer. So keeping the caps count to 28/30000 in the vendor container should do ya.

 

But I guess some more testing on the disparity would be good.

Edited by Mktavish
Link to comment
Share on other sites

Thanks for responding, and for doing your own testing as well! To answer your question, I used the GECK to give his vendor chest a Ref ID (It was already a persistent reference, so I just gave it a name) and then placed an activator in the general store that ran a "VendorChestChetREF.Activate Player" script when interacted with.

 

My concern with the disparity is if it compounds. Right now, it's only 36 caps (or 4%, as you pointed out) but depending on how it's calculated, 4% could easily turn into several thousand caps as the game progresses. Like right now it might be (Vendor Chest Caps + Inventory Caps) x 1.04 = Total Caps, but then after three days, it could be another 4% on top of that first total. Three days after that, 4% on top of the 4% on top of the first total, and so on. Eventually, that 4% could total over 30,000 caps if left unchecked!

 

I also had another thought. When I first found the 36 cap disparity, I had 18 caps in my inventory, which is exactly half of 36. This led me to wonder if the player's caps play any role in the formula. I did another test, this time ditching all my caps outside before even entering the store, but there was still a disparity (of only 13 caps this time, but still, more than twice the number of caps I had on me). I'm not sure if this proves anything but I'm passing it on as food for thought.

Link to comment
Share on other sites

"VendorChestChetREF.Activate Player"

 

So this is all I need in an "OnActivate" script placed on an item to activate ? (I use tool boxes)

 

Honestly I don't know New Vegas very well ... so I wouldn't be a good tester of this theory for NV .

Maybe it exists in F03 though ... can check that for ya with in game time.

 

The disparity could very well be a range ... and something aproaching 10% ... then becomes alarming imo.

 

But lets back the truck up for a minute. What are you talking about here ? What is the in game occurence that you would like to fix ?

Why exactly is a merchant ending up with 32,767 caps ?

Is it because you paid them that much for repair before the respawn could knock their caps back down to a few thousand ?

Could you just adjust their leveled Item caps ? Add more levels with lower amounts ? level 30 gives less than 20 example

Edited by Mktavish
Link to comment
Share on other sites

Yeah, just that snipped in an OnActivate block should do it. Here's my exact code:

scn VendorChestChecker

begin OnActivate
	if (IsActionRef Player == 1)
		VendorChestChetREF.Activate Player
	endif
end

And make sure you remember to give the chest itself that Reference ID.

 

Anyway, the game occurrence I'd like to fix is that when a vendor accrues over 32,767 caps in their barter menu, any items you sell them in exchange for caps, they will take the items from you but you will not receive any caps in return and their barter caps will not go down, so you can't fix the problem by buying more stuff. I know that the vendor caps glitch exists in Fallout 3 as well (and Oblivion too). It's a pretty well-known engine limitation that can't be fixed at a fundamental level, hence my attempt at a workaround.

 

A vendor could surpass 32,767 caps surprisingly easily in a number of ways. Mostly, it's if you buy a lot of expensive stuff from them using caps (i.e. the unique Gun Runners' Arsenal weapons, or equipment repairs from The Sink in Old World Blues) Also, as far as I know, their caps don't reset every three days. They keep their caps and restock more on top of it, so if you don't visit a vendor in a while, and put a hundred hours into the game, then come back, their inventory has been resetting every three days of game time you've been away but their caps have been accruing all that time as well, pushing them over the glitch threshold. This happens a lot with Lacey at the Mojave Outpost, since I think she has one of the highest starting cap totals in the game. I visited her, then went and did all the DLC in a row before coming back only to find that she no longer paid out for anything I sold her.

 

EDIT: One more issue that I just thought of. A vendor does not actually have caps in their vendor chest. Any caps that show up in their barter menu are placed there through leveled lists, therefore any script placed on the container that says something like...

ref ContainerREF
short ExcessCaps

begin GameMode

set ContainerREF to GetSelf
set ExcessCaps to (ContainerREF.GetItemCount Caps001 - 30000)

if (ContainerREF.GetItemCount Caps001 > 30000)
    ContainerREF.RemoveItem Caps001 ExcessCaps
endif

end

...would have absolutely no effect because the number of caps in the chest is always zero. I need to find out where the actual integer that represents a vendor's total number of available barter caps, is stored before I can affect it with a script.

Edited by user826
Link to comment
Share on other sites

Well I'm no expert, but the way I understand it, the only thing the container itself actually holds is a handful of leveled lists. A script will never find the actual GECK ID (i.e. Ammo308Caliber, Caps001, etc.) of the item listed in the container's inventory because the leveled list just tells the game to randomly "roll" to see how many of each item on the list should be displayed in the window that pops up when the player opens the container. It doesn't actually add that item to the container's inventory. This is backed up by the fact that most of the loot containers in the wasteland aren't named persistent references, so they wouldn't be able to be referenced in scripts anyway.

 

In short, I don't think the caps are stored in the container at all. The container is only used to store a set of rules for the game to interpret regarding the items that should be shown to the player. Like, for instance, an NPC wouldn't be able to reach into a random loot fridge in the wasteland and pull out food to eat because there isn't actually anything in the container at all. Only when the player opens it does it generate a list of contents that the player can take. Therefore, I think each vendors barter caps are stored in a variable or a global or some other game setting somewhere in the GECK, and not actually represented by the item "Caps001" in the game at all until they're transferred to the player.

Edited by user826
Link to comment
Share on other sites

  • Recently Browsing   0 members

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