Sound propagation

From DoomWiki.org

Sound propagation is a system in the Doom engine in which the "sound" emitted by player weapons can travel through the level, alerting monsters. Note that this is purely an issue of game mechanics, and is unrelated to actual audio — only attacks emit sound as far as this system is concerned. For example, selecting the chainsaw will cause sounds to be played, but this does not count as a sound for alerting monster. Inversely, punching the air is a silent action in-game, but since the player presses the attack button to trigger this action, it can be heard by monsters.

Technical[edit]

When a player hits the attack button, the function P_FireWeapon is called. This function checks that the player has enough ammo, and if so sets the player and its weapon in the relevant states, and also calls P_NoiseAlert. This means that the alert is sounded as soon as the button is pressed; not when the weapon actually fires. A weapon with a long loading time, such as the BFG 9000, can be used to propagate sound in a sector and shoot in another (after taking a teleporter or opening a door) without alerting the monsters in the second area.

Sectors have a soundtarget pointer. When P_NoiseAlert is called, it calls P_RecursiveSound for the player's current sector. This latter function sets the sector's soundtarget pointer to the player's mobj, then looks at each of the sector's lines. For every two-sided line, if the other sector has a height between floor and ceiling greater than 0, the function will recursively call itself for the other side's sector. If the two-sided line is marked as sound-blocking, the recursive call will take this into account by marking the sound as having been blocked once; and if the sound had already been blocked once already, it will not propagate to the other side of this line.

When monsters call the A_Look function, they check if their sector has a valid soundtarget. If so, they start chasing it, unless they are lying in ambush and wait for the player to enter their line of sight. But even an ambush monster will be woken up by a soundtarget, getting 360° vision.

Once a sector's soundtarget is set, it cannot normally be unset. Monsters that appear in the sector after the sound has been emitted (spawned, teleported, or resurrected there) will be woken up as if the sound had happened while they were there.

Note that since propagation is sector-based, sound can propagate across noncontiguous space by way of joined sectors.

Silent weapons[edit]

Strife features two silent weapons, the punch dagger and the crossbow with poison bolts. This is implemented by the engine checking if the player's weapon is one such sneaky weapon in the P_FireWeapon function, and not calling P_NoiseAlert in that case. This feature is exclusive to Strife, though some advanced source ports can allow to use it with other custom weapons.