Classes:ArtiPoisonBag3

From ZDoom Wiki
Jump to navigation Jump to search
Note: Wait! Stop! You do not need to copy this actor's code into your project! Here's why:
  1. This actor is already defined in GZDoom, there's no reason to define it again.
  2. In fact, trying to define an actor with the same name will cause an error (because it already exists).
  3. If you want to make your own version of this actor, use inheritance.
  4. Definitions for existing actors are put on the wiki for reference purpose only.
Thrown grenade fléchette
Actor type Artifact Game MiniHexenLogoIcon.png (Hexen)
DoomEd Number None Class Name ArtiPoisonBag3


Classes: InventoryArtiPoisonBagArtiPoisonBag3

The fléchette as used by Hexen's Fighter. When used, it is thrown like a grenade.

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.
class ArtiPoisonBag3 : ArtiPoisonBag
{
	Default
	{
		Inventory.Icon "ARTIPSB3";
		Tag "$TAG_ARTIPOISONBAG3";
	}
	
	override bool Use (bool pickup)
	{
		Actor mo = Spawn("ThrowingBomb", Owner.Pos + (0,0,35. - Owner.Floorclip + (Owner.player? Owner.player.crouchoffset : 0)), ALLOW_REPLACE);
		if (mo)
		{
			mo.angle = Owner.angle + (random[PoisonBag](-4, 3) * (360./256.));

			/* Original flight code from Hexen
			 * mo.momz = 4*F.RACUNIT+((player.lookdir)<<(F.RACBITS-4));
			 * mo.z += player.lookdir<<(F.RACBITS-4);
			 * P_ThrustMobj(mo, mo.ang, mo.info.speed);
			 * mo.momx += player.mo.momx>>1;
			 * mo.momy += player.mo.momy>>1;
			 */

			// When looking straight ahead, it uses a z velocity of 4 while the xy velocity
			// is as set by the projectile. To accommodate self with a proper trajectory, we
			// aim the projectile ~20 degrees higher than we're looking at and increase the
			// speed we fire at accordingly.
			double modpitch = clamp(-Owner.Pitch + 20, -89., 89.);
			double ang = mo.angle;
			double speed = (mo.Speed, 4.).Length();
			double xyscale = speed * cos(modpitch);

			mo.Vel.Z = speed * sin(modpitch);
			mo.Vel.X = xyscale * cos(ang) + Owner.Vel.X / 2;
			mo.Vel.Y = xyscale * sin(ang) + Owner.Vel.Y / 2;
			mo.AddZ(mo.Speed * sin(modpitch));

			mo.target = Owner;
			mo.tics -= random[PoisonBag](0, 3);
			mo.CheckMissileSpawn(Owner.radius);
			return true;
		}
		return false;
	}
	
	
}

DECORATE definition

Note: This is legacy code, kept for archival purposes only. DECORATE is deprecated in GZDoom and is completely superseded by ZScript. GZDoom internally uses the ZScript definition above.
ACTOR ArtiPoisonBag3 : ArtiPoisonBag native
{
  Inventory.Icon "ARTIPSB3"
  Tag "$TAG_ARTIPOISONBAG3"
}