B9: Loot tables and containers

Seeded loot at every point of interest's loot markers, rolled once per match
from the "loot" stream by LootSet.plan() and placed by Simulation.place_loot().

- Each marker holds a sea chest (chance by location) or floor loot (rolls on
  the location's weapon/consumable/ammo/nothing weights). Weapons roll a tier
  from the location's tier weights and come with their ammunition; chests
  hold a weapon (best of two tier rolls), a consumable and spare ammunition.
- Interact opens the nearest closed chest in reach unless a pickup is nearer,
  and spills its contents as pickups.
- Washed-up crate props hold one roll of the crate table and spill it when
  broken by any means.
- If the rolls leave fewer POI weapons than LOOT_MIN_POI_WEAPONS (one per
  player in a full lobby), extra weapon rolls top up floor spots.
- Chest and crate state is part of state_hash(). ServerLoop places loot.

Tests: test_loot (12), including a statistics run of 1,000 loot seeds over
four generated islands that checks tier shares against the tables, that
shrines beat hamlets, and that every match has a weapon per player at POIs
and 1.25 per player counting crates.

Closes #23

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-11 20:16:20 -05:00
co-authored by Claude Opus 5.5
parent 0c6ad36105
commit 0013a81658
9 changed files with 677 additions and 6 deletions
+20
View File
@@ -225,6 +225,26 @@ used up; taking damage doesn't. An item that would do nothing can't be started.
| Tar Patch | Adds a little armor, quickly |
| Cork Vest | Adds a lot of armor |
### Loot
Loot is rolled once per match from the seed, when the match places it, so the same seed
always gives the same loot and nothing depends on who gets somewhere first. Every loot
marker at a point of interest holds either a **sea chest** or **floor loot**. Chests are
likelier in exposed, high places (shrines, lighthouses) than in hamlets, and their
weapons roll their tier twice and keep the better one. A chest always holds a weapon
with its ammunition, a consumable and a spare ammunition pickup. Interact opens a chest
in reach and spills what it holds; a pickup that is nearer is taken first.
**Washed-up crates** on the beaches each hold one roll of their own table, spilled when
the crate is broken by any means.
Tables live in `LOOT_SOURCES`: per location, the chance of a chest, how many floor rolls,
weights for weapon, consumable, ammunition or nothing, and tier weights. Within a
category, rarer items are picked less often (`LOOT_RARITY_WEIGHTS`). If a match's rolls
leave fewer weapons at points of interest than `LOOT_MIN_POI_WEAPONS` (one per player in
a full lobby), extra weapon rolls are added to floor spots, so no match is starved. The
loot test checks all of this over 1,000 seeds.
A player has `PLAYER_MAX_HEALTH` health, up to `PLAYER_MAX_ARMOR` armor, which takes
damage first, and `INVENTORY_SLOTS` slots. The top `HEAD_HEIGHT` of the body takes
each weapon's headshot multiplier.