Painted Metropolis
README.md
impact
What a hit does: one place where cover, marks, surface rules and pigment properties meet.
Given a projectile that ended on something (modules/ballistics) or a cone pulse (modules/arms), it adds cover
to the thing or leaves a mark on the surface, starts the timed effects the surface rule and the pigment ask
for, bursts a splash over what stands near, and reports everything it did, including the offences the config
attaches to those moments, so the game can tell whoever tracks crimes. It owns no state of its own: it writes
to the stores it is given.
local Impact = require("~.modules.impact")
local impact = Impact.new(cfg, { cover = cover, splats = splats, field = field, query = query })
-- cover: modules/cover; splats: modules/splats; field: Surfaces.field(); query: as modules/ballistics
-- (query is only needed for splash)
local report = impact:land(event.shot, event.hit) -- after Ballistics:step returned an "impact"
local reports = impact:pulse(cone) -- a cone arm's pulse (needs query.overlap)
-- report = {
-- target, kind, part, what was hit (target nil for the static world)
-- pigment, arm, owner,
-- splat = id | nil, the mark it left
-- cover = { event, ... }, modules/cover's events for this hit (cover, effect, out)
-- effects = { { effect, id, seconds, radius, factor, x, z } }, timed effects started on the field
-- offences = { name, ... }, offences the config names for what happened, in order, no repeats
-- splashed = { report, ... } } the same for each thing the splash reached
Rules, all data: a hit on a thing whose `kind` is a cover kind adds `shot.cover` x the pigment's cover factor
(x the splash share); a "blind" effect lasts its seconds x the pigment's blind factor; a hit on anything else is
looked up in cfg.surfaces[kind] by the arm's name ("mark" leaves a splat, anything else starts an area effect
of rule.radius round the point and still leaves the mark); a pigment's own effects for that kind are added.
The interface is documented in the header of init.luau; this file repeats it for the asset browser.