8/9/2014 – Bartering – Let's try that again :)

Bartering is finished! I’m really pleased to check this one off because it ties a lot of other systems together.

On some level most rpgs are about stuff. Finding it, hoarding it, using it, buying it, selling it, stealing it. The buying and the selling is important because it makes every item useful to every player. There are seashells in the game but I’m guessing only 1/100 people will be picking up seashells just to keep them, right? Most of you will sell them at the nearest curio shop.

Bartering is one of the handful of skills you start the game with. It’s also the one place outside of the main quest where your character’s reputation has a real effect on gameplay: prices.

Each item in the world has a base currency value. But your bartering skill combined with your reputation determines how much people are willing to pay for those items. Here’s the math:

Code: Select all
int TotalValuePlayerGoods;
int TotalValueCharacterGoods;
float repPriceModifier = 0f;
float skillPriceModifier = 0f;
float goodsPriceModifier = 0f;

//recalculate the base value of goods in this barter session
int BaseValuePlayerGoods = RecalculateValueOfGoods (BarterParty.Player, BarterSession.PlayerGoods);
int BaseValueCharacterGoods = RecalculateValueOfGoods (BarterParty.Character, BarterSession.CharacterGoods);

//get the player's reputation with the current character (incorporates global reputation)
ReputationState rep = Profile.Get.CurrentGame.Character.Rep.GetReputation (BarteringCharacter.worlditem.FileName);
repPriceModifier = rep.NormalizedOffsetReputation;//this will be a value from -1 to 1
skillPriceModifier = BarterManager.State.NormalizedOffsetUsageLevel;//this will be a value from -1 to 1
goodsPriceModifier = (repPriceModifier + skillPriceModifier) / 2f;
if (BarterManager.HasBeenMastered) {
//mastering the barter skill reduces all penalties to zero
goodsPriceModifier = Mathf.Max (0, goodsPriceModifier);
goodsPriceModifier *= Globals.BarterMaximumPriceModifier;

//divide the final modifier by 2 to get its effects on both sets of goods
TotalValuePlayerGoods = BaseValuePlayerGoods + Mathf.FloorToInt (BaseValuePlayerGoods * (goodsPriceModifier / 2f));
TotalValueCharacterGoods = BaseValueCharacterGoods - Mathf.FloorToInt (BaseValueCharacterGoods * (goodsPriceModifier / 2f));

You won’t see these hard numbers in-game (though they appear in the screenshot for debugging purposes) but you’ll definitely notice when you buy an apple for 5 and can only sell it for 1. This is assuming they’ll barter with you in the first place. If your reputation is bad enough they’ll simply refuse, in which case you’ll have to make a living by stealing. It’s a downward spiral of criminal behavior…

Read more here: 8/9/2014 – Bartering – Let's try that again :)