Jump to content

Controls: Difference between revisions

From OpenBOR
 
(14 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Introduction ==
== Introduction ==
OpenBOR’s native control scheme is designed to be as intuitive as possible and conform to established standards for side scrolling action games. Through various native options and scripting techniques (see below), creators can map these controls to perform any desired action. You can even rename or remove commands entirely to create a unique control scheme specific to your game. In turn, players may map available commands to desired keys or buttons via Control Options in the main menu.
OpenBOR gives each player four movement directions, six attack inputs, Jump, Special, Start, and Screenshot. Players bind these logical inputs to keyboard keys or controller buttons through '''Control Options'''. Creators give them game-specific behavior through model commands, native options, and scripts.
 
Physical bindings and gameplay actions are separate. With the default keyboard layout, pressing '''C''' produces the '''Attack 5''' input. Model commands such as <code>com a5 freespecial1</code> assign an animation to that input. Naming it <code>Dash</code> in the controls menu then tells the player what it does in that game.


== Default Keys ==
== Default Keys ==
OpenBOR allots each player the following inputs and default mappings.
The following keyboard bindings are the defaults for '''Player 1'''. Attack 2-6 have physical bindings and are available for creator-defined character actions.


'''Left'''
[[File:OpenBOR Controls Default Keyboard.png|thumb|center|900px|Default Player 1 keyboard bindings. The upper action row is A/S/D/F; the lower row is Z/X/C/V. Players can remap the logical inputs to other keys or controller buttons.]]


* Move player left on screen.
{| class="wikitable"
* Cycle to previous column or option on current row in menus.
! Logical input !! Default key !! Native use
* Cycle to previous character during player select.
|-
| Left / Right || Left / Right arrows || Stage movement, menu navigation, and character selection.
|-
| Up / Down || Up / Down arrows || Stage movement along the depth axis, menu navigation, and palette selection. Down can crouch in a 2D stage when the model supports it.
|-
| Attack 1 || A || Basic attack, item pickup, and selection confirmation.
|-
| Attack 2 || S || Creator-defined action.
|-
| Attack 3 || Z || Creator-defined action.
|-
| Attack 4 || X || Creator-defined action.
|-
| Attack 5 || C || Creator-defined action.
|-
| Attack 6 || V || Creator-defined action.
|-
| Jump || D || Jump.
|-
| Special || F || Native breakaway special. See [[#Attack and Jump Special|Attack and Jump Special]] for alternate mappings and blocking behavior.
|-
| Start || Enter || Start or continue, join a game, and pause or resume play.
|-
| Screenshot || F12 || Save a screen capture. From the pause screen, open the options menu.
|-
| Escape || Esc || Back or cancel in menus, leave player selection, and resume from pause. This is a fixed engine control.
|}


'''Right'''
Attack 2-6 acquire character actions when a creator assigns them. They also participate in common menu and text-box confirmations through the engine's action-button masks.


* Move player right on screen.
=== Configuring Bindings ===
* Cycle to next column or option on current row in menus.
Open '''Control Options''', choose the player, select an input, and press the desired keyboard key or controller button. The menu groups Attack 1-6 together and scrolls when the font size or screen height requires it.
* Cycle to next character during player select.


'''Up'''
'''OK''' keeps the changes, '''Cancel''' restores the previous settings, and '''Default''' restores the defaults for that player. Choosing Default for Player 1 restores Attack 5 to C and Attack 6 to V. Players 2-4 begin with unassigned configurable controls and can be set up through their own control menus. Escape remains fixed.


* Moves player up on screen (along Z axis) in pseudo 3D stages.
Android supplies on-screen controls for all six attack inputs. Its default layout places Attack 5 and Attack 6 above Attack 3 and Attack 4; creators can customize the touch layout through <code>touch.txt</code>.
* Cycle upward through rows in menus.
* Cycle to previous color palette during player select.


'''Down'''
== Renaming Keys ==
Use <code>data/menu.txt</code> to give the binding menu labels that match your game's actions. When <code>translation/menu.txt</code> is available, it takes precedence.


* Moves player down on screen (along Z axis) in pseudo 3D stages.
<pre>
* Crouch/Duck in 2D stages.
renamekey {control} {label}
* Cycle downward through rows in menus.
disablekey {control}
* Cycle to next color palette during player select.
</pre>


'''Special'''
<code>renamekey</code> changes the displayed label. <code>disablekey</code> hides that input's row from the binding menu; its existing binding and availability to commands or scripts remain in place.


* Player Special.
Accepted configurable control names are:
* Blocking if enabled (see ajspecial below).


'''Jump'''
{| class="wikitable"
 
! Group !! Names
* Player Jumping.
|-
 
| Movement || <code>moveup</code>, <code>movedown</code>, <code>moveleft</code>, <code>moveright</code>
'''Attack 1'''
|-
 
| Attacks || <code>attack</code>, <code>attack2</code>, <code>attack3</code>, <code>attack4</code>, <code>attack5</code>, <code>attack6</code>
* Basic attack.
|-
* Confirm a selection.
| Other inputs || <code>jump</code>, <code>special</code>, <code>start</code>, <code>screenshot</code>
* Pick up items.
|}
 
'''Attack 2''' '''-''' Unused.
 
'''Attack 3''' '''-''' Unused.
 
'''Attack 4''' '''-''' Unused.
 
'''Start'''
 
* Begin or continue a game.
* Join multiplayer game in progress (if not an active player).
* Pause/resume game in progress (if an active player).
 
'''Screenshot'''
 
* Send a screen capture to Screenshots folder.
* Access main menu during game pause.
 
In addition, there is a universal '''Escape''' key:
 
* Cycle to previous page in menu.
* Exit player select and return to main menu.
* Shut down engine when not in game or in a menu.
* Resume a paused game.
 
== Renaming Keys ==
You can rename keys by adding a file to the data folder named <code>menu.txt</code>. Use the following commands in the menu.txt file to customize or remove keys.


* <code>renamekey {target command} {new name}</code>
For example, a game could use Attack 2 for magic, Attack 5 for a dash, and Attack 6 for an interaction:
* <code>disablekey {target command}</code>


Accepted keys for rename or removal:
<pre>
renamekey attack2 Magic
renamekey attack5 Dash
renamekey attack6 Interact
disablekey attack4
</pre>


* <code>moveup</code>
These labels describe the creator's chosen design. Assign the corresponding actions separately through commands or scripts. Renaming Attack 5 to Dash keeps its authoring name <code>attack5</code>, command token <code>a5</code>, and script flag <code>FLAG_ATTACK5</code>.
* <code>movedown</code>
* <code>moveright</code>
* <code>moveleft</code>
* <code>attack</code>
* <code>attack2</code>
* <code>attack3</code>
* <code>attack4</code>
* <code>jump</code>
* <code>special</code>
* <code>start</code>
* <code>screenshot</code>
 
In this example, <code>menu.txt</code> renames Special to Defend and Attack 2 to Magic, while removing unused commands Attack 3 and Attack 4. This presents the player with a more polished set of controls that match actual in game functionality.<syntaxhighlight lang="text" line="1">
renamekey attack Attack
renamekey attack2 Magic
renamekey special Defend
 
disablekey attack3
disablekey attack4
</syntaxhighlight>
[[File:Controls menu.webp|center|frame|Renaming keys to match their function in your projects adds a professional touch.]]


== Alternate Command Functions ==
== Alternate Command Functions ==
You can add to or change the existing functionality of commands entirely. Common examples include adding additional attacks mapped to the normally unused Attack 2+ commands, remapping the player special, or special move sequences.
Creators can assign attacks, evasive moves, interactions, and other behavior to the available inputs. Commands bind inputs to freespecial animations, native options select built-in behavior, and scripts can implement custom responses.


=== Command ===
=== Command ===
<syntaxhighlight lang="text">
<pre>
com {sequence} {freespecial#}
com {sequence} {freespecial#}
</syntaxhighlight>Enables mapping single button or command sequences to trigger a desired Freespecial animation. Place <code>com</code> into a model’s text header. You may add multiple commands to a model with no practical limits other than hardware resources.
</pre>Maps a button or input sequence to a freespecial animation. Place <code>com</code> in the model's text header, with one line for each mapping.


* '''Sequence''' is the input or sequence of inputs to trigger the command. Each sequence may contain up to sixty-four steps from the following list. Default in game leeway for command sequences is 50 [[Time#Elapsed Time 2|elapsed time]] ticks, or <code>0.25</code> seconds allowed between each new step:
* '''Sequence''' is the input or sequence of inputs to trigger the command. Each sequence may contain up to sixty-four steps from the following list. The default allowed gap between successive steps is 50 [[Time#Elapsed Time 2|elapsed-time]] ticks, or <code>0.25</code> seconds at the default 200-tick simulation rate:
** <code>f</code> - Left/right (same direction character is facing).
** <code>f</code> - Left/right (same direction character is facing).
** <code>b</code> - Left/Right (opposite direction character is facing).
** <code>b</code> - Left/Right (opposite direction character is facing).
Line 115: Line 96:
** <code>u</code> - Up.
** <code>u</code> - Up.
** <code>d</code> - Down.
** <code>d</code> - Down.
** <code>a</code> - Attack 1.
** <code>a</code> - Attack 1. <code>a1</code> is also accepted.
** <code>a2</code> - Attack 2.
** <code>a2</code> - Attack 2.
** <code>a3</code> - Attack 3.
** <code>a3</code> - Attack 3.
** <code>a4</code> - Attack 4.
** <code>a4</code> - Attack 4.
** <code>a5</code> - Attack 5.
** <code>a6</code> - Attack 6.
** <code>j</code> - Jump.
** <code>j</code> - Jump.
** <code>s</code> - Special.
** <code>s</code> - Special.
Line 124: Line 107:
** <code>sc</code> - Screenshot.
** <code>sc</code> - Screenshot.
** <code>+</code> - Chord input. Ex. <code>a + s</code> means press Attack and Special together. Each chord counts as one sequence step, regardless of how many inputs it may encompass.  
** <code>+</code> - Chord input. Ex. <code>a + s</code> means press Attack and Special together. Each chord counts as one sequence step, regardless of how many inputs it may encompass.  
*** <code>+[int grace time (default 0)]</code> - Optional grace period to press all buttons in a chord. Ex. <code>a + s +[100]</code> allows up to 100 ticks to press <code>a</code> and <code>s</code>. Longer grace periods make commands easier, but may also result in overly delayed activation if players are slow with their fingers and give the game an unresponsive, laggy feeling. Adjust to suit your game needs.
*** <code>+[int grace time (default 0)]</code> - Maximum time between the presses that form a chord. Ex. <code>a5 + a6 +[20]</code> accepts the two presses up to 20 ticks apart, with the earlier button still held. The command becomes eligible on the completing press; it does not wait for the full grace period. Zero requires the presses on the same logical tick.
** <code>~</code> - Release key. Ex. <code>~a</code> means release Attack.
** <code>~</code> - Release key. Ex. <code>~a</code> means release Attack.
** <code>[min time (default 0)][max time (default 0)]</code> - Time constraints for holding a key. Held requirements must share their sequence step with a press, release, or automatic trigger. Maximum time is optional.
** <code>[min time (default 0)][max time (default 0)]</code> - Time constraints for holding a key. Held requirements must share their sequence step with a press, release, or automatic trigger. Maximum time is optional.
Line 132: Line 115:
*** <code>a[0]</code> - Hold <code>a</code> without any time constraints.
*** <code>a[0]</code> - Hold <code>a</code> without any time constraints.
** <code>*[int time]</code> - Auto trigger if held to time. Ex. <code>a*[50]</code> means action triggers automatically after holding <code>a</code> for 50 ticks.
** <code>*[int time]</code> - Auto trigger if held to time. Ex. <code>a*[50]</code> means action triggers automatically after holding <code>a</code> for 50 ticks.
** <code>:[int time]</code> - Time allowed between sequence steps. Ex. <code>d -> f -> a -> :[100]</code> means you have 100 ticks to enter <code>d</code>, then 100 ticks to enter <code>f</code>, and another 100 to enter <code>a</code>. If not used, the global default applies instead. <code>:[time]</code> may appear once anywhere outside an unfinished <code>+</code> expression and requires at least two sequence steps. Does not count as a sequence step.  
** <code>:[int time]</code> - Maximum gap between successive sequence steps. Ex. <code>d -> f -> a5 :[100]</code> allows up to 100 ticks from Down to Forward, then up to 100 ticks from Forward to Attack 5. The first input begins the sequence. If omitted, the global default applies. <code>:[time]</code> may appear once anywhere outside an unfinished <code>+</code> expression and requires at least two sequence steps. Does not count as a sequence step.  
** <code>-></code> - Delimiter. Optional, but highly recommended for readability. Does not count as a sequence step.
** <code>-></code> - Delimiter. Optional, but highly recommended for readability. Does not count as a sequence step.
* '''Freespecial#''' is the animation that plays in response to the command, assuming other conditions are met (i.e. having enough energy if the animation has an energy cost).  
* '''Freespecial#''' is the animation that plays in response to the command, assuming other conditions are met (i.e. having enough energy if the animation has an energy cost).  


==== Example Sequences ====
==== Example Sequences ====
[[File:OpenBOR Controls Command Timing.png|thumb|center|900px|Three independent command examples: an ordered sequence, a chord with a 20-tick grace period, and a hold followed by release. Tick values are relative to the first input in each example.]]
{| class="wikitable"
{| class="wikitable"
!Command
!Command
Line 143: Line 128:
|<code>com a2 freespecial1</code>
|<code>com a2 freespecial1</code>
|Press Attack 2.
|Press Attack 2.
|-
|<code>com a5 freespecial1</code>
|Press Attack 5.
|-
|<code>com a6 freespecial2</code>
|Press Attack 6.
|-
|<code>com a5 -> a6 freespecial1</code>
|Press Attack 5, then Attack 6 within the sequence's allowed gap.
|-
|<code>com a5 + a6 +[20] freespecial2</code>
|Press Attack 5 and Attack 6 within 20 ticks, keeping the earlier button held.
|-
|<code>com a5[50] + ~a5 freespecial3</code>
|Hold Attack 5 for at least 50 ticks, then release it.
|-
|-
|<code>com d -> f -> a freespecial1</code>
|<code>com d -> f -> a freespecial1</code>
Line 151: Line 151:
|-
|-
|<code>com a + j +[100] freespecial1</code>
|<code>com a + j +[100] freespecial1</code>
|Press Attack and Jump within 100 ticks of each other.
|Press Attack and Jump within 100 ticks of each other, keeping the earlier button held.
|-
|-
|<code>com ~a freespecial1</code>
|<code>com ~a freespecial1</code>
Line 191: Line 191:


===== Tips =====
===== Tips =====
Don’t let the name “freespecial” confuse you. Freespecials are not inherently “special”. You can use them to create any sort of animation you like, from a simple punch or kick, evasive movement, taunt, or whatever else.
Freespecial animations can represent any creator-defined action, including a punch, kick, dash, taunt, or interaction.


Overly exact commands in a side scrolling environment are not necessary and may make your game more spastic to control instead of more precise. For example, to create the classic Hadouken input you should use <code>d -> f -> a</code> rather than <code>d -> d + f -> f -> a</code>.
Choose input patterns that suit the game's movement. For a quarter-circle-style command in a belt-scrolling game, <code>d -> f -> a</code> is often a practical choice.


If two or more sequences overlap, the more complex input from the player “wins”. This is the same command scheme seen in most fighting games. Again using the Hadouken example, you could create a command for the normal Hadouken <code>d -> f -> a</code>, and another for Shinku Hadouken as <code>d -> f -> d -> f -> a</code>. OpenBOR will recognize if a player uses the Shinku Hadouken input even though the last portion of it is identical to the Hadouken input.
When eligible mappings overlap, the matcher prefers the one completed by the newest input event. For mappings completed by the same event, it prefers more sequence steps, then more input tokens. For example, <code>d -> f -> d -> f -> a</code> takes priority over <code>d -> f -> a</code> when both match the same final Attack press.


=== Cancel ===
=== Cancel ===
<syntaxhighlight lang="text">
<pre>
cancel {int start frame} {int end frame} {int hits} {sequence} {freespecial#}
cancel {int start frame} {int end frame} {int hits} {sequence} {freespecial#}
</syntaxhighlight>Cancel is similar to Command, in that it maps command sequences to activate a Freespecial. However, cancels are unique to a single animation and can interrupt the animation on a successful input. This allows “canceling” from one animation to another for customized chains and combos.
</pre>Cancel is similar to Command, in that it maps command sequences to activate a Freespecial. However, cancels are unique to a single animation and can interrupt the animation on a successful input. This allows “canceling” from one animation to another for customized chains and combos.


Place cancels into the animation header of any Jump, Attack, Freespecial, or Follow animation. You may add as many cancels as you like to an animation to give it multiple cancel options. The animation you cancel into may also have its own cancels to create an entire series of combo branch points.  
Place cancels into the animation header of any Jump, Attack, Freespecial, or Follow animation. You may add as many cancels as you like to an animation to give it multiple cancel options. The animation you cancel into may also have its own cancels to create an entire series of combo branch points.  
Line 206: Line 206:
* '''Start Frame -''' The first frame in animation when cancel is available - Remember that frames are 0 indexed.
* '''Start Frame -''' The first frame in animation when cancel is available - Remember that frames are 0 indexed.
* '''End Frame -''' The last frame in animation when cancel is available.
* '''End Frame -''' The last frame in animation when cancel is available.
* '''Hits -''' Required number of combo hits, if any, before cancel is available.
* '''Hits -''' Required hit count for the current animation. This counter resets when that animation starts; use <code>0</code> when no hit is required.
* '''Sequence -''' Identical to [[Controls#Command|command]] sequence parameter.
* '''Sequence -''' Identical to [[Controls#Command|command]] sequence parameter.
* '''Freespecial# -''' Identical to [[Controls#Command|command]] Freespecial# parameter.
* '''Freespecial# -''' Identical to [[Controls#Command|command]] Freespecial# parameter.


Cancel is otherwise identical to Command and follows the same rules (input sequence, energy cost, etc.).
Cancel is otherwise identical to Command and follows the same rules (input sequence, energy cost, etc.).
=== Script API ===
Command sequences defined by <code>com</code> and <code>cancel</code> are stored in each model structure’s command collection. See [[Controls#Command Input Sequence|Command Input Sequence]] below for access details. The command history used to match player inputs against these sequences is stored in the player structure. See [[Player Property#Command Buffer|Command Buffer]] in [[Player Property]] for access details.


== Maximum Freespecials ==
== Maximum Freespecials ==
<syntaxhighlight lang="text">
<pre>
maxfreespecials {int}
maxfreespecials {int}


#default
#default
maxfreespecials 8
maxfreespecials 8
</syntaxhighlight>Models.txt command that sets the highest numbered freespecial animation available globally. The default and minimum value is 8. For example, <code>maxfreespecials 12</code> enables animation identifiers <code>freespecial1</code> through <code>freespecial12</code>.  
</pre>Models.txt command that sets the highest numbered freespecial animation available globally. The default and minimum value is 8. For example, <code>maxfreespecials 12</code> enables animation identifiers <code>freespecial1</code> through <code>freespecial12</code>.  


'''Tip:''' You may allocate any number, but don't set some silly amount like 100 when you only need a few more freespecial animations. This wastes memory. Figure out what you actually need and allocate accordingly.  
Set this to the highest freespecial number used by your models.  


== Attack and Jump Special ==
== Attack and Jump Special ==
<syntaxhighlight lang="text">
<pre>
ajspecial {flags}
ajspecial {key}


#default
# Default
ajspecial special
ajspecial special
</syntaxhighlight>Controls mapping of the native breakaway special attack and enables blocking for players. Accepts one of the following:
</pre>
 
This <code>models.txt</code> command selects the input for the native breakaway special attack. Choose one of the following:
 
{| class="wikitable"
! Value !! Special-attack input !! Script constant
|-
| <code>special</code> (default) || Special || <code>AJSPECIAL_KEY_SPECIAL</code>
|-
| <code>double</code> || Attack 1 + Jump || <code>AJSPECIAL_KEY_DOUBLE</code>
|-
| <code>attack2</code> || Attack 2 || <code>AJSPECIAL_KEY_ATTACK2</code>
|-
| <code>attack3</code> || Attack 3 || <code>AJSPECIAL_KEY_ATTACK3</code>
|-
| <code>attack4</code> || Attack 4 || <code>AJSPECIAL_KEY_ATTACK4</code>
|-
| <code>attack5</code> || Attack 5 || <code>AJSPECIAL_KEY_ATTACK5</code>
|-
| <code>attack6</code> || Attack 6 || <code>AJSPECIAL_KEY_ATTACK6</code>
|}


* <code>special</code> (default) – Special attack mapped to Special key.
With <code>double</code>, Special is available for blocking when the model's animation and block configuration support it. If the model has no Block animation, Special remains a fallback for the breakaway special.
* <code>double</code> – Special attacks mapped to Attack + Jump. Blocking enabled (if entity has a Block animation) and mapped to Special key.
* <code>attack2</code> –  Special attack mapped to Attack 2 key.
* <code>attack3</code> –  Special attack mapped to Attack 3 key.
* <code>attack4</code> –  Special attack mapped to Attack 4 key.


<code>Ajspecial</code> is exposed to script as a global_config property. Use the following constants:
Scripts access this setting through the global configuration property API. Obtain named constants with <code>openborconstant()</code>:


* <code>openborconstant("AJSPECIAL_KEY_SPECIAL")</code>
<pre>
* <code>openborconstant("AJSPECIAL_KEY_DOUBLE")</code>
* <code>openborconstant("AJSPECIAL_KEY_ATTACK2")</code>
* <code>openborconstant("AJSPECIAL_KEY_ATTACK3")</code>
* <code>openborconstant("AJSPECIAL_KEY_ATTACK4")</code>
<syntaxhighlight lang="c" line="1">
void config = openborvariant("global_config");
void config = openborvariant("global_config");
int property = openborconstant("GLOBAL_CONFIG_PROPERTY_AJSPECIAL");


int value = get_global_config(config, "ajspecial");
int previous = get_global_config_property(config, property);
 
set_global_config_property(
value = openborconstant("AJSPECIAL_KEY_ATTACK3");
    config, property, openborconstant("AJSPECIAL_KEY_ATTACK5")
set_global_config(config, "ajspecial", value);
);
</syntaxhighlight>
</pre>


==== Legacy ====
==== Legacy ====
Prior to OpenBOR 4.0, ajspecial accepted only the following:
Before OpenBOR 4.0, the documented numeric values were <code>0</code> for Special and <code>1</code> for Attack + Jump. Use the named values above for current authoring.
 
* <code>0</code> (default) – Special attack mapped to Special key.
* <code>1</code> – Special attacks mapped to Attack + Jump. Blocking enabled (if entity has a Block animation) and mapped to Special key.


== Key Control Constants ==
== Key Control Constants ==


=== Key ID Constants ===
=== Key ID Constants ===
Each key press sent from the control reading layer maps to one of the following constants. These are usually not used by creators unless you are capturing and manipulating the detected keys with InputAll (see below).  
<code>SDID_*</code> constants identify logical control slots. Use them where an API requests a control ID. Use the <code>FLAG_*</code> constants below when working with player input masks.  


* <code>openborconstant("SDID_ATTACK")</code> - Attack key.
* <code>openborconstant("SDID_ATTACK")</code> - Attack key.
Line 267: Line 279:
* <code>openborconstant("SDID_ATTACK3")</code> - Attack 3 key.
* <code>openborconstant("SDID_ATTACK3")</code> - Attack 3 key.
* <code>openborconstant("SDID_ATTACK4")</code> - Attack 4 key.
* <code>openborconstant("SDID_ATTACK4")</code> - Attack 4 key.
* <code>openborconstant("SDID_ATTACK5")</code> - Attack 5 key.
* <code>openborconstant("SDID_ATTACK6")</code> - Attack 6 key.
* <code>openborconstant("SDID_ESC")</code> - Escape key.
* <code>openborconstant("SDID_ESC")</code> - Escape key.
* <code>openborconstant("SDID_JUMP")</code> - Jump key.
* <code>openborconstant("SDID_JUMP")</code> - Jump key.
Line 278: Line 292:


=== Key Flag Constants ===
=== Key Flag Constants ===
Once OpenBOR has detected a physical key press, it is mapped and stored using the following event constants. These are then used to execute the appropriate in game action. You may in turn use these constants to evaluate and even manipulate detected events (see below). Note these constants are actually bit masks.  
<code>FLAG_*</code> constants represent inputs within the engine's input masks. Use named constants to test or combine inputs, such as <code>openborconstant("FLAG_ATTACK5") | openborconstant("FLAG_ATTACK6")</code>.  


* <code>openborconstant("FLAG_ATTACK")</code> - Attack key.
* <code>openborconstant("FLAG_ATTACK")</code> - Attack key.
Line 284: Line 298:
* <code>openborconstant("FLAG_ATTACK3")</code> - Attack 3 key.
* <code>openborconstant("FLAG_ATTACK3")</code> - Attack 3 key.
* <code>openborconstant("FLAG_ATTACK4")</code> - Attack 4 key.
* <code>openborconstant("FLAG_ATTACK4")</code> - Attack 4 key.
* <code>openborconstant("FLAG_ANYBUTTON")</code> - Shortcut for any action key (jump, special, any attack).
* <code>openborconstant("FLAG_ATTACK5")</code> - Attack 5 key.
* <code>openborconstant("FLAG_BACKWARD")</code> - Left or right key in opposite direction player's controlled entity faces.
* <code>openborconstant("FLAG_ATTACK6")</code> - Attack 6 key.
* <code>openborconstant("FLAG_CONTROLKEYS")</code> - Shortcut for any game control (anything other than Start, Screenshot, or Escape).
* <code>openborconstant("FLAG_ANYBUTTON")</code> - Start, Jump, Special, and all six attack inputs.
* <code>openborconstant("FLAG_BACKWARD")</code> - Backward relative to the entity's facing direction, as recorded in command history.
* <code>openborconstant("FLAG_CONTROLKEYS")</code> - The four movement directions, Jump, Special, and all six attack inputs.
* <code>openborconstant("FLAG_ESC")</code> - Escape key.
* <code>openborconstant("FLAG_ESC")</code> - Escape key.
* <code>openborconstant("FLAG_FORWARD")</code> - Left or right key in same direction player's controlled entity faces.
* <code>openborconstant("FLAG_FORWARD")</code> - Forward relative to the entity's facing direction, as recorded in command history.
* <code>openborconstant("FLAG_JUMP")</code> - Jump key.
* <code>openborconstant("FLAG_JUMP")</code> - Jump key.
* <code>openborconstant("FLAG_MOVEDOWN")</code> - Down key.
* <code>openborconstant("FLAG_MOVEDOWN")</code> - Down key.
Line 297: Line 313:
* <code>openborconstant("FLAG_SPECIAL")</code> - Special key.
* <code>openborconstant("FLAG_SPECIAL")</code> - Special key.
* <code>openborconstant("FLAG_START")</code> - Start key.
* <code>openborconstant("FLAG_START")</code> - Start key.
<code>FLAG_FORWARD</code> and <code>FLAG_BACKWARD</code> are added to command-history events. Ordinary player key masks use Left and Right; scripts can combine those inputs with the entity's facing direction when they need a relative direction.


== Key Events ==
== Key Events ==
When native options aren’t enough, OpenBOR provides several layers of key events. These allow you to capture an incoming key or command, and insert your own scripts to perform any action you can imagine.


=== Key Status ===
OpenBOR provides layered script hooks for intercepting and responding to player input. These include the global InputAll preprocessor, level and model <code>keyscript</code>, per-player <code>key#.c</code> files, and global <code>keyall.c</code>. Each layer executes before native gameplay input handling, allowing creators to observe, supplement, redirect, or replace default control behavior.
OpenBOR maintains three key status values for each player. Each value is an integer you can apply bitwise logic to obtain an individual on/off flag for each key.


* '''Hold -''' An engine update begins. If a key is on, the key is held.
Player input is represented by masks for held, newly pressed, newly released, pending native play, and disabled controls. <code>playerkeys()</code> reads the held, pressed, and released states. [[Player Property|Player properties]] also expose the pending and disabled masks for scripts that transform or consume input.
* '''Press -''' Player presses a key.
* '''Release''' - Player releases a key.


# InputAll - Runs on initial player input before any engine key handling or key scripts take place. Use this event if you want to change the command input itself. Examples include reversing player controls or creating shortcut keys for multi-button presses.
See [[Key Scripts]] for the complete reference, including execution order, scope, event data, key states, <code>keyscriptrate</code>, input cancellation, and examples.
# Level keyscript#
# Entity keyscript
# Global key#.c
# Global keyall.c
# Default key action.


== Command Buffer ==
=== Reading Input States ===
In order to detect key sequences and execute actions, OpenBOR keeps a 256 slot ring buffer for each player. Each buffer contains the last 256 player input events. Events recorded include the following:
<pre>
playerkeys(player_index, state, "input_name");
</pre>


* Any new key press.
Player indexes are <code>0</code> through <code>3</code>. The state argument selects:
* Any new key release.
* Any held key with an auto trigger reaching its time threshold.


Individual entries in the buffer host the following data:
{| class="wikitable"
 
! State !! Meaning !! Example
* Newly pressed keys.
* Snapshot of inputs held when a positive edge occurs.
* Keys newly released at the event.
* Automatic hold-threshold edges.
* Complete held-state snapshot.
* Elapsed Time of event.
* Tick time of event.
In turn the key properties are bit masks that may contain one or more [[Controls#Key Flag Constants|key flags]].
 
To access the buffer, you will need to first acquire the buffer pointer from player properties, then select an index. This will in turn provide the pointer to buffer entry where you may access the desired property.
=== Get buffer entry ===
Once you have the buffer pointer, supply an index from <code>0</code> - <code>255</code> to get the buffer entry pointer. Note, as this is a ring buffer, indexes correspond to array elements, not the chronological order of recorded events. <syntaxhighlight lang="c" line="1">
void command_buffer = get_player_property(player, openborconstant("PLAYER_PROPERTY_COMMAND_BUFFER"));
int index = 2; // 0 - 255
 
void buffer_entry = get_command_input_event_object(command_buffer, index);
</syntaxhighlight>
 
=== Access Buffer Entry Properties ===
Once you have obtained a buffer entry pointer, you may get or set buffer properties as follows.<syntaxhighlight lang="c" line="1">// Get
int key_held = get_command_input_event_property(buffer_entry, openborconstant("COMMAND_INPUT_EVENT_PROPERTY_HELD"));
 
// Set
int new_key_held = openborconstant("FLAG_MOVEUP") | openborconstant("FLAG_JUMP");
 
set_command_input_event_property(buffer_entry, openborconstant("COMMAND_INPUT_EVENT_PROPERTY_HELD"), new_key_held);</syntaxhighlight>
{| class="wikitable sortable"
|+Buffer Entry Properties
!Property Constat
!Description
|-
|<code>COMMAND_INPUT_EVENT_PROPERTY_HELD</code>
|Complete snapshot of keys held at the event. Keys released by the event remain included so commands such as <code>a[50] + ~a</code> can verify both the held duration and release.
|-
|<code>COMMAND_INPUT_EVENT_PROPERTY_HOLD</code>
|Automatic hold-threshold edges generated when inputs such as <code>a*[50]</code> reach their configured time.
|-
|-
|<code>COMMAND_INPUT_EVENT_PROPERTY_PRESS</code>
| <code>0</code> || Currently held || <code>playerkeys(0, 0, "attack5")</code>
|Keys newly pressed at event.
|-
|-
|<code>COMMAND_INPUT_EVENT_PROPERTY_PRESS_CHORD</code>
| <code>1</code> || Newly pressed || <code>playerkeys(0, 1, "attack5")</code>
|Snapshot of inputs held when a positive edge (key press) occurs. For example, if the player is holding <code>f</code> and presses <code>a</code>, the event's press chord will contain the key event masks <code>openborconstant("FLAG_FORWARD")</code> and <code>openborconstant("FLAG_ATTACK")</code>.
|-
|-
|<code>COMMAND_INPUT_EVENT_PROPERTY_RELEASE</code>
| <code>2</code> || Newly released || <code>playerkeys(0, 2, "attack5")</code>
|Key release on event.
|-
|<code>COMMAND_INPUT_EVENT_PROPERTY_TICKS</code>
|[[Time#Ticks 2|SDL ticks]] when event occurred. This property is not used by native logic.
|-
|<code>COMMAND_INPUT_EVENT_PROPERTY_TIME</code>
|[[Time#Elapsed Time 2|Elapsed time]] when event occurred. This property is important for sequence timing, so be careful of causing logic errors if you choose to modify it.
|}
|}
Held includes the initial press and remains set while the input stays down. Newly pressed and newly released describe the corresponding transition. Test the result as nonzero; the function returns matching input flags.
Supplying multiple names requires every requested input to match the selected state:
<pre>
// Both inputs are currently held.
if(playerkeys(0, 0, "attack5", "attack6"))
{
    // Apply the game's chosen response.
}
</pre>


== Command Input Sequence ==
== Command Input Sequence ==
Each <code>com</code> or <code>cancel</code> mapping stores its input sequence as an array containing up to sixty-four command input steps. Each step describes the input edges, held-key requirements, and timing restrictions that must be satisfied together.
Command sequences are part of a model structure and define the sequences recognized while an entity spawned from the model is under player control. Each <code>com</code> or <code>cancel</code> mapping stores its input sequence as an array containing up to sixty-four command input steps. Each step describes the input edges, held-key requirements, and timing restrictions that must be satisfied together.


Inputs joined with <code>+</code> occupy the same sequence step. For example, <code>a + j</code> stores the Attack and Jump flags together in the step's Press property. Sequence steps are stored in chronological order, with index <code>0</code> representing the first step.
Inputs joined with <code>+</code> occupy the same sequence step. For example, <code>a + j</code> stores the Attack and Jump flags together in the step's Press property. Sequence steps are stored in chronological order, with index <code>0</code> representing the first step.
Line 398: Line 374:
Unlike the command buffer, the sequence array is not a ring. Indexes follow the command's chronological input order. Only indexes below the parent command's step count belong to the loaded sequence.
Unlike the command buffer, the sequence array is not a ring. Indexes follow the command's chronological input order. Only indexes below the parent command's step count belong to the loaded sequence.


<syntaxhighlight lang="c" line="1">
<pre>
int index = 2; // 0 - 63
int index = 2; // 0 - 63


void sequence_step = get_command_input_step_object(command_sequence, index);
void sequence_step = get_command_input_step_object(command_sequence, index);
</syntaxhighlight>
</pre>


=== Sequence Step Properties ===
=== Sequence Step Properties ===
Each sequence step provides the following properties:
Once you have obtained a sequence-step pointer, use <code>get_command_input_step_property()</code> and <code>set_command_input_step_property()</code> to read or modify its members. Key flags and timing properties use unsigned 64-bit integer values.
 
<pre>
// Get the required press flags.
int step_press = get_command_input_step_property(sequence_step, openborconstant("COMMAND_INPUT_STEP_PROPERTY_PRESS"));
 
// Require Attack and Jump in the same step.
int new_step_press = openborconstant("FLAG_ATTACK") | openborconstant("FLAG_JUMP");
 
// Set the required press flags.
set_command_input_step_property(sequence_step, openborconstant("COMMAND_INPUT_STEP_PROPERTY_PRESS"), new_step_press);
</pre>


{| class="wikitable sortable"
{| class="wikitable sortable"
Line 433: Line 420:
|Maximum elapsed-time span allowed among the Press flags forming a chord. Zero requires the presses to occur on the same logical tick.
|Maximum elapsed-time span allowed among the Press flags forming a chord. Zero requires the presses to occur on the same logical tick.
|}
|}
[[Category:Openbor]]
[[Category:Openbor]]
[[Category:Script]]

Latest revision as of 00:43, 30 November 2026

Introduction

OpenBOR gives each player four movement directions, six attack inputs, Jump, Special, Start, and Screenshot. Players bind these logical inputs to keyboard keys or controller buttons through Control Options. Creators give them game-specific behavior through model commands, native options, and scripts.

Physical bindings and gameplay actions are separate. With the default keyboard layout, pressing C produces the Attack 5 input. Model commands such as com a5 freespecial1 assign an animation to that input. Naming it Dash in the controls menu then tells the player what it does in that game.

Default Keys

The following keyboard bindings are the defaults for Player 1. Attack 2-6 have physical bindings and are available for creator-defined character actions.

Default Player 1 keyboard bindings. The upper action row is A/S/D/F; the lower row is Z/X/C/V. Players can remap the logical inputs to other keys or controller buttons.
Logical input Default key Native use
Left / Right Left / Right arrows Stage movement, menu navigation, and character selection.
Up / Down Up / Down arrows Stage movement along the depth axis, menu navigation, and palette selection. Down can crouch in a 2D stage when the model supports it.
Attack 1 A Basic attack, item pickup, and selection confirmation.
Attack 2 S Creator-defined action.
Attack 3 Z Creator-defined action.
Attack 4 X Creator-defined action.
Attack 5 C Creator-defined action.
Attack 6 V Creator-defined action.
Jump D Jump.
Special F Native breakaway special. See Attack and Jump Special for alternate mappings and blocking behavior.
Start Enter Start or continue, join a game, and pause or resume play.
Screenshot F12 Save a screen capture. From the pause screen, open the options menu.
Escape Esc Back or cancel in menus, leave player selection, and resume from pause. This is a fixed engine control.

Attack 2-6 acquire character actions when a creator assigns them. They also participate in common menu and text-box confirmations through the engine's action-button masks.

Configuring Bindings

Open Control Options, choose the player, select an input, and press the desired keyboard key or controller button. The menu groups Attack 1-6 together and scrolls when the font size or screen height requires it.

OK keeps the changes, Cancel restores the previous settings, and Default restores the defaults for that player. Choosing Default for Player 1 restores Attack 5 to C and Attack 6 to V. Players 2-4 begin with unassigned configurable controls and can be set up through their own control menus. Escape remains fixed.

Android supplies on-screen controls for all six attack inputs. Its default layout places Attack 5 and Attack 6 above Attack 3 and Attack 4; creators can customize the touch layout through touch.txt.

Renaming Keys

Use data/menu.txt to give the binding menu labels that match your game's actions. When translation/menu.txt is available, it takes precedence.

renamekey {control} {label}
disablekey {control}

renamekey changes the displayed label. disablekey hides that input's row from the binding menu; its existing binding and availability to commands or scripts remain in place.

Accepted configurable control names are:

Group Names
Movement moveup, movedown, moveleft, moveright
Attacks attack, attack2, attack3, attack4, attack5, attack6
Other inputs jump, special, start, screenshot

For example, a game could use Attack 2 for magic, Attack 5 for a dash, and Attack 6 for an interaction:

renamekey attack2 Magic
renamekey attack5 Dash
renamekey attack6 Interact
disablekey attack4

These labels describe the creator's chosen design. Assign the corresponding actions separately through commands or scripts. Renaming Attack 5 to Dash keeps its authoring name attack5, command token a5, and script flag FLAG_ATTACK5.

Alternate Command Functions

Creators can assign attacks, evasive moves, interactions, and other behavior to the available inputs. Commands bind inputs to freespecial animations, native options select built-in behavior, and scripts can implement custom responses.

Command

com {sequence} {freespecial#}

Maps a button or input sequence to a freespecial animation. Place com in the model's text header, with one line for each mapping.

  • Sequence is the input or sequence of inputs to trigger the command. Each sequence may contain up to sixty-four steps from the following list. The default allowed gap between successive steps is 50 elapsed-time ticks, or 0.25 seconds at the default 200-tick simulation rate:
    • f - Left/right (same direction character is facing).
    • b - Left/Right (opposite direction character is facing).
    • l - Left.
    • r - Right.
    • u - Up.
    • d - Down.
    • a - Attack 1. a1 is also accepted.
    • a2 - Attack 2.
    • a3 - Attack 3.
    • a4 - Attack 4.
    • a5 - Attack 5.
    • a6 - Attack 6.
    • j - Jump.
    • s - Special.
    • st - Start.
    • sc - Screenshot.
    • + - Chord input. Ex. a + s means press Attack and Special together. Each chord counts as one sequence step, regardless of how many inputs it may encompass.
      • +[int grace time (default 0)] - Maximum time between the presses that form a chord. Ex. a5 + a6 +[20] accepts the two presses up to 20 ticks apart, with the earlier button still held. The command becomes eligible on the completing press; it does not wait for the full grace period. Zero requires the presses on the same logical tick.
    • ~ - Release key. Ex. ~a means release Attack.
    • [min time (default 0)][max time (default 0)] - Time constraints for holding a key. Held requirements must share their sequence step with a press, release, or automatic trigger. Maximum time is optional.
      • a[50] - Hold a for at least 50 ticks.
      • a[50][200] - Hold a for at least 50 ticks, but no more than 200 ticks.
      • a[0][200] - Hold a with no minimum hold time, but no more than 200 ticks.
      • a[0] - Hold a without any time constraints.
    • *[int time] - Auto trigger if held to time. Ex. a*[50] means action triggers automatically after holding a for 50 ticks.
    • :[int time] - Maximum gap between successive sequence steps. Ex. d -> f -> a5 :[100] allows up to 100 ticks from Down to Forward, then up to 100 ticks from Forward to Attack 5. The first input begins the sequence. If omitted, the global default applies. :[time] may appear once anywhere outside an unfinished + expression and requires at least two sequence steps. Does not count as a sequence step.
    • -> - Delimiter. Optional, but highly recommended for readability. Does not count as a sequence step.
  • Freespecial# is the animation that plays in response to the command, assuming other conditions are met (i.e. having enough energy if the animation has an energy cost).

Example Sequences

Three independent command examples: an ordered sequence, a chord with a 20-tick grace period, and a hold followed by release. Tick values are relative to the first input in each example.
Command Result
com a2 freespecial1 Press Attack 2.
com a5 freespecial1 Press Attack 5.
com a6 freespecial2 Press Attack 6.
com a5 -> a6 freespecial1 Press Attack 5, then Attack 6 within the sequence's allowed gap.
com a5 + a6 +[20] freespecial2 Press Attack 5 and Attack 6 within 20 ticks, keeping the earlier button held.
com a5[50] + ~a5 freespecial3 Hold Attack 5 for at least 50 ticks, then release it.
com d -> f -> a freespecial1 Press Down, then Forward, then Attack.
com a + j freespecial1 Press Attack and Jump on the same tick.
com a + j +[100] freespecial1 Press Attack and Jump within 100 ticks of each other, keeping the earlier button held.
com ~a freespecial1 Release Attack.
com f[0] + a freespecial1 Hold Forward and press Attack.
com f[50] + a freespecial1 Hold Forward for at least 50 ticks, then press Attack while still holding Forward.
com a[0] + j freespecial1 Hold Attack for any duration and press Jump.
com a[0][200] + j freespecial1 Press Jump while Attack has been held for no more than 200 ticks.
com a[50][200] + j freespecial1 Press Jump while Attack has been held for 50 through 200 ticks.
com a[50] + ~a freespecial1 Hold Attack for at least 50 ticks, then release it.
com a[50][200] + ~a freespecial1 Release Attack after holding it for 50 through 200 ticks.
com a*[50] freespecial1 Trigger automatically when Attack has been held for 50 ticks.
com f -> ~f freespecial1 Press Forward, then release Forward.
com b[60][180] + ~b -> f + a freespecial1 Hold Back for 60 through 180 ticks, release it, then press Forward and Attack together.
com b[60][180] + ~b -> f + a +[20] freespecial1 Perform the same charge command with a 20-tick grace period for the Forward and Attack chord.
Tips

Freespecial animations can represent any creator-defined action, including a punch, kick, dash, taunt, or interaction.

Choose input patterns that suit the game's movement. For a quarter-circle-style command in a belt-scrolling game, d -> f -> a is often a practical choice.

When eligible mappings overlap, the matcher prefers the one completed by the newest input event. For mappings completed by the same event, it prefers more sequence steps, then more input tokens. For example, d -> f -> d -> f -> a takes priority over d -> f -> a when both match the same final Attack press.

Cancel

cancel {int start frame} {int end frame} {int hits} {sequence} {freespecial#}

Cancel is similar to Command, in that it maps command sequences to activate a Freespecial. However, cancels are unique to a single animation and can interrupt the animation on a successful input. This allows “canceling” from one animation to another for customized chains and combos.

Place cancels into the animation header of any Jump, Attack, Freespecial, or Follow animation. You may add as many cancels as you like to an animation to give it multiple cancel options. The animation you cancel into may also have its own cancels to create an entire series of combo branch points.

  • Start Frame - The first frame in animation when cancel is available - Remember that frames are 0 indexed.
  • End Frame - The last frame in animation when cancel is available.
  • Hits - Required hit count for the current animation. This counter resets when that animation starts; use 0 when no hit is required.
  • Sequence - Identical to command sequence parameter.
  • Freespecial# - Identical to command Freespecial# parameter.

Cancel is otherwise identical to Command and follows the same rules (input sequence, energy cost, etc.).

Script API

Command sequences defined by com and cancel are stored in each model structure’s command collection. See Command Input Sequence below for access details. The command history used to match player inputs against these sequences is stored in the player structure. See Command Buffer in Player Property for access details.

Maximum Freespecials

maxfreespecials {int}

#default
maxfreespecials 8

Models.txt command that sets the highest numbered freespecial animation available globally. The default and minimum value is 8. For example, maxfreespecials 12 enables animation identifiers freespecial1 through freespecial12.

Set this to the highest freespecial number used by your models.

Attack and Jump Special

ajspecial {key}

# Default
ajspecial special

This models.txt command selects the input for the native breakaway special attack. Choose one of the following:

Value Special-attack input Script constant
special (default) Special AJSPECIAL_KEY_SPECIAL
double Attack 1 + Jump AJSPECIAL_KEY_DOUBLE
attack2 Attack 2 AJSPECIAL_KEY_ATTACK2
attack3 Attack 3 AJSPECIAL_KEY_ATTACK3
attack4 Attack 4 AJSPECIAL_KEY_ATTACK4
attack5 Attack 5 AJSPECIAL_KEY_ATTACK5
attack6 Attack 6 AJSPECIAL_KEY_ATTACK6

With double, Special is available for blocking when the model's animation and block configuration support it. If the model has no Block animation, Special remains a fallback for the breakaway special.

Scripts access this setting through the global configuration property API. Obtain named constants with openborconstant():

void config = openborvariant("global_config");
int property = openborconstant("GLOBAL_CONFIG_PROPERTY_AJSPECIAL");

int previous = get_global_config_property(config, property);
set_global_config_property(
    config, property, openborconstant("AJSPECIAL_KEY_ATTACK5")
);

Legacy

Before OpenBOR 4.0, the documented numeric values were 0 for Special and 1 for Attack + Jump. Use the named values above for current authoring.

Key Control Constants

Key ID Constants

SDID_* constants identify logical control slots. Use them where an API requests a control ID. Use the FLAG_* constants below when working with player input masks.

  • openborconstant("SDID_ATTACK") - Attack key.
  • openborconstant("SDID_ATTACK2") - Attack 2 key.
  • openborconstant("SDID_ATTACK3") - Attack 3 key.
  • openborconstant("SDID_ATTACK4") - Attack 4 key.
  • openborconstant("SDID_ATTACK5") - Attack 5 key.
  • openborconstant("SDID_ATTACK6") - Attack 6 key.
  • openborconstant("SDID_ESC") - Escape key.
  • openborconstant("SDID_JUMP") - Jump key.
  • openborconstant("SDID_MOVEDOWN") - Move down key.
  • openborconstant("SDID_MOVELEFT") - Move left key.
  • openborconstant("SDID_MOVERIGHT") - Move right key.
  • openborconstant("SDID_MOVEUP") - Move up key.
  • openborconstant("SDID_SCREENSHOT") - Screenshot key.
  • openborconstant("SDID_SPECIAL") - Special key.
  • openborconstant("SDID_START") - Start key.

Key Flag Constants

FLAG_* constants represent inputs within the engine's input masks. Use named constants to test or combine inputs, such as openborconstant("FLAG_ATTACK5") | openborconstant("FLAG_ATTACK6").

  • openborconstant("FLAG_ATTACK") - Attack key.
  • openborconstant("FLAG_ATTACK2") - Attack 2 key.
  • openborconstant("FLAG_ATTACK3") - Attack 3 key.
  • openborconstant("FLAG_ATTACK4") - Attack 4 key.
  • openborconstant("FLAG_ATTACK5") - Attack 5 key.
  • openborconstant("FLAG_ATTACK6") - Attack 6 key.
  • openborconstant("FLAG_ANYBUTTON") - Start, Jump, Special, and all six attack inputs.
  • openborconstant("FLAG_BACKWARD") - Backward relative to the entity's facing direction, as recorded in command history.
  • openborconstant("FLAG_CONTROLKEYS") - The four movement directions, Jump, Special, and all six attack inputs.
  • openborconstant("FLAG_ESC") - Escape key.
  • openborconstant("FLAG_FORWARD") - Forward relative to the entity's facing direction, as recorded in command history.
  • openborconstant("FLAG_JUMP") - Jump key.
  • openborconstant("FLAG_MOVEDOWN") - Down key.
  • openborconstant("FLAG_MOVELEFT") - Left key.
  • openborconstant("FLAG_MOVERIGHT") - Right key.
  • openborconstant("FLAG_MOVEUP") - Up key.
  • openborconstant("FLAG_SCREENSHOT") - Screenshot key.
  • openborconstant("FLAG_SPECIAL") - Special key.
  • openborconstant("FLAG_START") - Start key.

FLAG_FORWARD and FLAG_BACKWARD are added to command-history events. Ordinary player key masks use Left and Right; scripts can combine those inputs with the entity's facing direction when they need a relative direction.

Key Events

OpenBOR provides layered script hooks for intercepting and responding to player input. These include the global InputAll preprocessor, level and model keyscript, per-player key#.c files, and global keyall.c. Each layer executes before native gameplay input handling, allowing creators to observe, supplement, redirect, or replace default control behavior.

Player input is represented by masks for held, newly pressed, newly released, pending native play, and disabled controls. playerkeys() reads the held, pressed, and released states. Player properties also expose the pending and disabled masks for scripts that transform or consume input.

See Key Scripts for the complete reference, including execution order, scope, event data, key states, keyscriptrate, input cancellation, and examples.

Reading Input States

playerkeys(player_index, state, "input_name");

Player indexes are 0 through 3. The state argument selects:

State Meaning Example
0 Currently held playerkeys(0, 0, "attack5")
1 Newly pressed playerkeys(0, 1, "attack5")
2 Newly released playerkeys(0, 2, "attack5")

Held includes the initial press and remains set while the input stays down. Newly pressed and newly released describe the corresponding transition. Test the result as nonzero; the function returns matching input flags.

Supplying multiple names requires every requested input to match the selected state:

// Both inputs are currently held.
if(playerkeys(0, 0, "attack5", "attack6"))
{
    // Apply the game's chosen response.
}

Command Input Sequence

Command sequences are part of a model structure and define the sequences recognized while an entity spawned from the model is under player control. Each com or cancel mapping stores its input sequence as an array containing up to sixty-four command input steps. Each step describes the input edges, held-key requirements, and timing restrictions that must be satisfied together.

Inputs joined with + occupy the same sequence step. For example, a + j stores the Attack and Jump flags together in the step's Press property. Sequence steps are stored in chronological order, with index 0 representing the first step.

Sequence syntax is represented internally as follows:

  • Ordinary key input - Press property.
  • ~key - Release property.
  • key[min][max] - Hold, Hold Time, and Hold Time Maximum properties.
  • key*[time] - Hold Trigger and Hold Time properties.
  • +[time] - Chord Time property.
  • + - Combines input flags into the same step.
  • -> - Readability delimiter only. It is not stored.
  • :[time] - Applies to the complete command and is stored by the parent com/cancel structure rather than an individual step.

Get Sequence Step

Once you have obtained the input-sequence pointer from a com or cancel structure, supply an index from 0 through 63 to obtain an individual step pointer.

Unlike the command buffer, the sequence array is not a ring. Indexes follow the command's chronological input order. Only indexes below the parent command's step count belong to the loaded sequence.

int index = 2; // 0 - 63

void sequence_step = get_command_input_step_object(command_sequence, index);

Sequence Step Properties

Once you have obtained a sequence-step pointer, use get_command_input_step_property() and set_command_input_step_property() to read or modify its members. Key flags and timing properties use unsigned 64-bit integer values.

// Get the required press flags.
int step_press = get_command_input_step_property(sequence_step, openborconstant("COMMAND_INPUT_STEP_PROPERTY_PRESS"));

// Require Attack and Jump in the same step.
int new_step_press = openborconstant("FLAG_ATTACK") | openborconstant("FLAG_JUMP");

// Set the required press flags.
set_command_input_step_property(sequence_step, openborconstant("COMMAND_INPUT_STEP_PROPERTY_PRESS"), new_step_press);
Sequence Step Properties
Property Description
COMMAND_INPUT_STEP_PROPERTY_PRESS Key flags requiring a positive edge. Multiple flags form a press chord.
COMMAND_INPUT_STEP_PROPERTY_HOLD Key flags that must be held when the step's triggering edge occurs. This is a passive requirement and cannot trigger a step by itself.
COMMAND_INPUT_STEP_PROPERTY_HOLD_TRIGGER Key flags that automatically produce an input edge upon reaching Hold Time.
COMMAND_INPUT_STEP_PROPERTY_RELEASE Key flags requiring a negative edge.
COMMAND_INPUT_STEP_PROPERTY_HOLD_TIME Inclusive minimum held duration in elapsed-time ticks. For Hold Trigger flags, this is the exact automatic-trigger threshold.
COMMAND_INPUT_STEP_PROPERTY_HOLD_TIME_MAXIMUM Inclusive maximum duration for passive Hold flags. Zero removes the maximum.
COMMAND_INPUT_STEP_PROPERTY_CHORD_TIME Maximum elapsed-time span allowed among the Press flags forming a chord. Zero requires the presses to occur on the same logical tick.