else
{
// LadyHavoc: we only let the qc set certain flags, others are off-limits
- flags = (int)PRVM_G_FLOAT(OFS_PARM6) & (CHANNELFLAG_RELIABLE | CHANNELFLAG_FORCELOOP | CHANNELFLAG_PAUSED | CHANNELFLAG_FULLVOLUME | CHANNELFLAG_BGMVOLUME);
+ flags = (int)PRVM_G_FLOAT(OFS_PARM6) & (CHANNELFLAG_RELIABLE | CHANNELFLAG_FORCELOOP | CHANNELFLAG_PAUSED | CHANNELFLAG_FULLVOLUME | CHANNELFLAG_BGMVOLUME | CHANNELFLAG_TRAPEZOID);
}
// sound_starttime exists instead of sound_startposition because in a
// calculate stereo seperation and distance attenuation
VectorSubtract(listener_origin, ch->origin, source_vec);
dist = VectorLength(source_vec);
- f = dist * ch->distfade;
+
+ if (ch->flags & CHANNELFLAG_TRAPEZOID)
+ {
+ if (dist < ch->distfade * 0.4)
+ {
+ f = 1.0;
+ }
+ else
+ {
+ f = dist * (ch->distfade / 0.6);
+ f = 1.0 - f;
+ }
+ }
+ else
+ {
+ f = dist * ch->distfade;
- f =
- ((snd_attenuation_exponent.value == 0) ? 1.0 : pow(1.0 - min(1.0, f), (double)snd_attenuation_exponent.value))
- *
- ((snd_attenuation_decibel.value == 0) ? 1.0 : pow(0.1, 0.1 * snd_attenuation_decibel.value * f));
+ f =
+ ((snd_attenuation_exponent.value == 0) ? 1.0 : pow(1.0 - min(1.0, f), (double)snd_attenuation_exponent.value))
+ *
+ ((snd_attenuation_decibel.value == 0) ? 1.0 : pow(0.1, 0.1 * snd_attenuation_decibel.value * f));
+ }
intensity = mastervol * f;
if (intensity > 0)
flag != CHANNELFLAG_PAUSED &&
flag != CHANNELFLAG_FULLVOLUME &&
flag != CHANNELFLAG_BGMVOLUME &&
+ flag != CHANNELFLAG_TRAPEZOID &&
flag != CHANNELFLAG_LOCALSOUND)
return false;
#define CHANNELFLAG_RELIABLE (1 << 0) // send as reliable message (only used on server)
#define CHANNELFLAG_FORCELOOP (1 << 1) // force looping even if the sound is not looped
#define CHANNELFLAG_LOCALSOUND (1 << 2) // INTERNAL USE. Not settable by S_SetChannelFlag
-#define CHANNELFLAG_PAUSED (1 << 3) // pause status
+#define CHANNELFLAG_PAUSED (1 << 3) // pause status
#define CHANNELFLAG_FULLVOLUME (1 << 4) // isn't affected by the general volume
#define CHANNELFLAG_BGMVOLUME (1 << 8) // uses bgmvolume instead of volume
+#define CHANNELFLAG_TRAPEZOID (1 << 9) // uses trapezoidal falloff instead of linear
// ====================================================================
// Types and variables
else
{
// LadyHavoc: we only let the qc set certain flags, others are off-limits
- flags = (int)PRVM_G_FLOAT(OFS_PARM6) & (CHANNELFLAG_RELIABLE | CHANNELFLAG_FORCELOOP | CHANNELFLAG_PAUSED | CHANNELFLAG_FULLVOLUME | CHANNELFLAG_BGMVOLUME);
+ flags = (int)PRVM_G_FLOAT(OFS_PARM6) & (CHANNELFLAG_RELIABLE | CHANNELFLAG_FORCELOOP | CHANNELFLAG_PAUSED | CHANNELFLAG_FULLVOLUME | CHANNELFLAG_BGMVOLUME | CHANNELFLAG_TRAPEZOID);
}
if (nvolume < 0 || nvolume > 255)