Selling Price
The get_sell_price
function at 0x0052E1D0
takes a pointer to a class containing the mapped trade difficulty setting, a ware, town, and sell amount and returns the transaction price.
Formula
The price formula operates on 5 intervals, and the 4 price thresholds specify the bounds.
Interval | Bounds |
---|---|
0 | [0; \(t_0\)] |
1 | [\(t_0\); \(t_1\)] |
2 | [\(t_1\); \(t_2\)] |
3 | [\(t_2\); \(t_3\)] |
4 | [\(t_3\); \(\infty\)] |
Within every interval \(i\) the price \(p_i\) is defined as: \[ \begin{aligned} p_{i} &= p_{base} * w_{i} * f_{i} \end{aligned} \]
where \(w_i\) is the amount being sold to \(i\) and \(f\) is defined as: \[ \begin{aligned} f_4 &= 0.5\\ f_{i} &= m_i - v_i \underbrace{\frac{w_{relative\_stock} + w_{relative\_new\_stock}}{2 * \text{interval_width}}}_{\in [0; 1]}\\ f_0 &= d_{trade\_difficulty} - (v_i - d_{trade\_difficulty}) \underbrace{\frac{w_{relative\_stock} + w_{relative\_new\_stock}}{2 * \text{interval_width}}}_{\in [0; 1]} \end{aligned} \]
where \(w_{relative\_stock}\) and \(w_{relative\_new\_stock}\) are the stock's and new stock's offsets in the interval and \(m_i\) and \(v_i\) are defined as:
Bracket | \(m_i\) | \(v_i\) |
---|---|---|
0 | NaN | 1.4 |
1 | 1.4 | 0.4 |
2 | 1.0 | 0.3 |
3 | 0.7 | 0.2 |
and \(d_{trade\_difficulty}\) is defined as:
Difficulty | Value |
---|---|
0 (low) | 2.2 |
1 (normal) | 2.0 |
2 (high) | 1.8 |
Example
Let's assume we sell pig iron to a town with the following thresholds:
Threshold | Value |
---|---|
t0 | 20000 |
t1 | 60000 |
t2 | 70000 |
t3 | 80000 |
If we sell one bundle (2000), the resulting prices at different stock levels would be: