Submitted by
Gard on Sun, 2004-08-08 01:30.
Quake II
Custom door/plat/button sounds by Knightmare .
I've found a quick way to add support for custom door, plat and button sounds to Q2. This will be in the next release of KMQuake2, but it can easily be added to any MOD.
Methodology
Step 1:
In g_func.c, look for this code in the function SP_func_plat:
ent->moveinfo.sound_start = gi.soundindex ("plats/pt1_strt.wav");
ent->moveinfo.sound_middle = gi.soundindex ("plats/pt1_mid.wav");
ent->moveinfo.sound_end = gi.soundindex ("plats/pt1_end.wav");
and replace it with this:
if (ent->style > 0 && ent->style < 100) // custom sounds
{
ent->moveinfo.sound_start = gi.soundindex (va("plats/pt%02i_strt.wav", ent->style));
ent->moveinfo.sound_middle = gi.soundindex (va("plats/pt%02i_mid.wav", ent->style));
ent->moveinfo.sound_end = gi.soundindex (va("plats/pt%02i_end.wav", ent->style));
}
else
{
ent->moveinfo.sound_start = gi.soundindex ("plats/pt1_strt.wav");
ent->moveinfo.sound_middle = gi.soundindex ("plats/pt1_mid.wav");
ent->moveinfo.sound_end = gi.soundindex ("plats/pt1_end.wav");
}
This change could also be added to the func_trackchange entity in Lazarus.
Step 2:
In the SP_func_button, replace the following:
if (ent->sounds != 1)
ent->moveinfo.sound_start = gi.soundindex("switches/butn2.wav");
with this:
if (ent->style > 0 && ent->style < 100) // custom sounds
ent->moveinfo.sound_start = gi.soundindex (va("switches/butn%02i.wav", ent->style));
else if (ent->sounds != 1)
ent->moveinfo.sound_start = gi.soundindex ("switches/butn2.wav");
else
ent->moveinfo.sound_start = 0;
Step 3:
In both the SP_func_door and SP_func_door_rotating, replace this:
if (ent->sounds != 1)
{
ent->moveinfo.sound_start = gi.soundindex ("doors/dr1_strt.wav");
ent->moveinfo.sound_middle = gi.soundindex ("doors/dr1_mid.wav");
ent->moveinfo.sound_end = gi.soundindex ("doors/dr1_end.wav");
}
and replace it with this:
if (ent->style > 0 && ent->style < 100) // custom sounds
{
ent->moveinfo.sound_start = gi.soundindex (va("doors/dr%02i_strt.wav", ent->style));
ent->moveinfo.sound_middle = gi.soundindex (va("doors/dr%02i_mid.wav", ent->style));
ent->moveinfo.sound_end = gi.soundindex (va("doors/dr%02i_end.wav", ent->style));
}
else if (ent->sounds != 1)
{
ent->moveinfo.sound_start = gi.soundindex ("doors/dr1_strt.wav");
ent->moveinfo.sound_middle = gi.soundindex ("doors/dr1_mid.wav");
ent->moveinfo.sound_end = gi.soundindex ("doors/dr1_end.wav");
}
else
{
ent->moveinfo.sound_start = 0;
ent->moveinfo.sound_middle = 0;
ent->moveinfo.sound_end = 0;
}
FILES
The custom filenames for doors are:
- doors/drxx_strt.wav,
- doors/drxx_mid.wav,
- doors/drxx_end.wav
The custom filenames for plats are:
- plats/ptxx_strt.wav,
- plats/ptxx_mid.wav,
- plats/ptxx_end.wav
The custom filenames for buttons are:
Where xx is a 2-digit number from 01 to 99 that corresponds to the style value.
Comments
I decided to use the style key for custom sounds because many maps may have different sounds values set for doors. The default QERadiant .def file has door sound sets listed that are from Q1, and many mappers may have given their doors sounds values other than 0 and 1 (default and no sound). I didn't want to change the behavior of existing maps.
Creating an outdoor area using Gensurf
Entity Properties