A JumpIfNoAmmo: Difference between revisions

From ZDoom Wiki
Jump to navigation Jump to search
Content deleted Content added
Add return type
No edit summary
 
(9 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{DISPLAYTITLE:A_JumpIfNoAmmo}}
{{codepointer|Jump}}
'''[[Classes:StateProvider|StateProvider]]'''
state '''A_JumpIfNoAmmo''' (int ''offset'')<br />

state '''A_JumpIfNoAmmo''' (str "''state''")
{{c|state '''A_JumpIfNoAmmo''' (int ''offset'')}}
{{JumpNotice}}

{{c|state '''A_JumpIfNoAmmo''' (StateLabel ''label'')}}

== Usage ==
== Usage ==
This function can only be used with {{Class|Weapon|weapons}}. It jumps if the carrying player doesn't have enough ammunition for one attack of the currently used attack mode (defaulting to primary fire if called outside of a fire state).
This function can only be used with {{Class|Weapon|weapons}}. It jumps if the carrying player doesn't have enough ammunition for one attack of the currently used attack mode (defaulting to primary fire if called outside of a fire state).
Line 10: Line 13:
''Offset'' is the number of frames to jump ahead when there is no ammo.
''Offset'' is the number of frames to jump ahead when there is no ammo.
''State'' is what state to jump to when you're out of ammo.
''State'' is what state to jump to when you're out of ammo.

=== Parameters ===
Like other jump functions designed for DECORATE, this function's first argument accept different values, either a [[ZScript data types#StateLabel|state label]], or an integer number:
*{{c|int '''offset'''}}
:The number of states to skip over (''including'' the one where this function is called).
*{{c|StateLabel '''label'''}}
:The [[Actor_states#State_labels|name of the state sequence]] to jump to. The name must be given in quotation marks.


== Examples ==
== Examples ==
Line 16: Line 26:
{
{
Fire:
Fire:
CISG A 0 '''A_JumpIfNoAmmo'''("Reload")
TNT1 A 0 '''A_JumpIfNoAmmo'''("Reload");
CISG B 1 BRIGHT [[A_GunFlash]]
CISG B 1 BRIGHT
{
TNT1 A 0 [[A_FireCustomMissile]]("PistolShellcasingSpawn",0,0,-6,2)
CISG B 1 [[A_FireBullets]](3,2,-1,9.2,"BULLETHIT",1,0)
[[A_GunFlash]]();
[[A_FireBullets]](3, 2, -1, 9, pufftype: 'BulletHitPuff');
CISG CDE 2
Goto Ready
}
CISG CDE 2;
Goto Ready;

[[Category:Decorate Jump functions]]
[[Category:StateProvider]]

Latest revision as of 10:20, 22 November 2024

StateProvider

state A_JumpIfNoAmmo (int offset)

state A_JumpIfNoAmmo (StateLabel label)

Usage

This function can only be used with weapons. It jumps if the carrying player doesn't have enough ammunition for one attack of the currently used attack mode (defaulting to primary fire if called outside of a fire state).

This function also checks for the Infinite Ammo DMFlag or the infinite ammo powerup. If either are present, this will never jump.

Offset is the number of frames to jump ahead when there is no ammo. State is what state to jump to when you're out of ammo.

Parameters

Like other jump functions designed for DECORATE, this function's first argument accept different values, either a state label, or an integer number:

  • int offset
The number of states to skip over (including the one where this function is called).
  • StateLabel label
The name of the state sequence to jump to. The name must be given in quotation marks.

Examples

  States
  {
    Fire:
     TNT1 A 0 A_JumpIfNoAmmo("Reload");
     CISG B 1 BRIGHT 
     {
       A_GunFlash();
       A_FireBullets(3, 2, -1, 9, pufftype: 'BulletHitPuff');
     }
     CISG CDE 2;
     Goto Ready;