A_WeaponReady

From ZDoom Wiki
Jump to: navigation, search

A_WeaponReady [(int flags)]

A_WeaponReady is responsible for weapon bobbing and checking the fire keys and weapon changing keys. This function should be called in a weapon's “Ready” state so the weapon can be fired. The function can also be called in other states to allow a player to re-fire at any point.

Keep in mind that when A_WeaponReady is called, the sprite will accumulate a bobbing animation for around half a second if the player is in motion.

In case parts of this behavior are undesired, the following flags can be used:

  • WRF_NOBOB: The weapon's HUD sprites will not bob.
  • WRF_NOFIRE: The weapon will not be made ready for firing (same as WRF_NOPRIMARY|WRF_NOSECONDARY).
  • WRF_NOSWITCH: The weapon will not be made ready for deselection (and so cannot be switched off until the next call to A_WeaponReady without that flag).
  • WRF_DISABLESWITCH: Prevents from deselecting the weapon entirely until the next call to A_WeaponReady. NOSWITCH puts deselection on hold, whereas DISABLESWITCH cancels the deselection entirely. (New from 2.7.1)
  • WRF_NOPRIMARY: The weapon will not be ready for its normal fire.
  • WRF_NOSECONDARY: The weapon will not be ready for its alternate fire.
  • WRF_ALLOWRELOAD: The weapon will jump to the "Reload" state if the reload key is currently being pressed.
  • WRF_ALLOWZOOM: The weapon will jump to the "Zoom" state if the zoom key is currently being pressed.

Examples

  Ready:
  WEAP A 1 A_WeaponReady //Makes the weapon ready to fire
  Loop

  Fire:
  WEPF A 4
  WEPF B 4
  WEPF C 4 A_WeaponReady(WRF_NOBOB|WRF_NOSWITCH) //Allows the weapon to refire, but without any weapon bobbing or switching
  WEPF D 4
  WEPF E 4
  Goto Ready