Log inGet started
World

Painted Metropolis

Branchmain
Commit1e1d3a3d4d

README.md

firefight

Pursuers who shoot back: who may fire at a heat level, when, and how well.

It decides and nothing more. For every armed pursuer that has eyes on the suspect it runs a readable cycle:
AIM (a telegraph the host stages: the weapon comes up, a sound) for `warn` seconds, then a BURST of shots
`interval` apart, then a REST. Each shot comes back as a muzzle point and an aim point, already led for the
suspect's movement and thrown off by the arm's spread (wider when the suspect is moving, concealed, or the
shooter has just started). The host flies the shot through whatever projectile system it has and tells its
own rules what a hit strips; this module holds no projectile and no health.

  local Firefight = require("~.modules.firefight")
  local ff = Firefight.new(cfg.firefight, rng)        -- rng() -> [0, 1), seeded by the host
  ff:provoke()                                        -- the suspect fired or hit a pursuer (see `needsProvocation`)
  local events = ff:tick(dt, {
      level = 3,                                      -- 0-based heat level
      suspect = { x, y, z, vx, vy, vz, concealed = false },
      shooters = { { id = "w3", kind = "foot", x, y, z, sees = true, stunned = false } },
  })
  -- { type = "aim", by, arm, seconds }               the weapon comes up (stage it)
  -- { type = "shot", by, arm, from = { x, y, z }, at = { x, y, z }, wash, speed, gravity, range, radius, splash }
  -- { type = "lower", by }                           it lost sight, was stunned, or the level fell
  ff:armOf("w3")            -- the arm a shooter has up (nil when it is not engaged)
  ff:phase("w3")            -- "idle" | "aim" | "burst" | "rest"
  ff:reset()                -- the incident is over
  Firefight.carries(cfg.firefight, level, kind, index) -> arm name | nil
  -- whether the index-th pursuer of a kind is armed at a level (levels[].share decides how many are)

Config (cfg.firefight):
  arms[name] = { wash, range, speed, gravity, interval, burst, rest, spread, radius, splash?, muzzle? }
      wash: what a hit strips (the host's unit); burst: shots per burst; rest: seconds between bursts;
      spread: half-angle of the error cone in degrees; muzzle: height above the shooter's feet (default 1.4)
  levels[level + 1] = { arms = { [kind] = armName }, share = 0..1, engage = { min, max }, warn,
                        needsProvocation = bool }
      arms: which arm each kind of pursuer brings out at this level (a kind with no entry does not shoot);
      share: the share of pursuers of a kind that carry it; engage: metres inside which they fire;
      needsProvocation: they fire only after `provoke()` in this incident
  accuracy = { movingAbove, moving, concealed, firstBurst }     spread multipliers

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