r4835 - in trunk/data: qcsrc/server scripts
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Thu Oct 23 08:03:51 EDT 2008
Author: div0
Date: 2008-10-23 08:03:50 -0400 (Thu, 23 Oct 2008)
New Revision: 4835
Modified:
trunk/data/qcsrc/server/target_spawn.qc
trunk/data/scripts/entities.def
Log:
trigger_relay_if - to help with entity factories that create a limited number of objects (to not spam the server).
A factory is now:
- a target_spawn
- a trigger_relay_if targeting the target_spawn
- a trigger_multivibrator targeting the trigger_relay_if
For later, what about making a target_spawnfactory entity that creates all these.
Modified: trunk/data/qcsrc/server/target_spawn.qc
===================================================================
--- trunk/data/qcsrc/server/target_spawn.qc 2008-10-23 11:33:00 UTC (rev 4834)
+++ trunk/data/qcsrc/server/target_spawn.qc 2008-10-23 12:03:50 UTC (rev 4835)
@@ -216,7 +216,7 @@
target_spawn_use();
}
-void spawnfunc_target_spawn()
+void initialize_field_db()
{
if(!target_spawn_initialized)
{
@@ -242,7 +242,56 @@
target_spawn_initialized = 1;
}
+}
+
+void spawnfunc_target_spawn()
+{
+ initialize_field_db();
self.use = target_spawn_use;
self.message = strzone(strreplace("'", "\"", self.message));
InitializeEntity(self, target_spawn_spawnfirst, INITPRIO_LAST);
}
+
+
+void trigger_relay_if_use()
+{
+ float n;
+ var .string fld;
+ entity e;
+ 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)
+ ;
+
+ if(self.spawnflags & 1) // MORE THAN count valid targets
+ {
+ if(n)
+ SUB_UseTargets();
+ }
+ else // AT MOST count valid targets
+ {
+ if(!n)
+ SUB_UseTargets();
+ }
+}
+
+void spawnfunc_trigger_relay_if()
+{
+ self.use = trigger_relay_if_use;
+};
+
Modified: trunk/data/scripts/entities.def
===================================================================
--- trunk/data/scripts/entities.def 2008-10-23 11:33:00 UTC (rev 4834)
+++ trunk/data/scripts/entities.def 2008-10-23 12:03:50 UTC (rev 4835)
@@ -1132,3 +1132,15 @@
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.
+-------- 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
+count: The count of entities that must be found
+-------- SPAWNFLAGS --------
+MORETHAN: trigger if there are more than the given count, not at least
+*/
More information about the nexuiz-commits
mailing list