X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fcommon%2Ftriggers%2Ftrigger%2Fmulti.qc;h=5e8c641be542735efe020f155f2d7ff556f7dcbc;hp=91bfc99834b2953611707678ab25268269f3244e;hb=0071121b663dc3d841a2c28d27c1015899f0f402;hpb=52a450666dc3d315178b0cf2cb6ab716be524044 diff --git a/qcsrc/common/triggers/trigger/multi.qc b/qcsrc/common/triggers/trigger/multi.qc index 91bfc99834..5e8c641be5 100644 --- a/qcsrc/common/triggers/trigger/multi.qc +++ b/qcsrc/common/triggers/trigger/multi.qc @@ -1,133 +1,131 @@ +#include "multi.qh" // NOTE: also contains trigger_once at bottom #ifdef SVQC // the wait time has passed, so set back up for another activation -void multi_wait() -{SELFPARAM(); - if (self.max_health) +void multi_wait(entity this) +{ + if (this.max_health) { - self.health = self.max_health; - self.takedamage = DAMAGE_YES; - self.solid = SOLID_BBOX; + this.health = this.max_health; + this.takedamage = DAMAGE_YES; + this.solid = SOLID_BBOX; } } // the trigger was just touched/killed/used -// self.enemy should be set to the activator so it can be held through a delay +// this.enemy should be set to the activator so it can be held through a delay // so wait for the delay time before firing -void multi_trigger() -{SELFPARAM(); - if (self.nextthink > time) +void multi_trigger(entity this) +{ + if (this.nextthink > time) { return; // allready been triggered } - if(self.spawnflags & 16384) - if(!IS_PLAYER(self.enemy)) + if(this.spawnflags & 16384) + if(!IS_PLAYER(this.enemy)) return; // only players - if (self.classname == "trigger_secret") + if (this.classname == "trigger_secret") { - if (!IS_PLAYER(self.enemy)) + if (!IS_PLAYER(this.enemy)) return; found_secrets = found_secrets + 1; WriteByte (MSG_ALL, SVC_FOUNDSECRET); } - if (self.noise) - _sound (self.enemy, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NORM); + if (this.noise) + _sound (this.enemy, CH_TRIGGER, this.noise, VOL_BASE, ATTEN_NORM); // don't trigger again until reset - self.takedamage = DAMAGE_NO; + this.takedamage = DAMAGE_NO; - activator = self.enemy; - other = self.goalentity; - SUB_UseTargets(); + SUB_UseTargets(this, this.enemy, this.goalentity); - if (self.wait > 0) + if (this.wait > 0) { - self.think = multi_wait; - self.nextthink = time + self.wait; + setthink(this, multi_wait); + this.nextthink = time + this.wait; } - else if (self.wait == 0) + else if (this.wait == 0) { - multi_wait(); // waiting finished + multi_wait(this); // waiting finished } else - { // we can't just remove (self) here, because this is a touch function - // called wheil C code is looping through area links... - self.touch = func_null; + { // we can't just delete(this) here, because this is a touch function + // called while C code is looping through area links... + settouch(this, func_null); } } -void multi_use() -{SELFPARAM(); - self.goalentity = other; - self.enemy = activator; - multi_trigger(); +void multi_use(entity this, entity actor, entity trigger) +{ + this.goalentity = trigger; + this.enemy = actor; + multi_trigger(this); } -void multi_touch() -{SELFPARAM(); - if(!(self.spawnflags & 2)) - if(!other.iscreature) +void multi_touch(entity this, entity toucher) +{ + if(!(this.spawnflags & 2)) + if(!toucher.iscreature) return; - if(self.team) - if(((self.spawnflags & 4) == 0) == (self.team != other.team)) + if(this.team) + if(((this.spawnflags & 4) == 0) == (this.team != toucher.team)) return; // if the trigger has an angles field, check player's facing direction - if (self.movedir != '0 0 0') + if (this.movedir != '0 0 0') { - makevectors (other.angles); - if (v_forward * self.movedir < 0) + makevectors (toucher.angles); + if (v_forward * this.movedir < 0) return; // not facing the right way } // if the trigger has pressed keys, check that the player is pressing those keys - if(self.pressedkeys) - if(IS_PLAYER(other)) // only for players - if(!(other.pressedkeys & self.pressedkeys)) + if(this.pressedkeys && IS_PLAYER(toucher)) // only for players + if(!(CS(toucher).pressedkeys & this.pressedkeys)) return; - EXACTTRIGGER_TOUCH; + EXACTTRIGGER_TOUCH(this, toucher); - self.enemy = other; - self.goalentity = other; - multi_trigger (); + this.enemy = toucher; + this.goalentity = toucher; + multi_trigger(this); } -void multi_eventdamage (entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force) -{SELFPARAM(); - if (!self.takedamage) +void multi_eventdamage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force) +{ + if(!this.takedamage) return; - if(self.spawnflags & DOOR_NOSPLASH) + if(this.spawnflags & DOOR_NOSPLASH) if(!(DEATH_ISSPECIAL(deathtype)) && (deathtype & HITTYPE_SPLASH)) return; - self.health = self.health - damage; - if (self.health <= 0) + this.health = this.health - damage; + if (this.health <= 0) { - self.enemy = attacker; - self.goalentity = inflictor; - multi_trigger(); + this.enemy = attacker; + this.goalentity = inflictor; + multi_trigger(this); } } -void multi_reset() -{SELFPARAM(); - if ( !(self.spawnflags & SPAWNFLAG_NOTOUCH) ) - self.touch = multi_touch; - if (self.max_health) +void multi_reset(entity this) +{ + if ( !(this.spawnflags & SPAWNFLAG_NOTOUCH) ) + settouch(this, multi_touch); + if (this.max_health) { - self.health = self.max_health; - self.takedamage = DAMAGE_YES; - self.solid = SOLID_BBOX; + this.health = this.max_health; + this.takedamage = DAMAGE_YES; + this.solid = SOLID_BBOX; } - self.think = func_null; - self.nextthink = 0; - self.team = self.team_saved; + setthink(this, func_null); + this.nextthink = 0; + this.team = this.team_saved; } /*QUAKED spawnfunc_trigger_multiple (.5 .5 .5) ? notouch @@ -145,48 +143,44 @@ set "message" to text string */ spawnfunc(trigger_multiple) { - self.reset = multi_reset; - if (self.sounds == 1) - { - precache_sound ("misc/secret.wav"); - self.noise = "misc/secret.wav"; - } - else if (self.sounds == 2) - { - self.noise = strzone(SND(TALK)); - } - else if (self.sounds == 3) - { - precache_sound ("misc/trigger1.wav"); - self.noise = "misc/trigger1.wav"; - } - - if (!self.wait) - self.wait = 0.2; - else if(self.wait < -1) - self.wait = 0; - self.use = multi_use; + this.reset = multi_reset; + if (this.sounds == 1) + this.noise = "misc/secret.wav"; + else if (this.sounds == 2) + this.noise = strzone(SND(TALK)); + else if (this.sounds == 3) + this.noise = "misc/trigger1.wav"; + + if(this.noise) + precache_sound(this.noise); + + if (!this.wait) + this.wait = 0.2; + else if(this.wait < -1) + this.wait = 0; + this.use = multi_use; EXACTTRIGGER_INIT; - self.team_saved = self.team; + this.team_saved = this.team; + IL_PUSH(g_saved_team, this); - if (self.health) + if (this.health) { - if (self.spawnflags & SPAWNFLAG_NOTOUCH) - objerror ("health and notouch don't make sense\n"); - self.max_health = self.health; - self.event_damage = multi_eventdamage; - self.takedamage = DAMAGE_YES; - self.solid = SOLID_BBOX; - setorigin (self, self.origin); // make sure it links into the world + if (this.spawnflags & SPAWNFLAG_NOTOUCH) + objerror (this, "health and notouch don't make sense\n"); + this.max_health = this.health; + this.event_damage = multi_eventdamage; + this.takedamage = DAMAGE_YES; + this.solid = SOLID_BBOX; + setorigin(this, this.origin); // make sure it links into the world } else { - if ( !(self.spawnflags & SPAWNFLAG_NOTOUCH) ) + if ( !(this.spawnflags & SPAWNFLAG_NOTOUCH) ) { - self.touch = multi_touch; - setorigin (self, self.origin); // make sure it links into the world + settouch(this, multi_touch); + setorigin(this, this.origin); // make sure it links into the world } } }