ThingSound

From ZDoom Wiki
Jump to navigation Jump to search
Note: This function has been superseded by PlaySound, which duplicates and extends its functionality. Use of the newer function is advised in order to maintain maximum flexibility in your code.


void ThingSound (int tid, str sound, int volume);

Usage

Plays a sound at a thing. This is a point sound, so anyone far away will not hear it as loudly.

Parameters

  • tid: TID of the actor.
  • sound: The sound to be played, as defined in SNDINFO.
  • volume: An integer range from 0 to 127, with 127 being full volume and 0 being muted.

Examples

This script shuts down some kind of generator in the level. The sound source is an object close to the generator so when the player hits the switch to turn it off, they hear the powering down sound coming from the generator.

script 1 (void)
{
   // Message to the player
   Print(s:"Generator shut down.  Rear hatch access granted.");
 
   // Turn off the generator lights
   Light_ChangeToValue(1, 144);
   Light_ChangeToValue(2, 96);
 
   // Play a shutdown sound from the generator
   ThingSound(1, "ambient/poweroff", 127);
}