Log inGet started
Package

pursuer.module

README.md

pursuer

One pursuer's decisions, and the two input buses it speaks through.

A pursuer never moves an entity. Each tick its brain turns what it senses and what it was ordered into an
INTENT, and a bus writer turns the intent into the fields a character or a vehicle already reads:

  character bus   inputX, inputZ (world-space velocity, units per second), inputJump
                  (the engine's CharacterController reads exactly these; any mover with the same fields works)
  vehicle bus     inputThrottle (-1..1), inputSteer (-1..1, right positive), inputBrake (0..1), inputHandbrake (0..1)

  local Pursuer = require("~.modules.pursuer")
  local brain = Pursuer.new(cfg.pursuer, "foot")           -- a profile of cfg.pursuer: "foot", "car", or any other
  -- a profile is { patrol, investigate, chase, tired, stamina, recover, arrive, leash? } for someone on foot
  -- (profile.wheels ~= true) or { street, avenue, arrive, wheels = true } for a car
  local intent = brain:decide(dt, {
      x = 0, z = 0,                       -- where this pursuer is
      order = { role = "pursue", x, z },  -- from dispatch (role: stand | investigate | pursue | sweep | cordon)
      home = { x, z }?,                   -- its post; with a `leash` in its profile it turns back that far from it
      sees = true, sx = 4, sz = 9,        -- it has eyes on the suspect, and where
      stunned = 0,                        -- seconds it cannot act (blinded, slipped)
      beat = { x, z }?,                   -- where its patrol wants it when it has no order
      path = { { x, z }, ... }?,          -- the host's route to the order (roads, a nav path); optional
      roadClass = "street" | "avenue"?,   -- for a car: sets its top speed
      grabbing = false,                   -- its reach is winding up (it plants its feet)
  })
  -- intent = { mode, x, z, speed, hold }   mode: stunned | grab | chase | investigate | sweep | cordon | patrol |
  --                                         return (leashed: it gives up and goes home) | idle
  local vx, vz = Pursuer.characterBus(intent, x, z)
  local throttle, steer, brake, handbrake = Pursuer.vehicleBus(intent, x, z, fx, fz, forwardSpeed, cfg.frame.right)
  brain:stamina()     -- 0..1 (a foot pursuer tires in a chase and slows to cfg.foot.tired)

Routing is the host's: pass `path` and the brain walks its points in order; without one it heads straight
for the target (fine in the open, wrong round buildings).

The interface is documented in the header of init.luau; this file repeats it for the asset browser.