From ZDoom Wiki
Jump to navigation Jump to search

bool, Actor A_SpawnItem [(class<Actor> missile [, double distance [, double zheight [, bool useammo [, bool transfer_translation]]]])]

Note: This function has been superseded by A_SpawnItemEx, which duplicates and extends its functionality. Use of the newer function is advised in order to maintain maximum flexibility in your code.


Spawns the specified actor at the specified distance and height relative to the calling actor.

The function does not spawn monster-based actors if the calling actor was massacred or there is not enough space for them to spawn.

If both the originator and spawned actor are monster based, the spawned actor becomes affiliated with the originator. If, however, the originator is a player, the spawned actor, in this case, becomes a friendly monster which is allied with that player.


  • missile: the name of the actor to spawn. This can be any actor type, not just missiles. Default is "Unknown".
  • distance: the distance from the calling actor to spawn the actor. Positive values shift the spawn point forwards, while negative values shift it backwards. Default is 0.
  • zheight: how far from the bottom of the calling actor to spawn the actor. Positive values shift the spawn point upwards, while negative values shift it downwards. Default is 0.
  • useammo: whether or not ammo is required in order to spawn the actor if the function is called from a player's weapon, as well as whether or not to form a master/minion relationship between the originator and the spawned actor. Master and minions do not attack each other, and this relationship allows the use of functions that affect one another, such as A_DamageMaster and A_GiveToChildren. If this is true, ammo is required and the relationship is formed, otherwise, if this is false, ammo is not required and the relationship is not formed. Default is true.
  • transfer_translation: if this is true, the spawned actor uses the same translation as the calling actor, provided the spawned actor can be translated. Default is false.


The originator is the actor that is considered to be the "spawner" actor. Normally, the originator is the same as the calling actor of the function, except in the case of missile-based actors. A missile-based actor cannot be the originator, since the originator is whatever non-missile actor that it considers to be its spawner or shooter. If this actor does not exist, then there is no originator in this case.

Return value

The function returns two values:

  • A boolean based on whether the actor successfully spawned or not. An actor that does not spawn because of lack of ammo or massacre always counts as success.
  • A pointer to the spawned actor. If the actor fails to spawn due to lack of ammo or massacre, the returned value is null. When testing for space to spawn the actor in, the actor is spawned, tested and then immediately destroyed if it fails the test. The returned value in this case is still a pointer to the actor, not null. The space test is performed on monster-based actors only.

So based on the above, it is important to check for both of these values in order to determine whether an actor has truly spawned or not.


class TerranMarine : ScriptedMarine2
        Obituary "%o was killed by a Terran Marine.";
        Translation "112:127=198:207";
        DropItem "Clip", 256;
        DropItem "GreenMedikit", 128;
        DropItem "GreenStimpack", 128;
        DropItem "GreenArmor", 16;
        DropItem "BlueArmor", 8;
        DropItem "ArmorRed", 4;
        DropItem "ArmorGray", 2;
        ActiveSound "starcraft/active";
        DeathSound "starcraft/death";

        PLY2 A 4 A_Look;
        PLY2 B 4;
        Goto See;
        PLY2 AABBCCDD 2 A_FastChase;
        PLY2 A 0 NoiseAlert(0, 0);
        PLY2 G 4;
        PLY2 G 4 A_Pain;
        Goto Spawn+3;
        PLY2 E 8 A_FaceTarget;
        PLY2 E 2 A_PlaySound("starcraft/marinef1", CHAN_WEAPON);
        PLY2 F 2 A_CustomBulletAttack(5.6, 0, 1, 5, "BulletPuff", 0);
        PLY2 E 2 A_FaceTarget;
        PLY2 F 2 A_CustomBulletAttack(5.6, 0, 1, 5, "BulletPuff", 0);
        PLY2 E 2 A_FaceTarget;
        PLY2 F 2 A_CustomBulletAttack(5.6, 0, 1, 5, "BulletPuff", 0);
        PLY2 E 10 A_CPosRefire;
        Goto Missile+1;
        PLY2 H 10;
        PLY2 I 10 A_Scream;
        PLY2 J 10 A_NoBlocking;
        PLY2 KLM 10;
        PLY2 N 0 A_SpawnItem("SpawnTMarine");
        PLY2 N 512;
        Goto DDisp;
        PLY2 N 4 A_FadeOut(0.05);
        PLY2 O 5;
        PLY2 P 5 A_XScream;
        PLY2 Q 5 A_NoBlocking;
        PLY2 RSTUV 5;
        PLY2 W 0 A_SpawnItem("SpawnTMarine");
        PLY2 W 512;
        Goto XDisp;
        PLY2 W 4 A_FadeOut(0.05);
        PLY2 MLKJIH 5;
        Goto See;

class SpawnTMarine : Actor
        ALLY A 128;
        TFOG A 8
            A_SpawnItemEx("TerranMarine", 0, 0, 0, 0, 0, 0, 0, 64, 0);