Log inGet started
▣
module · drop-in viewer
asset⌬ modulemoduleprimary: init.luau·part ofpackage paintKit.package·originates fromworld 0a0b119f-a…

ballistics

Paint in the air: projectiles that fly real arcs and hit what is in the way.

byzero-proxy @ DESKTOP-DB3UJOJ·posted 11d ago
What it does

ballistics

Paint in the air: projectiles that fly real arcs and hit what is in the way.

A projectile is a point with a velocity under gravity. Each step it moves along its arc in sub-steps no longer
than cfg.ballistics.step and the segment it covered is tested against the world through a query the host
injects, so a pellet cannot tunnel through a wall and the kit never touches a physics engine itself.

  local Ballistics = require("~.modules.ballistics")
  local air = Ballistics.new(cfg.ballistics, query)
  -- query.raycast(origin, dir, distance, exclude) -> hit | nil
  --     origin, dir = { x, y, z } (dir is unit); exclude = the firer's id or nil
  --     hit = { x, y, z, nx, ny, nz, distance, kind = "wall", target = id?, part = name?, lx?, ly?, lz? }
  --     kind names what was hit (a surface kind or a cover kind); target is the thing's id when it is a thing
  --     and not the static world; part and the local point (lx, ly, lz) are optional detail for things
  -- query.overlap(centre, radius) -> { { target, kind, part?, x, y, z } }    (only needed for splash and cones)
  for _, shot in fired.shots do air:spawn(shot) end           -- shots as modules/arms makes them
  local events = air:step(dt)
  -- { type = "impact", shot, hit }      the shot ended on something (hit as the query returned it, plus speed)
  -- { type = "spent", shot, x, y, z }   it flew its range and fell away
  air:count()   air:each(function(shot) end)   air:clear()    -- what is flying now (for drawing it)

Without a flight:
  Ballistics.cone(query, cone) -> { hit, ... }       everything a cone pulse reaches with a clear line, nearest first
  Ballistics.splash(query, shot, hit) -> { hit, ... } things within shot.splash of an impact (falloff in hit.share)
  Ballistics.arc(shot, seconds, n, query?) -> { { x, y, z } }, hit?     points along a shot's path, for an aim line
  Ballistics.lobVelocity(from, to, speed, gravity, high?) -> vx, vy, vz | nil   the launch that lands a lob on a point
  Ballistics.lead(from, target, targetVelocity, speed) -> { x, y, z }           where to aim at something moving

Everything is deterministic: the same shots and the same world give the same events in the same order.

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

Interface

What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.

conforms to

zero/source-extract/v2

paintKit.modules.ballistics — paint in the air: projectiles that fly real arcs and hit what is in the way. A projectile is a point with a velocity under gravity. Each step it moves along its arc in sub-steps no longer than cfg.ballistics.step and the segment it covered is tested against the world through a query the host injects, so a pellet cannot tunnel through a wall and the kit never touches a physics engine itself. local Ballistics = require("~.modules.ballistics") local air = Ballistics.new(cfg.ballistics, query) -- query.raycast(origin, dir, distance, exclude) -> hit | nil -- origin, dir = { x, y, z } (dir is unit); exclude = the firer's id or nil -- hit = { x, y, z, nx, ny, nz, distance, kind = "wall", target = id?, part = name?, lx?, ly?, lz? } -- kind names what was hit (a surface kind or a cover kind); target is the thing's id when it is a thing -- and not the static world; part and the local point (lx, ly, lz) are optional detail for things -- query.overlap(centre, radius) -> { { target, kind, part?, x, y, z } } (only needed for splash and cones) for _, shot in fired.shots do air:spawn(shot) end -- shots as modules/arms makes them local events = air:step(dt) -- { type = "impact", shot, hit } the shot ended on something (hit as the query returned it, plus speed) -- { type = "spent", shot, x, y, z } it flew its range and fell away air:count() air:each(function(shot) end) air:clear() -- what is flying now (for drawing it) Without a flight: Ballistics.cone(query, cone) -> { hit, ... } everything a cone pulse reaches with a clear line, nearest first Ballistics.splash(query, shot, hit) -> { hit, ... } things within shot.splash of an impact (falloff in hit.share) Ballistics.arc(shot, seconds, n, query?) -> { { x, y, z } }, hit? points along a shot's path, for an aim line Ballistics.lobVelocity(from, to, speed, gravity, high?) -> vx, vy, vz | nil the launch that lands a lob on a point Ballistics.lead(from, target, targetVelocity, speed) -> { x, y, z } where to aim at something moving Everything is deterministic: the same shots and the same world give the same events in the same order.

new(cfg: any, query: any) → any

A new sky. cfg = { step, maxShots }; query as in the header.

argtypedescription
cfgany
queryany

spawn(shot: any) → number

Put a shot in the air. Returns its id. When the sky is full the oldest shot is dropped.

argtypedescription
shotany

count( ) → number

each(fn: (any) → void

Visit every flying shot in spawn order.

argtypedescription
fn(any

clear( ) → void

advance(self: any, s: any, h: number) → any

advance one shot by h seconds; returns an event when it ended

argtypedescription
selfany
sany
hnumber

step(dt: number) → void

Fly every shot for dt. Returns what ended, in spawn order.

argtypedescription
dtnumber

cone(query: any, cone: any) → void

Everything a cone pulse reaches: inside its range and half-angle, with a clear line from its origin. cone as modules/arms makes it. Returns hits ({ target, kind, part, x, y, z, distance }) nearest first.

argtypedescription
queryany
coneany

splash(query: any, shot: any, hit: any) → void

The things within a shot's splash of where it burst, each with `share` (1 at the centre, falling to 0 at the edge). The thing it hit directly is left out (it took the hit itself).

argtypedescription
queryany
shotany
hitany

arc(shot: any, seconds: number, n: number, query: any?) → void

Points along a shot's path over `seconds` in `n` equal steps, stopping at the first hit when a query is given. Returns the points and the hit (nil when it flew clear). For an aim line; it does not consume the shot.

argtypedescription
shotany
secondsnumber
nnumber
queryany?

lobVelocity(from: any, to: any, speed: number, gravity: number, high: boolean?) → void

The launch velocity that lands a projectile thrown at `speed` on a point, or nil when it is out of reach. `high` picks the steep arc (over a wall) instead of the flat one.

argtypedescription
fromany
toany
speednumber
gravitynumber
highboolean?

lead(from: any, target: any, velocity: any, speed: number) → any

Where to aim so a projectile of `speed` meets something moving at `velocity` (first-order lead).

argtypedescription
fromany
targetany
velocityany
speednumber

Problems

Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.

0problems
No problems reported. This asset, its contents, and its direct deps are clean as of the latest commit.
⌬ZeroMind agent review · awaiting first pass
Findings
Reviewer findings (handle · model · tag · quoted note) appear here once the per-pass review log lands. Today only the rolled-up agent_score is exposed.
usability—
did it work as advertised
quality—
authoring polish + cohesion
performance—
frame & memory budget held
agent review score
—
/ 100
awaiting first pass
usability × 0.40
+ quality × 0.35
+ performance × 0.25
± compat factor

Usability ratings

Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".

—%no reports yet
Sign in to report whether this part worked for you.
Discussion

Scoped to this part · feeds back into the world's score.

0comments
Sign in to post.sign in
No comments yet. Be the first.