Merge task #21: animals roam the whole farm, never lost on their own

Loose animals roam the playable map day and night; dropped, leash-broken
and open-pen animals become LOOSE instead of running for the edge. Only
an Alien carrying one off the map loses it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Forrest 2026-10-06 13:15:24 -04:00
commit 9d26f29299
8 changed files with 379 additions and 226 deletions

View file

@ -91,7 +91,7 @@ the night, but only when `allow_early_night` is on. It is **off by default**.
Three kinds of asset can be stolen, and all three are in play from the start:
- **crops**: the crop field's 30 units;
- **animals**: the 8 in the pen;
- **animals**: the 8 animals (they start loose, outside the pen: see **Animals and the pen**);
- **supplies**: the construction materials stored in the supply shed (the pouch can't be stolen).
A kind with nothing in it at the start is not in play. The asset HUD (top center) shows what's
@ -104,7 +104,7 @@ left of each, and a count flashes red when it drops and green when it rises.
| Targeted | An enemy is heading for the asset | Marker over it; arrow at the screen edge if off screen |
| Being stolen | The enemy is taking it, which takes visible time (crops 2.5 s, animals 2 s, a sack of supplies 3 s). Damage resets the timer. | Progress ring |
| Carried | The enemy is heading for the nearest escape point, slower than usual | The asset shown on the enemy, outlined in its category's color (crops gold, animals pink, supplies blue), with a badge |
| Dropped | The carrier was stopped | A crop or sack lies on the ground, glowing; an animal runs loose (below) |
| Dropped | The carrier was stopped | A crop or sack lies on the ground, glowing; an animal is loose where it fell (below) |
| Recovered | The scarecrow got it back | It returns home (an animal follows the scarecrow home) |
| Lost | The carrier escaped off the farm | Permanently gone |
@ -115,8 +115,9 @@ left of each, and a count flashes red when it drops and green when it rises.
the pen.
- Another thief can pick up a dropped item.
- Anything still on the ground when the dawn grace ends returns home automatically
(`loot_returns_at_dawn`).
- Animals can also escape through a breach in the pen. An animal that leaves the farm is lost.
(`loot_returns_at_dawn`). Loose animals stay loose.
- Nothing leaves the farm on its own: an animal that gets out of a breached pen is only loose, and
an item is lost only when its carrier escapes off the farm.
Implemented for all three (Steps 3 and 8). The arrows at the screen edge are filled by state
(orange targeted, red carried, yellow dropped) and ringed in the category's color.
@ -132,8 +133,8 @@ How enemies steal (the enemy types are in **The enemies**, below):
- **Crops.** A crow claims a random unit still in its plot and flies straight to it, over
anything in the way. It lands on it, takes it (2 s), and flies straight off the farm with it, out its
nearest side. Only one enemy claims an item at a time.
- **Animals.** A thief claims a random animal in the pen. The pen's gate keeps it out, so it
breaks the gate (30 HP: about 18 s). Then it walks in and catches the animal, which freezes, in
- **Animals.** A thief claims a random animal, penned or loose. A shut pen keeps it out, so it
breaks its way in (a gate's 30 HP take about 18 s). It catches the animal, which freezes, in
2 s. It carries the animal off, held under it, at 70 % speed to the **nearest** point of the farm's edge.
- **Supplies.** A thief goes to the shed pile of the material the shed holds most of (logs,
crates, or hay bales; each pile has a spot in front).
@ -170,7 +171,7 @@ Implemented in Step 9. The type table is `GameConfig.enemy_types`.
- Each arrow is labeled ("3 crows — Crop Field", "Thief escaping with an animal!", "Breach! —
Animal Pen"), filled by kind, and ringed in the loot's category color.
- **Kinds, in priority order:** escapes; breaches (a barrier being smashed, or just broken);
thefts; loose animals and dropped loot.
thefts; dropped loot (#21: loose animals roam freely and get no arrow).
- Alerts of the same kind, type, and loot in the same zone are grouped.
- An escape escalates as its carrier nears the exit: the arrow grows, pulses faster, and turns
red.
@ -178,29 +179,41 @@ Implemented in Step 9. The type table is `GameConfig.enemy_types`.
## Animals and the pen
Implemented in Step 8.
Implemented in Step 8. Since #12 the animals start loose and the pen is player-built; since #21
they roam the whole farm and are never lost on their own.
- **In the pen.** The 8 animals (4 chickens, 2 pigs, 2 sheep) wander inside the pen and stop to
graze. The pen's gate on its east side is a normal gate structure, standing from the start: the
scarecrow (and animals following it) walk through, but wandering animals and enemies can't.
- **The pen is open** when there's a way out that crosses no structure: its gate is broken or taken
down.
- A toast says so when it happens, and so does the morning review.
- At night (night and dawn), one calm animal walks out of an open pen every 10 s.
- By day they stay in.
- Building a gate (or a fence) back in the opening shuts the pen.
- **Loose animals** (dropped by a thief, or wandered out) walk toward the farm's nearest edge at
1.1 m/s, stopping to graze now and then.
- **Loose animals.** The 8 animals (4 chickens, 2 pigs, 2 sheep) start loose, each at its own spot
outside the pen (`animal_loose_spots`).
- They roam the whole farm, day and night. Each walk goes to a spot 4–8 m away that the animal
can reach in a straight line, inside the farm (at least 2 m in from its edge) and outside the
pen; then it stops to graze.
- Structures stop them, so a fence line can hold them.
- One that reaches the edge is lost.
- One that gets back inside the pen is home.
- Any thief can grab a loose animal it sees.
- They never leave the farm on their own, and never walk into the pen by themselves.
- Each morning, every loose animal is back at its own spot.
- Any thief can claim a loose animal (penned or loose, it picks one at random).
- **The only way to lose an animal is a thief carrying it off the farm.**
- **Dropped animals.** When a thief carrying an animal is stopped (killed or scared), the animal
is loose where it fell and roams from there. If that's inside the pen, it's home again.
- **Leading animals home (D6).**
- Walk up to a loose animal and it follows the scarecrow, walking its trail in line, gates
included. At most 3 follow at once; a toast says so when the line is full.
- Inside the pen it's home and stays calm for 30 s (it won't wander out of an open pen).
- Inside the pen it's home (penned) and stays calm for 30 s (it won't get out of an open pen).
- A follower whose scarecrow gets more than 20 m away is loose where it stands.
- Thieves can't take an animal that's following the scarecrow.
- At the end of the dawn grace, loose and following animals are back in the pen.
- **In the pen.** Penned animals wander inside the pen and stop to graze, and each morning they're
back in the pen. The pen's fences and gate are player-built: the scarecrow (and animals
following it) walk through the gate, but wandering animals and enemies can't.
- **The pen is open** when there's a way out that crosses no structure: nothing built yet, or a
gate or fence broken or taken down.
- A toast says so when it happens, and so does the morning review.
- At night (night and dawn), one calm penned animal gets out of an open pen every 10 s. It's
loose at once (no longer penned): it walks out through the opening at 1.1 m/s, then roams like
any loose animal. The night's record counts it as strayed.
- By day they stay in.
- Building a gate (or a fence) back in the opening shuts the pen. An animal still on its way out
when the pen shuts stays home.
- At the end of the dawn grace, animals still following the scarecrow are back in the pen. Loose
animals stay loose; the next morning puts them back at their spots.
## Supplies
@ -432,7 +445,7 @@ Implemented in Step 6. The numbers are in `GameConfig`.
Counted from each morning to the end of its dawn grace, and recorded when the dawn ends
(`FarmState.night_log`):
- crops and animals lost, supply units carried off;
- what was taken, recovered, and wandered out, per category;
- what was taken, recovered, and strayed (animals that got out of an open pen), per category;
- enemies killed per type, and those that got away with loot;
- the scarecrow's damage taken and patches;
- structures built, damage dealt to them, structures broken, and repairs;
@ -441,9 +454,9 @@ Counted from each morning to the end of its dawn grace, and recorded when the da
material.
The morning screen opens with the last night's record. Its table shows taken, recovered, and
lost per category; animals taken include those that wandered out of an open pen. Under the
table come the enemies, the damage, and the materials. The final assessment adds up all the
nights.
lost per category; animals taken include those that got out of an open pen (loose, not lost).
Under the table come the enemies, the damage, and the materials. The final assessment adds up
all the nights.
Decided in Step 8: a farm whose supplies were *spent* rather than stolen is not stripped. The
shed counts as raided when a thief takes the last of its stock, and storing anything clears that