- Added SNDINFO $attenuation command. This multiplies the attenuation passed to S_Sound. e.g.

$attenuation Boom 0
  Will make the "Boom" sound play with 0 attenuation, or in other words, at full volume throughout
  the level.

SVN r3629 (trunk)
This commit is contained in:
Randy Heit 2012-05-07 01:16:56 +00:00
parent 2117c84a78
commit 45027e4620
3 changed files with 20 additions and 1 deletions

View file

@ -152,6 +152,7 @@ enum SICommands
SI_Volume, SI_Volume,
SI_MusicAlias, SI_MusicAlias,
SI_EDFOverride, SI_EDFOverride,
SI_Attenuation,
}; };
// Blood was a cool game. If Monolith ever releases the source for it, // Blood was a cool game. If Monolith ever releases the source for it,
@ -247,6 +248,7 @@ static const char *SICommandStrings[] =
"$volume", "$volume",
"$musicalias", "$musicalias",
"$edfoverride", "$edfoverride",
"$attenuation",
NULL NULL
}; };
@ -501,6 +503,7 @@ int S_AddSoundLump (const char *logicalname, int lump)
newsfx.next = 0; newsfx.next = 0;
newsfx.index = 0; newsfx.index = 0;
newsfx.Volume = 1; newsfx.Volume = 1;
newsfx.Attenuation = 1;
newsfx.PitchMask = CurrentPitchMask; newsfx.PitchMask = CurrentPitchMask;
newsfx.NearLimit = 2; newsfx.NearLimit = 2;
newsfx.LimitRange = 256*256; newsfx.LimitRange = 256*256;
@ -1204,6 +1207,17 @@ static void S_AddSNDINFO (int lump)
} }
break; break;
case SI_Attenuation: {
// $attenuation <logical name> <attenuation>
int sfx;
sc.MustGetString();
sfx = S_FindSoundTentative(sc.String);
sc.MustGetFloat();
S_sfx[sfx].Attenuation = (float)sc.Float;
}
break;
case SI_Rolloff: { case SI_Rolloff: {
// $rolloff *|<logical name> [linear|log|custom] <min dist> <max dist/rolloff factor> // $rolloff *|<logical name> [linear|log|custom] <min dist> <max dist/rolloff factor>
// Using * for the name makes it the default for sounds that don't specify otherwise. // Using * for the name makes it the default for sounds that don't specify otherwise.

View file

@ -901,6 +901,8 @@ static FSoundChan *S_StartSound(AActor *actor, const sector_t *sec, const FPolyO
} }
else if (sfx->bRandomHeader) else if (sfx->bRandomHeader)
{ {
// Random sounds attenuate based on the original (random) sound as well as the chosen one.
attenuation *= sfx->Attenuation;
sound_id = FSoundID(S_PickReplacement (sound_id)); sound_id = FSoundID(S_PickReplacement (sound_id));
if (near_limit < 0) if (near_limit < 0)
{ {
@ -928,6 +930,9 @@ static FSoundChan *S_StartSound(AActor *actor, const sector_t *sec, const FPolyO
sfx = &S_sfx[sound_id]; sfx = &S_sfx[sound_id];
} }
// Attenuate the attenuation based on the sound.
attenuation *= sfx->Attenuation;
// The passed rolloff overrides any sound-specific rolloff. // The passed rolloff overrides any sound-specific rolloff.
if (forcedrolloff != NULL && forcedrolloff->MinDistance != 0) if (forcedrolloff != NULL && forcedrolloff->MinDistance != 0)
{ {

View file

@ -41,7 +41,6 @@ struct sfxinfo_t
int lumpnum; // lump number of sfx int lumpnum; // lump number of sfx
unsigned int next, index; // [RH] For hashing unsigned int next, index; // [RH] For hashing
// unsigned int frequency; // [RH] Preferred playback rate
float Volume; float Volume;
BYTE PitchMask; BYTE PitchMask;
@ -65,6 +64,7 @@ struct sfxinfo_t
enum { NO_LINK = 0xffffffff }; enum { NO_LINK = 0xffffffff };
FRolloffInfo Rolloff; FRolloffInfo Rolloff;
float Attenuation; // Multiplies the attenuation passed to S_Sound.
}; };
// Rolloff types // Rolloff types