Thing_Spawn — spawns an actor at a map spot
Thing_Spawn (tid, type, angle, newtid);
Thing_Spawn ( tid, // Map spot(s) to spawn the new thing at type, // The type of thing to spawn angle, // Byte angle for the new thing to face newtid // Thing ID to assign to the newly-spawned thing );
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_Spawn and compare the two results to see if the count increased. In most cases, you should not actually need to know this.
This special will create a teleport flash at the location where the new thing spawns. If you do not want this, use Thing_SpawnNoFog instead.
Spawn an imp at mapspot 1, facing north:
Thing_Spawn (1, T_IMP, 64);
Spawn an imp at mapspot 1, facing north, and give the imp TID 5:
Thing_Spawn (1, T_IMP, 64, 5);
This script will repeatedly try to spawn a cyberdemon at mapspot 2, facing south 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; do { Thing_Spawn (2, T_CYBERDEMON, 192, 1000); count2 = ThingCount (T_CYBERDEMON, 1000); // If the spot was occupied, give it some time to become vacant. delay (10); } until (count2 > count1); }
Hexen
Skull Tag added newtid, which was later adopted by ZDoom 1.23
Thing_Projectile | Thing_ProjectileGravity | Thing_SpawnFacing | Thing_SpawnNoFog