Skip to content

Commit d11e247

Browse files
committed
autotrader discount
1 parent 9283f19 commit d11e247

File tree

5 files changed

+56
-2
lines changed

5 files changed

+56
-2
lines changed

src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
- [Range](./ships/sea-battles/projectiles/range.md)
5151
- [Impact](./ships/sea-battles/projectiles/impact.md)
5252
- [Reefs](./ships/sea-battles/reefs.md)
53+
- [Auto Traders](./auto-traders.md)
5354
- [Letters](./letters.md)
5455
- [Charge](./letters/0a-charge.md)
5556
- [Indictment](./letters/19-indictment.md)

src/auto-traders.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Auto Traders
2+
Both captains and administrators are represented by the same struct.
3+
The following fields have been identified:
4+
```c
5+
struct auto_trader
6+
{
7+
unsigned __int16 field_0_next_auto_trader_index;
8+
signed __int16 field_2;
9+
int field_4_timestamp;
10+
unsigned __int8 field_8;
11+
unsigned __int8 field_9_navigation_skill;
12+
unsigned __int8 field_A_trade_skill;
13+
unsigned __int8 field_B_combat_skill;
14+
__int16 field_C_daily_wage;
15+
char field_E;
16+
unsigned __int8 field_F_merchant_index;
17+
};
18+
```
37.3 KB
Loading
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import logging
2+
from matplotlib import pyplot as plt
3+
4+
5+
def calculate_discount(xp: int):
6+
return 100 - (2 * (50 - xp // 43))
7+
8+
9+
LOGGER = logging.getLogger()
10+
plt.clf()
11+
plt.title("Auto Trader Discount")
12+
plt.xlabel("Experience")
13+
plt.ylabel("Discount (Percent)")
14+
15+
x_data = []
16+
y_data = []
17+
for i in range(0, 251):
18+
x_data.append(i)
19+
y_data.append(calculate_discount(i))
20+
21+
plt.plot(x_data, y_data)
22+
plt.savefig("buying-price-autotrader-discount.png", dpi=200)

src/towns/ware-prices/buying-price.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Buy Price
1+
# Buying Price
22
The `get_buy_price` function at `0x0052E430` takes a ware, town, and buy amount and returns the transaction price.
33

44
## Formula
@@ -29,7 +29,7 @@ where \\(w\_i\\) is the amount being bought from \\(i\\) and \\(f\\) is defined
2929

3030
where \\(w\_{relative\\_stock}\\) and \\(w\_{relative\\_remain}\\) are the stock's and remainder's offsets in the interval and \\(m\_i\\) and \\(v\_i\\) are defined as:
3131

32-
|Bracket|\\(m\_i\\)|\\(v\_i\\)|
32+
|Interval|\\(m\_i\\)|\\(v\_i\\)|
3333
|-|-|-|
3434
|0|4|2.5|
3535
|1|1.5|0.5|
@@ -48,3 +48,16 @@ Let's assume we buy pig iron from a town with the following thresholds:
4848

4949
If we buy one bundle (2000), the resulting prices at different stock levels would be:
5050
![image](buying-price-pigiron.png)
51+
52+
## Auto Trader Discount
53+
Auto traders (captains and administrators) get a discount depending on their trade skill.
54+
The discount is calculated as follows:
55+
```python
56+
100 - (2 * (50 - xp // 43))
57+
```
58+
![image](buying-price-autotrader-discount.png)
59+
60+
The calculation can be observed at `0x004D5347` for captains and at `0x004FF7E8` for administrators.
61+
Since a new discount is unlocked every 43 experience, auto traders reach the maximum discount at 215 experience, way before they reach level 5 at 250 experience.
62+
63+
The discount is applied after the transaction's amount has been determined.

0 commit comments

Comments
 (0)