Log inGet started
Package

creatures.module

Newest version

README.md

game.creatures

The infected of LAST CARRIAGE: EVACUATION — three of them standing in the station, and the one in the rescue uniform that keeps calling.

The entry point (scenes/main.scene/entrypoint.luau) requires this module and calls start(ctx), update(dt), onPlayer(player) and stop(). start runs once at scene load and spawns everything; update is the per-frame work and never raises (its own body is wrapped, and a failure is warned rather than thrown).

The rule the slice is built on

Nobody here can see the player. Every creature is an aiKit listener brain: sight is off in the preset, the brain writes spots from sounds only, and it acts on where a noise was, never on where the player is. The player's footsteps reach them through aiKit's own footstep noise (silent below its quiet speed, so a crouch-walk is not heard and a walk is). Everything else the game makes a sound with — a thrown bottle, a struck door, a bang — arrives on Core's noise event and goes onto aiKit's bus here, with no maker named, so a creature walks to the bottle rather than to whoever threw it.

Core.NOISE is a 0..1-ish loudness; aiKit hears in metres of carry and multiplies that by the listener's hearing sensitivity. metres() maps between them at 7 m per unit, which puts a walk at about 5 m and a run at about 11 m — the reaches aiKit's own footstep noises use — and a crouch-walk under 2 m.

What spawns

entitypresetwherewhat it is
Infected_Carriageinfected(−0.55, 2.2, 20.2)standing in the red light at the far end of the carriage
Infected_Pillarinfected(7.55, 2.2, 27.4)on the platform by the pillar row
Infected_Stairinfected(8.10, 2.2, 40.4)between the work lamp and the evacuation stair
Rescuerrescuer(6.20, 2.2, −5.0)the dark south end of the platform, where the tunnel mouth is

The bodies are one generated figure — game/models/infected_rig, made from design/references/infected-rescuer.png: shredded black rescue coveralls with a torn reflective stripe, dust-caked grey skin, goggles pushed up, both arms held stiffly forward. The ordinary infected wear it smaller and tinted greyer; the rescuer wears it full height and closest to the reference. look.shape = "none" in both presets keeps aiKit from building its own stylised body underneath.

game/models/infected_walk_anims.a is a slow shamble, retuned onto each body's ClipPlayer once the skinned mesh has hydrated.

The rescuer

Blind like the others, and it never learns where the player is. It hears a sound, walks to just short of it, stops, knocks three times on metal, and then asks for an answer in the player's own voice (game/models/infected_voice, spoken from its position). Its knock is put on the noise bus attributed to itself, so the other infected come to it while the rescuer ignores its own sound. Answering it — any loud noise nearby — is what brings it all the way in; from then on it closes and strikes.

Events and shared state

  • Core.emit("hurt", {}) when a creature lands a melee hit (the brain's acted event, throttled).
  • Core.emit("hunted", { on = true|false }) when the number of creatures actively following a sound, searching or attacking changes from zero.
  • Core.emit("voice", { who = "rescuer", line = "infected_voice" }) when the rescuer speaks.
  • Core.state.creaturesNear — how many are hunting; Core.state.rescuerDistance — metres from the player to the rescuer.
  • Core.state.phase reaching dead or escaped freezes the whole slice.

Surviving a reload

A module reload in the middle of a game starts its module-level state again, while the creatures it spawned are still standing in the station. adopt() takes those over instead of spawning a second set on top of them; the Core noise listener is registered when the file loads (not when the scene starts) for the same reason, and only the newest registration acts.

The nav map

The station's navKit map is baked when play starts. A scene load that did not finish leaves it unbaked, and then every path comes back "no path on map 'default'" and the creatures stand still — so ensureMap() asks for the bake itself the first time it finds no map, and does nothing once there is one.

Known constraint

The carriage and the platform are separate islands on the nav map: 0.85 m of track bed stands between the carriage door and the platform edge, which no walker crosses. A creature therefore stays on the surface it was placed on — the Infected_Carriage one is confined to the carriage, and the rescuer has to be placed on the platform to reach the player at all.

Debugging

Creatures.debugState() hands back the slice's live state table (read only): the roster, the rescuer's lead / callT / lastDist, and the frame counter.