1) Open up snd_dma.c, and somewhere on the top of file let's declare our cvars:
Code: Select all
cvar_t sfx_water = {"sfx_water", "ambience/water1.wav"};
cvar_t sfx_wind = {"sfx_wind", "ambience/wind2.wav"};
cvar_t sfx_slime = {"sfx_slime","misc/null.wav"};
cvar_t sfx_lava = {"sfx_lava","misc/null.wav"};
Code: Select all
void S_UpdateContentSounds (void)
{
S_StopAllSounds (true);
if (sfx_water.string) {ambient_sfx[AMBIENT_WATER] = S_PrecacheSound (sfx_water.string);}
if (sfx_wind.string) {ambient_sfx[AMBIENT_SKY] = S_PrecacheSound (sfx_wind.string);}
if (sfx_slime.string) {ambient_sfx[AMBIENT_SLIME] = S_PrecacheSound (sfx_slime.string);}
if (sfx_lava.string) {ambient_sfx[AMBIENT_LAVA] = S_PrecacheSound (sfx_lava.string);}
}
3) After this, find and comment these 2 lines in S_Init ():
Code: Select all
ambient_sfx[AMBIENT_WATER] = S_PrecacheSound ("ambience/water1.wav");
ambient_sfx[AMBIENT_SKY] = S_PrecacheSound ("ambience/wind2.wav");
4) After the 2 lines we just commented out, let's place our call to S_UpdateContentSounds:
Code: Select all
// ambient_sfx[AMBIENT_WATER] = S_PrecacheSound ("ambience/water1.wav");
// ambient_sfx[AMBIENT_SKY] = S_PrecacheSound ("ambience/wind2.wav");
S_UpdateContentSounds ();
Code: Select all
Cvar_RegisterVariable(&_snd_mixahead, NULL);
Code: Select all
Cvar_RegisterVariable(&sfx_water, S_UpdateContentSounds);
Cvar_RegisterVariable(&sfx_wind, S_UpdateContentSounds);
Cvar_RegisterVariable(&sfx_slime, S_UpdateContentSounds);
Cvar_RegisterVariable(&sfx_lava, S_UpdateContentSounds);
And that's it. To test what we did, let's grab a looping sound for replacement (for example, the bubbling lava sound from Quake 2 will fit nicely) and copy it to the <your_quake_dir>id1/sound/ambience folder (create it if you dont have it yet). You'll need to precache the file, so you'll need to fiddle (a little bit) with QuakeC. Just open world.qc and find the line that says:
Code: Select all
W_Precache (); // get weapon precaches
Code: Select all
precache_sound ("ambience/lava1.wav");
Run your modified engine, start a new game, bring down the console and type:
sfx_lava "ambience/lava1.wav"
Now just get a bit close of the hard skill gate lava pit and hear the lava bubbling.
The ability of not only changing the existing sound effects for water and outdoor areas but also setting similar effects for lava and slime is a great resource for mappers and modders to set the environment mood. And it's easy enough to even the begginer engine coder to add.Well, that's it. Enjoy!