From 40f4d0cb58c7e3e8e3698b79296ddcc1b3f5aea5 Mon Sep 17 00:00:00 2001 From: div0 Date: Fri, 31 Oct 2008 09:09:05 +0000 Subject: [PATCH] trigger_relay_if was useless. Make it useful, by letting it check cvars. git-svn-id: svn://svn.icculus.org/nexuiz/trunk@4948 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- data/qcsrc/server/target_spawn.qc | 31 +++++-------------------------- data/scripts/entities.def | 10 +++++----- 2 files changed, 10 insertions(+), 31 deletions(-) diff --git a/data/qcsrc/server/target_spawn.qc b/data/qcsrc/server/target_spawn.qc index efb6494bd..d621c79fd 100644 --- a/data/qcsrc/server/target_spawn.qc +++ b/data/qcsrc/server/target_spawn.qc @@ -299,33 +299,12 @@ void trigger_relay_if_use() n = self.count; // TODO make this generic AND faster than nextent()ing through all, if somehow possible - if(self.netname == "targetname") - fld = targetname; - else if(self.netname == "netname") - fld = netname; - else if(self.netname == "target") - fld = target; - else if(self.netname == "classname") - fld = classname; - else - { - objerror("invalid field specified for trigger_relay_if"); - return; - } - - for(e = world; (e = find(e, fld, self.message)) && (n > 0); --n) - ; + n = (cvar_string(self.netname) == cvar_string(self.message)); + if(self.spawnflags & 1) + n = !n; - if(self.spawnflags & 1) // MORE THAN count valid targets - { - if(n) - SUB_UseTargets(); - } - else // AT MOST count valid targets - { - if(!n) - SUB_UseTargets(); - } + if(n) + SUB_UseTargets(); } void spawnfunc_trigger_relay_if() diff --git a/data/scripts/entities.def b/data/scripts/entities.def index 828c9b163..f9d8dbce0 100644 --- a/data/scripts/entities.def +++ b/data/scripts/entities.def @@ -1135,16 +1135,16 @@ DISABLED: do not allow damaging this until it is first activated INDICATE: indicate amount of damage already taken by coloring */ -/*QUAKED trigger_relay_if (0 1 0) (-8 -8 -8) (8 8 8) MORETHAN -Relays the trigger event if there are at most count entities of the given type. +/*QUAKED trigger_relay_if (0 1 0) (-8 -8 -8) (8 8 8) NEGATE +Relays the trigger event if a cvar is set to a specified value. -------- KEYS -------- target: The entity/entities to relay the trigger events to targetname: The name other entities can use to target this entity -netname: The name of the field to check (can currently only be targetname, netname, target or classname) -message: The value of the field to check +netname: The name of the cvar to check +message: The value of the cvar to check count: The count of entities that must be found -------- SPAWNFLAGS -------- -MORETHAN: trigger if there are more than the given count, not at least +NEGATE: trigger if the cvar does NOT match the value. */ /*QUAKED weapon_hlac (1 0 .5) (-30 -30 0) (30 30 32) FLOATING -- 2.39.2