r4756 - in trunk/data: . qcsrc/server

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Tue Oct 14 15:22:00 EDT 2008


Author: div0
Date: 2008-10-14 15:22:00 -0400 (Tue, 14 Oct 2008)
New Revision: 4756

Modified:
   trunk/data/defaultNexuiz.cfg
   trunk/data/qcsrc/server/cl_weaponsystem.qc
   trunk/data/qcsrc/server/g_subs.qc
Log:
antilag: add mode 3 (old 1) and 1 (current 1 without relying on prydon cursor)


Modified: trunk/data/defaultNexuiz.cfg
===================================================================
--- trunk/data/defaultNexuiz.cfg	2008-10-14 19:01:04 UTC (rev 4755)
+++ trunk/data/defaultNexuiz.cfg	2008-10-14 19:22:00 UTC (rev 4756)
@@ -268,7 +268,7 @@
 
 locs_enable 0
 pausable 0
-set g_antilag 2 // 1: client side hitscan, 2: history trace
+set g_antilag 2 // 1: re-aim to enemy that was aimed at in the past, 2: shoot completely in the past, 3: client-side hitscan
 set g_shootfromeye 0
 set g_shootfromcenter 0
 set g_weapon_stay 0

Modified: trunk/data/qcsrc/server/cl_weaponsystem.qc
===================================================================
--- trunk/data/qcsrc/server/cl_weaponsystem.qc	2008-10-14 19:01:04 UTC (rev 4755)
+++ trunk/data/qcsrc/server/cl_weaponsystem.qc	2008-10-14 19:22:00 UTC (rev 4756)
@@ -50,6 +50,7 @@
 	// calculate the shotdir from the chosen shotorg
 	w_shotdir = normalize(trueaimpoint - w_shotorg);
 
+#if 0
 	// explanation of g_antilag:
 	// if client reports it was aiming at a player, and the serverside trace
 	// says it would miss, change the aim point to the player's new origin,
@@ -118,6 +119,48 @@
 			}
 		}
 	}
+#else
+	if (antilag)
+	{
+		if (cvar("g_antilag") == 1) // switch to "ghost" if not hitting original
+		{
+			traceline(w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, MOVE_NORMAL, self);
+			if (!trace_ent.takedamage)
+			{
+				traceline_antilag_force (self, w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, MOVE_NORMAL, self, ANTILAG_LATENCY(self));
+				if (trace_ent.takedamage && trace_ent.classname == "player")
+				{
+					entity e;
+					e = trace_ent;
+					traceline(w_shotorg, e.origin, MOVE_NORMAL, self);
+					if(trace_ent == e)
+						w_shotdir = normalize(trace_ent.origin - w_shotorg);
+				}
+			}
+		}
+		else if(cvar("g_antilag") == 3) // client side hitscan
+		{
+			if (self.cursor_trace_ent)                 // client was aiming at someone
+			if (self.cursor_trace_ent != self)         // just to make sure
+			if (self.cursor_trace_ent.takedamage)      // and that person is killable
+			if (self.cursor_trace_ent.classname == "player") // and actually a player
+			{
+				// verify that the shot would miss without antilag
+				// (avoids an issue where guns would always shoot at their origin)
+				traceline(w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, MOVE_NORMAL, self);
+				if (!trace_ent.takedamage)
+				{
+					// verify that the shot would hit if altered
+					traceline(w_shotorg, self.cursor_trace_ent.origin, MOVE_NORMAL, self);
+					if (trace_ent == self.cursor_trace_ent)
+						w_shotdir = normalize(self.cursor_trace_ent.origin - w_shotorg);
+					else
+						print("antilag fail\n");
+				}
+			}
+		}
+	}
+#endif
 
 	self.solid = oldsolid; // restore solid type (generally SOLID_SLIDEBOX)
 

Modified: trunk/data/qcsrc/server/g_subs.qc
===================================================================
--- trunk/data/qcsrc/server/g_subs.qc	2008-10-14 19:01:04 UTC (rev 4755)
+++ trunk/data/qcsrc/server/g_subs.qc	2008-10-14 19:22:00 UTC (rev 4756)
@@ -215,7 +215,7 @@
 Additionally it moves players back into the past before the trace and restores them afterward.
 ==================
 */
-void traceline_antilag (entity source, vector v1, vector v2, float nomonst, entity forent, float lag)
+void traceline_antilag_force (entity source, vector v1, vector v2, float nomonst, entity forent, float lag)
 {
 	local entity player;
 	local float oldsolid;
@@ -225,9 +225,6 @@
 		lag = 0;
 	if (clienttype(forent) != CLIENTTYPE_REAL)
 		lag = 0; // only antilag for clients
-	if (lag)
-	if (cvar("g_antilag") != 2)
-		lag = 0;
 
 	// change shooter to SOLID_BBOX so the shot can hit corpses
 	oldsolid = source.solid;
@@ -261,6 +258,12 @@
 	// restore shooter solid type
 	source.solid = oldsolid;
 }
+void traceline_antilag (entity source, vector v1, vector v2, float nomonst, entity forent, float lag)
+{
+	if (cvar("g_antilag") != 2)
+		lag = 0;
+	traceline_antilag_force(source, v1, v2, nomonst, forent, lag);
+}
 
 /*
 ==================




More information about the nexuiz-commits mailing list