From ZDoom Wiki
Jump to navigation Jump to search
Note: This page describes a function made for one of the natively supported games. These functions are made with very specific purpose and provide no flexibility, so using them in custom projects is not recommended. Authors are encouraged to use one of the more generalized functions in custom projects. For example: A_FireBullets.


action void A_FirePistol()

For more information on this article, visit the A_FirePistol page on the Doom Wiki.


Performs Doom's pistol attack, firing one pellet dealing 5 * 1d3 damage. This is a shortcut to calling A_FireBullets, A_PlaySound and A_GunFlash with certain predetermined hardcoded parameters.

If vertical bullet spread for weapons is enabled, the function applies vertical spread in addition to the horizontal one.

This code is the equivalent of calling A_FirePistol:

   A_FireBullets (5.6, 0, 1, 5, "BulletPuff");
   A_StartSound("weapons/pistol", CHAN_WEAPON);

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_FirePistol()
	bool accurate;

	if (player != null)
		Weapon weap = player.ReadyWeapon;
		if (weap != null && invoker == weap && stateinfo != null && stateinfo.mStateType == STATE_Psprite)
			if (!weap.DepleteAmmo (weap.bAltFire, true))

			player.SetPsprite(PSP_FLASH, weap.FindState('Flash'), true);
		player.mo.PlayAttacking2 ();

		accurate = !player.refire;
		accurate = true;

	A_StartSound ("weapons/pistol", CHAN_WEAPON);
	GunShot (accurate, "BulletPuff", BulletSlope ());