Fallout and Fallout 2 Barter Formula?

Discussion in 'Fallout RPG Gameplay & Tech' started by QuantumApprentice, Jun 21, 2019.

  1. QuantumApprentice

    QuantumApprentice First time out of the vault

    Feb 9, 2018
    Here's another zany question probably nobody has bothered to ask...does anybody know what the actual formula or pseudo-code for how npc's price their stuff is?

    I've taken the time to create a data set of several of the npc shopkeepers for both Fallout and Fallout 2, but the trend lines appear logarithmic or polynomial when looking for best fit with excel. Now I don't trust excel to give me great results with it's limited equation solving ability, so I figured I'd ask here.

    It looks like the original Fallout may have a much steeper curve, but it dips into profitability at pretty low skill levels, while fallout 2 requires absurdly high skill levels even with discount bonuses.
    Also, I'll happily post my data if nobody has a direct answer and somebody wants to help derive it.

    There also appear to be other variables besides barter and discounts going into the formula, but (counter to Per Jorner's walkthrough) charisma does not seem to have any direct affect other than the effect it has on your barter skill.
    Last edited: Jun 21, 2019
  2. NovaRain

    NovaRain Casual Modder Modder

    Mar 10, 2007
    Master_Trader = 100;
    if (player_has_master_trader) Master_Trader = 125;
    barter_mod = script_modifier + reaction_modifier; // reaction_modifier is 50/0/-25 for good/neutral/bad.
    barter_diff = barter_mod + player_barter_skill - trader_barter_skill + Master_Trader;
    if (barter_diff < 10) barter_diff = 10;
    if (barter_diff > 300) barter_diff = 300;
    total_price = caps_total + (item_total_cost_without_caps * 100) / barter_diff;
    Ian has Barter 30%. The player has Barter 200% and Master Trader perk.
    The barter_mod is 0.
    Now buying a 10mm SMG (1000 caps) from him will be:
    barter_diff = 0 + 200 - 30 + 125 = 295
    price_on_table = (1000 * 100) / 295 = 338

    Master_Trader = 0.0;
    if (player_has_master_trader) Master_Trader = 25.0;
    barter_mod = script_modifier + reaction_modifier; // reaction_modifier is -15/0/25 for good/neutral/bad.
    barter_percent = (barter_mod + 100.0 - Master_Trader) * 0.01;
    if (barter_percent < 0.0) barter_percent = 0.0099999998;
    barter_ratio = [(trader_barter_skill + 160.0) / (highest_barter_skill_in_party + 160.0)] * 2.0;
    total_price = caps_total + item_total_cost_without_caps * barter_ratio * barter_percent;
    Eldridge has Barter 115%. The player has Barter 200% and Master Trader perk.
    If the player becomes a Made Man for any family, the barter_mod will be -20.
    Now buying a 10mm SMG (1000 caps) from him will be:
    barter_percent = (-20 + 100 - 25) * 0.01 = 0.55
    barter_ratio = [(115 + 160) / (200 + 160)] * 2 = 1.52778
    price_on_table = 1000 * 1.52778 * 0.55 = 840
    Last edited: Jun 24, 2019
    • [Rad] [Rad] x 1
  3. QuantumApprentice

    QuantumApprentice First time out of the vault

    Feb 9, 2018
    Heck yeah!
    NovaRain with the answer AND the pseudo-code!
    Where do you get the voluminous amount of information you always have?
    Thank you!

    A couple of odd discrepancies I noticed when trying to test these formulas out:

    Ian's barter skill for Fallout 1 is listed at 20%, not 30% according to Cubik's "FO1/2 Critter Proto Editor" (v1.0.1.0), however your formula seems to work for a couple of different values in game so it's possible the critter proto editor is incorrect, but I'm not sure where to verify Ian's barter other than with this tool. Can I trust other barter values in it?

    According to the wiki (and the in-game description), in both games you're supposed to get a 25% discount with the Master Trader perk, but for Fallout 1 your formula treats the perk as +25 invisible Barter skill points (which is not the same as 25% discount). Your formula still seems to give correct values, suggesting that the descriptions listed are not correct for the original Fallout.

    Any thoughts? Have you run into this stuff before? Is it worth a wiki edit?

    And finally, I can't get Eldridge's prices to line up with your formula for Fallout 2.
    With the Made Man and Master Trader perks and 200% Barter skill I can only get the price down to 1145.
    Without Master Trader the price is 1527, which makes the 25% discount seem correct this time at least, but this suggests the Made Man perk isn't being added in. That being said, I can't seem to find the Made Man perk in F2SE (the Fallout 2 Save-game Editor), so who knows if I really have it or not. My karma page lists it, and I get the option to ask for it in dialogue, but it doesn't seem to have an effect.

    After checking Per Jorner's walk-through, he says:
    "For each boss there is a chain of quests, upon the completion of which you become a Made Man of that family. This means you get a popularity boost among the citizenry, free sex at the Cat's Paw, special services at the New Reno Arms (but seemingly no discount on Eldridge's normal stock, nor Renesco's)".

    So it appears this perk is faulty for the main vendors in New Reno (at least in current vanilla version) :(
    (Also, giving an SMG to Eldridge's "special stock" and then checking the price by purchasing it again does not seem to add any sort of discount either) :( :(
    Actually, it looks like this is the main reason I can't get prices to line up, as when I remove that from the math, the prices seem to match again. I'll run a few more tests and see how it goes, thanks for helping me out! XD :)

    I'm testing this with the Steam version of Fallout and Fallout 2, no mods installed.

    Other questions:
    What is the "caps_total" variable in the formula? (You don't seem to use this in the examples you gave)

    Multiple "barter_mod_from_script" variables appear to be calculated sequentially instead of cumulatively (ie Maida Buckner gives you a 20% discount if you buy one round of drinks, but a second round of drinks only gives you an extra 12% cumulative discount from the original price, but it could be a 15% discount applied to the final price after the initial 20% discount). How does the formula account for this?
  4. NovaRain

    NovaRain Casual Modder Modder

    Mar 10, 2007
    From the engine dump databases that I've already told you in an old post.

    Download Cubik's latest critter proto editor (v1.4.6.11). Or extract Ian's proto from master.dat from FO1 and check the proto in some hex editor.

    Made Man status is not a perk but a reputation from setting global variables, and his discount from Made Man is in killap's UP/RP (was bugged in vanilla).

    The amount of "money/caps" item on trader's table, the value of money itself shouldn't be effected by barter skill right? $1 is $1.
    • [Rad] [Rad] x 1
  5. QuantumApprentice

    QuantumApprentice First time out of the vault

    Feb 9, 2018
    Oh man, I forgot about that. Still wish I could open those and read them, I'd seriously abuse google translate with it :P

    Woohoo! Thank you sir! This one is up to date (Ian's barter is 30) and shows more info besides XD
    Sadly, my current dat explorer only works for FO2, so I'd have to do some searching for the FO1 dat explorer, but I'm pretty sure 30 is the correct skill level.

    Yeah, I found that out the hard way :P

    Was this used as an exchange rate for things like Redding's mine scrip? I don't recall if Fallout had more than one currency though.
  6. QuantumApprentice

    QuantumApprentice First time out of the vault

    Feb 9, 2018
    I get what you're saying here, but for order of operations shouldn't it read:
    2 * (115 + 160)/(200 + 160)
    [(115 + 160)/(200 + 160)] * 2


    is it actually:
    barter_ratio = 2 * (trader_barter_skill + 160.0) / (highest_barter_skill_in_party + 160.0)
    barter_ratio = ((trader_barter_skill + 160.0) / (highest_barter_skill_in_party + 160.0)) * 2
    Last edited: Jun 22, 2019
  7. NovaRain

    NovaRain Casual Modder Modder

    Mar 10, 2007
    • [Rad] [Rad] x 1
  8. QuantumApprentice

    QuantumApprentice First time out of the vault

    Feb 9, 2018
    Sorry for bringing it up, but thank you for understanding :)

    Ok, I got both formulas to work perfectly for several characters in each game...but...

    I can't get Maida Buckner's prices to match.
    All the other characters I've tested so far I was able to apply a simple barter modifier of 25 or 50 or something similar to get everything to line up, but her prices have some weird non-repeating ratio applied to them, so I think I'm missing something in her barter modifier.

    Is there some way to find the barter modifiers for npc's? At least for shopkeepers?
  9. NovaRain

    NovaRain Casual Modder Modder

    Mar 10, 2007
    You need to check their scripts and local variable in saved games, because barter_mod is also effected by reaction value (the first local variable, not all traders set it, for example Eldridge doesn't).
    Maida Buckner has Barter 55% and no barter modifier in her script. My character has Barter 170% and Master Trader perk, so buying a crowbar ($65) from her with good reaction costs:
    barter_mod = 0 + (-15, from good reaction) = -15
    barter_percent = (-15 + 100.0 - 25.0) * 0.01 = 0.6
    barter_ratio = [(55 + 160.0) / (170 + 160.0)] * 2.0 = 1.30303
    crowbar cost = 65 * 1.30303 * 0.6 = 50
    • [Rad] [Rad] x 1
  10. QuantumApprentice

    QuantumApprentice First time out of the vault

    Feb 9, 2018
    It sounds like you're saying the reaction variable has a significant effect?
    Does this mean each type of reaction (positive, neutral, negative as described in the wiki) gets a set bonus or penalty? If it works that way is it always 15 points? If not, what is this set bonus/penalty?

    These are the two links I can find that have info about the Reaction system, but they're inconsistent and don't agree with each other:

    This is really frustrating, neither wiki list's her Barter skill level, the critter tables listed here: give her a 0 in Barter, the newer "FO1/2 Critter Proto Editor" you pointed me to (v. lists her barter as 16, and the only other Proto editor I managed to get working (Proto Manager v1.03 by Mr.Stalin) also lists her as having 16 barter. I will note that the proto manager does have a "Critters Flags" section where she is flagged for "Barter", but I have no idea what this means.

    The crazy thing is when you used 55 for her barter skill it only takes a barter_percent of 1.25 to make her numbers line up. Even crazier, when testing Master Trader on her, it gives the same discount as if you only buy one round of drinks.
    So, from what you describe, it looks like her first modifier is -25 (from bad reaction to neutral?), and her second is another -15 (from neutral to good reaction?)

    Either way, how can I verify what her actual barter is? Does the "Barter" flag have something to do with it?
    Last edited: Jun 26, 2019
  11. NovaRain

    NovaRain Casual Modder Modder

    Mar 10, 2007
    I've already updated my fist post above with reaction modifiers.

    Because in the game she actually uses "Bad Merchant" as her template. Sometimes you need to use Fallout mapper to check critters on a map.
    • [Rad] [Rad] x 1
  12. QuantumApprentice

    QuantumApprentice First time out of the vault

    Feb 9, 2018
    Thanks! Oh wait, Fallout has reaction modifiers too? Well that explains Mrs. Stapleton's overpriced books.

    How do you get the mapper to list her template? The only thing I can get it to list is her script file (kcmaida.int). Her script file also has a "maida_barter" procedure, but I'm unclear how to read the rest of it.

    If you have the time, would you be willing to explain how to get the template to show up? Or point to a guide if one exists?
  13. QuantumApprentice

    QuantumApprentice First time out of the vault

    Feb 9, 2018
    Ok, I found the "Bad Merchant" template in the mapper, though I have no idea how you're supposed to know this is a template.

    Maida Buckner - Bad Merchant.png

    So if Maida uses a template that replaces her own barter skills with whatever is in the template, how do we find out what the template skills are?
  14. NovaRain

    NovaRain Casual Modder Modder

    Mar 10, 2007
    You can check it in the critter proto editor.
    • [Rad] [Rad] x 1
  15. QuantumApprentice

    QuantumApprentice First time out of the vault

    Feb 9, 2018
    Well that just makes sense :P Thank you! :)

    But I noticed there's a number in this box that looks like it might relate to the proto id number.

    FO2 Mapper - proto id.png

    Is that what it's supposed to be? Only it's offset by 1 since the editor starts the id's at 0, while the actual proto files start at 1? Or is it just the list order?
    (I ask because 00000056.pro is listed as a Male Bad Merchant with 50 barter, but 00000057.pro is the one you highlighted which has the correct values.)
    Last edited: Jun 30, 2019
  16. QuantumApprentice

    QuantumApprentice First time out of the vault

    Feb 9, 2018
    Oh, and one last question:

    Does the game always recognize the Template values over the Critter values?

    For instance, since Big Sally Dunton has Master Trader as her template, does that mean the game will always use 120 Barter for Sally's skill level instead of whatever her own proto file shows? Are there exceptions to this?:

    sally dunton.png
  17. NovaRain

    NovaRain Casual Modder Modder

    Mar 10, 2007
    Sally doesn't have her own proto. The case for Maida Buckner is the devs set up an unique proto (00000098.pro) for her in the game files but didn't really use it, it's a "bad merchant" critter (00000057.pro) being placed on the map with Maida Buckner's script attached.
    • [Rad] [Rad] x 1
  18. QuantumApprentice

    QuantumApprentice First time out of the vault

    Feb 9, 2018
    Ah ok, thanks for explaining. Are there a lot of exceptions like this?

    I'm specifically trying to find out if I can reliably determine what a critter's barter skill is by checking either their named proto or their template proto (give or take the wiki).
    Last edited: Jul 1, 2019