Sound ambient

Sound ambient

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.

Fields

origin As usual
soundtype One of the following numbers:
  • 1 - windmill
  • 2 - dripping, echoing sewer water sound
  • 3 - dripping water with no echo
  • 4 - subtle sky/wind
  • 5 - crickets / night sounds
  • 6 - birds
  • 7 - raven caw
  • 8 - rocks falling
  • 9 - lava bubble (doesn't work, fixeable by looping).
  • 10 - water gurgle (ditto)
  • 11 - metal (not looped and code problems)
  • 12 - pounding (ditto)
  • 13 - random moans and screams (ditto)
  • 14 - creaking (ditto)
  • 15 - chain rattling (ditto)

a custom entity

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);

}
If the above code is compiled and included in progs.dat (see the Chop Shop's section on Hexen 2 editing for basic info on how to do this), the following entity will play the lava sound intermittently, but reasonably often:

classnamecustom_sound_ambience
netnameambience/lava.wav
flags10
flags220

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.


Back to the list.