Spawn

Usage

Spawns an actor at the given X, Y and Z coordinates. Optionally a TID and a byte angle can be specified. The coordinates are specified in fixed point.

The Z coordinate is absolute, i.e. not relative to the floor height of the sector. So if you want something to spawn 128 units above a floor that is at a height of 64, then the Z coordinate needs to be 128 + 64 = 192.

Unlike Thing_Spawn, Spawn does not create teleport fog. If you want teleport fog to appear, use the function again to spawn it manually.

To spawn something at the location of another actor, e.g. a MapSpot, use SpawnSpot instead. To get a list of the things you can spawn in the game, visit the Classes page.

The return value is the number of things spawned.

Examples

This script spawns a Cacodemon above the player about three seconds after he enters the map. There is a 25% chance to instead spawn a Pain Elemental. Since the script is dependent upon the player's location there is the potential for failure due to coordinate obstruction. In an attempt to account for this, the script analyzes the return value of Spawn to determine success or failure, and upon failure will wait a tic and attempt the spawn again.

In this example Health Bonuses will "rain" down on the activating player n number of times, where n is the amount passed to the script argument. The effect is achieved by spawning the bonuses above the player's head and at randomized x and y coordinates. This example spawns in a square pattern.