grab.module
README.md
grab
The moment of capture, made readable: a telegraphed reach on foot, a closing box
round a vehicle. Neither is a distance check that fires at once.
On foot each pursuer has a Reach: in range with a clear line it winds up (the animation and sound hook); when
the windup ends the grab lands only if the suspect is still inside the escape distance with a clear line,
otherwise it misses and the pursuer recovers before trying again.
local Grab = require("~.modules.grab")
local reach = Grab.reach(cfg.grab)
local phase, event = reach:tick(dt, distance, hasLine, factor?)
-- factor (default 1) scales the reach and the escape distance: a suspect who cannot run is easier to take
-- phase: "idle" | "windup" | "recover"; event: nil | "windup" | "hit" | "miss" | "ready"
reach:progress() -- 0..1 through the windup (drives the HUD flash and the arm's blend)
reach:cancel() -- the pursuer was stunned or blinded
In a vehicle the suspect is boxed when it is nearly stopped with a pursuer close for long enough:
local box = Grab.box(cfg.grab.vehicle)
local progress, done = box:tick(dt, speed, nearestPursuerDistance) -- 0..1, true when it completes
The interface is documented in the header of init.luau; this file repeats it for the asset browser.