[nexuiz-commits] r7436 - trunk/data/qcsrc/server

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Fri Aug 14 06:27:25 EDT 2009


Author: div0
Date: 2009-08-14 06:27:25 -0400 (Fri, 14 Aug 2009)
New Revision: 7436

Modified:
   trunk/data/qcsrc/server/cl_physics.qc
Log:
race/cts: clip movement vector to the "keyboard axes" (i.e. forward, right, or diagonal) as countermeasure to strafebot.

Please test whether it has any negative impact to keyboard users.

It currently makes race/cts unplayable for joystick users... we need a similar feature in the engine to fix that (to make cl_movement match again).


Modified: trunk/data/qcsrc/server/cl_physics.qc
===================================================================
--- trunk/data/qcsrc/server/cl_physics.qc	2009-08-14 05:20:31 UTC (rev 7435)
+++ trunk/data/qcsrc/server/cl_physics.qc	2009-08-14 10:27:25 UTC (rev 7436)
@@ -499,6 +499,49 @@
 	float buttons_prev;
 	float not_allowed_to_move;
 	string c;
+	
+	if(g_race || g_cts)
+	{
+		// if record times matter
+		// ensure nothing EVIL is being done (i.e. strafebot)
+		// this hinders joystick users though
+		// but it still gives SOME analog control
+		// TODO implement this for engine cl_movement code too (basically, clipping to the four axes)
+		wishvel_x = fabs(self.movement_x);
+		wishvel_y = fabs(self.movement_y);
+		wishvel_z = 0;
+		wishspeed = vlen(wishvel);
+		if(wishvel_x >= 2 * wishvel_y)
+		{
+			// pure X motion
+			if(self.movement_x > 0)
+				self.movement_x = wishspeed;
+			else
+				self.movement_x = -wishspeed;
+			self.movement_y = 0;
+		}
+		else if(wishvel_y >= 2 * wishvel_x)
+		{
+			// pure Y motion
+			self.movement_x = 0;
+			if(self.movement_y > 0)
+				self.movement_y = wishspeed;
+			else
+				self.movement_y = -wishspeed;
+		}
+		else
+		{
+			// diagonal
+			if(self.movement_x > 0)
+				self.movement_x = 0.70710678118654752440 * wishspeed;
+			else
+				self.movement_x = -0.70710678118654752440 * wishspeed;
+			if(self.movement_y > 0)
+				self.movement_y = 0.70710678118654752440 * wishspeed;
+			else
+				self.movement_y = -0.70710678118654752440 * wishspeed;
+		}
+	}
 
 	buttons = self.BUTTON_ATCK + 2 * self.BUTTON_JUMP + 4 * self.BUTTON_ATCK2 + 8 * self.BUTTON_ZOOM + 16 * self.BUTTON_CROUCH + 32 * self.BUTTON_HOOK + 64 * self.BUTTON_USE + 128 * (self.movement_x < 0) + 256 * (self.movement_x > 0) + 512 * (self.movement_y < 0) + 1024 * (self.movement_y > 0);
 



More information about the nexuiz-commits mailing list