sf2.moves
Moves are the attacks and actions a fighter can perform. Register a new move, a template to reuse, or a trigger that plays a sound or effect. Patch or fork a move that already exists. Get sf2 with local sf2 = require("sf2").
sf2.moves.register
Section titled “sf2.moves.register”Create a move, a reusable move template, or a trigger that plays a sound or effect.
Signature: sf2.moves.register(definition)
Parameters
| Parameter | Type | Required |
|---|---|---|
definition |
MoveDefinition |
Required |
Fields of MoveDefinition
| Field | Type | Required | Meaning |
|---|---|---|---|
kind |
"move" |
Optional | The default. |
id |
string |
Required | — |
inherit |
(string|MoveTemplateHandle)[] |
Optional | Native template names first, then this mod’s template handles. |
events |
"controlled"|("finish"|"start"|"interval_end"|"interval_start"|"hit"|"strike"|"every_frame"|"birth"|"round_stage"|"mod_expires"|"key_pressed"|MoveEvent)[] |
Optional | — |
when |
MoveWhen |
Optional | — |
windows |
MoveWindows |
Optional | — |
attacks |
MoveAttack[] |
Optional | — |
only_for |
MoveWhen |
Optional | Requirements such as { rig = “Skeleton”, weapon = “Katana” }. |
align |
"parent"|"head_top"|"head"|"neck"|"chest"|"stomach"|"pelvis"|"left_shoulder"|"right_shoulder"|"left_elbow"|"right_elbow"|"left_wrist"|"right_wrist"|"left_knuckles"|"right_knuckles"|"left_fingertips"|"right_fingertips"|"left_hip"|"right_hip"|"left_knee"|"right_knee"|"left_ankle"|"right_ankle"|"left_heel"|"right_heel"|"left_toe"|"right_toe"|"left_toe_tip"|"right_toe_tip"|MoveAlignment |
Optional | A body point to keep where the fighter stands, “parent”, or a table. |
face |
"enemy"|"away"|"keep"|"turn"|"with_enemy"|"opposite_enemy"|"with_parent"|"opposite_parent"|"impulse"|"reverse_impulse"|MoveFace |
Optional | Which way the fighter turns when the move starts. |
type |
"move"|"attack" |
Optional | — |
priority |
integer |
Optional | — |
frames_per_sample |
integer |
Optional | Game frames per animation sample; default 3 unless a template sets it. |
first_sample |
integer |
Optional | — |
last_sample |
integer |
Optional | — |
mirror |
"head_top"|"head"|"neck"|"chest"|"stomach"|"pelvis"|"left_shoulder"|"right_shoulder"|"left_elbow"|"right_elbow"|"left_wrist"|"right_wrist"|"left_knuckles"|"right_knuckles"|"left_fingertips"|"right_fingertips"|"left_hip"|"right_hip"|"left_knee"|"right_knee"|"left_ankle"|"right_ankle"|"left_heel"|"right_heel"|"left_toe"|"right_toe"|"left_toe_tip"|"right_toe_tip"|string|false |
Optional | Mirror node; fighter-rig moves default to “left_heel”. |
tactic_equivalent |
string |
Optional | — |
tactic_weapon |
string |
Optional | — |
looped |
boolean |
Optional | — |
ends_stage |
boolean |
Optional | — |
animation |
BinaryHandle|string |
Required | — |
transitions |
MoveTransition[] |
Optional | — |
on |
MoveOn |
Optional | — |
profile |
MoveProfile |
Optional | — |
tactic_distance |
MoveTacticDistance |
Optional | — |
tactic_when |
MoveWhen |
Optional | — |
no_wall_repulsion |
boolean |
Optional | — |
no_interpolation_frames |
boolean |
Optional | — |
no_magic_recharge |
boolean |
Optional | — |
velocity |
MoveVelocity |
Optional | — |
style_factor |
number |
Optional | — |
Fields every kind shares (MoveTemplateDefinition, TriggerDefinition)
| Field | Type | Required | Meaning |
|---|---|---|---|
id |
string |
Required | — |
events |
"controlled"|("finish"|"start"|"interval_end"|"interval_start"|"hit"|"strike"|"every_frame"|"birth"|"round_stage"|"mod_expires"|"key_pressed"|MoveEvent)[] |
Optional | — |
when |
MoveWhen |
Optional | — |
More fields of MoveTemplateDefinition
| Field | Type | Required | Meaning |
|---|---|---|---|
kind |
"template" |
Required | Makes a reusable template instead of a move. |
inherit |
(string|MoveTemplateHandle)[] |
Optional | Native template names first, then this mod’s template handles. |
windows |
MoveWindows |
Optional | — |
attacks |
MoveAttack[] |
Optional | — |
only_for |
MoveWhen |
Optional | Requirements such as { rig = “Skeleton”, weapon = “Katana” }. |
align |
"parent"|"head_top"|"head"|"neck"|"chest"|"stomach"|"pelvis"|"left_shoulder"|"right_shoulder"|"left_elbow"|"right_elbow"|"left_wrist"|"right_wrist"|"left_knuckles"|"right_knuckles"|"left_fingertips"|"right_fingertips"|"left_hip"|"right_hip"|"left_knee"|"right_knee"|"left_ankle"|"right_ankle"|"left_heel"|"right_heel"|"left_toe"|"right_toe"|"left_toe_tip"|"right_toe_tip"|MoveAlignment |
Optional | A body point to keep where the fighter stands, “parent”, or a table. |
face |
"enemy"|"away"|"keep"|"turn"|"with_enemy"|"opposite_enemy"|"with_parent"|"opposite_parent"|"impulse"|"reverse_impulse"|MoveFace |
Optional | Which way the fighter turns when the move starts. |
type |
"move"|"attack" |
Optional | — |
priority |
integer |
Optional | — |
frames_per_sample |
integer |
Optional | Game frames per animation sample; default 3 unless a template sets it. |
first_sample |
integer |
Optional | — |
last_sample |
integer |
Optional | — |
mirror |
"head_top"|"head"|"neck"|"chest"|"stomach"|"pelvis"|"left_shoulder"|"right_shoulder"|"left_elbow"|"right_elbow"|"left_wrist"|"right_wrist"|"left_knuckles"|"right_knuckles"|"left_fingertips"|"right_fingertips"|"left_hip"|"right_hip"|"left_knee"|"right_knee"|"left_ankle"|"right_ankle"|"left_heel"|"right_heel"|"left_toe"|"right_toe"|"left_toe_tip"|"right_toe_tip"|string|false |
Optional | Mirror node; fighter-rig moves default to “left_heel”. |
tactic_equivalent |
string |
Optional | — |
tactic_weapon |
string |
Optional | — |
looped |
boolean |
Optional | — |
ends_stage |
boolean |
Optional | — |
More fields of TriggerDefinition
| Field | Type | Required | Meaning |
|---|---|---|---|
kind |
"trigger" |
Required | Makes a trigger instead of a move. |
actions |
(SoundAction|HitEffectAction)[] |
Optional | — |
Returns: A handle: move (default), template or trigger, matching kind.
When: Entrypoint. Register templates before the moves that inherit them.
local step_template = sf2.moves.register { kind = "template", id = "forward_step", inherit = { "ForwardStep" },}local opening_step = sf2.moves.register { id = "opening_step", animation = sf2.assets.binary("animations/opening"), inherit = { "Step", "Forward", step_template }, priority = 10, windows = { block = true, throwable = true },}sf2.moves.register { kind = "trigger", id = "opening_step_sound", events = { { start = opening_step } }, actions = { { type = "sound", audio = sf2.assets.audio("audio/step"), volume = 0.7 } },}kind picks what is registered; shared move fields, events and conditions are in Moves.
"move"needs ananimation. Restrict it (for example withonly_for) so it does not reach more fighters than intended."template"needs no animation and has no timing of its own, so give window and attack bounds asfrom_sample/to_sample. It is not selectable until a move inherits it."trigger"needs onlyid;actionsaresoundorhit_effectentries. For more logic, use a combat callback (Combat scripting).
sf2.moves.fork
Section titled “sf2.moves.fork”Copy an existing move so one weapon subtype or item can use a changed version.
Signature: sf2.moves.fork { id, source, subtype?, like?, item? }
Parameters
| Parameter | Type | Required |
|---|---|---|
definition |
MoveFork |
Required |
Fields of MoveFork
| Field | Type | Required | Meaning |
|---|---|---|---|
id |
string |
Required | Local fork ID; the copy is named “<mod id>.<id>”. |
source |
string |
Required | Exact built-in move name, or an earlier fork name, to copy. |
subtype |
string |
Optional | Weapon subtype that gets the copy (removed from the source lock group). |
like |
string |
Optional | With “subtype”: copies a move locked to this weapon subtype. Not with “item”. |
item |
ItemHandle|string |
Optional | The one item that gets the copy: a handle or item ID. |
Returns: The copy’s runtime move name (a string). Pass it as move to sf2.moves.patch.
When: Entrypoint. Forks exist before move patches run.
-- NinjaSword gets its own heavy slash; Katana keeps the original.local ninja = sf2.moves.fork { id = "KatanaHeavySlash_Ninja", source = "KatanaHeavySlash", subtype = "NinjaSword" }sf2.moves.patch { move = ninja, playback_rate = { expected = 1.0, value = 1.2 } }
-- Only the Golden Katana gets a heavier kick.local kick = sf2.moves.fork { id = "HighKick_Golden", source = "HighKick", item = "core:items/weapon/weapon_golden_katana" }Set exactly one of subtype or item; like goes only with subtype.
- With
subtype, the source must be locked to a group containing that subtype. The copy is locked to the subtype alone, and the subtype is removed from the source’s group. - With
item, the copy keeps the source’s locks plus the item, and the source gains a “not this item” lock. This works for any move, including ones every weapon shares. - The copy answers to every name the source does, so combos naming the source also match it. Patches on the source do not carry over; patch the copy separately.
- A new subtype (say
"Scythe2") has no moves locked to it, so uselike = "Scythe"to copy the source from an existing subtype it is locked to. You need onelikefork per move. To share the original moves instead, useitem_locks.addinsf2.moves.patch.
Only one mod can fork a given source for a given subtype or item. See Moves.
sf2.moves.patch
Section titled “sf2.moves.patch”Change an existing move’s timing, animation, conditions, attacks, or which items and perks unlock it.
Signature: sf2.moves.patch { move, disable?, enable?, when?, hit?, sound_frame?, input?, priority?, animation?, playback_rate?, speed?, cooldown?, profile_icon?, windows?, attacks?, replace?, item_locks?, perk_locks?, exclude_items? }
Parameters
| Parameter | Type | Required |
|---|---|---|
definition |
MovePatch |
Required |
Fields of MovePatch
| Field | Type | Required | Meaning |
|---|---|---|---|
move |
string |
Required | — |
disable |
boolean |
Optional | — |
enable |
boolean |
Optional | Switches on a restricted move that the game holds back for content mods. |
when |
MoveWhen |
Optional | Conditions added to the move. |
hit |
MoveHitPatch |
Optional | — |
sound_frame |
MoveSoundFramePatch |
Optional | — |
input |
MoveInputPatch |
Optional | — |
priority |
MovePriorityPatch |
Optional | — |
animation |
MoveAnimationPatch |
Optional | — |
playback_rate |
MovePlaybackRatePatch |
Optional | — |
speed |
MoveSpeedPatch |
Optional | — |
cooldown |
MoveCooldown |
Optional | — |
profile_icon |
MoveProfileIconPatch |
Optional | The move’s picture in the profile’s move list. |
windows |
MoveWindowEdits |
Optional | — |
attacks |
MoveAttackEdit[] |
Optional | — |
replace |
MoveReplacementDefinition |
Optional | Replaces the move with a new definition. |
item_locks |
MoveItemLocks |
Optional | — |
perk_locks |
MovePerkLocks |
Optional | — |
exclude_items |
(string|ItemHandle)[] |
Optional | Items that stop getting the move (handles or qualified item IDs). |
Returns: nil, or the new move’s handle when replace is given.
When: Entrypoint.
sf2.moves.patch { move = "FrontKick", windows = { change = { uninterruptible = { expected = { from = 12, to = 50 }, value = { to = 44 } } } }, priority = { expected = 120, value = 125 },}sf2.moves.patch { move = "WaspFly_150", disable = true }move is an exact, case-sensitive native move name (or the name sf2.moves.fork returned), not a handle. Only one patch may own a move across all mods, so put every change to it in one table. See Moves for condition, key and hit-reaction names.
Most operations are guarded: write { expected = ..., value = ... }, where expected is what the base game has now. If it does not match (another game version, or another mod’s change), the whole patch is rejected rather than changing something else. Frame values are game frames; if the move’s timing is unknown, use from_sample / to_sample.
disable = truemakes the move’s selection condition always fail; it must be the only operation in its patch.enable = trueswitches on a restricted move: one the game ships but holds back for a content mod. Without a mod that enables it, a restricted move is never selected, by the player or the AI, and is not listed among the player’s moves. Enabling a move that is not restricted does nothing. It can sit beside other operations, but not besidedisable. A script that starts a move directly (fighter:play_move) is not held back.
sf2.moves.patch { move = "AxeKickOld", enable = true }The restricted moves are the Definitive Edition’s additions, grouped here by the families to enable together:
| Family | Moves |
|---|---|
| Unarmed kicks and punches | AxeKickOld, FrontJumpScissorsKick, AirPunch, WallRunUp |
| Leg Push throw | ThrowLegPush, ThrowLegPushV, StandupAfterLegFall, ThrowLegPushProfile, ThrowLegPushVProfile |
| Chinese Swords | ChineseSwordsSuperSlash |
| Rifle shot | RifleShot2Start, RifleShot2Middle, MiddleHitU (the hit reaction the shot causes) |
| Shadow Cloak | ShadowCloakPlayer |
| Arcane Martial Art | ArcaneMartialArtPunchHitBoxWall |
| Mind Throw | MindThrowPlayerNormal, MindThrowPlayer2Normal, MindThrowStartNormal, MindThrowMiddleNormal, MindThrowWallNormal, MindThrowHitNormal |
| Spheres | Sphere1Player, Sphere1Start, Sphere1Middle, Sphere1Wall, Sphere2Player, Sphere2Start, Sphere2Middle, Sphere2Wall, Sphere3Player, Sphere3Start, Sphere3Middle, ComboSphere3Player, ComboSphere3Start |
hitneeds the move to have exactly one attack with one full-length reaction; otherwise useattacks.sound_framemoves one direct sound (matched by clipnameand frameexpected). Sounds started by events are not supported.animationswaps the.bytesclip (expectedis the current filename,valueanother native clip orsf2.assets.binary(...)). Check the new clip’s timing fits the move’s windows.playback_rate(0.5to2.0) changes speed while windows and events stay on the same keyframes; damage and travel distance do not change. Not for looped or physics moves.speedchanges how fast a flying move travels sideways, in units per frame: a thrown or fired missile such as the musket’s ball (MusketShotMiddleflies at30).expectedis the move’s current speed; moves that do not fly are at0. A faster missile also reaches its target sooner, so it is harder to dodge.
sf2.moves.patch { move = "MusketShotMiddle", speed = { expected = 30, value = 45 } }cooldown = { frames, button? }stops a fighter from starting the move again while it plays and forframesframes (60 per second) after it ends. The count starts when the move finishes or when something cuts it short, such as a hit. It holds for the player and for opponents, in every fight and in dojo practice.button(punch,kick,rangedorraid_charge) shows the recharge as a ring filling round that button of the player’s; other moves on the button stay usable. The cooldown is not guarded and adds a condition to the move, so it can sit besidewhen.
sf2.moves.patch { move = "RifleSuperSlash", cooldown = { frames = 180, button = "punch" } }profile_iconchanges the picture the profile’s move list shows for the move.expectedis the icon the game gives it now (theIconof the move’s<Profile>entry in moves.xml, such asTrick5.high_punch);valueis a sprite handle, from your mod or acore:sprite. The move must have a profile entry. Icons in the list are about 190 UI units across, so a 380-pixel picture wantspixels_per_unit = 200in its sprite descriptor.
sf2.moves.patch { move = "WallRunUp", enable = true, profile_icon = { expected = "Trick5.high_punch", value = sf2.assets.sprite("sprites/moves/wall_run") },}Windows
Section titled “Windows”windows applies change, remove, then add, keyed by window kind or custom name. Each entry must select exactly one existing window (add needs a name the move lacks). In expected and remove, leave out a bound the window does not set: no from means the start of the move, no to means the end.
sf2.moves.patch { move = "HighKick", windows = { change = { uninterruptible = { expected = { to = 41 }, value = { to = 35 } } }, remove = { block = { from = 42 } }, add = { invulnerable = { name = "Dodge", from = 0, to = 8 } }, },}Attacks
Section titled “Attacks”attacks selects each attack by its authored id (usually starting at 0) and guards its fields. from/to are frames, and the hit reactions must still cover the whole window. You cannot add or remove ranged, magic or raid_charge damage terms.
sf2.moves.patch { move = "HighKick", attacks = { { id = 0, from = { expected = 12, value = 9 }, damage = { expected = 0.12, value = 0.15 }, hit = { expected = "High", value = "Middle" } } },}replace
Section titled “replace”replace swaps the move for a complete new definition under its native name. It takes the fields of sf2.moves.register plus a required expected_file (the original .bytes filename) and no target. Nothing is inherited from the original, so redefine its conditions, windows and actions. Perk triggers and transitions that name the original reach the replacement.
local step = sf2.moves.patch { move = "ExistingStep", replace = { id = "guarded_step", expected_file = "existing_step.bytes", animation = sf2.assets.binary("animations/guarded_step"), inherit = { "Step", "Controlled" }, windows = { uninterruptible = { to = 35 } }, },}Item and perk locks
Section titled “Item and perk locks”A lock is a requirement for the move to be usable. Lock edits apply at game load, so they need Apply & Restart, and each edit (same move and subtype, perk or item) belongs to one mod.
item_locks.add = { { slot, source_subtype, subtype } }letssubtypeuse the move alongsidesource_subtype. The move must have exactly one matching requirement, and subtype matching is case-sensitive. It does not change an item’s own subtype or supply animations.- Some moves are locked to one exact item rather than a subtype, such as Titan’s Mind Throw cast (
MindThrowPlayer), which needs Titan’s sword. For those, anaddentry takes{ source_item, item }instead:item(a handle or item ID) then unlocks the move alongsidesource_item. Both must be the same kind of equipment (two weapons, say), and the move must have exactly one requirement namingsource_item. item_locks.remove = { { slot, subtype } }takes a subtype out so those fighters lose the move. Removing the only subtype is rejected.perk_locks.add = { { source_perk, perk } }letsperkunlock a move thatsource_perklocks, without taking it from the original perk. The move needs exactly one direct lock onsource_perk.perk_locks.remove = { perk, ... }removes exact direct perk locks, leaving others.exclude_items = { item, ... }stops those items getting the move while other items of their subtype keep it.
sf2.moves.patch { move = "SaiSpit", item_locks = { add = { { slot = "weapon", source_subtype = "Sai", subtype = "ChineseSwords" } } },}sf2.moves.patch { move = "KatanaSpinningSlash", exclude_items = { "core:items/weapon/weapon_golden_katana" },}-- Your own copy of Titan's sword also unlocks Titan's Mind Throw cast.sf2.moves.patch { move = "MindThrowPlayer", item_locks = { add = { { source_item = "core:items/weapon/WEAPON_TITAN_GIANT_SWORD", item = my_titan_sword } } },}remove and exclude_items are the source-side halves of a fork. While developing, Reload mods (F9) applies edited patches in a running game.