NULL, // #174
NULL, // #175
NULL, // #176
-NULL, // #177
+VM_localsound, // #177
NULL, // #178
NULL, // #179
NULL, // #180
vector(string) stov = #117;
string(string s) strzone = #118;
void(string s) strunzone = #119;
+void(string s, float chan, float vol) localsound = #177;
// FTEQW range #200-#299
=========
VM_localsound
-localsound(string sample)
+localsound(string sample, float chan, float vol)
=========
*/
void VM_localsound(prvm_prog_t *prog)
{
const char *s;
+ float chan, vol;
- VM_SAFEPARMCOUNT(1,VM_localsound);
+ VM_SAFEPARMCOUNTRANGE(1, 3,VM_localsound);
s = PRVM_G_STRING(OFS_PARM0);
-
- if(!S_LocalSound (s))
+ if(prog->argc == 3)
+ {
+ chan = PRVM_G_FLOAT(OFS_PARM1);
+ vol = PRVM_G_FLOAT(OFS_PARM2) == 0 ? 1 : PRVM_G_FLOAT(OFS_PARM2);
+ if(!S_LocalSoundEx(s, chan, vol))
+ {
+ PRVM_G_FLOAT(OFS_RETURN) = -4;
+ VM_Warning(prog, "VM_localsound: Failed to play %s for %s !\n", s, prog->name);
+ return;
+ }
+ }
+ else if(!S_LocalSound (s))
{
PRVM_G_FLOAT(OFS_RETURN) = -4;
VM_Warning(prog, "VM_localsound: Failed to play %s for %s !\n", s, prog->name);
S_PaintAndSubmit();
}
-qbool S_LocalSound (const char *sound)
+qbool S_LocalSoundEx (const char *sound, int chan, float fvol)
{
sfx_t *sfx;
int ch_ind;
// fun fact: in Quake 1, this used -1 "replace any entity channel",
// which we no longer support anyway
// changed by Black in r4297 "Changed S_LocalSound to play multiple sounds at a time."
- ch_ind = S_StartSound (cl.viewentity, 0, sfx, vec3_origin, 1, 0);
+ ch_ind = S_StartSound (cl.viewentity, chan, sfx, vec3_origin, fvol, 0);
if (ch_ind < 0)
return false;
channels[ch_ind].flags |= CHANNELFLAG_LOCALSOUND;
return true;
}
+
+qbool S_LocalSound (const char *sound)
+{
+ return S_LocalSoundEx(sound, 0, 1);
+}
return false;
}
+qbool S_LocalSoundEx (const char *s, int chan, float fvol)
+{
+ return false;
+}
+
void S_BlockSound (void)
{
}
// S_StartSound returns the channel index, or -1 if an error occurred
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_LocalSoundEx (const char *s, int chan, float fvol);
qbool S_LocalSound (const char *s);
void S_StaticSound (sfx_t *sfx, vec3_t origin, float fvol, float attenuation);