r4837 - in trunk/data: qcsrc/server scripts
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Thu Oct 23 08:26:27 EDT 2008
Author: div0
Date: 2008-10-23 08:26:25 -0400 (Thu, 23 Oct 2008)
New Revision: 4837
Modified:
trunk/data/qcsrc/server/g_triggers.qc
trunk/data/qcsrc/server/target_spawn.qc
trunk/data/scripts/entities.def
Log:
add limiting to target_spawn (now can refuse to spawn more than a given count)
Modified: trunk/data/qcsrc/server/g_triggers.qc
===================================================================
--- trunk/data/qcsrc/server/g_triggers.qc 2008-10-23 12:22:48 UTC (rev 4836)
+++ trunk/data/qcsrc/server/g_triggers.qc 2008-10-23 12:26:25 UTC (rev 4837)
@@ -1101,6 +1101,7 @@
void monoflop_use()
{
self.nextthink = time + self.wait;
+ self.enemy = activator;
if(self.state)
return;
self.state = 1;
@@ -1112,12 +1113,14 @@
return;
self.nextthink = time + self.wait;
self.state = 1;
+ self.enemy = activator;
SUB_UseTargets();
}
void monoflop_think()
{
self.state = 0;
+ activator = self.enemy;
SUB_UseTargets();
}
@@ -1142,6 +1145,7 @@
newstate = (time < cyclestart + self.wait);
+ activator = self;
if(self.state != newstate)
SUB_UseTargets();
self.state = newstate;
Modified: trunk/data/qcsrc/server/target_spawn.qc
===================================================================
--- trunk/data/qcsrc/server/target_spawn.qc 2008-10-23 12:22:48 UTC (rev 4836)
+++ trunk/data/qcsrc/server/target_spawn.qc 2008-10-23 12:26:25 UTC (rev 4837)
@@ -9,6 +9,8 @@
.void() target_spawn_spawnfunc;
float target_spawn_spawnfunc_field;
.entity target_spawn_activator;
+.float target_spawn_id;
+float target_spawn_count;
void target_spawn_useon(entity e)
{
@@ -20,6 +22,7 @@
entity oldactivator;
n = tokenize_sane(self.message);
+ self.target_spawn_activator = activator;
for(i = 0; i < n-1; i += 2)
{
@@ -175,7 +178,7 @@
oldactivator = activator;
self = e;
- activator = self.target_spawn_activator;
+ activator = oldself.target_spawn_activator;
self.target_spawn_spawnfunc();
@@ -191,6 +194,25 @@
}
}
+float target_spawn_cancreate()
+{
+ float c;
+ entity e;
+
+ c = self.count;
+ if(c == 0) // no limit?
+ return 1;
+
+ ++c; // increase count to not include MYSELF
+ for(e = world; (e = findfloat(e, target_spawn_id, self.target_spawn_id)); --c)
+ ;
+
+ // if c now is 0, we have AT LEAST the given count (maybe more), so don't spawn any more
+ if(c == 0)
+ return 0;
+ return 1;
+}
+
void target_spawn_use()
{
entity e;
@@ -198,8 +220,11 @@
if(self.target == "")
{
// spawn new entity
+ if(!target_spawn_cancreate())
+ return;
e = spawn();
target_spawn_useon(e);
+ e.target_spawn_id = self.target_spawn_id;
}
else
{
@@ -249,6 +274,7 @@
initialize_field_db();
self.use = target_spawn_use;
self.message = strzone(strreplace("'", "\"", self.message));
+ self.target_spawn_id = ++target_spawn_count;
InitializeEntity(self, target_spawn_spawnfirst, INITPRIO_LAST);
}
Modified: trunk/data/scripts/entities.def
===================================================================
--- trunk/data/scripts/entities.def 2008-10-23 12:22:48 UTC (rev 4836)
+++ trunk/data/scripts/entities.def 2008-10-23 12:26:25 UTC (rev 4837)
@@ -1112,6 +1112,7 @@
targetname: used to trigger this
message: entity field list
target: when set, target_spawn edits entities, instead of creating new ones
+count: make sure no more than count entities have been created by this (refuse to spawn new ones if exceeded)
-------- SPAWNFLAGS --------
ONLOAD: create a first entity on map load
*/
More information about the nexuiz-commits
mailing list