[nexuiz-commits] r6216 - in trunk/data: qcsrc/server scripts

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Thu Mar 19 06:39:49 EDT 2009


Author: div0
Date: 2009-03-19 06:39:49 -0400 (Thu, 19 Mar 2009)
New Revision: 6216

Modified:
   trunk/data/qcsrc/server/cl_client.qc
   trunk/data/qcsrc/server/defs.qh
   trunk/data/qcsrc/server/g_triggers.qc
   trunk/data/qcsrc/server/miscfunctions.qc
   trunk/data/scripts/entities.def
Log:
make misc_follow able to set up attachments (so you can attach a model to another in a map, useful for zym animations)
add a cheat +button8: drag'n'drop of entities


Modified: trunk/data/qcsrc/server/cl_client.qc
===================================================================
--- trunk/data/qcsrc/server/cl_client.qc	2009-03-18 14:26:13 UTC (rev 6215)
+++ trunk/data/qcsrc/server/cl_client.qc	2009-03-19 10:39:49 UTC (rev 6216)
@@ -2377,6 +2377,33 @@
 	}
 
 	target_voicescript_next(self);
+
+	if(sv_cheats)
+		if(self.BUTTON_DRAG)
+			if(!self.dragentity)
+				if(self.cursor_trace_ent)
+					if(!self.cursor_trace_ent.tag_index)
+					{
+						self.dragentity = self.cursor_trace_ent;
+						if(cvar("chase_active"))
+						{
+							if(gettagindex(self, "tag_weapon"))
+								attach_sameorigin(self.dragentity, self, "tag_weapon");
+							else
+								attach_sameorigin(self.dragentity, self, "");
+						}
+						else
+							attach_sameorigin(self.dragentity, self.weaponentity, "");
+						self.dragentity.effects |= EF_FLAME;
+					}
+	
+	if(!self.BUTTON_DRAG)
+		if(self.dragentity)
+		{
+			self.dragentity.effects &~= EF_FLAME;
+			detach_sameorigin(self.dragentity);
+			self.dragentity = world;
+		}
 }
 
 

Modified: trunk/data/qcsrc/server/defs.qh
===================================================================
--- trunk/data/qcsrc/server/defs.qh	2009-03-18 14:26:13 UTC (rev 6215)
+++ trunk/data/qcsrc/server/defs.qh	2009-03-19 10:39:49 UTC (rev 6216)
@@ -11,6 +11,7 @@
 #define BUTTON_INFO   button7
 #define BUTTON_CHAT   buttonchat
 #define BUTTON_USE    buttonuse
+#define BUTTON_DRAG   button8
 
 // Globals
 
@@ -551,3 +552,5 @@
 .float wasplayer;
 
 float servertime, serverprevtime, serverframetime;
+
+.entity dragentity;

Modified: trunk/data/qcsrc/server/g_triggers.qc
===================================================================
--- trunk/data/qcsrc/server/g_triggers.qc	2009-03-18 14:26:13 UTC (rev 6215)
+++ trunk/data/qcsrc/server/g_triggers.qc	2009-03-19 10:39:49 UTC (rev 6216)
@@ -1347,11 +1347,33 @@
 		return;
 	}
 
-	dst.movetype = MOVETYPE_FOLLOW;
-	dst.aiment = src;
-	dst.punchangle = src.angles;
-	dst.view_ofs = dst.origin - src.origin;
-	dst.v_angle = dst.angles - src.angles;
+	if(self.spawnflags & 1)
+	{
+		// attach
+		if(self.spawnflags & 2)
+		{
+			setattachment(dst, src, self.message);
+		}
+		else
+		{
+			attach_sameorigin(dst, src, self.message);
+		}
+	}
+	else
+	{
+		if(self.spawnflags & 2)
+		{
+			dst.movetype = MOVETYPE_FOLLOW;
+			dst.aiment = src;
+			// dst.punchangle = '0 0 0'; // keep unchanged
+			dst.view_ofs = dst.origin;
+			dst.v_angle = dst.angles;
+		}
+		else
+		{
+			follow_sameorigin(dst, src);
+		}
+	}
 
 	remove(self);
 }

Modified: trunk/data/qcsrc/server/miscfunctions.qc
===================================================================
--- trunk/data/qcsrc/server/miscfunctions.qc	2009-03-18 14:26:13 UTC (rev 6215)
+++ trunk/data/qcsrc/server/miscfunctions.qc	2009-03-19 10:39:49 UTC (rev 6216)
@@ -2047,3 +2047,69 @@
 	}
 	return vecs;
 }
+
+
+
+void attach_sameorigin(entity e, entity to, string tag)
+{
+	vector org, t_forward, t_left, t_up, e_forward, e_up;
+	vector org0, ang0;
+
+	ang0 = e.angles;
+	org0 = e.origin;
+
+	org = e.origin - gettaginfo(to, gettagindex(to, tag));
+	t_forward = v_forward;
+	t_left = v_right * -1;
+	t_up = v_up;
+
+	e.origin_x = org * t_forward;
+	e.origin_y = org * t_left;
+	e.origin_z = org * t_up;
+
+	// current forward and up directions
+	if(substring(e.model, 0, 1) == "*") // bmodels have their own rules
+		e.angles_x = -e.angles_x;
+	fixedmakevectors(e.angles);
+
+	// untransform forward, up!
+	e_forward_x = v_forward * t_forward;
+	e_forward_y = v_forward * t_left;
+	e_forward_z = v_forward * t_up;
+	e_up_x = v_up * t_forward;
+	e_up_y = v_up * t_left;
+	e_up_z = v_up * t_up;
+
+	e.angles = fixedvectoangles2(e_forward, e_up);
+	if(substring(e.model, 0, 1) == "*") // bmodels have their own rules
+		e.angles_x = -e.angles_x;
+
+	setattachment(e, to, tag);
+	setorigin(e, e.origin);
+}
+
+void detach_sameorigin(entity e)
+{
+	vector org;
+	org = gettaginfo(e, 0);
+	e.angles = fixedvectoangles2(v_forward, v_up);
+	if(substring(e.model, 0, 1) == "*") // bmodels have their own rules
+		e.angles_x = -e.angles_x;
+	e.origin = org;
+	setattachment(e, world, "");
+	setorigin(e, e.origin);
+}
+
+void follow_sameorigin(entity e, entity to)
+{
+	e.movetype = MOVETYPE_FOLLOW; // make the hole follow
+	e.aiment = to; // make the hole follow bmodel
+	e.punchangle = to.angles; // the original angles of bmodel
+	e.view_ofs = e.origin - to.origin; // relative origin
+	e.v_angle = e.angles - to.angles; // relative angles
+}
+
+void unfollow_sameorigin(entity e)
+{
+	e.movetype = MOVETYPE_NONE;
+}

Modified: trunk/data/scripts/entities.def
===================================================================
--- trunk/data/scripts/entities.def	2009-03-18 14:26:13 UTC (rev 6215)
+++ trunk/data/scripts/entities.def	2009-03-19 10:39:49 UTC (rev 6216)
@@ -1183,11 +1183,16 @@
 wait: wait so many seconds before triggering
 */
 
-/*QUAKED misc_follow (.5 .5 .5) (-8 -8 -8) (8 8 8)
+/*QUAKED misc_follow (.5 .5 .5) (-8 -8 -8) (8 8 8) ATTACH LOCAL
 Makes one entity follow another. Will not work with all entities.
 -------- KEYS --------
 target: points to the entity to move (e.g. something that won't move by itself)
 killtarget: points to the entity that is to be used as the source (e.g. a func_plat)
+message: tag name to attach to (if ATTACH is used)
+punchangle: angle modifier (if LOCAL is used, and ATTACH is not)
+-------- SPAWNFLAGS --------
+ATTACH: attachment will be used instead of MOVETYPE_FOLLOW (mostly useful for attaching stuff to ZYM models)
+LOCAL: do not untransform the coordinates (that is, the map specifies local coordinates, not global ones). Mostly useful with ATTACH.
 */
 
 /*QUAKED weapon_minstanex (1 0 .5) (-30 -30 0) (30 30 32) FLOATING



More information about the nexuiz-commits mailing list