Changing prices
SetPriceFactors and ClearPriceFactors scale one trader’s prices.
Traders scales one trader's prices
Use SetPriceFactors to scale one trader’s prices, and ClearPriceFactors to remove your mod’s scale.
public static class Traders
{
public static bool SetPriceFactors(string modId, string shopId, float buy, float sell);
public static bool ClearPriceFactors(string modId, string shopId);
}
| Method | Returns | What it does |
|---|---|---|
SetPriceFactors(modId, shopId, buy, sell) | bool | Scales one trader’s prices. Returns true when set. |
ClearPriceFactors(modId, shopId) | bool | Removes your factors from one trader. |
Things to know
- A price factor scales a trader’s prices.
buyscales what the player pays when buying from the trader.sellscales what the player gets when selling to the trader. A factor of 1.25 means 25 percent more. A factor must be above 0 and at most 4. - Each mod has its own factors, and all mods’ factors are multiplied together.
TraderInfo.BuyFactorandSellFactorshow the result. - Factors apply everywhere the game and the framework show or charge a price. That is the game’s own trade screen,
Shops.PriceOf,Shops.Stock, theShops.PriceQueryevent, andTraders.BuyandTraders.Sell. - Price factors are not saved, and every normal level load clears them. Set them again from an
Events.SceneLoadedhandler, as the quick example does.SetPriceFactorsandClearPriceFactorsalso work insideEvents.SceneLoadedand while a save is loading or being written. (every Single scene load clears them) PriceFactorsAvailableisfalsewhen price factors don’t work. ThenSetPriceFactorsreturnsfalse. (it is true when the price hook (Trade.GetItemStackPrice) is installed)
Limits
- A price never goes below 1 OC for each unit (or the same amount in RM). That is the game’s own lowest price, so a factor or a
Shops.PriceQueryhandler can’t make an item free.