A_WeaponProjectile
From DoomWiki.org
A_WeaponProjectile(type, angle, pitch, hoffset, voffset) is a generic weapon projectile function that is part of the MBF21 specification. It has five parameters, using the values in the "Args" fields as arguments.
The first argument determines the actor that is to be spawned as a projectile using the actor's DeHackEd number; if not provided, no projectile will be spawned. The second argument sets the angle in degrees at which the projectile is fired relative to the direction the player is facing (negative value = angle to the right, positive value = angle to the left). The third argument defines the pitch in degrees of the projectile relative to the player (negative value = upward, positive value = downward). The fourth argument sets the horizontal offset of the projectile relative to the player in map units (negative value = to the left, positive value = to the right). Finally, the fifth argument sets the vertical offset relative to the default firing height of the player in map units (negative value = below, positive value = above).
All arguments except the first one will default to zero if not provided and must be passed in fixed point, meaning the intended value has to be multiplied by 65536 (FRACUNIT), while all remaining ones use integer values, meaning the intended values can be input as is.
The projectile's tracer is set to the player's autoaim target, if available. Note also that, unlike native Doom code pointers, this function does not consume ammo, trigger the muzzle flash state, nor play a sound.
Example[edit]
The following is an example of how to set the A_WeaponProjectile
code pointer in a DeHackEd file using BEX syntax:
Frame 61 Args1 = 34 Args2 = 0 Args3 = 0 Args4 = 0 Args5 = 0 [CODEPTR] FRAME 61 = WeaponProjectile
Or using DECOHack syntax:
state 61 { MISG B 12 A_WeaponProjectile(34, 0, 0, 0, 0) goto 62 }
The example above uses A_WeaponProjectile
to replace the A_FireMissile code pointer in the rocket launcher's animation sequence. Apart from not consuming any ammo, this will result in identical behavior, since A_FireMissile does not play the firing sound of the rocket (played through the wake-up sound of the rocket itself) nor does it trigger the muzzle flash animation for the rocket launcher (called separately through A_GunFlash).
External links[edit]
- A_WeaponProjectile in the DSDA-Doom source code, hosted on GitHub.
- MBF21 specification, hosted on GitHub.