ambient_generic

Modified

12-Jul-2023

This entity is used to play sound-files. They can be looping or not. You can use this to play music as well but ambient_music fits more for this purpose.

Keyvalues


OnDestroy Function ondestroyfn : Name of the function to use from already parsed .as script files when entity is destroyed (killed) in any way. If the function belongs to namespace, you must use prefix with the namespace name (e.g. mynamespace::MyFunction) for the keyvalue.

Name targetname : Set name of ambient_generic so other entities can trigger it to play sound. Depending on trigger use-type: 'Off'- stop the sound, 'Toggle'- play/stop sound interchangeably, 'On'- start the sound but it's working only when any other signal was received previously. Kill-targeting this entity will stop sound from playing.

Sound File message : Name of the sound file to play. Supported formats are: AIFF, ASF, DLS, FLAC, IT, M3U, MID, MOD, MP2, MP3, OGG, S3M, VAG, WAV, WMA, XM. Hammer will only let you select WAV-files, but other formats do work as they are fully supported by the game's sound engine. Type the path in manually in that case. File Path starts in the 'sound'-folder, example: 'mymap/soundfile.ogg'. Alternatively, a sentence can be played using the ! prefix followed by a sentence name for the keyvalue, e.g. "!C1A2_0". Check the default_sentences.txt file for options.

Volume (10 = loudest) health : Set how loud the sound shall be in a range from 0 (not audible) to 10 (normal). Note that this is linear, while the human hearing sense is logarithmic. That means, 10 people talking sound two times as loud as one person talking. 100 people talking sound three times as loud as one person talking. So, a value of '1' will make the sound sound only half as loud as a value of '10' would. A value of '0.1' would make it a third as loud as a value of '10' would. So, if you want your sound to actually be quiet, you are likely to set a value below 1.0.

Play Mode playmode : This is the new way of setting whether a sound will loop or not. If a value other than 'Default' is selected, the 'Unlooped/Cyclic'-flag will be ignored and this option will be referenced to instead. You can also enable linear rolloff with this option, to allow you to setup your own radius. Note that linear rolloff isn't true to how sound works in real life, so it might sound/feel odd.

  • 0 : Default : Looping /on/off set to default for sound.
  • 1 : Play Once : Always play once. 'Unlooped/Cyclic'-flag will be ignored.
  • 2 : Loop : Always loop. 'Unlooped/Cyclic'-flag will be ignored
  • 5 : Linear / Play Once : Always play once and use linear rolloff- "Linear minimum radius" and "Linear maximum radius". 'Unlooped/Cyclic'-flag will be ignored
  • 6 : Linear / Loop : Always loop and use linear rolloff- "Linear minimum radius" and "Linear maximum radius". 'Unlooped/Cyclic'-flag will be ignored

Dynamic Presets preset : Allows you to specify a dynamic preset to enhance the sound. Used for sounds like machines warmup as it will repeatedly play a sound changing it's pitch and other parameters. You should probably experiment with these to find something that sounds good, if you don't want to stick with the default.

  • 0 : None
  • 1 : Huge Machine
  • 2 : Big Machine
  • 3 : Machine
  • 4 : Slow Fade in
  • 5 : Fade in
  • 6 : Quick Fade in
  • 7 : Slow Pulse
  • 8 : Pulse
  • 9 : Quick pulse
  • 10 : Slow Oscillator
  • 11 : Oscillator
  • 12 : Quick Oscillator
  • 13 : Grunge pitch
  • 14 : Very low pitch
  • 15 : Low pitch
  • 16 : High pitch
  • 17 : Very high pitch
  • 18 : Screaming pitch
  • 19 : Oscillate spinup/down
  • 20 : Pulse spinup/down
  • 21 : Random pitch
  • 22 : Random pitch fast
  • 23 : Incremental Spinup
  • 24 : Alien
  • 25 : Bizzare
  • 26 : Planet X
  • 27 : Haunted

Start Volume volstart : Start volume for fade-in; between 0.0 and 10.0.

Fade in time (0-100) fadein : Time, in seconds, till the sound will reach "Volume"-value after being triggered on, starting from "Start volume"-value.

Fade out time (0-100) fadeout : Time, in seconds, till the sound will have faded out completely after being triggered off.

Pitch (> 100 = higher) pitch : Sound playback speed, in per-cent.

Start Pitch pitchstart : Initial sound playback speed, in per-cent. Changes towards "Pitch" within fade in time.

Spin up time (0-100) spinup : Time, in seconds, over which a spinup sound-effect (consecutive fade-ins) shall be applied as the sound starts playing.

Spin down time (0-100) spindown : Time, in seconds, over which a spindown sound-effect (consecutive fade-outs) shall be applied as the sound is turned off.

LFO type lfotype : Allows you to set up a low frequency oscillator to modify volume and/or pitch over time, as the sound plays.

  • 0 : Off
  • 1 : Square Wave
  • 2 : Triangle Wave
  • 3 : Random
  • 4 : Saw Tooth Wave
  • 5 : Sine Wave

LFO rate (0-1000) lforate : Rate, in Hertz, at which the LFO oscillates. You'll usually want to put low values like 0.3.

LFO mod pitch (0-100) lfomodpitch : Set how much the LFO shall affect the sound's pitch.

LFO mod vol (0-100) lfomodvol : Set how much the LFO shall affect the sound's volume.

Incremental spinup count cspinup : Set how many consecutive fade-ins/fade-outs shall be applied to spin-up and spin-down sound-effect.

Linear Min Radius linearmin : When you set the play mode to use linear rolloff, the value set here will be used as the minimum sound radius, meaning the sound will be heard at full volume within this radius around the ambient_generic. You may only choose one of these preset values, as the volume curves need to be precalculated for performance reasons.

  • 0 : 0 - 0 units
  • 1 : 1 - 256 units
  • 2 : 2 - 512 units
  • 3 : 3 - 768 units
  • 4 : 4 - 1,024 units
  • 5 : 5 - 1,280 units
  • 6 : 6 - 1,536 units
  • 7 : 7 - 1,792 units
  • 8 : 8 - 2,048 units
  • 9 : 9 - 2,304 units
  • 10 : 10 - 2,560 units
  • 11 : 11 - 2,816 units
  • 12 : 12 - 3,072 units
  • 13 : 13 - 3,328 units
  • 14 : 14 - 3,584 units
  • 15 : 15 - 3,840 units
  • 16 : 16 - 4,096 units

Linear End Radius linearmax : When you set the play mode to use linear rolloff, the value set here will be used as the maximum sound radius, meaning the sound cannot be heard outside of this radius around the ambient_generic. You may only choose one of these preset values, as the volume curves need to be precalculated for performance reasons.

  • 1 : 1 - 256 units
  • 2 : 2 - 512 units
  • 3 : 3 - 768 units
  • 4 : 4 - 1,024 units
  • 5 : 5 - 1,280 units
  • 6 : 6 - 1,536 units
  • 7 : 7 - 1,792 units
  • 8 : 8 - 2,048 units
  • 9 : 9 - 2,304 units
  • 10 : 10 - 2,560 units
  • 11 : 11 - 2,816 units
  • 12 : 12 - 3,072 units
  • 13 : 13 - 3,328 units
  • 14 : 14 - 3,584 units
  • 15 : 15 - 3,840 units
  • 16 : 16 - 4,096 units

Flags


  • 1 : Play Everywhere : The sound will play everywhere.

  • 2 : Small Radius (~384) : Non-linear big sound radius.

  • 4 : Medium Radius (~768) : Non-linear huge sound radius.

  • 8 : Large Radius (~1536) : Non-linear extra-huge sound radius.

  • 16 : Start Silent : If set, this sound will start off. Only makes sense for looped sounds. This is usually left unchecked for ambient looping sounds, however only with other than default play mode. See notes for more info.

  • 32 : Un-looped|Cyclic : The sound will play once when triggered. If triggered while playing, the sound will stop and restart immediately.

  • 64 : User Only (+origin) : The sound will only be audible to the activator of this entity when triggered. If "Play everywhere" flag is set, the sound will be audible to everyone at their own position.

Looped sounds that starts enabled ("Start silent" flag unchecked) should use other than default play mode (preferably Linear/Looped) or they need to be triggered by trigger_auto after short delay (e.g. one second) with "Start silent" flag selected. This is because ambient_generics with default play mode are not correctly processed at map start, and works only after triggered.

If no sound radius is set, 'Medium radius' is used as a default. You should set only one sound radius, or 'Play everywhere'.