Skip to content

sf2.projectiles

Projectiles are things a fighter throws or shoots. Register a projectile definition while your mod loads, then spawn it from a combat callback with fighter:spawn_projectile. Get sf2 with local sf2 = require("sf2").

Declare a reusable projectile definition; your Lua decides when and where to spawn it.

Signature: sf2.projectiles.register(definition)

Parameters

Parameter Type Required
definition ProjectileDefinition Required

Fields of ProjectileDefinition

Field Type Required Meaning
id string Required —
name string Required —
core_skeleton string Required —
start_move MoveHandle Required —
item string|ItemHandle Optional —
copy_parent_type "weapon"|"ranged"|"magic" Optional —
lifetime_frames integer Optional Frames the projectile lasts, 1 to 600. Default 180.

Returns: A projectile definition handle (a reusable recipe, not a live projectile).

When: Startup. Requires id, name, core_skeleton, start_move, and one of item or copy_parent_type.

-- `flight` is a previously registered compatible child move.
local dart = sf2.projectiles.register {
id = "dart", name = sf2.mod.id .. ".dart",
core_skeleton = "SkeletonMissile",
item = sf2.items.get("core:items/ranged/RANGED_C2_Z2_MONK_SHURIKEN"),
start_move = flight, lifetime_frames = 120,
}

Prefix name with your mod ID. start_move must be a registered move handle that works with the item and rig. copy_parent_type ("weapon", "ranged" or "magic") copies that slot from the caster, so the caster must have one. Names are not checked against assets, so a typo shows only when the projectile spawns. lifetime_frames counts from birth.