A_FireRailgun

From ZDoom Wiki
Jump to navigation Jump to search
Note: This function exists to keep parity with Skulltag. For customizable railgun attacks, A_RailAttack is recommended instead.

StateProvider

action void A_FireRailgun(class<Actor> puffType = "BulletPuff", int offset_xy = 0)

Usage

Fires a railgun with largely predetermined parameters. This rail will do 100 damage in deathmatch and 150 in all other modes. Also displays the Flash state of the weapon.

The function's behavior is essentially equivalent to:

A_GunFlash();
A_RailAttack(deathmatch? 100 : 150); 

Parameters

  • class<Actor> puffType
The puff used by the attack. Defaults to Doom's BulletPuff. This allows customizing the attack behavior further.
  • int offset_xy
Horizontal offset of the attack. Determines the rail's original position.

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_FireRailgun(class<Actor> puffType = "BulletPuff", int offset_xy = 0)
	{
		if (player == null)
		{
			return;
		}

		Weapon weap = player.ReadyWeapon;
		if (weap != null && invoker == weap && stateinfo != null && stateinfo.mStateType == STATE_Psprite)
		{
			if (!weap.DepleteAmmo (weap.bAltFire, true))
				return;
			
			State flash = weap.FindState('Flash');
			if (flash != null)
			{
				player.SetSafeFlash(weap, flash, random[FireRail](0, 1));
			}
			
		}

		int damage = deathmatch ? 100 : 150;
		A_RailAttack(damage, offset_xy, false, pufftype: puffType);	// note that this function handles ammo depletion itself for Dehacked compatibility purposes.
	}


See Also