Files
EscapistsReintroduced/docs/living-island/T4-smart-actions.md
T
jakub cab998fb64 Combine Workshop addon and fix prison startup
Merge owned systems into one addon while preserving resource identities. Gate player admission on the replicated prison scene, restore the original framed door, and hold enemy AI until escape. Correct scenario branding and author metadata, include publishing assets, and retain regression and native verification evidence.
2026-09-20 16:42:52 +02:00

3.2 KiB

T4 — Soldiers doing something

Read docs/living-island/README.md first, including the rules section. Depends on T2.

Goal

The soldiers you already pay for should look busy rather than standing at a waypoint. This adds zero agents — it changes behaviour, not population, and is the cheapest immersion in the whole plan.

What to build

addons/core/Scripts/Game/ERR/ERR_SiteActivity.c.

Use the vanilla smart-action system:

  • SCR_AISmartActionComponent — sits on a world entity that offers an action; ReserveAction(AIAgent), ReleaseAction(), GetOnActionEnd(), GetOnActionFailed().
  • SCR_SmartActionWaypoint.SetSmartActionEntity(IEntity entityWithSmartAction, string smartActionTag) — the waypoint that sends a group member to perform it.

Per site, author a handful of activity slots: a position, a tag and which site kinds use it. When a garrison is physical and not alerted, assign idle members to free slots; when the site is alerted or the group is in combat, release the slots immediately and let normal AI take over.

Sensible slots to start with, by site kind:

  • Checkpoint: one soldier at the barrier facing the road, one leaning against the parked vehicle, one seated.
  • Outpost / depot: a sentry at the gate, someone working at a crate, someone resting.
  • Radio station: an operator near the equipment, a sentry on the door.
  • Prison: a guard patrolling the walkway, a guard at the gate.

Rules

  • Activity assignment runs on the existing site tick, not a new one, and at most once every 5 s per site.
  • Never assign more than half a garrison to activities at once; the rest hold defensive positions. A checkpoint where everyone is smoking is worse than one where nobody is.
  • Alert state wins instantly: on perception contact, release every slot for that site in the same tick.
  • Slots are reserved so two soldiers never claim the same one; release on action end, action failure, death, and on going dormant.
  • If the vanilla smart action fails or is unavailable for a slot, fall back to a plain hold position and log once per site — never leave a soldier idle in a broken state.

Acceptance criteria

  1. Approaching a manned checkpoint, at least one soldier is performing an activity rather than standing.
  2. Firing a shot near the site causes every activity to be released and the garrison to respond, with no soldier stuck in an animation.
  3. Active agent count is unchanged by this task — assert it in the admin status output before and after.
  4. A garrison that goes dormant and returns re-acquires activities without leaking reservations (reservation count returns to zero while dormant).
  5. python3 tools/check.py passes.

Tests to write

tests/test_site_activity.py:

  • The pure selection rule never assigns more than half the garrison.
  • A slot already reserved is not handed to a second agent.
  • Alert state returns an empty assignment set regardless of free slots.
  • Release-on-dormant leaves zero reservations.

Do not

  • Do not write custom animation code. Use the vanilla smart-action system only.
  • Do not add activity slots to the ledger records; slots are site content.
  • Do not let an activity survive an alert, a death, or a dormant transition.