diff --git a/docs/plan.md b/docs/plan.md new file mode 100644 index 0000000..3c2e29f --- /dev/null +++ b/docs/plan.md @@ -0,0 +1,433 @@ +# Harvest Season — post-overhaul fix batch (2026-10-06) + +Status: planned, not started. Seven issues the user found playtesting the alien overhaul +(`docs/tasks.md` #1–#15, all merged by 3e85104). Tasks are numbered **#16–#22** to continue that +list; the user's original item number is in brackets. Root causes were traced in code on +2026-10-06. Line numbers point at decf96b, so re-check them before editing. + +## Ground rules for workers + +- **Godot binary:** `godot` is not on PATH here. Use `~/Downloads/Godot_v4.7.2-stable_linux.x86_64` + everywhere these docs say `godot`. Exit code 127 means the binary wasn't found, not a pass. +- **Tests:** `godot --headless --path . --script res://game/tests/run_tests.gd`. The exit code is + the failure count and is never 0 here: about 25 checks fail because of tuning, and the + test_roster "All three" check is flaky. Run the suite before editing, diff the FAIL lines + afterwards, and judge your task by new FAIL lines only. One suite: `-- --suite=test_x`. +- **Parallel worktrees:** give each headless run its own `XDG_DATA_HOME` so `user://` saves don't + collide. +- **`farm.tscn`:** edit it as text. A headless `ResourceSaver.save()` drops the `uid=` lines; if + you must re-save from a script, restore them the way `game/tools/build_prop_collision.gd` does. +- **Co-op:** changing the shape of `state.to_dict()` or the snapshot/event wire format means + bumping `CoopSession.PROTOCOL` (`coop_session.gd:48`, currently 3). Changing the save format + means bumping `FarmState.VERSION` (`farm_state.gd:11`, currently 6) and adding a `migrate` step + in `save_game.gd`. For the two-process check, run `game/tools/coop_smoke.gd` (see + `game/COOP.md`). +- **Graph:** after modifying code, run `graphify update .`. + +## Decisions (resolved 2026-10-06) + +1. **Crop fields move onto the south brown soil.** The user chose this over laying soil under + the current spot. The playable map extends south to include them (#20). +2. **Animals roam the whole farm and are never lost on their own.** An animal that leaves an open + pen becomes loose again. An animal is lost only when an Alien carries it off the map. A closed + pen still protects the animals inside it (#21). + +## Defaults (assumed; flip any of these on request) + +- **Pouch:** `pouch_capacity` stays shared, so one `pouch_upgrade` purchase grows both pouches. + - Goop from a kill goes to the killer's pouch. Bomb and turret kills credit the nearest avatar. + - When the partner leaves, their pouch is deposited in the shed. +- **Torch band:** about 4.5 m long (measured from the muzzle) and 1.6 m wide. Config-tunable. +- **Alien Ray beam:** about 20 m long. It stops at walls and pierces enemies, hitting each one + along it (capped by config). Damage is applied per tick while fire is held. +- **UFO model:** a flattened saucer built in code from a disc, a dome, a rim ring and small + lights. No imported asset. +- **Crop models:** existing ithappy prefabs from `assets/farm/ithappy/farm/prefabs/assets/plant/`. + - Lettuce/cabbage: `plant_004` / `plant_005` (≈0.45 m heads). + - Corn: `plant_001` (≈2.66 m stalk). + - These were picked by size and palette only. Confirm them in the editor and fall back to + primitives if they don't read right. + +## Tasks + +### #16 [1] Per-player pouch in co-op + +**Root cause:** this is by design, not a sync bug: there is exactly one pouch. +- `ResourceStore` keeps a single `pouch` and `pouch_capacity` (`resource_store.gd:13-15`) in the + shared `FarmState.resources` (`farm_state.gd:102`). +- That state is replicated whole to the client (`coop_session.gd:321-328`, applied at `621-638`). +- `game/COOP.md` says "Everything is shared: the shed, the pouch…", and `test_coop.gd:181-182` + asserts the shared pouch. + +Every pouch path goes through `campaign.state.resources`: +- **Gathering:** `interactions.gd:296` (room check) and `:339` (`add_to_pouch`). +- **Deposit:** `interactions.gd:182-185`. A partner idling in the shed instantly banks whatever + the other player gathers. +- **Pouch-first paying:** `resource_store.gd:85-93`, via `FarmState.pay` (`farm_state.gd:222`). + Callers: + - repair, `interactions.gd:226` + - patch, `scarecrow.gd:148` + - structures, `structure_system.gd:243,371,428` + - upgrades, `upgrades.gd:91,105` +- **Goop drop:** `farm_sim.gd:636`. +- **`pouch_upgrade`:** `upgrades.gd:120-121`. + +**Approach:** +- **Storage:** the shed stays shared. The pouch becomes one per slot (`pouches[slot]`, where slot + 0 is the host or solo player), with one shared `pouch_capacity`. +- **Slot parameter:** `add_to_pouch`, `deposit`, `available`, `missing`, `can_afford` and `pay` + take a `slot` that defaults to 0, so solo callers don't change. +- **Callers pass the acting avatar's slot:** + - `Interactions` uses `kit.slot`. + - The Scarecrow patch uses its own slot. + - The host's `_do_request` uses the requester's slot for "place" and "buy". + - `Upgrades.buy` and `StructureSystem.place` take a slot. +- **Goop:** credit the killer's slot (see Defaults). +- **HUD:** `resource_hud.gd:36-37` shows the local avatar's pouch. Retarget it in + `FarmSim.set_local` (`farm_sim.gd:522`). Also update `review_panel.gd:131` and + `tutorial.gd:122`. +- **Partner leaves:** `remove_partner` (`farm_sim.gd:500`) deposits the partner's pouch into the + shed. +- **Versions:** bump `FarmState.VERSION` 6→7, with a `save_game.gd` `migrate` step that adds an + empty partner pouch. Bump `CoopSession.PROTOCOL` 3→4. +- **Docs:** `game/COOP.md`, `game/RULES.md`. + +**Files:** +- Code: `resource_store.gd`, `farm_state.gd`, `save_game.gd`, `interactions.gd`, `scarecrow.gd`, + `structure_system.gd`, `upgrades.gd`, `farm_sim.gd`, `coop_session.gd`, `resource_hud.gd`, + `review_panel.gd`, `tutorial.gd` +- Docs: `COOP.md`, `RULES.md` +- Tests: `test_coop.gd`, `test_save.gd`, `test_economy.gd`, `test_cycle.gd`, `test_flow.gd`, + `game/tools/soak_night.gd` + +**Acceptance:** +- In `test_coop`: + - P2's gathering fills only P2's pouch. + - P1 standing in the shed doesn't bank P2's pouch. + - Each player pays from their own pouch plus the shed. + - One `pouch_upgrade` raises both capacities. +- In `test_save`, a v6 save migrates. +- Solo behaviour is unchanged, and there are no new FAIL lines. + +### #17 [2] Propane Torch sprays a band of fire + +**Root cause:** damage works, but there's nothing to see and the hit area is small. +- **Path:** `step()` → `_held(&"fire")` → `attack()` → `_use()` → `_torch_tick()` + (`scarecrow_combat.gd:267,288,383-385,474-479`). +- **Hit test:** `_cone_hit` (`:484-511`) measures `torch_range` 3.5 from the scarecrow's centre. + That reaches only about 2.45 m past the 1.05 m muzzle. It uses a 55° arc, hits at most 5 + targets, and deals 1 damage every 0.2 s. +- **Feedback the player gets:** + - A 0.09 s kick on an orange-tinted corn-shooter mesh, replayed on every tick + (`weapon_models.gd:28-29,68,143-150`). + - The pitchfork "stab" sound (`farm_audio.gd:300`). + - The enemy's hurt flash. +- **Test gap:** `test_weapons.gd:357-369` calls `attack_toward()` once. It checks no held fire and + no visual. + +**Approach:** +- **Band hit test:** add `_band_hit` beside `_cone_hit`. + - It projects each enemy onto the aim direction from the muzzle. + - A hit requires `0 ≤ along ≤ torch_range` and `|across| ≤ torch_width/2 + hit radius`. + - Keep the `_clear_line` check. +- **Config:** drop `torch_arc`, add `torch_width`, and lengthen `torch_range` (see Defaults). +- **Flame visual:** a `CPUParticles3D` on the torch pivot, sized to the band (pattern: + `structure_system.gd:809-830`). + - `_use` / `_show_attack` light it, and a short timeout (about 1.5 × `torch_tick_interval`) keeps + it lit. It stays lit while fire is held and goes out on release. + - Stop replaying the kick on every tick. +- **Co-op:** the existing `["attack", slot, w]` events (`coop_session.gd:163`, applied at + `687-693`) light the flame on the partner's screen. No protocol change is needed. For a remote + avatar, take the direction from the model's yaw. +- **Sound:** give the torch its own `burned` signal and sound in `farm_audio.gd`, instead of + `stabbed`. + +**Files:** `scarecrow_combat.gd`, `weapon_models.gd` (or a new `torch_flame.gd`), +`game_config.gd` / `game_config.tres`, `farm_audio.gd`, `test_weapons.gd`. + +**Acceptance (`test_weapons`):** +- An enemy in the band ahead is hit. +- An enemy beside it, outside the width, is not hit. +- An enemy behind is not hit. +- Holding fire over N steps ticks repeatedly and stops on release (use `Input.action_press` as + `test_theft.gd:191-201` does). +- The flame is visible while fire is held and hidden after release. + +### #18 [3] Alien Ray fires a beam + +**Root cause:** `_shoot_alien_ray` (`scarecrow_combat.gd:448-456`) is a copy of `_shoot_potato`. +It fires one non-piercing projectile through `_shots.fire`, using the shared kernel mesh +(`farm_projectiles.gd:58-62`), every 0.9 s. +- Its description text (`game_config.gd:156`) already says "beam". +- The root `plan.md` "no hitscan" rule was for the original prototype; no code or test enforces + it. + +**Approach:** +- **Held weapon:** like the torch, it ticks every `alien_ray_tick_interval` while fire is held. +- **Each tick:** + 1. Cast a world ray (WORLD_LAYER) from the origin through the muzzle, out to + `alien_ray_range`. This gives the beam segment, clipped at the first wall. + 2. Damage every enemy within `alien_ray_width/2 + hit radius` of that segment, up to + `alien_ray_pierce` enemies. + 3. This needs a new EnemySystem query that returns all hits; `sweep_hit` + (`enemy_system.gd:501`) returns only the nearest. +- **Visual:** a top-level `MeshInstance3D`: an unshaded, emissive green cylinder or box, oriented + and scaled from the muzzle to the hit point each frame while firing. +- **Co-op:** the visual uses the same hold-timeout and attack-event path as the torch. The + partner recomputes the wall clip locally, which is deterministic because the world geometry is + static. +- **Config:** + - Remove `alien_ray_speed` and `alien_ray_lifetime`. + - Add `alien_ray_range` (≈20), `alien_ray_tick_interval`, `alien_ray_width` and + `alien_ray_pierce`. + - `alien_ray_damage` becomes damage per tick. +- **Counters:** add a `beam_ticks` counter to `attacks()` (`scarecrow_combat.gd:316-317`) and stop + incrementing `shots_fired`. +- **Comments:** update the headers at `scarecrow_combat.gd:38-42` and `weapon_models.gd:14-17`. + +**Files:** `scarecrow_combat.gd`, `enemy_system.gd`, `weapon_models.gd`, `game_config.gd` / +`game_config.tres`, `test_weapons.gd`. + +**Acceptance (`test_weapons`):** replace `_buy_equip_hit(... alien_ray ...)` at `:356` and keep +the buy/equip checks. Then check: +- A far target is hit on the same step. +- A target behind a wall is not hit. +- Two enemies in line are both hit. +- The beam mesh is visible while fire is held and hidden after release. + +**Order:** #17 and #18 share files. Run #18 after #17, which sets the held-visual pattern. + +### #19 [4] UFO model built from primitives + +**Root cause:** all flyers are drawn by one MultiMesh (`HordeRenderer`) using one mesh. +- `farm_sim.gd:177-179` passes `EnemySystem.build_bird_mesh(0.0055)` as the only flyer mesh. +- `commit_render` (`enemy_system.gd:565-582`) writes every flyer into that one buffer. +- `horde_renderer.gd:21-41` overrides the material with `game/resources/thief.gdshader`. That + shader flaps vertices by `abs(VERTEX.x)` and has a single `base_color` uniform. + +**Approach:** +- **Mesh:** add `static func build_ufo_mesh()` to `enemy_system.gd`. + - It merges the `get_mesh_arrays()` of a CylinderMesh disc, a SphereMesh dome, a TorusMesh rim + and small sphere lights into one `ArrayMesh`, transformed into place, with an + `ARRAY_COLOR` per part. `build_bird_mesh` (`:608-625`) is the template. + - Centre it on its origin, with nothing more than about 1.5 m below. UFOs dive to + `land_altitude` 1.55 (`thief_behavior.gd:197-209`). + - Forward is −Z, with yaw only. +- **Renderer:** create a second `HordeRenderer` for UFOs in `EnemySystem.setup` (`:145-149`). +- **Shader:** a new `game/resources/ufo.gdshader`. It takes albedo from `COLOR`, has no flap and + an optional slow spin from `TIME`, and keeps the hit flash (`INSTANCE_CUSTOM.g`) and + `night_glow`. +- **Buffers:** `commit_render` fills one buffer per type. Mirror `write_new` (`:257`), + `move_slot` (`:599`) and `clear` (`:206-208`) on both renderers. +- **DayNight:** register the new material with DayNight (`day_night.gd:38-42,111-112`; + `farm_sim.gd:254`). +- **Sound (optional):** give UFOs their own arrival sound; today they reuse the crow's. + +**Files:** `enemy_system.gd`, `horde_renderer.gd`, new `game/resources/ufo.gdshader`, +`farm_sim.gd`, `day_night.gd`, `test_roster.gd`. + +**Acceptance:** +- In `test_roster`, a spawned UFO is in the UFO renderer's visible instances and not in the bird + renderer's. Crows are unchanged. +- Eyeball the saucer in a screenshot of night 5 or of the `ufos.tres` scenario. + +### #20 [5] New crop fields on the south brown soil, with their own plant models + +**Root cause (placement):** +- LettuceField (`farm.tscn:2244-2249`) sits at (−6, 0, 7) and CornField (`:2635-2640`) at + (7, 0, 7), each 10×10, on the green grass plane (`farm.tscn:127-132`). +- The brown soil is the ithappy `ground_008` / `ground_011` tiles (`farm.tscn:166-173`): + - `ground_011_004` lies under the sunflower Crop Field. + - `ground_008_004` (SW, x ≈ −25…7.5, z ≈ 14.6…45) and `ground_011_003` (SE, x ≈ 13.4…46, + z ≈ 14.2…45) are bare. Both are outside the playable map (z ≤ 15, `farm_zones.gd:11`) and + inside the "South Fields (outside the fence)" straw zone (`farm.tscn:3453`). +- The plant y offsets (0.288 / 0.535) were copied from CropField, which sits at y −0.36 + (`farm.tscn:1005`). So the new plants float about 0.36 m up. + +**Root cause (models):** +- `crop_unit.gd:11-13`: the `crop` field is cosmetic only, and nothing reads it. +- Every lettuce and corn unit's children are the sunflower prefabs `plant_007` / `plant_008` + (`farm.tscn:30-31`; e.g. `:2261-2264`, `:2652-2655`). +- The carried/dropped crop token is always `plant_007` (`loot_system.gd:60,159-161`). + +**Approach:** +- **Placement:** defaults below; confirm them with `game/tools/render_overview.gd --zones`. + - Lettuce/cabbage field: x −6…4, z 20…30, on the SW soil. + - Corn field: x 24…34, z 20…30, on the SE soil. + - Match the zone y to the soil surface; CropField uses −0.36. +- **Map bounds:** extend `FarmZones.playable` south to cover the fields with margin: + `Rect2(-13, -45, 60, 80)`, i.e. z −45…35. + - The south side has no perimeter fence, so no fence work is needed. + - `roam` already reaches z ≈ 47. +- **Knock-on effects:** + - The nav grid (`farm_sim.gd:132`, built over `playable.grow(5)`) grows about 33%. Measure the + flow-field rebuild time before and after. + - The spawn edge (`zones.edge(spawn_margin)`) moves south. The enemy and projectile bounds + (`farm_sim.gd:179,195`) follow automatically. + - The SouthFields zone's hay points at (−10, 25) and (24, 27) fall inside the new map; (24, 27) + is inside the corn field. Move the zone and those points south of z ≈ 37. Outside zones must + stay outside the playable map. +- **Thief targeting:** `ThiefBehavior.field_rect` is the bounding box of all three crop fields + (see `docs/followups.md`). With the fields this far apart it would cover most of the south map, + so switch to per-field rects. +- **Models:** + - Replace the new units' plant children: lettuce/cabbage get `plant_004` / `plant_005`, corn + gets `plant_001` (see Defaults). + - Pick the crop token per crop in `loot_system.gd`, from `_units[id].crop`. +- **Docs:** update `game/LAYOUT.md` (map size, zone table, crop units, SouthFields). + +**Files:** +- Code and scenes: `farm.tscn`, `farm_zones.gd`, `crop_unit.gd` (only if model choice moves into + code), `loot_system.gd`, `thief_behavior.gd` +- Docs: `game/LAYOUT.md` +- Tests: + - `test_farm_layout.gd`: 60×60 check (`:29`), inside-playable and overlap checks (`:56-59`), + side names (`:112-113`), open south (`:139`), and `MAX_TRAVEL` (`:13`), which will have to + rise. + - `test_theft.gd`: its edge-cell list (`:35`) includes (20, 18), which is now inside the map. + +**Acceptance:** +- In `test_farm_layout`: + - Both new fields lie on the soil tiles' footprints and inside the playable map. + - No zones overlap, and outside zones are outside the map. + - Lettuce and corn units don't use the sunflower prefabs. +- The staged-field cases in `test_theft` (`:300-366`) still pass. + +**Risk:** the new fields are about 35–40 m from the scarecrow's start at (3, −13), so night defence +spreads out further. Playtest the balance. + +### #21 [6] Animals roam the whole farm and are never lost on their own + +**Root causes:** +1. **An open pen leaks at night.** During NIGHT and DAWN, while `pen_open` is true, `_wander_out()` + (`animal_system.gd:406-425`) turns one calm HOME animal into DROPPED every + `animal_wander_interval` (10 s; the first after about 3 s). Since #11 removed the scene fence and + the starting gate, `pen_open` stays true until the whole ring is built. +2. **DROPPED animals always run for the edge and are deleted.** `_stray()` (`:322-336`) follows + `escape_field`, then `loot.animal_escaped()` → `_lose` (`loot_system.gd:693-703`) marks the + animal LOST and hides it (`animal_system.gd:457`). + - The escape goal is the outline of `zones.edge(3)` (`farm_sim.gd:151`). The pen's west wall + is at x = −10, only about 5 m from the west exit band, which is the user's "a few steps". + - This runs in any phase. + - Animals also become DROPPED when `FOLLOW_LEASH` breaks (more than 20 m from their scarecrow; + `animal_system.gd:33,346-351`) or when a carrier is killed (`loot_system.gd:394-403`). +3. **Loose animals are tethered.** `LOOSE_WANDER_RADIUS` is 0.8 (`animal_system.gd:35`), and + `_wander_goal` (`:397-403`) stays around `_loose_spot`. The spots (`game_config.gd:92-95`) hug + the pen; the x = −12 spots are about 3 m from the exit band. + +**Approach (Decision 2):** +- **No self-escape:** remove `_stray`'s edge path and `animal_escaped`. + - A DROPPED animal (an Alien dropped it, its carrier was killed, or its leash broke) becomes + LOOSE where it stands. + - Keep the two real loss paths: a thief carrying an animal off the map (`thief_behavior.gd:508-512` + → `loot.escape`), and `on_enemy_removed` with reason LEFT (`loot_system.gd:493-498`). +- **Open pen:** `_wander_out` turns HOME into LOOSE (no escape) and calls `FarmState.unpen_animal` + (`farm_state.gd:192`). Keep `pen_open` and its messaging. +- **Roaming, day and night:** `_wander_goal` picks a goal 4–8 m from the animal's current + position. The goal must be: + - inside the playable rect shrunk by a margin (pass the rect in `setup`, wired at + `farm_sim.gd:185`; `behavior.farm_rect` already exists), + - walkable (`nav.is_walkable`), + - reachable in a clear line (`nav.line_clear`, `farm_navigation.gd:187`). +- **Mornings:** `sync_from_state` (`animal_system.gd:153`) puts loose animals back at their loose + spots, so no new save fields are needed. Move the x = −12 spots inward. +- **Dawn:** `return_dropped` (`loot_system.gd:479-490`) auto-pens DROPPED animals at dawn. Remove + it, since no DROPPED animals remain by then. +- **Text:** fix every place that promises animals "wander out" or "run for the edge": + - header comments in `animal_system.gd:3-22` and `loot_system.gd:15-26` + - `RULES.md:179-195` + - the toast at `farm_sim.gd:335-337` + - `review_panel.gd:128-129` +- **`animals_strayed` event:** keep it (it now counts animals that left the pen). This avoids + churn in save data and tests (`test_save.gd:125`, `test_farm_state.gd:30`, `test_cycle.gd:155`, + `soak_night.gd:234`, `review_panel.gd:155`). +- **Leave as is:** followers become HOME as soon as they cross the unfenced pen rect + (`animal_system.gd:340`). + +**Files:** `animal_system.gd`, `loot_system.gd`, `farm_sim.gd`, `game_config.gd` / +`game_config.tres`, `review_panel.gd`, `game/RULES.md`, `test_targets.gd`. + +**Acceptance (`test_targets`):** +- Over a long day and night, loose animals roam more than 4 m but stay inside the playable map. + This replaces the "none wandered off" check in `_loose_start` (`:85-95`). +- An Alien-dropped animal becomes LOOSE, not LOST (`:105-107`, `:221-226`). +- At night an open pen lets animals out as LOOSE, and none become LOST (rework `_breach`, + `:286-340`). +- Carrying an animal off the map still loses it. +- `_make_loose` (`:507`) and `_leading` (`:279-281`) are updated to the new route into HOME. +- The `pen_open` checks in `test_structures` still pass. + +### #22 [7] The joining player can open the store + +**Status:** the cause is not confirmed; reading the code didn't show a blocker. The open path is +wired: +1. The host handles P2's press through `RemoteControls.take` (`interactions.gd:160`). +2. The partner's `Interactions` finds the ShedCounter in `setup` (`:93-101`) and focuses it in + `_nearest` (`:361-365`). +3. Having no panel, it emits `shed_requested` (`:271-277`), which becomes a `["shed"]` event + (`coop_session.gd:167`). +4. The client opens `sim.shed_panel` if it's daytime (`:701-703`). + +Purchases are already routed to the host: `buy_request` → `["buy", id]` (`:212-213`) → +`_do_request` (`:549-555`). + +**Co-op defects found on the way:** +- **No shop prompt on the client.** `_gather_node` (`coop_session.gd:804-813`) resolves only the + workbench and the gather nodes. So the client's replicated focus is null at the counter, and + its label never shows "[E / X] Shop" (`interactions.gd:399-401`, `shed_counter.gd:41`). +- **Presses can be silently dropped.** The host consumes P2's press on every tick + (`interactions.gd:160`), even when its lagging copy of P2 isn't within reach yet. +- **Pressing interact again doesn't close the shop on the client.** `_close_menu` + (`coop_session.gd:929-935`) ignores presses. +- **A partner's purchase doesn't equip the new weapon.** `bought` fires only on the local path + (`upgrade_panel.gd:136-138`, `farm_sim.gd:272-275`). + +**Approach:** +1. **Test first.** Add a failing test to `test_coop.gd`: + - Put `client.player` at `counter.global_position + (0, 0, 1.2)` and pump about 20 ticks. + - Press and release `interact`, then pump again. + - Assert `client.shed_panel.is_open`, `not host.shed_panel.is_open`, and `remote.ui_open`. + - Repeat for the Workbench after `host.structures.grant_workbench()`. + + Also try a two-process `coop_smoke.gd` run, since the loopback pair may not reproduce a timing + cause. Fix whatever the test pins down. +2. **Fix all four defects above:** + - Add the ShedCounter to `_gather_node`. + - On the host, keep a partner's press pending for a short window (about 0.3 s) until its focus + is valid, instead of dropping it. + - On the client, treat interact while a menu is open as "close". + - When the host handles a partner's "buy", emit an equip event for the buyer's slot. + - With #16 in place, "buy" pays from the requester's pouch. + +**Files:** `coop_session.gd`, `interactions.gd`, `upgrade_panel.gd`, `farm_sim.gd`, +`test_coop.gd` (and possibly `shed_counter.gd`). + +**Depends on #16:** they share files and the PROTOCOL bump, and "buy" needs per-player paying. + +**Acceptance:** +- The new `test_coop` cases pass for both shops. +- The client can buy a weapon: it pays from P2's pouch plus the shed, and the weapon lands in + P2's hand. +- In a two-process smoke run, the client opens the shed. + +## File overlap and order + +| File | Tasks | +|---|---| +| `coop_session.gd`, `interactions.gd` | #16, #22 | +| `scarecrow_combat.gd`, `weapon_models.gd`, `test_weapons.gd` | #17, #18 | +| `enemy_system.gd` | #18 (beam query), #19 (renderer) | +| `loot_system.gd` | #20 (crop token), #21 (escape/drop) | +| `farm_sim.gd` | #16, #19, #21, #22 (separate regions) | +| `game_config.gd` / `game_config.tres` | #17, #18, #21 | +| `farm.tscn` | #20 only | + +- **Wave 1 (parallel):** #16, #17, #19, #20, #21. Their overlaps in `farm_sim.gd`, + `loot_system.gd` and `game_config.gd` are in separate regions; merge carefully. +- **Wave 2:** #18 after #17, and #22 after #16. + +This batch supersedes these entries in `docs/followups.md`: +- UFOs use the crow mesh (#19). +- The torch's kick placeholder (#17). +- `ThiefBehavior.field_rect` spans all crop fields (#20). +- `LAYOUT.md` doesn't list the new fields (#20). diff --git a/docs/tasks.md b/docs/tasks.md index ae9ca81..be0bca1 100644 --- a/docs/tasks.md +++ b/docs/tasks.md @@ -167,3 +167,56 @@ this overhaul; judge tasks by *new* FAIL lines versus the baseline, not by a zer logic. *Acceptance:* new test confirming animals spawn loose at campaign start, can be led into a freshly-enclosed pen, and behave per existing containment/escape/theft rules once penned. + +# Post-overhaul fix batch (2026-10-06) + +Root causes, approach, files, and decisions live in `docs/plan.md` (#16–#22). Wave 1 runs in +parallel; wave 2 waits on the task named. + +## Wave 1 + +- [ ] **#16 Per-player pouch in co-op.** [user item 1] Blocks #22. + Shed stays shared; pouch becomes one per avatar slot (shared `pouch_capacity`, so one + `pouch_upgrade` grows both). Every gather/deposit/pay path takes the acting slot. HUD shows the + local pouch. FarmState v7 + migration, CoopSession PROTOCOL 4. + *Acceptance:* test_coop proves separate pouches, no cross-banking in the shed, own-pouch paying; + v6 save migrates; solo unchanged; no new FAIL lines. + +- [ ] **#17 Propane Torch sprays a band of fire.** [user item 2] Blocks #18. + Rectangular band hit test from the muzzle (`torch_width`, longer `torch_range`, drop + `torch_arc`); particle flame lit while fire is held (also on the partner's screen via the + existing attack events); own sound. + *Acceptance:* test_weapons band in/out/behind checks, sustained hold ticks and stops on release, + flame visible only while held. + +- [ ] **#19 UFO model built from primitives.** [user item 4] + Merged primitive saucer ArrayMesh drawn by a second HordeRenderer with its own shader (vertex + colors, no flap, keeps hit flash/night glow). + *Acceptance:* test_roster: UFOs render in the UFO renderer, not the bird one; crows unchanged. + +- [ ] **#20 New crop fields on the south soil, with their own plant models.** [user item 5] + Lettuce field → SW soil, corn field → SE soil; playable map extends south (z −45…35); SouthFields + hay points move out; per-field thief rects; lettuce/corn use their own plant prefabs and crop + tokens; LAYOUT.md updated. + *Acceptance:* test_farm_layout (fields on soil, inside map, no overlaps, not sunflower models); + test_theft staged-field cases pass. + +- [ ] **#21 Animals roam the whole farm, never lost on their own.** [user item 6] + No self-escape to the edge; dropped/leash-broken animals and animals leaving an open pen become + LOOSE; loose animals roam the playable map day and night; only an Alien carrying one off the + map loses it. + *Acceptance:* reworked test_targets loose/drop/breach cases; test_structures pen checks pass. + +## Wave 2 + +- [ ] **#18 Alien Ray fires a beam.** [user item 3] Blocked by #17. + Held beam, ticked damage, clipped at walls, pierces enemies along it; emissive beam mesh; config + range/width/tick/pierce replace speed/lifetime. + *Acceptance:* test_weapons same-step far hit, wall blocks, two-in-line both hit, beam visible + only while held. + +- [ ] **#22 Joining player can open the store.** [user item 7] Blocked by #16. + Failing test_coop case first (both shops), then fix: client shop prompt (`_gather_node`), + host keeps a partner's press pending until focus is valid, interact closes the client menu, + partner purchases equip on the buyer's slot and pay from the buyer's pouch. + *Acceptance:* new test_coop cases pass for shed and Workbench; two-process smoke opens the shed.