Blast Kit: Explosion Area Damage, Knockback and Juice in One Call
README.md
Blast Kit
An explosion in one call: area damage with falloff, knockback, kill credit and a big effect. For grenades, rockets, bombs, smart bombs, exploding barrels, mines and boss slams.
local Blast = require("blastKit.api")
-- once, in your game's setup: hand in the kits the blast uses (both optional)
Blast.use({ health = require("SecondWind.api"), juice = require("juiceKit.juice") })
-- any time
Blast.at(grenade.position, { radius = 6, damage = 80, by = thrower, team = "red", knockback = 12 })
What one call does
- Plays the effect: juiceKit's
explosionLargepreset (or thejuiceyou name, orjuice = false), plus anyeffect(pos, radius)you handed touse. - Finds the targets in
radius: the list or function intargets, or every target the health module knows (health.all()), minusexcludeand anythingfilterrejects. - Damages each one:
damage(a number, scaled by falloff from the centre down tominFalloffat the edge, or a function of target, distance and falloff) through the health module withby,team,type = "explosion",originandknockback, so kill credit, teams and knockback work. - Calls
onHit(target, amount, hit)for each, which is all you need with your own health system.
It returns the hits, nearest first: { target, amount, distance, falloff, direction }.
Options
radius (5), damage (60), falloff (true), minFalloff (0.2), flat (ignore height, for top-down games), targets, filter, exclude, by, team, type, label, knockback (10), onHit, apply (false = effects only), effects (false = no effect), juice (preset name or false), health and juiceModule (per call).
Also
Blast.query(pos, opts): who would be hit and for how much, hurting nobody (AI, previews, tests).Blast.use({ health, juice, effect }),Blast.backends().
Multiplayer
Damage once, show everywhere: send the blast's position to every peer and call Blast.at(pos, { ..., apply = isHost }), so every player sees the explosion and the host deals the damage. SecondWind then syncs health to everyone.
The test suite blastKit checks radius, falloff, filters, damage functions, the health and juice routes and effects-only mode.