M2.5: wildlife, wolves, hunting, fishing and sleeping on the server

This commit is contained in:
Paul Bailey
2026-11-04 21:25:10 +00:00
parent 26be17b05f
commit a211fe4c63
20 changed files with 1258 additions and 88 deletions

View File

@@ -226,10 +226,39 @@ offline there's no server and your game decides, exactly as before.
- Characters are saved in `worlds/<world>/players/<player id>.json`, with
the world, so you come back where you left off.
Until later phases, while online: animals, hunting and fishing are off
(M2.5), and so is sleeping (it needs the sleep rule, M2.5). The HUD says so.
The server doesn't yet check that you're out of stamina when you sprint
(it charges you, but doesn't stop you).
**Wildlife, hunting, fishing and sleep** *(built in M2.5: `creature_net.gd`,
autoload CreatureNet)*.
- The server's world runs the animals and the wolf pack. Animals live
around every player (the budget per player, up to twice it however many
are on), and go once they're far from all of them. A player joining gets
some wildlife about them straight away.
- **The pack splits between the players it hunts**: wolf 1 takes the
nearest to the den, wolf 2 the next, preferring players away from a fire.
Each hunted player has their own circle and their own one-wolf-at-a-time
darts. Fire, torches and walls work per player as in single-player.
- Ten times a second everyone gets every animal, wolf and carcass (23 bytes
each, split so no packet goes over the MTU: an oversized unreliable packet
is simply lost) and every fishing float. Games show them as **puppets**
(`creature.gd`/`bobber.gd` `puppet`) that animate and can be hit or
butchered, and decide nothing. Something missing for a second goes.
- **Hitting** (club, spear thrust) sends the creature's id; the server runs
Actions.melee on your character there. **Shooting and throwing** send only
the aim: the arrow or spear starts from where the server knows your eyes
are. The server's projectile hits; everyone else's screens fly a copy for
show (sent once, when it's loosed). An arrow that misses lands as a
dropped item for anyone.
- **Fishing**: one float per player, on the server. Bites, misses and a
snapped line are told to the player whose float it is (`Actions.tell`).
- **Sleeping** follows `sleep` in `server.json`: `all_online` (default),
`half` or `anyone`. Getting into a bed you've claimed puts you "in bed"
(moving more than 1.5 m gets you out); once enough players are in bed
the night passes for everyone (fires burn down, things regrow, the clock
jumps to 06:00) and sleepers wake rested.
- The pack's howls and "the wolves are hunting tonight" go to everyone;
being bitten or gored flashes your screen red as in single-player.
Still to come: the server doesn't yet stop you sprinting when you're out of
stamina (it charges you, but doesn't stop you).
**Interest.** On a 320 m worldlet with 8 players, the server sends every
entity to everyone at first. Distance-based interest is a later
@@ -303,7 +332,7 @@ player" or "this player":
| **M2.2** *(done)* | player bodies and name tags; predicted movement, interpolation for others | two players walk around together at 100 ms simulated latency without visible rubber-banding |
| **M2.3** *(done)* | world state replicated: resource nodes, pickups, pieces, chests, fires, doors, clock, weather | one chops a tree and the other sees it fall; one builds a wall and the other walks into it |
| **M2.4** *(done)* | intents as RPCs; per-player inventory, stats, diet, death and graves; per-player saves and migration | two players craft, eat, die and loot their own graves; an old single-player save loads |
| **M2.5** | wildlife and wolves server-side, projectiles, fishing, sleeping with the rule | a pack hunts two players at once; arrows hit on both screens |
| **M2.5** *(done)* | wildlife and wolves server-side, projectiles, fishing, sleeping with the rule | a pack hunts two players at once; arrows hit on both screens |
| **M2.6** | server rules: PvP, raiding, locks and friends, death penalty, difficulty; admin console and chat | each preset (co-op, rivals, adversarial) behaves as described in §4 |
| **M2.7** | hosting polish: "Host game" button, systemd and launchd samples, backups, a Tailscale how-to in the docs | Paul runs it on the home server, and a friend joins over Tailscale and plays for an hour |