From ZDoom Wiki
Jump to: navigation, search

A_SpawnProjectile (string missiletype, float spawnheight, float spawnofs_xy, double angle, int flags, angle pitch, int ptr)

A customizable projectile attack for monsters. This serves as a replacement for A_CustomMissile which has a pitch miscalculation in it, kept around for older mod compatibility.


  • missiletype - The missile to fire.
  • spawnheight - Raises the missile spawn point on the actor by this amount in units. Default is 32.0.
  • spawnofs_xy - Moves the missile spawn point to the right if positive, left if negative. Default is 0.
  • angle - Adds this much offset to the actor's angle, which is aimed at the target first. Default is 0.
  • flags - Used to determine the aim mode. By default, it is aimed directly at the target.

The following flags can be used to change this behavior (use | between flags to combine):

  • CMF_AIMOFFSET - The missile is aimed parallel to a missile with a spawn height of 32 and an xy-offet of 0. This can be useful if you want to have a monster shoot multiple missiles at once.
  • CMF_AIMDIRECTION - The missile is not aimed at a target. Instead, it is shot in the specified direction with the specified pitch.
  • CMF_TRACKOWNER - If a missile is fired by another missile, use this flag to ensure the secondary projectile knows who is its real owner. This behavior would have been the default, but it wasn't in the 2.0.x branch of ZDoom, allowing erroneous behavior which has been used by some mods, so fixing this would break compatibility.
  • CMF_CHECKTARGETDEAD - With this flag, the function will not spawn a missile if the calling actor's current target is dead.
  • CMF_ABSOLUTEPITCH - Use the pitch parameter as an absolute value, ignoring the calculated aim pitch. Implied CMF_AIMDIRECTION. The main difference here is that a target is required, where CMF_AIMDIRECTION does not require a target.
  • CMF_OFFSETPITCH - Use the pitch parameter as an offset to the calculated aim pitch.
  • CMF_SAVEPITCH - The pitch used for firing the missile is saved as the missile's own pitch. (Require CMF_AIMDIRECTION, CMF_ABSOLUTEPITCH, or CMF_OFFSETPITCH.)
  • CMF_ABSOLUTEANGLE - Use the angle parameter as an absolute value, ignoring the calculated aim angle. The calling actor's angle is still factored in, however.
  • CMF_BADPITCH - Uses the old pitch method. There are some cases where aiming can be inverted and requires this flag in order to fix it, such as CMF_OFFSETPITCH.
  • pitch - Offsets the projectile's aim vertically by this amount. Positive values aim down, while negative aim up. Only used if at least one of the flags CMF_AIMDIRECTION, CMF_ABSOLUTEPITCH and CMF_OFFSETPITCH are used. Default is 0.
  • ptr - The actor to fire the missile at. This takes an actor pointer. By default, the calling actor fires at its target (AAPTR_TARGET).


   POSS E 10 A_FaceTarget
   POSS F 8 A_SpawnProjectile("NormalBullet", 48)
   POSS E 8
   Goto See