Skip to content

Commit 64602fa

Browse files
committed
tavern interaction, bath house
1 parent 3c68e84 commit 64602fa

File tree

4 files changed

+113
-1
lines changed

4 files changed

+113
-1
lines changed

src/SUMMARY.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
- [Storage](./basics/storage.md)
1111
- [Ship Types](./basics/ships.md)
1212
- [Ship Artillery](./basics/ship-artillery.md)
13-
- [Operations](./0010-operations/0000.md)
13+
- [Operations](./operations.md)
14+
- [Tavern Interaction](./operations/0052-tavern-interaction.md)
1415
- [Scheduled Tasks](./scheduled-tasks/0000.md)
1516
- [Update Shipyard Experience](./scheduled-tasks/0006-update-shipyard-experience.md)
1617
- [Celebration](./scheduled-tasks/0007-celebration.md)
@@ -29,6 +30,7 @@
2930
- [Taxes](./towns/taxes.md)
3031
- [Tavern](./towns/tavern.md)
3132
- [Sailors](./towns/tavern/sailors.md)
33+
- [Bath House](./towns/bath-house.md)
3234
- [Sieges](./towns/sieges.md)
3335
- [Initialization](./towns/sieges/initialization.md)
3436
- [Merchants](./ch05-00-merchants.md)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ The following operations have been identified:
8787
|0x37|Join Guild|
8888
|0x39|Bathe|
8989
|0x41|Form Militia Squad|
90+
|0x52|Tavern Interaction|
9091
|0xc2|Autosave|
9192
|0xc4|Advance Time|
9293
|0x9f|Start Ship Combat|
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Tavern Interaction
2+
3+
The tavern interaction operations are enqueued by the tavern's panel when switching between the tavern's pages.
4+
The following fields have been identified:
5+
6+
```c
7+
struct operation_tavern_interaction
8+
{
9+
int field_0_rand;
10+
int field_4_merchant_index;
11+
int field_8_town_index;
12+
tavern_interaction field_C_interaction_type;
13+
};
14+
```
15+
16+
Depending on the interaction type, one of the following actions may be done.
17+
18+
## 1
19+
20+
## 3 and 8
21+
22+
## 5
23+
24+
## Weapons Dealer
25+
If the interaction's merchant index is invalid, the town's weapons dealer is unlocked, and no other action is performed.
26+
This happens if a merchant navigates from the weapons dealer page to a different page.
27+
28+
Otherwise if the town's weapons dealder is unlocked, it'll be locked to the merchant, and a criminal investigation might be started.
29+
An investigation is started only if all of the following conditions are met:
30+
- The merchant is not the alderman
31+
- The merchant is not the mayor in the particular town
32+
- The town is not sieged, blocked, boycotted or under pirate attack
33+
- The following formula is true: `(rand & 0x3ff) < 102`
34+
- The following formula is true: `weaponsdealer_timestamp < now + 0x200`
35+
36+
If all conditions are met, the investigation scheduled task is scheduled at `(now + 0x200) | 0x80`, and the weapons dealer timestamp is set to `now`.
37+
38+
## Burglar
39+
The burglar is handled like the weapons dealer, except the exceptions for alderman, local mayor and town status don't exist.
40+
41+
## 9
42+
43+
## Leave

src/towns/bath-house.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Bath House
2+
3+
## Bribes
4+
Every town with a bathhouse has 4 councillors which can be bribed.
5+
6+
### Attendance
7+
Between 0 and 4 bribable councillors are present in the bath house.
8+
The bath house panel has an array of attendance selection timestamps at offset `0xd4`, whose entries denote when the attendance in a given town will be updated.
9+
These timestamps are updated to `now + 0x100` when
10+
- the bath house window is closed.
11+
- fast forward is activated.
12+
- the options screen is opened.
13+
- any window is opened after the bath house window has just been closed.
14+
15+
Therefore, continuously opening an individual bath house locks the current attendance.
16+
17+
Attendance is decided as follows:
18+
```python
19+
def will_attend(rand: int):
20+
return rand % 100 < 7
21+
```
22+
so each councillor has a 7% chance to attend.
23+
24+
### Price Formula
25+
The `town_calculate_expected_bribe` function at `0x00529E20` determines the amount of money the merchant needs to offer for the bribe to be successful.
26+
27+
It defines the following *bribe base factors* for each rank:
28+
29+
|Rank|Bribe Base Factor|
30+
|-|-|
31+
|Shopkeeper|0|
32+
|Trader|1|
33+
|Merchant|2|
34+
|Travelling Merchant|3|
35+
|Councillor|5|
36+
|Patrician|7|
37+
|Mayor|10|
38+
|Alderman|15|
39+
40+
The bribe result is calculated as follows:
41+
```python
42+
def calculate_expected_bribe(rank: int, already_bribed: bool):
43+
price = 500 * (rand % 11 + 4 * BRIBE_BASE_FACTORS[rank] + 16)
44+
if already_bribed:
45+
price *= 2
46+
return price
47+
48+
def calculate_bribe_result(amount: int, rank: int, already_bribed: bool):
49+
price = calculcate_expected_bribe(rank, already_bribed)
50+
if amount < price:
51+
return BribeResult.OK
52+
elif amount >= price * 1.5:
53+
return BribeResult.GOOD
54+
else:
55+
return BribeResult.FAILED
56+
```
57+
58+
The result can be identified by the councillor's response:
59+
60+
|Result|Response|
61+
|-|-|
62+
|Ok|"Aha, a bribe eh! But all right, I'll take your gold. We'll see what I can do for you at the appointed time."|
63+
|Good|"Oh, that's a very enticing sum. You can be certain of my loyalty."|
64+
|Failed|"What am I supposed to do with this pittance? You ought to realise yourself, that a man in my position expects a little more from someone of your standing."|
65+
66+
Both `Ok` and `Good` enqueue a *Bath House Bribe Success* operation, while `Failed` enqueues a *Bath House Bribe Failed* operation.

0 commit comments

Comments
 (0)