SOLVED - <stockGenerators> what is the opposite of "Expensive"

Started by o-o-o, January 07, 2018, 08:37:56 PM

Previous topic - Next topic

o-o-o

While working with TraderKindDefs for a new faction, I want to allow for some pricing flexibility and arbitrage (buy low from this faction, sell high to that faction), but the only useful price modifier that I can find is <price>Expensive</price>.  In looking at other faction mods, I found <price>Normal</price> in the Umbra Company mod, but figure this has no real pricing effect.  I was pretty sure I came across something like "Cheap" or "Inexpensive" in some of these other mods, but didn't write it down at the time and can not find it now.

Anyone know what the other available price modifiers are?

Note that I checked the CoreXML A17 file, which is normally a really good asset.  I now strongly suspect that it was built by querrying all of the vanilla XML docs; this generated a list of all of the functions that were used, but that there are other existing functions that were not used in the vanilla XML files that is does not report.

BrokenValkyrie

#1
There 5 category of price ignoring undefined.

  public enum PriceType : byte
  {
    Undefined,
    VeryCheap,
    Cheap,
    Normal,
    Expensive,
    Exorbitant,
  }


It corresponds with the following value

    public static float PriceMultiplier(this PriceType pType)
    {
      switch (pType)
      {
        case PriceType.VeryCheap:
          return 0.4f;
        case PriceType.Cheap:
          return 0.7f;
        case PriceType.Normal:
          return 1f;
        case PriceType.Expensive:
          return 2f;
        case PriceType.Exorbitant:
          return 5f;
        default:
          return -1f;
      }
    }


You can look at the code responsible for calculating price to see it does have influence.

    private void InitPriceDataIfNeeded()
    {
      if ((double) this.pricePlayerBuy > 0.0)
        return;
      this.priceFactorBuy_TraderPriceType = this.PriceTypeFor(TradeAction.PlayerBuys).PriceMultiplier();
      this.priceFactorSell_TraderPriceType = this.PriceTypeFor(TradeAction.PlayerSells).PriceMultiplier();
      this.priceGain_PlayerNegotiator = TradeSession.playerNegotiator.GetStatValue(StatDefOf.TradePriceImprovement, true);
      this.priceGain_FactionBase = TradeSession.trader.TradePriceImprovementOffsetForPlayer;
      this.pricePlayerBuy = (float) ((double) this.BaseMarketValue * 1.5 * (double) this.priceFactorBuy_TraderPriceType * (1.0 + (double) Find.Storyteller.difficulty.tradePriceFactorLoss));
      this.pricePlayerBuy *= 1f - this.priceGain_PlayerNegotiator - this.priceGain_FactionBase;
      this.pricePlayerBuy = Mathf.Max(this.pricePlayerBuy, 0.5f);
      if ((double) this.pricePlayerBuy > 99.5)
        this.pricePlayerBuy = Mathf.Round(this.pricePlayerBuy);
      this.priceFactorSell_ItemSellPriceFactor = this.AnyThing.GetStatValue(StatDefOf.SellPriceFactor, true);
      this.pricePlayerSell = (float) ((double) this.BaseMarketValue * 0.5 * (double) this.priceFactorSell_TraderPriceType * (double) this.priceFactorSell_ItemSellPriceFactor * (1.0 - (double) Find.Storyteller.difficulty.tradePriceFactorLoss));
      this.pricePlayerSell *= 1f + this.priceGain_PlayerNegotiator + this.priceGain_FactionBase;
      this.pricePlayerSell = Mathf.Max(this.pricePlayerSell, 0.01f);
      if ((double) this.pricePlayerSell > 99.5)
        this.pricePlayerSell = Mathf.Round(this.pricePlayerSell);
      if ((double) this.pricePlayerSell < (double) this.pricePlayerBuy)
        return;
      Log.ErrorOnce("Trying to put player-sells price above player-buys price for " + (object) this.AnyThing, 65387);
      this.pricePlayerSell = this.pricePlayerBuy;
    }


o-o-o

Awesome, this was exactly what I was looking for.  All of my tinkering so far has been in the XML files.  I aspire to (someday) do some code work via Harmony to implement some features that are not XML possible, but for now the code is one big black box for me.  So I would have had a very hard time finding this on my own.