GunShot

From ZDoom Wiki
Jump to navigation Jump to search

StateProvider

action void GunShot(bool accurate, Class<Actor> pufftype, double pitch)

Usage

An attack function used internally by some of the Doom weapon functions, such as A_FirePistol, A_FireShotgun, A_FireCGun. This function itself is just a wrapper for LineAttack.

Note: This function has very niche functionality, being designed specifically to handle overarching behaviors common for all Doom hitscan weapons. It's unlikely to be useful in custom projects.


Parameters

  • bool accurate
If true, the attack will have no spread. This is normally set on the first shot, when player.refire is still 0 (A_ReFire has not been called).
  • class<Actor> pufftype
The puff class to spawn.
  • double pitch
Contains current attack pitch (normally the same as the player's pitch).

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.
	protected action void GunShot(bool accurate, Class<Actor> pufftype, double pitch)
	{
		int damage = 5 * random[GunShot](1, 3);
		double ang = angle;

		if (!accurate)
		{
			ang += Random2[GunShot]() * (5.625 / 256);

			if (GetCVar ("vertspread") && !sv_novertspread)
			{
				pitch += Random2[GunShot]() * (3.549 / 256);
			}
		}

		LineAttack(ang, PLAYERMISSILERANGE, pitch, damage, 'Hitscan', pufftype);
	}

See also