state A_JumpIfInput (int keys, state label, int flags = 0, int owner = AAPTR_DEFAULT)
A_JumpIfInput
Availability
ZandroX only. Does not exist in Zandronum 3.2, and has no GZDoom equivalent — GZDoom exposes raw input through the
GetPlayerInputexpression function instead, which this engine does not have.Works in netgames, unlike the
A_Overlayfamily. The jump is decided by the server and replicated, so it is consistent for everyone — at the cost of latency, see below.
Usage
Jumps to label when a player is holding the buttons named in keys.
Before this, DECORATE could not see input at all. Reacting to a button mid-animation meant
running a client-side ACS script that polled GetPlayerInput and pushed the actor into a state
from outside — awkward to write, and easy to desync. A_JumpIfInput puts the test in the state
sequence where the branch actually happens.
The usual application is branching out of a loop that is already running: letting a player
interrupt a wind-up by releasing fire, tap altfire mid-Fire sequence to switch firing modes,
or hold a movement key to change a melee attack's direction.
By default the test passes while any listed button is held, and it is re-tested every tic
the state runs. JIF_ALL, JIF_EDGE and JIF_NOT change that.
Being a jump function, this never sets the result of an inventory state chain — a
CustomInventory whose Pickup state calls it will not have the pickup cancelled by a failed
test.
Parameters
-
int keysAn OR-mask of the
BT_*button constants to test, combined with|— for exampleBT_ATTACK | BT_ALTATTACK.A mask of
0never matches, even withJIF_NOT. The empty-mask guard runs before the inversion, soA_JumpIfInput(0, "Somewhere", JIF_NOT)never jumps rather than always jumping.These eight are the gameplay buttons. They already reach the server every tic, so they cost nothing extra to test:
Constant Value Button BT_ATTACK1 Fire BT_USE2 Use / open BT_JUMP4 Jump BT_CROUCH8 Crouch BT_TURN18016 Turn 180° BT_ALTATTACK32 Alt fire BT_RELOAD64 Reload BT_ZOOM128 Zoom The rest are movement, look and script buttons. They are not transmitted every tic normally; see Network cost.
Constant Value Button BT_SPEED256 Run BT_STRAFE512 Strafe modifier BT_MOVERIGHT1024 Strafe right BT_MOVELEFT2048 Strafe left BT_BACK4096 Move back BT_FORWARD8192 Move forward BT_RIGHT16384 Turn right BT_LEFT32768 Turn left BT_LOOKUP65536 Look up BT_LOOKDOWN131072 Look down BT_MOVEUP262144 Move up (swim / fly) BT_MOVEDOWN524288 Move down (swim / fly) BT_SHOWSCORES1048576 Show scoreboard BT_USER12097152 +user1BT_USER24194304 +user2BT_USER38388608 +user3BT_USER416777216 +user4 -
state labelWhere to jump when the test passes. A quoted state name (
"AltFire") or a bare numeric offset from the current state.0or"None"means no jump, which makes the call a no-op. -
int flagsMultiple flags can be combined with
|. The following are available:-
JIF_ALL — require every button in
keysto be held at once, instead of any single one.A_JumpIfInput(BT_ATTACK|BT_ALTATTACK, "Both", JIF_ALL)fires only while both are down. -
JIF_EDGE — match only on the tic the input becomes newly satisfied, not for as long as it is held. This is what distinguishes a tap from a hold: without it, a state that loops while the player holds altfire will jump on every tic.
With
JIF_ALL, the edge is the tic the combination completes — the last button of the combo going down — not each individual press. -
JIF_NOT — invert the result, jumping when the test is not satisfied. Applied last, after
JIF_ALLandJIF_EDGE, soJIF_EDGE|JIF_NOTjumps on every tic that is not a rising edge, which is rarely what you want. PairJIF_NOTwith the default orJIF_ALL.
-
-
int ownerAn
AAPTR_*pointer selector choosing whose input to read. Defaults toAAPTR_DEFAULT, the calling actor's own player.Use it to have one actor react to another's input — a deployed turret reading its owner's buttons via
AAPTR_MASTER, for example. If the selected pointer is null or is not a player, no jump happens.
Latency
The server decides the jump, so for the player who pressed the button it lands roughly one
round-trip after the press, rather than instantly. Real fire and altfire feel immediate because
they are client-predicted; A_JumpIfInput is not. Keep that in mind for anything meant to feel
tight — a parry window sized in single tics will not survive the trip.
Actors flagged +CLIENTSIDEONLY are exempt: they evaluate the jump locally, with no latency and
no replication.
Network cost
The eight gameplay buttons above are in the low byte of the button word and are sent every tic already, so testing them costs nothing.
Everything above that byte — movement, look, BT_SPEED, and BT_USER1–BT_USER4 — is not
normally transmitted. So that the server can see them, the client now sends the full 32-bit
button set on any tic where one of them is held. That costs a few extra bytes per tic, and only
while such a button is actually down.
Examples
A super shotgun that lets the player interrupt the reload by tapping altfire, dumping the second
shell for a quicker recovery. JIF_EDGE is what makes this a tap rather than a hold — without
it the jump would trigger on the first tic altfire is down and every tic after.
ACTOR InterruptibleSSG : SuperShotgun
{
States
{
Fire:
SHT2 A 3
SHT2 A 7 A_FireShotgun2
SHT2 B 7
SHT2 C 7 A_CheckReload
SHT2 D 7 A_JumpIfInput(BT_ALTATTACK, "QuickEject", JIF_EDGE)
SHT2 EFG 6
SHT2 H 6 A_Refire
Goto Ready
QuickEject:
SHT2 EF 3
SHT2 H 4
Goto Ready
}
}
A charged attack that releases when the player lets go of fire, using JIF_NOT against the
default "any button held" test. The charge loop runs for as long as fire is down; the first tic
it is not, the jump fires.
Fire:
PLSG A 2 A_JumpIfInput(BT_ATTACK, "Release", JIF_NOT)
PLSG B 2 A_JumpIfInput(BT_ATTACK, "Release", JIF_NOT)
PLSG A 0 A_JumpIfInput(BT_ATTACK, "Fire", JIF_NOT)
Goto Fire
Release:
PLSG C 4 A_FireProjectile("PlasmaBall")
PLSG D 4
Goto Ready
A melee attack whose finisher depends on the player holding forward and run together — a
JIF_ALL combination test:
Melee:
PUNG B 4
PUNG C 4 A_JumpIfInput(BT_FORWARD|BT_SPEED, "Lunge", JIF_ALL)
PUNG D 4 A_CustomPunch(20)
Goto Ready
Lunge:
PUNG C 2 A_Recoil(-8)
PUNG D 4 A_CustomPunch(40)
Goto Ready
Note that BT_FORWARD and BT_SPEED both sit above the low byte, so this test is one of the
cases that makes the client send the full button word while those keys are down.
See also
- A_JumpIf — jump on an arbitrary DECORATE expression
- Actor pointers — the
AAPTR_*selectors theownerparameter takes - Psprite layers — note that a jump issued from an overlay layer is not replicated, so it is single-player only