ZDoom Line Specials



Thing_SpawnFacing — spawns an actor facing the same direction as the map spot it is spawned at.


Thing_SpawnFacing (tid, type, bNoFog, newtid);
Thing_SpawnFacing (
  tid,       // Map spot(s) to spawn the new thing at
  type,      // The type of thing to spawn
  bNoFog,    // Whether or not to spawn a teleport flash
  newtid     // Thing ID to assign to the newly-spawned thing


This is the Thing ID of the map spot you want to spawn a new thing at. If there is more than one map spot with this TID, then a new thing will spawn at each map spot.
This is the type of thing to spawn. The numbers used here correspond to a thing's spawn ID and not its editor number. You can get a complete list of spawn IDs by looking at zdefs.acs, or by using the command "dumpspawnables" at the ZDoom console.
Set this to 0 to also spawn a teleport flash, and set it to 1 to spawn the new thing silently.
This is the Thing ID to assign to the newly spawned thing(s). If you make this non-zero, then you will be able to affect the new thing(s) using all the normal thing specials that take a TID as an argument.


This special works equally well whether you use it in a script or on a line. However, if you use it in a script, it is strongly recommended that you specify type using the names defined in zdefs.acs instead of by using the corresponding number. This is so that your script will be more readable, although the special will work equally well whether you use the names or not.


Although tid is often the TID of a map spot, it can refer to any thing on the map—not just map spots.

If there is no room for a thing at the location where it is to spawn, then it will not spawn at all. The only way to detect this is to use ThingCount before and after Thing_SpawnFacing and compare the two results to see if the count increased. In most cases, you should not actually need to know this.

Unlike Thing_Spawn and Thing_SpawnNoFog, this special will spawn the new thing facing in the direction of map spot that it spawns at. For example, if you spawn a monster at a mapspot that is facing west, then the new monster will also be facing west.


Spawn an imp at mapspot 1, with teleport flash:

Thing_SpawnFacing (1, T_IMP, NO);

Spawn an imp at mapspot 1, without teleport flash, and give the imp TID 5:

Thing_SpawnFacing (1, T_IMP, YES, 5);

This script will repeatedly try to spawn a cyberdemon at mapspot 2 until it succeeds. You can adapt this as necessary to spawn monsters that absolutely must be spawned.

script 1 (void)
    // Notice that we give the spawned cyberdemon a TID of 1000. Counting things
    // with a specific TID is faster than counting things without a particular TID.
    int count1 = ThingCount (T_CYBERDEMON, 1000);
    int count2;

        Thing_SpawnFacing (2, T_CYBERDEMON, NO, 1000);
        count2 = ThingCount (T_CYBERDEMON, 1000);

        // If the spot was occupied, give it some time to become vacant.
        delay (10);
    until (count2 > count1);

First Available In

ZDoom 1.23

See Also

Thing_Projectile | Thing_ProjectileGravity | Thing_Spawn | Thing_SpawnNoFog