Bullet Hell Patterns: Spirals, Rings and Spreads Kit
README.md
bulletPatternsKit.api
The public API of bulletPatternsKit: fires bullet hell patterns through projectileKit, hit-tests
them against any set of targets (with pierce, homing and per-target radii), runs emitters, and
syncs volleys across peers. Gameplay code (enemies, bosses, turrets, the player's own weapons)
calls it: local BP = require("bulletPatternsKit.api").
Fields
VERSION:"1.0.0"(matches package.yaml).CHANNEL:"bulletPatternsKit.fire", the multiplayer channel synced volleys use.LOOKS,DEFAULT_LOOK("bpOrbMagenta"),patterns(the pure maths module).
Firing
fire(pattern, opts) -> number: one volley here only; returns the shot count (delayed ones included).fireSynced(pattern, opts) -> number: one volley on every peer (sender included).encodeVolley(pattern, opts) -> event,fireEvent(event, source?) -> number: the synced event by hand.shots(pattern, opts),catalog(),names(): the pure pattern data.
opts:
from:{x,y,z},{1,2,3}, vector, entity or id (entity origins getheight, default 1 m).angle(radians in XZ, 0 = +X, pi/2 = +Z) oraimAt(position or entity).count,arc,speed, plus any pattern option (see the reference guide).look(projectileKit look; defaultbpOrbMagenta),size,range(m, 40),draw,impact.radius(shot hit radius, 0.22),targetRadius(default target radius, 0.5).seed,t: the deterministic inputs (spirals turn witht, shotguns and wall gaps useseed).hit: name of a handler registered withonHit;onHit: a function (local fire only).targets: function returning entities, ids or{ entity = e, radius = r }; ortargetSet: a registered name (default"localPlayers").pierce(extra targets passed through, 0),homing(deg/s, 0),homeOn(set name or function the homing steers toward; default the hit targets).logic = false: drawn only, never hits.data: small table of strings/numbers, reaches handlers.
Hits and targets
onHit(name, fn(targetEntity, info)): register on every peer. info ={ pattern, pos = {x,y,z}, angle, speed, data, shotId, volley, synced, source, pierceLeft }.setTargets(name, fn),targetsOf(name): named target sets;"localPlayers"defaults to this client's player body.position(v):{x,y,z}of any position-like value.
Emitters
emitter(spec) -> handle: spec ={ pattern, from, aim?, every, volleys?, rotate, delay, synced, ...fire opts }.handle:stop(),handle.alive,handle.fired.emitterSynced(spec): every volley viafireSynced; run on the authority only.step(dt, alsoProjectiles?): the Runner calls it each frame; tests call it by hand.
Readouts
stats():{ shots, pending, emitters, volleys, fired, hits, syncedSent, syncedReceived }.clear(): stop emitters, drop delayed shots, end BP shots in flight.resetStats().looks().