r5475 - in trunk/data: qcsrc/server scripts

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Fri Jan 9 11:50:53 EST 2009


Author: div0
Date: 2009-01-09 11:50:53 -0500 (Fri, 09 Jan 2009)
New Revision: 5475

Modified:
   trunk/data/qcsrc/server/t_plats.qc
   trunk/data/scripts/entities.def
Log:
hooray! func_vectormamamam can now also project to planes, or to vectors!


Modified: trunk/data/qcsrc/server/t_plats.qc
===================================================================
--- trunk/data/qcsrc/server/t_plats.qc	2009-01-09 16:45:52 UTC (rev 5474)
+++ trunk/data/qcsrc/server/t_plats.qc	2009-01-09 16:50:53 UTC (rev 5475)
@@ -1642,73 +1642,84 @@
 .entity wp00, wp01, wp02, wp03;
 
 .float targetfactor, target2factor, target3factor, target4factor;
+.vector targetnormal, target2normal, target3normal, target4normal;
 
-void func_vectormamamam_controller_think()
+vector func_vectormamamam_origin(entity o, float t)
 {
-	vector v;
+	vector v, p;
+	float f;
 	entity e;
 
-	self.nextthink = time + 0.1;
+	f = o.spawnflags;
+	v = '0 0 0';
 
-	v = self.owner.destvec;
-	
-	e = self.owner.wp00;
+	e = o.wp00;
 	if(e)
-		v = v + e.origin + 0.1 * e.velocity;
+	{
+		p = e.origin + t * e.velocity;
+		if(f & 1)
+			v = v + (p * o.targetnormal) * o.targetnormal * o.targetfactor;
+		else
+			v = v + (p - (p * o.targetnormal) * o.targetnormal) * o.targetfactor;
+	}
 
-	e = self.owner.wp01;
+	e = o.wp01;
 	if(e)
-		v = v + e.origin + 0.1 * e.velocity;
+	{
+		p = e.origin + t * e.velocity;
+		if(f & 2)
+			v = v + (p * o.target2normal) * o.target2normal * o.target2factor;
+		else
+			v = v + (p - (p * o.target2normal) * o.target2normal) * o.target2factor;
+	}
 
-	e = self.owner.wp02;
+	e = o.wp02;
 	if(e)
-		v = v + e.origin + 0.1 * e.velocity;
+	{
+		p = e.origin + t * e.velocity;
+		if(f & 4)
+			v = v + (p * o.target3normal) * o.target3normal * o.target3factor;
+		else
+			v = v + (p - (p * o.target3normal) * o.target3normal) * o.target3factor;
+	}
 
-	e = self.owner.wp03;
+	e = o.wp03;
 	if(e)
-		v = v + e.origin + 0.1 * e.velocity;
+	{
+		p = e.origin + t * e.velocity;
+		if(f & 8)
+			v = v + (p * o.target4normal) * o.target4normal * o.target4factor;
+		else
+			v = v + (p - (p * o.target4normal) * o.target4normal) * o.target4factor;
+	}
 
-	self.owner.velocity = (v - self.owner.origin) * 10;
+	return v;
 }
 
+void func_vectormamamam_controller_think()
+{
+	self.nextthink = time + 0.1;
+	self.owner.velocity = (self.owner.destvec + func_vectormamamam_origin(self.owner, 0.1) - self.owner.origin) * 10;
+}
+
 void func_vectormamamam_findtarget()
 {
-	vector s0;
-
-	s0 = '0 0 0';
-
 	if(self.target != "")
-	{
 		self.wp00 = find(world, targetname, self.target);
-		if(self.wp00)
-			s0 = s0 + self.wp00.origin * self.targetfactor;
-	}
 
 	if(self.target2 != "")
-	{
 		self.wp01 = find(world, targetname, self.target2);
-		if(self.wp01)
-			s0 = s0 + self.wp01.origin * self.target2factor;
-	}
 
 	if(self.target3 != "")
-	{
 		self.wp02 = find(world, targetname, self.target3);
-		if(self.wp02)
-			s0 = s0 + self.wp02.origin * self.target3factor;
-	}
 
 	if(self.target4 != "")
-	{
 		self.wp03 = find(world, targetname, self.target4);
-		if(self.wp03)
-			s0 = s0 + self.wp03.origin * self.target4factor;
-	}
 
 	if(!self.wp00 && !self.wp01 && !self.wp02 && !self.wp03)
 		objerror("No reference entity found, so there is nothing to move. Aborting.");
 
-	self.destvec = self.origin - s0;
+	self.destvec = self.origin - func_vectormamamam_origin(self.owner, 0);
 
 	local entity controller;
 	controller = spawn();
@@ -1738,6 +1749,18 @@
 	if(!self.target4factor)
 		self.target4factor = 1;
 
+	if(vlen(self.targetnormal))
+		self.targetnormal = normalize(self.targetnormal);
+
+	if(vlen(self.target2normal))
+		self.target2normal = normalize(self.target2normal);
+
+	if(vlen(self.target3normal))
+		self.target3normal = normalize(self.target3normal);
+
+	if(vlen(self.target4normal))
+		self.target4normal = normalize(self.target4normal);
+
 	self.blocked = generic_plat_blocked;
 	if(self.dmg & (!self.message))
 		self.message = " was squished";

Modified: trunk/data/scripts/entities.def
===================================================================
--- trunk/data/scripts/entities.def	2009-01-09 16:45:52 UTC (rev 5474)
+++ trunk/data/scripts/entities.def	2009-01-09 16:50:53 UTC (rev 5475)
@@ -1333,20 +1333,29 @@
 netname: list of <frequencymultiplier> <phase> <x> <y> <z> quadruples, separated by spaces; note that phase 0 represents a sine wave, and phase 0.25 a cosine wave (by default, it uses 1 0 0 0 1, to match func_bobbing's defaults
 */
 
-/*QUAKED func_vectormamamam (0 .5 .8) ?
+/*QUAKED func_vectormamamam (0 .5 .8) ? PROJECT_ON_TARGETNORMAL TARGET2NORMAL_IS_DIRECTION TARGET3NORMAL_IS_DIRECTION TARGET4NORMAL_IS_DIRECTION
 Solid entity that moves according to the movement of multiple given entities (max 4)
 -------- KEYS --------
 target: first reference entity
 targetfactor: factor by which to take the first reference entity (default 1).
+targetnormal: if set, the first reference entity's location is first projected onto a plane with that normal
 target2: second reference entity
 target2factor: factor by which to take the second reference entity (default 1).
+target2normal: if set, the second reference entity's location is first projected onto a plane with that normal
 target3: third reference entity (optional)
 target3factor: factor by which to take the third reference entity (default 1).
+target3normal: if set, the third reference entity's location is first projected onto a plane with that normal
 target4: fourth reference entity (optional)
 target4factor: factor by which to take the fourth reference entity (default 1).
+target4normal: if set, the fourth reference entity's location is first projected onto a plane with that normal
 noise: path/name of .wav or .ogg file to play. Use looping sounds only (e.g. sound/world/drone6.wav - See Notes).
 dmg: damage a player who gets crushed by it receives
 dmgtime: interval to apply dmg to a player who is s in the way
 message: death message when a player gets crushed
 message2: death message when someone gets pushed into this (default: "was thrown into a world of hurt by"). The # character is replaced by the attacker name if present (and it instead does not get appended to the end)
+-------- SPAWNFLAGS --------
+PROJECT_ON_TARGETNORMAL: target's origin is projected onto the given direction vector, not on the plane perpendicular to it
+PROJECT_ON_TARGET2NORMAL: target2's origin is projected onto the given direction vector, not on the plane perpendicular to it
+PROJECT_ON_TARGET3NORMAL: target3's origin is projected onto the given direction vector, not on the plane perpendicular to it
+PROJECT_ON_TARGET4NORMAL: target4's origin is projected onto the given direction vector, not on the plane perpendicular to it
 */




More information about the nexuiz-commits mailing list