X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Ftriggers%2Ftarget%2Fspeaker.qc;h=046128f796d2cef4d353942496d952cb8d8c11c5;hb=a823548db666d01ecf1ef8b8e559caa61334ce26;hp=75f733c09eefa44d420a36c894beb88dfa05b791;hpb=9a3b01ba5da2726001a5ed74645a15ce764a3675;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/triggers/target/speaker.qc b/qcsrc/common/triggers/target/speaker.qc index 75f733c09..046128f79 100644 --- a/qcsrc/common/triggers/target/speaker.qc +++ b/qcsrc/common/triggers/target/speaker.qc @@ -1,21 +1,21 @@ #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() -{SELFPARAM(); - if (!IS_REAL_CLIENT(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(actor)) return; string snd; - if(substring(self.noise, 0, 1) == "*") + if(substring(this.noise, 0, 1) == "*") { - var .string sample = GetVoiceMessageSampleField(substring(self.noise, 1, -1)); + var .string sample = GetVoiceMessageSampleField(substring(this.noise, 1, -1)); if(GetPlayerSoundSampleField_notFound) snd = SND(Null); - else if(activator.(sample) == "") + 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) @@ -25,23 +25,23 @@ void target_speaker_use_activator() } } 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() -{SELFPARAM(); +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 = GetVoiceMessageSampleField(substring(self.noise, 1, -1)); + var .string sample = GetVoiceMessageSampleField(substring(this.noise, 1, -1)); if(GetPlayerSoundSampleField_notFound) snd = SND(Null); - else if(activator.(sample) == "") + 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) @@ -51,32 +51,32 @@ void target_speaker_use_on() } } 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() -{SELFPARAM(); - sound(self, CH_TRIGGER_SINGLE, SND_Null, VOL_BASE * self.volume, self.atten); - self.use = target_speaker_use_on; +void target_speaker_use_off(entity this, entity actor, entity trigger) +{ + sound(this, CH_TRIGGER_SINGLE, SND_Null, VOL_BASE * this.volume, this.atten); + this.use = target_speaker_use_on; } -void target_speaker_reset() -{SELFPARAM(); - if(self.spawnflags & 1) // LOOPED_ON +void target_speaker_reset(entity this) +{ + 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() -{SELFPARAM(); +spawnfunc(target_speaker) +{ // TODO: "*" prefix to sound file name // TODO: wait and random (just, HOW? random is not a field) if(self.noise) @@ -101,7 +101,7 @@ void spawnfunc_target_speaker() self.use = target_speaker_use_activator; else if(self.spawnflags & 1) // LOOPED_ON { - target_speaker_use_on(); + target_speaker_use_on(self, NULL, NULL); self.reset = target_speaker_reset; } else if(self.spawnflags & 2) // LOOPED_OFF