A_PosAttack

From ZDoom Wiki
Jump to navigation Jump to search
Ktip.png 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_CustomBulletAttack.

Actor

void A_PosAttack()

DoomWiki.org
For more information on this article, visit the A_PosAttack page on the Doom Wiki.

Usage

The attack of Doom's zombieman. This shoots one bullet and plays the sound “grunt/attack”.

It is the equivalent to calling A_CustomBulletAttack with the parameters (22.5, 0, 1, random(1,5)*3, "BulletPuff", 0, CBAF_NORANDOM).

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.
	void A_PosAttack()
	{
		if (target)
		{
			A_FaceTarget();
			double ang = angle;
			double slope = AimLineAttack(ang, MISSILERANGE);
			A_StartSound("grunt/attack", CHAN_WEAPON);
			ang  += Random2[PosAttack]() * (22.5/256);
			int damage = Random[PosAttack](1, 5) * 3;
			LineAttack(ang, MISSILERANGE, slope, damage, "Hitscan", "Bulletpuff");
		}
	}

Examples

This example is taken straight from Doom's Zombieman.

 Missile:
   POSS E 10 A_FaceTarget;
   POSS F 8 A_PosAttack;
   POSS E 8;
   goto See;

This example uses a generic function to exactly replicate it instead.

 Missile:
   POSS E 10 A_FaceTarget;
   POSS E 0 A_StartSound ("grunt/attack", CHAN_WEAPON);
   POSS F 8 A_CustomBulletAttack (22.5, 0, 1, random(1,5) * 3, flags: CBAF_NORANDOM);
   POSS E 8;
   goto See;

See also