ambient_generic

An ambient_generic plays a sound or a sentence at its position, either once each time you trigger it or as a loop.
Attributes
targetnameTriggering the entity starts the sound, and if the sound loops, the next trigger stops it. See Common keys.
Names the parent, an entity that this one moves and turns with. The entity keeps the place and the angles it has on the parent in the editor. If several entities have the name, the first one counts. A name ending in .1 to .4 puts a sprite or a model that isn't solid on that attachment point of the model of the parent. A solid brush on a parent that turns needs its own origin brush. Moving objects explains it all.
If you leave this key empty, the entity doesn't move with anything.
parentflagsKeeps some of the entity's own position or angles instead of following the parent. Add up the values of the axes to keep: 2 for X, 4 for Y, 8 for Z, 16 for pitch, 32 for yaw and 64 for roll. So 112 keeps the entity level. 0 follows the parent on every axis.
0messageSets the sound it plays, which can be:
- a
.wavfile in thesound/folder - a sentence from
sound/sentences.txt, with a!in front of its name - an
.mp3file in thesound/folder, which plays as music likeambient_music(see MP3 files)
healthSets how loud the sound is, from 0 for silent up to 10 for full volume.
If you leave this key empty, it is 0 and the sound is silent, unless you pick a Dynamic Presets effect or play an .mp3, which ignore Volume.
10presetPicks a ready-made effect that changes the sound while it plays. If you pick a preset, the entity ignores Volume, Start Volume, the fade, pitch and spin keys, the LFO keys and Incremental spinup count, because the preset sets all of these itself. Every preset fades the sound in when it starts. In the list, "spins up" means the pitch rises as the sound starts, and "spins down" means it falls when you turn the sound off.The 28 choices
None (0)volstartSets the volume a fade in starts from and a fade out ends at, from 0 for silent up to 10 for full volume.
0fadeinFades the sound in from Start Volume when it starts, from 1 for the fastest fade up to 100 for the slowest, and 0 means no fade in.
0fadeoutFades the sound out to Start Volume when you turn it off, from 1 for the fastest fade up to 100 for the slowest, and 0 means the sound stops at once.
0pitchSets the pitch of the sound: 100 is normal, 50 is one octave lower, 200 is one octave higher and 255 is the highest.
If you leave this key empty, the sound plays at normal pitch. With a spin up, the sound stops as soon as it starts, but with Start Pitch empty too, it plays at the lowest pitch instead. With a spin down, the sound plays at normal pitch and spins down from there when you turn it off.
100pitchstartSets the pitch a spin up starts from and a spin down ends at.
If you leave this key empty, a spin up starts at normal pitch, and a spin down slides all the way to the lowest pitch before the sound stops.
100spinupRaises the pitch from Start Pitch to Pitch when the sound starts, from 1 for the fastest spin up to 100 for the slowest, and 0 means no spin up.
0spindownLowers the pitch to Start Pitch when you turn the sound off, from 1 for the fastest spin down to 100 for the slowest, and 0 means no spin down.
0lfotypeMakes the pitch or the volume swing up and down while the sound plays (LFO means "low frequency oscillator").
- Off (0) - No swing
- Square (1) - Jumps between high and low
- Triangle (2) - Rises and falls smoothly
- Random (3) - Jumps to random values
Off (0)lforateSets how fast the swing goes, from 0 up to 1000, and a higher value is faster.
0lfomodpitchSets how far the swing moves the pitch, in percent from 0 up to 100, and 0 means the pitch doesn't swing.
0lfomodvolSets how far the swing moves the volume, in percent from 0 up to 100, and 0 means the volume doesn't swing.
0cspinupMakes each trigger raise the pitch one step instead of turning the sound off. The steps go from Start Pitch up to the highest pitch, and this key sets how many there are, up to 100, with 0 turning it off.
0Sets whether the sound loops. See Play modes.
- Default (0) - The flag Not Toggled and the loop points of the WAV file decide (see Looping a sound)
- Play once (1) - Plays once per trigger, even a WAV file that has loop points
- Loop (2) - Loops, even a WAV file that has no loop points
- Play once, linear falloff (5) - Plays once, and the volume falls with distance as Linear Min and Linear Max set
- Loop, linear falloff (6) - Loops, and the volume falls with distance as Linear Min and Linear Max set
Default (0)With a linear falloff, sets how far the sound plays at full volume, counted in steps of 256 units, so 2 means 512 units.
0Flags
1Play EverywhereEvery player hears the sound equally loud, anywhere on the map
2Small RadiusPlayers hear the sound up to about 500 units away
4Medium RadiusPlayers hear the sound up to about 800 units away. This flag is set by default, and the entity also uses this radius when no radius flag is set
8Large RadiusPlayers hear the sound up to about 1250 units away
16Start SilentA looping sound doesn't start with the map, but waits for a trigger
32Not ToggledThe sound plays once per trigger, and triggering it while it plays starts it again from the beginning, so a trigger can't turn it off
Play modes
When the map starts, the entity reads the length and the loop points of the WAV file. If the server can't read the
file, the entity ignores the play mode and works like Default, and with developer 1 set in the console, the
console names the entity.
If a player joins after a looping sound has started, they hear it one second after they enter the game.
With a linear falloff, the entity ignores the radius flags and measures each player's distance from their eyes. If you also set Play Everywhere, the mode "Play once, linear falloff" works like "Play once", and the mode "Loop, linear falloff" works like "Loop".
See also Music and sound.
MP3 files
You can use an .mp3 file as the sound, and every player hears it everywhere, at the MP3 volume set in their own
game options. The entity ignores Volume, the pitch keys, the presets and the radius flags. The MP3 only loops
if you set Play Mode to one of its two looping modes, "Loop" or "Loop, linear falloff", and Start Silent
works as usual.
The file name must follow the rules of ambient_music. If it breaks them, the entity
is removed, and with developer 1 set in the console, the server console reports it.
Notes
- Without Not Toggled, the entity treats every sound as a loop, so the first trigger starts it and the next one stops it. A WAV file without loop points plays only once, though, so every second trigger just stops a sound that has already ended
- If you pick a preset, the entity ignores Volume because the preset sets the volume itself: most presets play at full volume, and the three pulse presets, "Slow Pulse", "Pulse" and "Quick pulse", play at half volume
- The spin down and the fade out only happen when you turn off a looping sound
- With Incremental spinup count, or the preset "Incremental Spinup", a trigger never turns the sound off, and once the last step is reached, more triggers do nothing
- If you set more than one radius flag, the entity uses the smallest radius, and Play Everywhere wins over all of them
- If WAV Name is empty, the entity is removed when the map starts, and with
developer 1set in the console, the console reports it - If
trigger_changevalueortrigger_copyvaluechanges Volume or Pitch while a looping sound plays, you hear the new volume or pitch at once, but with a preset the entity keeps the preset's values. A new sound that the map has already loaded, for example because another entity uses it, stops the old one and plays at once. Any other sound would have to be precached, so the entity keeps its sound and, withdeveloper 1set in the console, prints a console line, and an MP3 can't be changed at all. See Changing keys
See also
ambient_music- an MP3 every player hears, everywhereambient_random- plays one of up to five sounds, picked at randomspeaker- plays random sentences of a sentence group, at random timesenv_sound- sets the echo of a room for players near it- Music and sound -
ambient_musicand the play modes - Making custom sounds - how to make a WAV file that loops, on TWHL
Changes since 1.38
- You can use the new keys Play Mode, Linear Min and Linear Max
- You can use an
.mp3file as the sound


