A_FireCGun
Jump to navigation
Jump to search
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_FireCGun()
Usage
Does the standard Chaingun attack. It plays the sound "weapons/chngun", runs the Flash state, and fires one bullet similar to A_FirePistol.
If vertical bullet spread for weapons is enabled, the function applies vertical spread in addition to the horizontal one.
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_FireCGun()
{
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, 1))
return;
A_StartSound ("weapons/chngun", CHAN_WEAPON);
State flash = weap.FindState('Flash');
if (flash != null)
{
// Removed most of the mess that was here in the C++ code because SetSafeFlash already does some thorough validation.
State atk = weap.FindState('Fire');
let psp = player.GetPSprite(PSP_WEAPON);
if (psp)
{
State cur = psp.CurState;
int theflash = atk == cur? 0:1;
player.SetSafeFlash(weap, flash, theflash);
}
}
}
player.mo.PlayAttacking2 ();
GunShot (!player.refire, "BulletPuff", BulletSlope ());
}
Examples
This code is from the Chaingun:
Fire:
CHGG AB 4 A_FireCGun;
CHGG B 0 A_ReFire;
Goto Ready;