Item price depending on item quantity

Hello!
I have a problem with a feature I tried implementing in my caravan-based game. I’m awful at math, so maybe there is a simple answer to my question, we’ll see.

I want to have a mechanic that changes a value of an item depending on quantity of an item, and I’d like to have some basic control over this process, at least to cap it (to avoid extreme situations). The goal is to create trade routes that actually makes sense.

Example:
The “basic” price of Stone is 30. When a city has a lot of stone it costs 20. When a city has barely any stone it costs 50. This number should change based on quantity and never exceed the max or min. value.

In addition to this (but its ‘optional’, items has different sensivity to quantity changes.
Example:
Standard amount of grain in a city is 5,000. When the city has 8,000 the price changes by a notable but not extreme number, because a stockpile of wheat is good.
Standard amount of stone in a city is 500. When the city has 800 the price changes by a lot, because it’s city main income and the stockpile is almost full.

But the most important for me is functional example #1.
Help?

Most simplistic functional example #1

aaaaaa

3 Likes

Omg big thank you! Looks really clean and works just fine.

1 Like