A_WeaponBulletAttack

From DoomWiki.org

A_WeaponBulletAttack(hspread, vspread, numbullets, damagebase, damagedice) is a generic weapon bullet attack function that is part of the MBF21 specification. It has five parameters, using the values in the "Args" fields as arguments.

The first argument defines the maximum horizontal spread of the bullet attack, while the second sets the maximum amount for the vertical spread. Both of these will default to zero if not provided, resulting in no spread being applied to the attack (setting both values to 1 will yield the same result). The third argument defines how many bullets are being fired and will default to 1 if not provided. The fourth and fifth arguments set the damage range for the attack, with the fourth argument controlling the base damage, while the fifth one supplies the damage multiplier. The base damage will default to 5 and the damage multiplier to 3 if not provided (mirroring A_FirePistol). The damage is calculated using the following formula:

damage = (damagebase * random(1, damagedice))

The first two arguments have to be passed to the function in fixed point, meaning the intended value has to be multiplied by 65536 (FRACUNIT), while all the remaining ones use integer values, meaning the intended values can be input as is. The function will also call A_FaceTarget and play the attack sound of the calling actor. Note that unlike native Doom code pointers, this function does not consume ammo, trigger the muzzle flash state, or play a sound.

Example[edit]

The following is an example of how to set the A_WeaponBulletAttack code pointer in a DeHackEd file using BEX syntax:

Frame 36
Args1 = 737280
Args2 = 465108
Args3 = 20
Args4 = 5
Args5 = 3

[CODEPTR]
FRAME 36 = WeaponBulletAttack

Or using DECOHack syntax:

state 36
{
 SHT2 A 7 A_WeaponBulletAttack(11.25, 7.097, 20, 5, 3)
 goto 37
}

The example above uses A_WeaponBulletAttack to emulate the behavior of A_FireShotgun2, the super shotgun's firing function (but without consuming ammo, playing the DSHTGN sound, or triggering the weapon's muzzle flash state).

External links[edit]