+#include "speaker.qh"
#ifdef SVQC
// TODO add a way to do looped sounds with sound(); then complete this entity
-void target_speaker_use_off();
-void target_speaker_use_activator()
+void target_speaker_use_off(entity this, entity actor, entity trigger);
+void target_speaker_use_activator(entity this, entity actor, entity trigger)
{
- if (!IS_REAL_CLIENT(activator))
+ if (!IS_REAL_CLIENT(actor))
return;
string snd;
- if(substring(self.noise, 0, 1) == "*")
+ if(substring(this.noise, 0, 1) == "*")
{
- var .string sample;
- sample = GetVoiceMessageSampleField(substring(self.noise, 1, -1));
+ var .string sample = GetVoiceMessageSampleField(substring(this.noise, 1, -1));
if(GetPlayerSoundSampleField_notFound)
- snd = "misc/null.wav";
- else if(activator.sample == "")
- snd = "misc/null.wav";
+ snd = SND(Null);
+ else if(actor.(sample) == "")
+ snd = SND(Null);
else
{
- tokenize_console(activator.sample);
+ tokenize_console(actor.(sample));
float n;
n = stof(argv(1));
if(n > 0)
}
}
else
- snd = self.noise;
- msg_entity = activator;
- soundto(MSG_ONE, self, CH_TRIGGER, snd, VOL_BASE * self.volume, self.atten);
+ snd = this.noise;
+ msg_entity = actor;
+ soundto(MSG_ONE, this, CH_TRIGGER, snd, VOL_BASE * this.volume, this.atten);
}
-void target_speaker_use_on()
+void target_speaker_use_on(entity this, entity actor, entity trigger)
{
string snd;
- if(substring(self.noise, 0, 1) == "*")
+ if(substring(this.noise, 0, 1) == "*")
{
- var .string sample;
- sample = GetVoiceMessageSampleField(substring(self.noise, 1, -1));
+ var .string sample = GetVoiceMessageSampleField(substring(this.noise, 1, -1));
if(GetPlayerSoundSampleField_notFound)
- snd = "misc/null.wav";
- else if(activator.sample == "")
- snd = "misc/null.wav";
+ snd = SND(Null);
+ else if(actor.(sample) == "")
+ snd = SND(Null);
else
{
- tokenize_console(activator.sample);
+ tokenize_console(actor.(sample));
float n;
n = stof(argv(1));
if(n > 0)
}
}
else
- snd = self.noise;
- sound(self, CH_TRIGGER_SINGLE, snd, VOL_BASE * self.volume, self.atten);
- if(self.spawnflags & 3)
- self.use = target_speaker_use_off;
+ snd = this.noise;
+ _sound(this, CH_TRIGGER_SINGLE, snd, VOL_BASE * this.volume, this.atten);
+ if(this.spawnflags & 3)
+ this.use = target_speaker_use_off;
}
-void target_speaker_use_off()
+void target_speaker_use_off(entity this, entity actor, entity trigger)
{
- sound(self, CH_TRIGGER_SINGLE, "misc/null.wav", VOL_BASE * self.volume, self.atten);
- self.use = target_speaker_use_on;
+ sound(this, CH_TRIGGER_SINGLE, SND_Null, VOL_BASE * this.volume, this.atten);
+ this.use = target_speaker_use_on;
}
-void target_speaker_reset()
+void target_speaker_reset(entity this)
{
- if(self.spawnflags & 1) // LOOPED_ON
+ if(this.spawnflags & 1) // LOOPED_ON
{
- if(self.use == target_speaker_use_on)
- target_speaker_use_on();
+ if(this.use == target_speaker_use_on)
+ target_speaker_use_on(this, NULL, NULL);
}
- else if(self.spawnflags & 2)
+ else if(this.spawnflags & 2)
{
- if(self.use == target_speaker_use_off)
- target_speaker_use_off();
+ if(this.use == target_speaker_use_off)
+ target_speaker_use_off(this, NULL, NULL);
}
}
-void spawnfunc_target_speaker()
+spawnfunc(target_speaker)
{
// TODO: "*" prefix to sound file name
// TODO: wait and random (just, HOW? random is not a field)
- if(self.noise)
- precache_sound (self.noise);
+ if(this.noise)
+ precache_sound (this.noise);
- if(!self.atten && !(self.spawnflags & 4))
+ if(!this.atten && !(this.spawnflags & 4))
{
IFTARGETED
- self.atten = ATTEN_NORM;
+ this.atten = ATTEN_NORM;
else
- self.atten = ATTEN_STATIC;
+ this.atten = ATTEN_STATIC;
}
- else if(self.atten < 0)
- self.atten = 0;
+ else if(this.atten < 0)
+ this.atten = 0;
- if(!self.volume)
- self.volume = 1;
+ if(!this.volume)
+ this.volume = 1;
IFTARGETED
{
- if(self.spawnflags & 8) // ACTIVATOR
- self.use = target_speaker_use_activator;
- else if(self.spawnflags & 1) // LOOPED_ON
+ if(this.spawnflags & 8) // ACTIVATOR
+ this.use = target_speaker_use_activator;
+ else if(this.spawnflags & 1) // LOOPED_ON
{
- target_speaker_use_on();
- self.reset = target_speaker_reset;
+ target_speaker_use_on(this, NULL, NULL);
+ this.reset = target_speaker_reset;
}
- else if(self.spawnflags & 2) // LOOPED_OFF
+ else if(this.spawnflags & 2) // LOOPED_OFF
{
- self.use = target_speaker_use_on;
- self.reset = target_speaker_reset;
+ this.use = target_speaker_use_on;
+ this.reset = target_speaker_reset;
}
else
- self.use = target_speaker_use_on;
+ this.use = target_speaker_use_on;
}
- else if(self.spawnflags & 1) // LOOPED_ON
+ else if(this.spawnflags & 1) // LOOPED_ON
{
- ambientsound (self.origin, self.noise, VOL_BASE * self.volume, self.atten);
- remove(self);
+ ambientsound (this.origin, this.noise, VOL_BASE * this.volume, this.atten);
+ delete(this);
}
- else if(self.spawnflags & 2) // LOOPED_OFF
+ else if(this.spawnflags & 2) // LOOPED_OFF
{
- objerror("This sound entity can never be activated");
+ objerror(this, "This sound entity can never be activated");
}
else
{
// Quake/Nexuiz fallback
- ambientsound (self.origin, self.noise, VOL_BASE * self.volume, self.atten);
- remove(self);
+ ambientsound (this.origin, this.noise, VOL_BASE * this.volume, this.atten);
+ delete(this);
}
}
#endif