r4765 - in trunk/data: qcsrc/server scripts

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Thu Oct 16 07:51:58 EDT 2008


Author: div0
Date: 2008-10-16 07:51:57 -0400 (Thu, 16 Oct 2008)
New Revision: 4765

Modified:
   trunk/data/qcsrc/server/t_plats.qc
   trunk/data/qcsrc/server/target_spawn.qc
   trunk/data/scripts/entities.def
Log:
bugfix target_spawn, and change docs to match it


Modified: trunk/data/qcsrc/server/t_plats.qc
===================================================================
--- trunk/data/qcsrc/server/t_plats.qc	2008-10-16 10:44:32 UTC (rev 4764)
+++ trunk/data/qcsrc/server/t_plats.qc	2008-10-16 11:51:57 UTC (rev 4765)
@@ -507,6 +507,8 @@
 		return;
 	if (other.classname != "player")
 		return;
+	if(other.velocity * self.movedir < 0)
+		return;
 	self.enemy = other;
 	if (other.owner)
 		self.enemy = other.owner;

Modified: trunk/data/qcsrc/server/target_spawn.qc
===================================================================
--- trunk/data/qcsrc/server/target_spawn.qc	2008-10-16 10:44:32 UTC (rev 4764)
+++ trunk/data/qcsrc/server/target_spawn.qc	2008-10-16 11:51:57 UTC (rev 4765)
@@ -12,7 +12,7 @@
 
 void target_spawn_useon(entity e)
 {
-	float i, n, valuefieldpos, sPWNed;
+	float i, n, valuefieldpos;
 	string key, value, valuefield, valueoffset, valueoffsetrandom;
 	entity valueent;
 	vector data, data2;
@@ -21,18 +21,24 @@
 
 	n = tokenize_sane(self.message);
 
-	sPWNed = FALSE;
-
 	for(i = 0; i < n-1; i += 2)
 	{
 		key = argv(i);
 		value = argv(i+1);
-		data = stov(db_get(TemporaryDB, strcat("/target_spawn/field/", key)));
-		if(data_y == 0) // undefined field, i.e., invalid type
+		if(key == "$")
 		{
-			print("target_spawn: invalid/unknown entity key ", key, " specified, ignored!\n");
-			continue;
+			data_x = -1;
+			data_y = FIELD_STRING;
 		}
+		else
+		{
+			data = stov(db_get(TemporaryDB, strcat("/target_spawn/field/", key)));
+			if(data_y == 0) // undefined field, i.e., invalid type
+			{
+				print("target_spawn: invalid/unknown entity key ", key, " specified, ignored!\n");
+				continue;
+			}
+		}
 		if(substring(value, 0, 1) == "$")
 		{
 			value = substring(value, 1, strlen(value) - 1);
@@ -45,20 +51,12 @@
 			else
 			{
 				// replace me!
-				valuefieldpos = strstrofs(value, ".", 0);
-				valuefield = "";
-				if(valuefieldpos != -1)
-				{
-					valuefield = substring(value, valuefieldpos + 1, strlen(value) - valuefieldpos - 1);
-					value = substring(value, 0, valuefieldpos);
-				}
-
 				valuefieldpos = strstrofs(value, "+", 0);
 				valueoffset = "";
 				if(valuefieldpos != -1)
 				{
-					valueoffset = substring(valuefield, valuefieldpos + 1, strlen(valueoffset) - valuefieldpos - 1);
-					valuefield = substring(valuefield, 0, valuefieldpos);
+					valueoffset = substring(value, valuefieldpos + 1, strlen(value) - valuefieldpos - 1);
+					value = substring(value, 0, valuefieldpos);
 				}
 
 				valuefieldpos = strstrofs(valueoffset, "+", 0);
@@ -69,6 +67,14 @@
 					valueoffset = substring(valueoffset, 0, valuefieldpos);
 				}
 
+				valuefieldpos = strstrofs(value, ".", 0);
+				valuefield = "";
+				if(valuefieldpos != -1)
+				{
+					valuefield = substring(value, valuefieldpos + 1, strlen(value) - valuefieldpos - 1);
+					value = substring(value, 0, valuefieldpos);
+				}
+
 				if(value == "self")
 				{
 					valueent = self;
@@ -113,7 +119,7 @@
 					data2 = stov(db_get(TemporaryDB, strcat("/target_spawn/field/", valuefield)));
 					if(data2_y == 0) // undefined field, i.e., invalid type
 					{
-						print("target_spawn: invalid/unknown entity key replacement ", value, " specified, ignored!\n");
+						print("target_spawn: invalid/unknown entity key replacement ", valuefield, " specified, ignored!\n");
 						continue;
 					}
 					value = getentityfieldstring(data2_x, valueent);
@@ -156,28 +162,27 @@
 				}
 			}
 		}
-		putentityfieldstring(data_x, e, value);
-
-		if(key == "classname" && !sPWNed)
+		if(key == "$")
 		{
-			if(self.spawnflags & 1)
-			{
-				if(!e.target_spawn_spawnfunc)
-					putentityfieldstring(target_spawn_spawnfunc_field, e, strcat("spawnfunc_", value));
+			putentityfieldstring(target_spawn_spawnfunc_field, e, value);
 
-				oldself = self;
-				oldactivator = activator;
+			oldself = self;
+			oldactivator = activator;
 
-				self = e;
-				activator = self.target_spawn_activator;
+			self = e;
+			activator = self.target_spawn_activator;
 
-				self.target_spawn_spawnfunc();
+			self.target_spawn_spawnfunc();
 
-				self = oldself;
-				activator = oldactivator;
-			}
-			sPWNed = TRUE;
+			self = oldself;
+			activator = oldactivator;
 		}
+		else
+		{
+			if(data_y == FIELD_VECTOR)
+				value = strreplace("'", "", value); // why?!?
+			putentityfieldstring(data_x, e, value);
+		}
 	}
 }
 
@@ -202,7 +207,8 @@
 void target_spawn_spawnfirst()
 {
 	activator = self.target_spawn_activator;
-	target_spawn_use();
+	if(self.spawnflags & 2)
+		target_spawn_use();
 }
 
 void spawnfunc_target_spawn()
@@ -211,6 +217,7 @@
 	{
 		float n, i;
 		string fn;
+		vector prev, new;
 		float ft;
 
 		n = numentityfields();
@@ -218,13 +225,19 @@
 		{
 			fn = entityfieldname(i);
 			ft = entityfieldtype(i);
-			db_put(TemporaryDB, strcat("/target_spawn/field/", fn), vtos(i * '1 0 0' + ft * '0 1 0' + '0 0 1'));
-			if(fn == "target_spawn_spawnfunc")
-				target_spawn_spawnfunc_field = i;
+			new = i * '1 0 0' + ft * '0 1 0' + '0 0 1';
+			prev = stov(db_get(TemporaryDB, strcat("/target_spawn/field/", fn)));
+			if(prev_y == 0)
+			{
+				db_put(TemporaryDB, strcat("/target_spawn/field/", fn), vtos(new));
+				if(fn == "target_spawn_spawnfunc")
+					target_spawn_spawnfunc_field = i;
+			}
 		}
 
 		target_spawn_initialized = 1;
 	}
 	self.use = target_spawn_use;
+	self.message = strzone(strreplace("'", "\"", self.message));
 	InitializeEntity(self, target_spawn_spawnfirst, INITPRIO_LAST);
 }

Modified: trunk/data/scripts/entities.def
===================================================================
--- trunk/data/scripts/entities.def	2008-10-16 10:44:32 UTC (rev 4764)
+++ trunk/data/scripts/entities.def	2008-10-16 11:51:57 UTC (rev 4765)
@@ -1081,10 +1081,11 @@
 ANDNOT: the items listed will get removed from the player
 */
 
-/*QUAKED target_spawn (1 0 1) (-8 -8 -8) (8 8 8) SPAWNFUNC ONLOAD
+/*QUAKED target_spawn (1 0 1) (-8 -8 -8) (8 8 8) - ONLOAD
 Spawns an entity when triggered.
 The entity field list is a single string of the form:
-"field" "value" "field" "value" ... "classname" "item_bullets" ... "field" "value"
+'field' 'value' 'field' 'value' ... 'classname' 'item_bullets' ... 'field' 'value'
+The special "field" name $ calls a void(void) function, for example a spawn function.
 Field values can use various variable replacements:
 $E
 $E.field
@@ -1093,15 +1094,24 @@
 where "E" can be self, activator and pusher.
 Example is a Mario-style question mark block which could throw a new weapon_nex when activated like this:
 {
+"classname" "func_button"
+"angle" "-1"
+"wait" "5"
+"target" "makenex"
+"speed" "1000"
+"lip" "64"
+...
+}
+{
 "classname" "target_spawn"
-"message" "origin \"$self.origin+0 0 128\" velocity \"$activator.velocity+0 0 200\" owner $activator flags 65536 colormap $activator.colormap target_spawn_spawnfunc weapon_nex classname droppedweapon think thrown_wep_think nextthink $time+0.5"
-"spawnflags" "1"
+"origin" "0 0 448"
+"targetname" "makenex"
+"message" "origin $self.origin owner $activator flags 65536 colormap $activator.colormap classname droppedweapon $ spawnfunc_weapon_nex think thrown_wep_think nextthink $time+0.5 velocity $activator.velocity velocity_z 512 movetype 3"
 }
 -------- KEYS --------
 targetname: used to trigger this
 message: entity field list
 target: when set, target_spawn edits entities, instead of creating new ones
 -------- SPAWNFLAGS --------
-SPAWNFUNC: call the spawn function when the "classname" key is mentioned in the fields list
 ONLOAD: create a first entity on map load
 */




More information about the nexuiz-commits mailing list