M1c: weather, snap building, shelter, beds and regrowth

- Seeded weather (clear/cloudy/rain/storm, snow and blizzards on cold days
  and above the snowline), lightning, synthesised rain/wind/thunder sound
- Rain/snow particles stopped by roofs; wet ground, settled snow and wind
  via global shader uniforms
- Snap-together wood floor, wall, door, roof and gable with structural
  support, collapse and X to dismantle
- Shelter detection: dry under a roof, warmer and Rested inside with a fire;
  rain burns an uncovered campfire faster
- Bed sets the spawn point and lets you sleep through the night
- Trees, boulders and ground pickups regrow; timers saved
- Grass cleared under floors; shorter HUD hint
- New test_weather_building suite (62 checks) and tests/run_all.sh, which
  also fails on script errors
This commit is contained in:
Paul Bailey
2026-11-04 10:16:41 +00:00
parent fc7eb3cfed
commit fed96ef118
36 changed files with 2421 additions and 58 deletions

View File

@@ -55,7 +55,13 @@ Item fields: `id`, `name`, `description`, `stack`, `category`
| Animals *(M1d)* | weapon | raw meat, hide, bone |
Tool **tiers** gate harder resources later (e.g. iron ore needs a tier-2
pickaxe). Felled trees leave stumps. Resources regrow over time *(M1c)*.
pickaxe). Felled trees leave stumps.
**Regrowth** *(built in M1c, `props.gd`)*: felled trees grow back after
2400 s (2 days), mined boulders after 3600 s, picked-up sticks/stones/flint/
mushrooms after 900 s. A timer waits (retries every 2 min) while you're
standing on the spot or something is built there. Timers are saved, and
sleeping advances them.
### 2.4 Crafting & stations
Recipes list inputs, an output and an optional **station** that must be within
@@ -65,12 +71,34 @@ panel shows every recipe you know, greyed out with the missing inputs in red.
### 2.5 Building
- **Placement mode**: holding a placeable shows a ghost preview (green = valid,
red = blocked). R rotates it, left-click places it.
- M1a pieces: campfire, workbench, chest.
- *(M1c)* Snap-together pieces: wood floor, wall, door, roof, stairs, with
snap points and Valheim-style **structural support** (stability falls off
with distance from the ground; unsupported pieces collapse).
- **Shelter detection**: you count as sheltered when rays upward hit a roof and
most sideways rays hit walls. That drives "dry" and "rested" status.
- M1a pieces: campfire, workbench, chest. M1c adds a bed.
- *(built in M1c)* Snap-together wood pieces, crafted at a workbench
(shift-click Craft makes 5): floor (2 wood), wall (2), door (4), roof
(2 wood + 1 fiber), gable (1). Everything is 2 m on a side. A roof rises
1 m over 2 m, so two roofs from opposite walls of a 4 m hut meet at a ridge,
and gables close the ends. Geometry and snap points live in
`build_piece.gd`, rules in `build_system.gd`.
- **Snapping**: the ghost sits on your crosshair, then moves to the nearest
pair of snap points (its own and a nearby piece's), with rotation locked to
that piece's 90-degree grid. R turns building pieces a quarter turn. Away
from other pieces, floors sit level on the highest ground under them.
- **Support**: touching the ground = 100%. Otherwise a piece takes the best
of its neighbours minus 10% going up/down or 25% sideways. Under 30% it
can't be placed, so an overhang reaches about 4 floors.
- **Dismantling**: X on any placed piece puts it back in your inventory
(chests must be empty, graves can't be). Pieces left below 30% support
collapse and come back to you too. Loose chests/fires/beds drop to the
ground.
- **Shelter detection**: roofed = 3 of 5 rays straight up hit a building piece.
Sheltered = roofed and at least 6 of 8 sideways rays hit walls within 8 m.
Roofed keeps rain off you (and off a campfire). Sheltered cuts the weather's
chill to a quarter, adds +8 warmth, and with a fire nearby makes you Rested
after 20 s (stamina regen +50% for 5 min).
- **Bed**: E sets your spawn point (death respawns you there while it
stands). E again at night (19:30 to 05:30) sleeps until 06:00 if the bed is
sheltered: the clock, fires, regrowth and weather move on, you lose a
little food, and you wake dry, warm and Rested.
- Grass doesn't grow through floors.
### 2.6 Survival stats *(M1b)*
| Stat | Drains from | Restored by | At zero |
@@ -103,10 +131,26 @@ Built in M1b (`scripts/player/survival.gd`), current numbers:
- Day/night cycle: 20 real minutes per day by default. The sun, sky, fog and
ambient light follow time of day. Nights are dark enough that a campfire or
torch matters.
- Weather is a seeded state machine: clear → cloudy → rain → storm, plus
**snow** on cold days and always near the snowline. Each state sets the
cloud cover, fog, wind (grass/trees already read wind), particles and
sound, plus a warmth modifier. Transitions blend over about a minute.
- *(built in M1c)* Weather is a function of the world seed and the absolute
world time (`weather.gd`), so it isn't saved and every M2 client can
compute the same weather. A slow noise "front" picks the state. Measured
over 60 days on seed 1337: clear 38%, cloudy about 30%, rain/snow 33%,
storm 12%. A wet spell lasts about 6 minutes. A new world's first
10 minutes are always clear.
- About 1 day in 4 (never day 1) is a **cold day** (-8 warmth): rain falls as
snow and storms become blizzards. Above the snowline (28 m) it always
snows.
- Warmth from weather: cloudy -3, rain -6, storm -12, snow -14, blizzard -24.
Rain on you (no roof) keeps you Wet. Snow chills but doesn't soak. Rain on
an uncovered campfire burns its fuel up to 4x faster.
- Each state sets cloud cover, sun and ambient light, fog, wind and
precipitation, blending over about 50 s. Storms flash lightning, with
thunder 0.5 to 2.5 s later.
- Visuals and sound (`weather_fx.gd`, client side): GPU rain and snow
particles stopped by a heightfield collider, so it doesn't rain indoors.
Wet ground, settled snow (on terrain, rocks, grass and tree crowns) and wind
strength are global shader uniforms. Rain, wind and thunder sounds are
synthesised from filtered noise, and rain is muffled under a roof.
### 2.8 Creatures & hunting *(M1d)*
- **Rabbit**: skittish, fast, gives a little meat.
@@ -137,7 +181,9 @@ Built in M1b (`scripts/player/survival.gd`), current numbers:
inventory, hotbar slot; placed pieces and chest contents; tree and boulder
damage, stumps, mined rocks; collected pickups. Everything else regenerates
from the seed. Since M1b it also stores stats, time of day, bush regrowth
timers, campfire fuel and graves. *(Later: weather.)*
timers, campfire fuel and graves. Since M1c: building pieces (door open or
shut), the bed spawn point and regrowth timers. Weather isn't saved: it
follows from the seed and the time.
### 2.11 Death *(built in M1b)*
- On death you respawn at your bed (or the island spawn) and leave a **grave
@@ -163,7 +209,7 @@ Built in M1b (`scripts/player/survival.gd`), current numbers:
|---|---|---|
| **M1a** *(done)* | items/recipes data, inventory + hotbar, pickups, chop/mine with tools, crafting UI, campfire / workbench / chest placement, chest storage, pause menu, **title screen + world slots + save/load + autosave** (pulled forward from M1c) | you craft an axe, fell a tree, build a fire, stash wood in a chest, quit and continue |
| **M1b** *(done)* | hunger/warmth/stamina/health HUD, day/night cycle with moon and stars, campfire warmth + fuel, cooking, bushes (fiber, berries), mushrooms, torches, **death + grave bag** (pulled forward from M1c) | you survive your first night by the fire |
| **M1c** | weather (rain, storm, snow) + wet/shelter, snap building (floor/wall/roof/door) with support, bed spawn point, resource regrowth | you build a hut and wait out a storm |
| **M1c** *(done)* | weather (rain, storm, snow, blizzard, lightning, sound) + wet/shelter/rested, snap building (floor/wall/door/roof/gable) with support, dismantling and collapse, bed spawn point + sleeping, resource regrowth | you build a hut and wait out a storm |
| **M1d** | rabbit/deer/boar AI, club/spear/bow, hides, cooked food buffs | you hunt a deer and eat its meat |
## 5. Open decisions (current defaults in bold)