Classname: | sound_ambient |
Purpose: | ambience |
H2 Code: | sound.hc |
fields required: | origin, soundtype |
Some run continuously, others are intermittent, and 9-15 don't work
at all, due to a combination of incomplete programming and not
being `looped' (for looping and what to do about it, see
this
little discussion by Armin Rigo). 9 & 10 can be fixed just by putting a looped version of their .wav files (lava.wav, water.wav) in the directory yourgame\sound\ambience (`yourgame' being the directory for your project's files), whereas the others require some changes to the code (the single-component sounds should be quite straightforward for people with a bit of programming experience, I don't know about the multi-component ones such as 13 and 14). The non-looped sounds that don't work as ambients can also be gotten as triggered sounds with custom variants of sound_maker (some of them seem like they would be useful), and also as intermittent sounds with the `custom_sound_ambient' entity at the end of this page. |
origin | As usual | |
soundtype | One of the following numbers:
|
Here is the code for an entity, custom_sound_ambient, that specifies the sound as a filename in the netname field (see the example for the format). If flags and flags2 fields are provided, they specify the maximum and mininum wait for the (random) time that the sound will be produced next, and the sound should not be looped. If flags is unspecified, the sound will run continuously and must be looped.
void custom_sound_ambient (void) { precache_sound (self.netname); self.noise1 = (self.netname); if (self.flags) { self.think = sound_again; thinktime self : random(self.flags,self.flags2); } if (!self.think) ambientsound (self.origin, self.noise1, 1, ATTN_STATIC); else sound (self, CHAN_VOICE, self.noise1, 1, ATTN_NORM); } |
|
Note that the sound file name needs both the .wav extension and the subdirectory name (within the `sound' subdirectory of the .pak or game directory directory), using the forward slash rather than the backslash.
The Raven coders seem to make a point of not passing long string arguments to entities, so there's probably some reason not to do it too often. Modifying the sound entities code is relatively easy.