NULL, // #174
NULL, // #175
NULL, // #176
-NULL, // #177
+VM_localsound, // #177
NULL, // #178
NULL, // #179
// DOOMBRINGER range #180-#199
=========
VM_localsound
-localsound(string sample)
+localsound(string sample, float channel, float volume)
=========
*/
void VM_localsound(prvm_prog_t *prog)
{
const char *s;
+ int chan;
+ float vol;
- VM_SAFEPARMCOUNT(1,VM_localsound);
+ VM_SAFEPARMCOUNT(3, VM_localsound);
s = PRVM_G_STRING(OFS_PARM0);
+ chan = PRVM_G_INT(OFS_PARM1);
+ vol = PRVM_G_FLOAT(OFS_PARM2);
- if(!S_LocalSound (s))
+
+ if(!S_LocalSound2 (s, chan, vol))
{
PRVM_G_FLOAT(OFS_RETURN) = -4;
VM_Warning(prog, "VM_localsound: Failed to play %s for %s !\n", s, prog->name);
channels[ch_ind].flags |= CHANNELFLAG_LOCALSOUND;
return true;
}
+
+qbool S_LocalSound2 (const char *sound, int chnl, float vlume)
+{
+ sfx_t *sfx;
+ int ch_ind;
+
+ if (!snd_initialized.integer || nosound.integer)
+ return true;
+
+ sfx = S_PrecacheSound (sound, true, false);
+ if (!sfx)
+ {
+ Con_Printf("S_LocalSound: can't precache %s\n", sound);
+ return false;
+ }
+
+ // menu sounds must not be freed on level change
+ sfx->flags |= SFXFLAG_MENUSOUND;
+
+ // Reki 5-28-2021
+ // A small hack to try to support lazy QC practices
+ if (vlume == 0)
+ vlume = 1;
+
+ ch_ind = S_StartSound (cl.viewentity, chnl, sfx, vec3_origin, vlume, 0);
+ if (ch_ind < 0)
+ return false;
+
+ channels[ch_ind].flags |= CHANNELFLAG_LOCALSOUND;
+ return true;
+}
int S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation);
int S_StartSound_StartPosition_Flags (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation, float startposition, int flags, float fspeed);
qbool S_LocalSound (const char *s);
+qbool S_LocalSound2 (const char *s, int chnl, float vlume);
void S_StaticSound (sfx_t *sfx, vec3_t origin, float fvol, float attenuation);
void S_StopSound (int entnum, int entchannel);