Hosting and domain costs until October 2024 have been generously sponsored by dumptruck_ds. Thank you!
sound
From Quake Wiki
void sound(entity e, float channel, string soundPath, float volume, float attenuation)
Usage
Plays a sound at an entity's location using one of its sound channels. A sound must be precached during map load in order to be considered valid. Once a sound is playing the only way to stop it is by passing an empty sound to play on the same channel. Sounds will always interrupt each other if played on the same channel, but CHAN_AUTO
will attempt to avoid this.
Parameters
- e
- The entity to play the sound from.
- channel
- Can be a value from 0 to 7 (whole numbers only). 0 (
CHAN_AUTO
) will try and not override any currently playing sounds. Default values:CHAN_AUTO
CHAN_WEAPON
CHAN_VOICE
CHAN_ITEM
CHAN_BODY
- soundPath
- The path of the sound file. Supports WAV (.wav) files.
- volume
- Can be a value from 0 to 1.
- attenuation
- Determines the linear falloff of the sound over distance. A value of 0 (
ATTN_NONE
) will have no fall off. The larger the value, the greater the falloff. Default values:ATTN_NONE
ATTN_NORM
ATTN_IDLE
ATTN_STATIC
Example
void monster_my_monster() { // Make sure to precache the sound first in the initialization function precache_sound("mymonster/missile.wav"); } void MyMonsterMissileAttack() { // Play the sound on the monster's weapon channel sound(self, CHAN_WEAPON, "mymonster/missile.wav", 1, ATTN_NORM); }