Bastion Works: Towers, Turrets and Targeting Kit
README.md
projectileKit.testSuite
Tests for projectileKit: the flight maths (bullets, ballistic shells, homing missiles, lead), the shot loop (hits, arrivals, recycling shot tables, the shot budget) and the render pools (entities made once and reused frame after frame, parked when unused).
Running
In edit mode:
tools.use("tests", "run", { suites = { "projectileKit" } })
Each test clears shots and counters before it runs and restores the budget and clears the pools afterwards, so the suite leaves nothing behind.
What it checks
projectileKit maths
vec.ofreads arrays, xyz tables and vectors; the quaternion helpers turn +Z where asked.- A shell solved by
solveBallisticlands exactly on its aim point and peaksarcmetres above the higher end. - A bullet flies straight at its speed and hits a target standing on its line.
- A homing missile launched straight up turns onto a target that walks sideways and hits it.
lead()aims ahead of a walking target so a bullet and the target meet.
projectileKit shots and pools
- Fired shots run through
PK.stepand callonHitonce each; finished shot tables are reused by later shots. - Over the shot budget a shot lands at once instead of flying, so no hit is lost.
- Drawing reuses pooled entities: the same number of tracers on later frames makes no new entities, and unused ones are parked at zero scale.
- Budget presets exist for desktop, web and phone and set every number.
- Beams last only while they are called, and arcs, puffs and bursts are effects with a lifetime.