r4166 - in trunk/data/qcsrc: client common server

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sun Aug 24 08:12:21 EDT 2008


Author: div0
Date: 2008-08-24 08:12:20 -0400 (Sun, 24 Aug 2008)
New Revision: 4166

Added:
   trunk/data/qcsrc/client/hook.qc
Modified:
   trunk/data/qcsrc/client/Main.qc
   trunk/data/qcsrc/client/View.qc
   trunk/data/qcsrc/client/progs.src
   trunk/data/qcsrc/common/util.qc
   trunk/data/qcsrc/common/util.qh
   trunk/data/qcsrc/server/g_hook.qc
Log:
jitter-less grappling hook (and currently using a placeholder beam)


Modified: trunk/data/qcsrc/client/Main.qc
===================================================================
--- trunk/data/qcsrc/client/Main.qc	2008-08-24 08:47:06 UTC (rev 4165)
+++ trunk/data/qcsrc/client/Main.qc	2008-08-24 12:12:20 UTC (rev 4166)
@@ -754,6 +754,10 @@
 			Net_ReadSpectating();
 			bHandled = true;
 			break;
+		case 13: // TE_BEAM
+			Net_GrapplingHook();
+			bHandled = true;
+			break;
 		default:
 			// No special logic for this temporary entity; return 0 so the engine can handle it
 			bHandled = false;

Modified: trunk/data/qcsrc/client/View.qc
===================================================================
--- trunk/data/qcsrc/client/View.qc	2008-08-24 08:47:06 UTC (rev 4165)
+++ trunk/data/qcsrc/client/View.qc	2008-08-24 12:12:20 UTC (rev 4166)
@@ -52,6 +52,7 @@
 	R_AddEntities(MASK_NORMAL | MASK_ENGINE | MASK_ENGINEVIEWMODELS);
 
 	// Render the Scene
+	Draw_GrapplingHook();
 	R_RenderScene();
 
 	// Draw the mouse cursor

Added: trunk/data/qcsrc/client/hook.qc
===================================================================
--- trunk/data/qcsrc/client/hook.qc	                        (rev 0)
+++ trunk/data/qcsrc/client/hook.qc	2008-08-24 12:12:20 UTC (rev 4166)
@@ -0,0 +1,72 @@
+vector HookStart[255];
+vector HookEnd[255];
+float HookKillTime[255];
+void Net_GrapplingHook()
+{
+	float i;
+	vector start, end;
+
+	i = ReadShort();
+	end_x = ReadCoord();
+	end_y = ReadCoord();
+	end_z = ReadCoord();
+	start_x = ReadCoord();
+	start_y = ReadCoord();
+	start_z = ReadCoord();
+
+	if(i <= 0 || i >= 256) // not owned by a client
+		return;
+	--i;
+
+	HookKillTime[i] = time + 0.1;
+	HookStart[i] = start;
+	HookEnd[i] = end;
+}
+
+void Draw_GrapplingHookLine(vector from, vector to, float thickness, vector org, vector view_forward)
+{
+	// I want to draw a quad...
+	// from and to are MIDPOINTS.
+	
+	vector axis, thickdir, A, B, C, D;
+	float length_tex;
+
+	axis = normalize(to - from);
+	length_tex = vlen(to - from) / thickness;
+
+	// direction is perpendicular to the view normal, and perpendicular to the axis
+	thickdir = normalize(cross(axis, org - from));
+
+	A = from - thickdir * (thickness / 2);
+	B = from + thickdir * (thickness / 2);
+	C = to + thickdir * (thickness / 2);
+	D = to - thickdir * (thickness / 2);
+
+	R_BeginPolygon("particles/nexbeam", DRAWFLAG_ADDITIVE);
+		R_PolygonVertex(A, '0 0 0', '.5 1 0', 1);
+		R_PolygonVertex(B, '1 0 0', '.5 1 0', 1);
+		R_PolygonVertex(C, '1 0 0' + length_tex * '0 1 0', '.5 1 0', 1);
+		R_PolygonVertex(D, '0 0 0' + length_tex * '0 1 0', '.5 1 0', 1);
+	R_EndPolygon();
+}
+
+void Draw_GrapplingHook()
+{
+	float i;
+	vector a, b, o;
+
+	o = pmove_org + '0 0 1' * getstati(STAT_VIEWHEIGHT);
+	makevectors(input_angles);
+
+	for(i = 0; i < 255; ++i)
+	{
+		if(time >= HookKillTime[i])
+			continue;
+		if(i == player_localentnum - 1)
+			a = o + v_forward * 8 - v_right * 8 + v_up * -12;
+		else
+			a = HookStart[i];
+		b = HookEnd[i];
+		Draw_GrapplingHookLine(a, b, 8, o, v_forward);
+	}
+}

Modified: trunk/data/qcsrc/client/progs.src
===================================================================
--- trunk/data/qcsrc/client/progs.src	2008-08-24 08:47:06 UTC (rev 4165)
+++ trunk/data/qcsrc/client/progs.src	2008-08-24 12:12:20 UTC (rev 4166)
@@ -21,6 +21,8 @@
 sbar.qc
 mapvoting.qc
 
+hook.qc
+
 Main.qc
 View.qc
 

Modified: trunk/data/qcsrc/common/util.qc
===================================================================
--- trunk/data/qcsrc/common/util.qc	2008-08-24 08:47:06 UTC (rev 4165)
+++ trunk/data/qcsrc/common/util.qc	2008-08-24 12:12:20 UTC (rev 4166)
@@ -468,3 +468,11 @@
 	
 	return valstr;
 }
+
+vector cross(vector a, vector b)
+{
+	return
+		'1 0 0' * (a_y * b_z - a_z * b_y)
+	+	'0 1 0' * (a_z * b_x - a_x * b_z)
+	+	'0 0 1' * (a_x * b_y - a_y * b_x);
+}

Modified: trunk/data/qcsrc/common/util.qh
===================================================================
--- trunk/data/qcsrc/common/util.qh	2008-08-24 08:47:06 UTC (rev 4165)
+++ trunk/data/qcsrc/common/util.qh	2008-08-24 12:12:20 UTC (rev 4166)
@@ -59,3 +59,5 @@
 string GametypeNameFromType(float g);
 string mmsss(float t);
 string ScoreString(float vflags, float value);
+
+vector cross(vector a, vector b);

Modified: trunk/data/qcsrc/server/g_hook.qc
===================================================================
--- trunk/data/qcsrc/server/g_hook.qc	2008-08-24 08:47:06 UTC (rev 4165)
+++ trunk/data/qcsrc/server/g_hook.qc	2008-08-24 12:12:20 UTC (rev 4166)
@@ -181,7 +181,7 @@
 	}
 
 	makevectors(self.angles_x * '-1 0 0' + self.angles_y * '0 1 0');
-	te_beam(self, self.origin + v_forward * (-9), org);
+	te_beam(self.owner, self.origin + v_forward * (-9), org);
 }
 
 void GrapplingHookTouch (void)




More information about the nexuiz-commits mailing list