A_ClearReFire

From ZDoom Wiki
Jump to navigation Jump to search


StateProvider

action void A_ClearReFire()

Usage

Clears the refire counter set by A_ReFire. Normally, whenever A_ReFire is called, it increments the player.refire field in the PlayerInfo struct of the player who is the owner of the weapon. This has two effects:

  • When player.refire is above 0 (A_ReFire has been called at least once), hitscan attacks fired with A_FireBullets using 1 bullet will not have perfect accuracy (see here for details on this).
  • If Hold/AltHold states are present and player.refire is above 0, the next A_ReFire call will jump to those states rather than to the start of Fire/AltFire. This may lead to weird results if the weapon is for some reason deselected when firing, before returning to the Ready state and calling A_WeaponReady: when it's selected again, firing it will immediately send it to one of the hold states. Thus, clearing the refire counter manually may be important.

Examples

This is a weapon that uses A_ClearReFire to continue the chaingun animation.

class NewChaingun : Chaingun
{
	States
	{
	Fire:
		CHGG A 4 A_FireCGun;
		CHGG A 0 A_ReFire;
		Goto Ready;
	Hold:
		CHGG B 4 A_FireCGun;
		CHGG B 0 A_ClearReFire
		Goto Ready;
	}
}

ZScript definition

Note: The ZScript definition below is for reference and may be different in the current version of GZDoom.The most up-to-date version of this code can be found on GZDoom GitHub.
	action void A_ClearReFire()
	{
		if (NULL != player)	player.refire = 0;
	}