Skip to content

Commit 6e4b6b0

Browse files
committed
more investigation, basic letters
1 parent 0037900 commit 6e4b6b0

File tree

7 files changed

+114
-2
lines changed

7 files changed

+114
-2
lines changed

src/SUMMARY.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
- [Bath House Bribe Failure](./operations/0043-bath-house-bribe-failure.md)
1616
- [Tavern Interaction](./operations/0052-tavern-interaction.md)
1717
- [Scheduled Tasks](./scheduled-tasks/0000.md)
18+
- [Criminal Investigation](./scheduled-tasks/0005-criminal-investigation.md)
1819
- [Update Shipyard Experience](./scheduled-tasks/0006-update-shipyard-experience.md)
1920
- [Celebration](./scheduled-tasks/0007-celebration.md)
2021
- [Update Sailor Pools](./scheduled-tasks/0026-update-sailor-pools.md)
@@ -48,6 +49,9 @@
4849
- [Range](./ships/sea-battles/projectiles/range.md)
4950
- [Impact](./ships/sea-battles/projectiles/impact.md)
5051
- [Reefs](./ships/sea-battles/reefs.md)
52+
- [Letters](./letters.md)
53+
- [Charge](./letters/0a-charge.md)
54+
- [Indictment](./letters/19-indictment.md)
5155
- [Modloader](./modloader.md)
5256
- [Known Bugs](./bugs.md)
5357
- [New Settlement Ware Production](./bugs/new-settlement-ware-production.md)

src/ch05-03-reputation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ TODO list options
6262

6363
## Social
6464
`local_social_rep` is the merchant's social reputation in the town.
65-
It is changed through by many actions, and degrades over time.
65+
It is changed through many actions, and degrades over time.
6666

6767
### Recurring Constants
6868
The following values appear in multiple calculations, and appear to have fixed values.

src/letters.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Letters

src/letters/0a-charge.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Charge
2+
Charge letters are sent by criminal investigation scheduled tasks.
3+
4+
## Text
5+
A charge letter always starts with *Today, you have been charged for the following reason*.
6+
The following text depends on the crime type:
7+
8+
|Crime Type|Text|
9+
|-|-|
10+
|5|*You have been seen behaving indecently.*|
11+
|6|*You are accused of heresy.*|
12+
|7|*You have stated that the world is round.*|
13+
|8|*You stand accused of taking part in a punishable offence, undermining the good of the Hanseatic League.*|
14+
15+
Finally the suffix *We will thoroughly examine this charge and inform you of the outcome of investigations as soon as possible* is appended to every accusation letter.

src/letters/19-indictment.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Indictment
2+
Indictment letters are sent by criminal investigation scheduled tasks.
3+
4+
## Text
5+
The text depends on the crime type:
6+
7+
|Crime Type|Content|
8+
|-|-|
9+
|0|*Severe charges have been made against you. The court will be provided with evidence that you met in %s in the town of %s with lawless elements, and obviously made criminal plans with them.*|
10+
|1|*You are accused of recently committing a breach of the rules of the Hanseatic League by breaking the Boycott of %s. Several traders observed you in this law-breaking deed.*|
11+
|2|*Several witnesses have sworn that they recognised your ship %s during the recent pirates attack, and that it was flying the pirate's flag.*|
12+
|3|*A worthless scoundrel was taken into custody in %s today, as he was breaking into the trading office of %s %s in pursuit of his criminal activities. Under careful questioning, he admitted the deed, and said, that you had paid him, to carry out this treacherous burglary.*|
13+
|4|*A capable trader recently succeeded in boarding a cowardly pirate ship and arrested the captain. At first, he did not admit anything, but couldn't hold out against our penetrating interrogation, and admitted it was your idea and with your support that he did this.*|
14+
|8|*You stand accused of taking part in a punishable offence, undermining the good of the Hanseatic League.*|
15+
|9|*Several witnesses to a recent pirate attack, have sworn that they recognised your ship, %s with a pirate flag run up the mast and firing on Hanseatic League ships.*|
16+
|10|*Several witnesses to a recent pirate attack, have sworn that they recognised your ship %s with a pirate flag run up the mast and plundering Hanseatic League ships.*|
17+
|11|*Several witnesses to a recent pirate attack, have sworn that they recognised your ship %s with a pirate flag run up the mast and sinking Hanseatic League ships.*|
18+
|12|*Several witnesses to a recent pirate attack, have sworn that they recognised your ship %s with a pirate flag run up the mast and capturing Hanseatic Leagueague ships.*|
19+
|13|*Several witnesses to a recent pirate attack on %s have sworn that they recognised your ship %s displaying a pirate flag run up the mast.*|
20+
|14|*Several witnesses to a recent pirate attack on %s have sworn that they recognised your ship %s displaying a pirate flag run up the mast and firing on the town's defences.*|
21+
|15|*Several witnesses to a recent pirate attack on %s have sworn that they recognised your ship %s displaying a pirate flag run up the mast, breaching the town's defences and plundering the town's coffers.*|
22+
23+
The suffix *We will investigate this atrocious charge. Expect a message in the near future, which will inform you of the results of our investigations* is appended to every indictment letter.

src/operations/0052-tavern-interaction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ An investigation is started only if all of the following conditions are met:
3333
- The following formula is true: `(rand & 0x3ff) < 102`
3434
- The following formula is true: `weaponsdealer_timestamp < now + 0x200`
3535

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`.
36+
If all conditions are met, a criminal investigation scheduled task is scheduled to `(now + 0x200) | 0x80`, and the weapons dealer timestamp is set to `now`.
3737

3838
## Burglar
3939
The burglar is handled like the weapons dealer, except the exceptions for alderman, local mayor and town status don't exist.
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Criminal Investigation
2+
3+
## Begin
4+
When a criminal investigation task is executed for the first time, the status is `crime_investigation_status_pending`.
5+
The task handler sends a *Charge* or *Indictment* letter to the offending merchant, sets the status to `crime_investigation_status_investigating`, and reschedules the task according to the result of the following computation:
6+
```c
7+
(now + (((now & 7) + 8) << 8)) | 0x80
8+
```
9+
10+
The lower 3 bits of the current time are used as a synchronized pseudorandom number ranging from `0` to `7`.
11+
To that number `8` is added, and the result is shifted by `8` to get a timespan between 8 to 15 days.
12+
That timespan is added to the current time, and the 8th bit is set to constrain the time of day between 12:00 and 24:00.
13+
14+
Both random fields are filled with the result of `rand()` with a `RAND_MAX` of `32767`.
15+
16+
## Verdict
17+
TODO
18+
19+
## Scheduled Task Data
20+
The following task fields have been identified:
21+
```c
22+
struct scheduled_task_criminal_investigation
23+
{
24+
unsigned __int8 field_0_merchant_index __tabform(NODUPS);
25+
unsigned __int8 field_1_town_index;
26+
char field_2;
27+
unsigned __int8 field_3_hometown_index;
28+
int field_4_timestamp;
29+
crime_type field_8_crime_type;
30+
crime_investigation_status field_9_status;
31+
unsigned __int16 field_A_random1;
32+
unsigned __int16 field_C_random2;
33+
signed __int16 field_E;
34+
};
35+
```
36+
37+
where `crime_type` was found to be:
38+
```c
39+
enum crime_type : unsigned __int8
40+
{
41+
crime_type_criminal_plans = 0x0,
42+
crime_type_boycott_broken = 0x1,
43+
crime_type_pirate_attack = 0x2,
44+
crime_type_burglary = 0x3,
45+
crime_type_pirate_sponsor = 0x4,
46+
crime_type_indecent_behaviour = 0x5,
47+
crime_type_heresy = 0x6,
48+
crime_type_round_world = 0x7,
49+
crime_type_undermining_league = 0x8,
50+
crime_type_pirate_firing_on_ships = 0x9,
51+
crime_type_pirate_plundering_ships = 0xA,
52+
crime_type_pirate_sinking_ships = 0xB,
53+
crime_type_pirate_capturing_ships = 0xC,
54+
crime_type_pirate_attacking_town = 0xD,
55+
crime_type_pirate_firing_on_town = 0xE,
56+
crime_type_pirate_plundering_town = 0xF,
57+
};
58+
```
59+
60+
and `crime_investigation_status` was found to be:
61+
```c
62+
enum crime_investigation_status : unsigned __int8
63+
{
64+
crime_investigation_status_pending = 0x0,
65+
crime_investigation_status_investigating = 0x1,
66+
crime_investigation_status_confiscation_successful = 0x2,
67+
crime_investigation_status_unknown = 0x3,
68+
};
69+
```

0 commit comments

Comments
 (0)