Log inGet started
World

Painted Metropolis

Branchmain
Commit1e1d3a3d4d

README.md

arms

Paint arms: weapons that fire pigment out of the same tins the murals use.

An arm is data (cfg.arms[name], see modules/config): how many projectiles a shot throws and how they scatter,
how fast and far they fly, what a hit adds, how many shots a tin gives, how loud it is. This module is the
hands: which arms are owned, which is up, the cadence between shots, the paint each shot costs. It builds the
projectiles of a shot (origin and velocity, scatter from a seeded generator) and hands them back; flight and
hits are modules/ballistics, what a hit does is modules/impact.

  local Arms = require("~.modules.arms")
  local arms = Arms.new(cfg, supply, { arms = { "pistol" }, rng = rng })   -- rng() -> [0, 1), seeded by the host
  arms:own("lob")   arms:owns("lob")   arms:select("lob")   arms:cycle(1)   arms.arm
  arms:selectPigment("ochre")   arms:cyclePigment(1)   arms.pigment
  arms:tick(dt)                               -- cools the cadence
  local r = arms:fire({ origin = { x, y, z }, dir = { x, y, z }, mount = nil, owner = "player" })
  -- { ok = false, reason = "no arm" | "cooling" | "empty" | "no pigment" | "not mounted" | "blocked" }
  -- { ok = true, arm, pigment, used = tins, loudness, heard,
  --   shots = { { arm, pigment, owner, x, y, z, vx, vy, vz, gravity, range, radius, cover, splash } },   pellet / lob / stream
  --   cone = { arm, pigment, owner, x, y, z, dx, dy, dz, range, halfAngle, cover, radius } }              cone (cover = this pulse's)
  arms:block("washed")   arms:block(nil)      -- the host forbids firing (and why); nil lifts it
  arms:ammo()            -- { shots, tins, pigment } with the pigment that is up
  arms:view()            -- { { id, mode, selected, shots, perTin, cooling (0..1), mount, usable, reason } } for a wheel
  arms:serialise()   arms:restore(data)       -- owned arms and what is selected

A stream or cone arm is fired every tick while the trigger is held: `fire` answers "cooling" between pulses, so
the caller needs no cadence of its own. A shot costs 1 / shotsPerTin of a tin of the pigment that is up; when
less than a shot is left of it the arm falls to another pigment the supply still holds.

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