A_Jump
From ZDoom Wiki
A_Jump (int chance, int offset, ...)
A_Jump (int chance, str state, ...)
| Warning: Using state labels as arguments without quotation marks has been deprecated and will no longer work. Make sure to enclose all your string arguments with quotation marks to ensure full compatibility with future ZDoom versions. Refer to the available example(s) for proper usage |
Randomly advances to different frame. The chance value can range between 0 and 256. A chance of 0 will never jump, while a chance of 256 will always jump. If the jump does not happen, then the frame or instruction immediately following the A_Jump will be used as if A_Jump had not been present. If more than one offset values are present, A_Jump will choose one of them at random.
Note that offset specifies the number of frames to skip over, and not the number of lines. Instructions like goto, loop and stop cannot be jumped to directly for this reason. (If you need the A_Jump command to skip directly to an instruction, see the last example below for a way to do this)
Examples
POSS A 0 A_Jump (255,2) POSS A 5 POSS A 5 // <- Jumps to this one (almost always) POSS A 5
POSS A 0 A_Jump (0, 4) POSS ABC 5 POSS D 5 // <- Jumps to this one (never) POSS E 3
POSS A 0 A_Jump (127, 1) goto Melee // <- This line is skipped because it doesn't define a frame POSS A 5 // <- Jumps to this one (chance of about 50%) POSS B 3
POSS A 0 A_Jump (127, 5) POSS BCDE 5 Goto See POSS F 5 // <- Jumps to this frame, skipping frames B, C, D and E defined above Goto See
POSS A 0 A_Jump (127, 2) POSS A 5 goto Death POSS B 4 // <- Jumps to this one POSS C 3
POSS A 0 A_Jump (127, 2, 3, 6) POSS A 5 // <-- Has a 50% chance of dropping through to here (no jump), otherwise... goto Death POSS B 6 // <-- Jumps here... goto See POSS BCD 5 // <-- Or here... goto Death POSS E -1 // <-- Or here, with equal probability.
POSS A 0 A_Jump (127, 4)
POSS ABC 3
Stop
POSS A 0 // <- Jumps to this one
//(this state is like a jump mark for the goto See instruction on the next line)
goto See
// The above example can also be rewritten using a named state:
POSS A 0 A_Jump (127, "See")
POSS ABC 3
Stop

