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

Loose animals now roam the whole playable map, day and night. Each walk
goes to a goal 4-8 m away that is walkable, in a clear straight line,
at least 2 m inside FarmZones.playable (passed into AnimalSystem.setup),
and neither inside the pen nor across it. Every morning a loose animal
is back at its loose spot (no save change).

Animals no longer escape on their own:
- _stray and LootSystem.animal_escaped are gone.
- A new LootSystem.animal_loose makes an animal LOOSE where it stands
  and unpens it. It covers a carrier killed or scared (drop), a broken
  follow leash, and an animal getting out of an open pen (animal_strays,
  which still records animals_strayed).
- An animal dropped inside the pen is home again.
- An animal let out of an open pen walks out along the escape field,
  then roams. If the pen shuts first, it stays home.
- return_dropped still pens followers at dawn's end, but leaves loose
  animals loose.
- The only loss paths left are a carrier leaving the farm
  (thief escape, or removal with reason LEFT).

Loose spots at x = -12 move inward to (6|9|12, 0.5). The toast,
review-panel, dropped-animal toast, RULES.md and header text no longer
promise animals wander off or run for the edge.

test_targets: _loose_start has a 90 s day + 90 s night roam run (every
animal >4 m, never off the map or into the pen, none lost), a morning
reset to the spots, a killed carrier leaving the animal loose, and an
unopposed thief carrying one off. _animal_theft, _leading, _breach and
_make_loose follow the new rules. AWAY moves off the map so roaming
animals can't start following the parked scarecrow.

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

View file

@ -76,22 +76,24 @@ extends Resource
## A supply thief takes this many units of the material the shed holds most of (never more than
## there is).
@export_range(1, 100) var supply_bundle: int = 5
## Loose animals (dropped, or wandered out of an open pen) walk toward the farm's nearest edge at
## this speed, stopping to graze now and then; one that gets off the farm is lost.
## An animal getting out of an open pen walks out at this speed; once it's out it's loose and
## roams the farm like any other (AnimalSystem). Animals never leave the farm on their own.
@export var stray_speed: float = 1.1
## At night, while the pen is open (its gate broken or removed), one animal wanders out every
## this many seconds. An animal brought back stays calm (won't wander out) for animal_calm_time.
## At night, while the pen is open (nothing built yet, or its gate broken or removed), one calm
## penned animal gets out every this many seconds and is loose. An animal brought back stays calm
## (won't get out again) for animal_calm_time.
@export var animal_wander_interval: float = 10.0
@export var animal_calm_time: float = 30.0
## Animals following the scarecrow walk its trail at up to this speed.
@export var follow_speed: float = 6.0
## Where loose animals start (#12): scattered open-farmyard spots outside FarmZone.Kind.ANIMAL_PEN
## (x -10..4, z -11..-1), walkable, and clear of the future crop fields (x -11..-1 z 2..12 and
## x 2..12 z 2..12 -- see LAYOUT.md). Each is grazed around (AnimalSystem.LOOSE_WANDER_RADIUS)
## until the player leads that animal into a built pen. Cycles if there are more animals than spots.
## Where loose animals start (#12), and where a loose one is back every morning (#21: in between
## it roams the whole farm): a row of open-farmyard spots south and south-east of
## FarmZone.Kind.ANIMAL_PEN (x -10..4, z -11..-1), walkable, clear of the crop fields (x -11..-1
## z 2..12, x 2..12 z 2..12, and the sunflowers from x 14 -- see LAYOUT.md), and well in from the
## farm's edge. Cycles if there are more animals than spots.
@export var animal_loose_spots: Array[Vector2] = [
Vector2(-9.0, 0.5), Vector2(-6.0, 0.5), Vector2(-3.0, 0.5), Vector2(0.0, 0.5), Vector2(3.0, 0.5),
Vector2(-12.0, -3.0), Vector2(-12.0, -6.0), Vector2(-12.0, -9.0),
Vector2(6.0, 0.5), Vector2(9.0, 0.5), Vector2(12.0, 0.5),
]
## What a thief with no set target goes for ("any" in a night plan), and where a thief whose target
## is gone goes next: relative weights per category.