Spawning

From DoomWiki.org

Spawning is the creation of a thing in a level, particularly during play. In the Doom games in-game significant spawning is present as respawning (where things return to the game), from attacks that spawn missiles, and through the final boss that generates monsters. Other item creations, like dropped items, blood splats and other effects can also be called spawning. Other games based on the Doom engine or source ports may provide additional forms of in-game spawning, such as with scripting (Hexen's ACS, for example).

Monster respawning[edit]

Graph of Doom's respawning algorithm, indicating the cumulative chance that a monster will have respawned every second after death. The median respawn time of ~38 seconds after death is highlighted.

When the respawn setting is applied, any monsters that leave corpses behind when defeated and that initially start off in a level (this thus excludes those generated by other things or monsters) which are felled during play respawn at their original starting point. A monster will not spawn while something is occupying its starting location. The respawning happens after a randomized time delay. When a monster respawns, its corpse is whisked away with a teleport flash while another teleport flash marks the arrival of its new incarnation or replacement. Respawned monsters that had been targeting the player before death instantly become alert and move towards their target, but those who had been targeting other monsters or players that are dead are spawned in a nonactive state. The respawn setting can be applied with any skill level using the -respawn parameter in the command line, but it will always be used when the "Nightmare!" skill level is chosen.

On MAP30 of Doom II-based WADs, normal rules affecting respawning regarding occupied space are not followed; instead, anything occupying a monster's starting location will be telefragged upon their respawn, including the player even if he is invincible by the means of god mode or the invulnerability power-up. This is due to a general exception to telefragging mechanics added specifically to MAP30 for the sake of the Final boss's spawn cube functionality.

Technical[edit]

The algorithm for respawning a Doom enemy is called every tic and proceeds roughly as follows:

  • Has at least 12 seconds elapsed since the enemy's death? If not, do not respawn. This time period is increased to 16 seconds in Strife.
  • Is the current global level time a multiple of 32 tics? If not, do not respawn.
  • Choose a random number from 0 to 255. Is it less than or equal to 4? If so, respawn.

Therefore, after 12 seconds have passed, a dead enemy has approximately a 35 / 32 * 6 / 256 = 2.6% chance[notes 1] of respawning in a given second. By treating the chance of respawning as a geometric distribution, it can be calculated that the median respawn time is approximately 38 seconds, and the mean respawn time is approximately 50 seconds.

Beginning with v1.666 of Doom and Doom II, lost souls do not respawn because they are not considered monsters by the engine.

In Strife, monsters which have the MF_NOTDMATCH bit flag set will not respawn. This includes most bosses.

Item respawning[edit]

In version 1.5 of Doom a v2.0 deathmatch mode was added that allows certain items to respawn after a period in a way similar to monsters respawning (see above), applying a bluish teleportation flash with a unique teleportation noise where the item is respawning. For purposes of game balance, the partial invisibility and invulnerability powerups do not respawn. Items may respawn even if some thing has moved onto their location, and thus a player may stand at the location where an item will return to get it quickly upon its arrival. This setting is applied when the -altdeath parameter is added.

Strife adds a -random parameter. If used in concert with -altdeath, it will cause the types of items queued for respawning to be swapped from the back of the queue to the front, so that the positions of respawning items are effectively randomized, depending on player item collection patterns.

Source ports frequently generalize the -altdeath option via configuration settings or as part of new multiplayer modes, thus permitting more or fewer items to respawn.

Player respawning[edit]

After being killed, any player in a multiplayer game will respawn once a key or button assigned to key_use is pressed by the user controlling that player. During cooperative games the player will respawn at that player's starting location, and during deathmatch games, at a random deathmatch start point. Like with monsters, returning players will arrive in the level with a teleport flash, but player corpses are not immediately removed when the player returns, giving a rough visual cue during play of how many times each player has died. In Doom, Heretic, and Hexen, corpses are placed on a queue which is gradually flushed as players die. This queue does not exist in Strife, as player corpses in that game automatically remove themselves after a set amount of time, even if the player has not respawned yet.

If all deathmatch spots are blocked, the game will attempt to respawn a player at his cooperative mode starting point, so valid deathmatch levels should still include a full set of cooperative starting points. If the points are missing, the "player corpses walking" glitch may result.

Notes[edit]

  1. Due to the pseudorandom number generator used in Doom, there are actually 6 values out of 256 that are less than or equal to 4.

See also[edit]