[nexuiz-commits] r6296 - in trunk/data: . qcsrc/server

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Thu Mar 26 04:32:22 EDT 2009


Author: div0
Date: 2009-03-26 04:32:08 -0400 (Thu, 26 Mar 2009)
New Revision: 6296

Modified:
   trunk/data/defaultNexuiz.cfg
   trunk/data/qcsrc/server/cl_physics.qc
Log:
new and better jetpack code and settings


Modified: trunk/data/defaultNexuiz.cfg
===================================================================
--- trunk/data/defaultNexuiz.cfg	2009-03-26 07:10:46 UTC (rev 6295)
+++ trunk/data/defaultNexuiz.cfg	2009-03-26 08:32:08 UTC (rev 6296)
@@ -1416,9 +1416,10 @@
 seta cl_showpressedkeys	0	"Show which movement keys someone is pressing: 1 for spectating, 2 for always"
 set cl_showpressedkeys_position "1 0.8"	"1 0 would be upper right corner, 0.5 0.5 the center"
 
-set g_jetpack 0 "Jetpack mutator (experimental)"
-set g_jetpack_accel_side 400 "max jetpack sideways acceleration" 
-set g_jetpack_accel_up 1150 "max jetpack upwards acceleration" 
-set g_jetpack_accel_upadjust 1.5 "view angle adjustment" 
-set g_jetpack_accel_maxspeed 2000 "max speed for jetpack (also, when jetpack becomes inoperative because of this, it takes no cells)" 
-set g_jetpack_accel_ammo 2 "cells per second for jetpack" 
+set g_jetpack 0 "Jetpack mutator (experimental)"2
+set g_jetpack_antigravity 0.8 "factor of gravity compensation of the jetpack"
+set g_jetpack_acceleration_side 1000 "acceleration of the jetpack in xy direction"
+set g_jetpack_acceleration_up 500 "acceleration of the jetpack in z direction (note: you have to factor in gravity here, if antigravity is not 1)"
+set g_jetpack_maxspeed_side 1500 "max speed of the jetpack in xy direction"
+set g_jetpack_maxspeed_up 400 "max speed of the jetpack in z direction"
+set g_jetpack_ammo 2 "cells per second for jetpack" 

Modified: trunk/data/qcsrc/server/cl_physics.qc
===================================================================
--- trunk/data/qcsrc/server/cl_physics.qc	2009-03-26 07:10:46 UTC (rev 6295)
+++ trunk/data/qcsrc/server/cl_physics.qc	2009-03-26 08:32:08 UTC (rev 6296)
@@ -529,49 +529,6 @@
 
 		if (self.waterlevel == WATERLEVEL_SWIMMING)
 			CheckWaterJump ();
-
-		if (g_jetpack && self.BUTTON_HOOK)
-		{
-			//makevectors(self.v_angle_y * '0 1 0');
-			makevectors(self.v_angle);
-			wishvel = v_forward * self.movement_x + v_right * self.movement_y;
-			// add remaining speed as Z component
-			maxairspd = sv_maxairspeed*max(1, maxspd_mod);
-			wishvel_x *= 1 / maxairspd;
-			wishvel_y *= 1 / maxairspd;
-			wishvel_z = 0;
-			wishvel_z += sqrt(max(0, 1 - wishvel * wishvel));
-			wishvel_z += cvar("g_jetpack_accel_upadjust");
-			wishvel = normalize(wishvel);
-			wishvel_x *= cvar("g_jetpack_accel_side");
-			wishvel_y *= cvar("g_jetpack_accel_side");
-			wishvel_z *= cvar("g_jetpack_accel_up");
-
-			wishdir = normalize(wishvel);
-			wishspeed = vlen(wishvel);
-
-			f = (1 - (self.velocity * wishdir) / cvar("g_jetpack_maxspeed"));
-			if(cvar("g_jetpack_ammo"))
-			{
-				if(self.ammo_cells < 0.01)
-					f = 0;
-				else
-					f = min(f, self.ammo_cells / (cvar("g_jetpack_ammo") * frametime));
-			}
-			if (f > 0)
-			{
-				self.velocity = self.velocity + wishvel * f * frametime;
-				float c;
-				c = self.ammo_cells;
-				self.ammo_cells -= frametime * cvar("g_jetpack_ammo") * f;
-				if(floor(c / 5) != floor(self.ammo_cells / 5))
-					sprint(self, "jetpack: less than ", ftos(floor(c)), " cells left\n");
-				else if(self.ammo_cells < 0.01 && cvar("g_jetpack_ammo"))
-					sprint(self, "jetpack: out of fuel\n");
-				self.flags &~= FL_ONGROUND;
-				self.modelflags |= MF_ROCKET;
-			}
-		}
 	}
 
 	if (self.flags & FL_WATERJUMP )
@@ -679,6 +636,61 @@
 				self.velocity = self.velocity + wishdir * min(f, sv_accelerate*maxspd_mod * frametime * wishspeed);
 		}
 	}
+	else if (g_jetpack && self.BUTTON_HOOK && (!cvar("g_jetpack_ammo") || self.ammo_cells >= 0.01))
+	{
+		//makevectors(self.v_angle_y * '0 1 0');
+		makevectors(self.v_angle);
+		wishvel = v_forward * self.movement_x + v_right * self.movement_y;
+		// add remaining speed as Z component
+		maxairspd = sv_maxairspeed*max(1, maxspd_mod);
+		// fix speedhacks :P
+		wishvel = normalize(wishvel) * min(vlen(wishvel) / maxairspd, 1);
+		// add the unused velocity as up component
+		wishvel_z += sqrt(max(0, 1 - wishvel * wishvel));
+		// it is now normalized, so...
+		wishvel_x *= cvar("g_jetpack_acceleration_side");
+		wishvel_y *= cvar("g_jetpack_acceleration_side");
+		wishvel_z *= cvar("g_jetpack_acceleration_up");
+		wishvel_z += cvar("g_jetpack_antigravity") * sv_gravity;
+
+		float fxy, fz;
+		fxy = bound(0, 1 - (self.velocity * normalize(wishvel_x * '1 0 0' + wishvel_y * '0 1 0')) / cvar("g_jetpack_maxspeed_side"), 1);
+		if(wishvel_z - sv_gravity > 0)
+			fz = bound(0, 1 - self.velocity_z / cvar("g_jetpack_maxspeed_up"), 1);
+		else
+			fz = bound(0, 1 + self.velocity_z / cvar("g_jetpack_maxspeed_up"), 1);
+
+		float fvel;
+		fvel = vlen(wishvel);
+		wishvel_x *= fxy;
+		wishvel_y *= fxy;
+		wishvel_z = (wishvel_z - sv_gravity) * fz + sv_gravity;
+		fvel = vlen(wishvel) / fvel;
+
+		if(cvar("g_jetpack_ammo"))
+		{
+			if(self.ammo_cells < 0.01)
+				f = 0;
+			else
+				f = min(1, self.ammo_cells / (cvar("g_jetpack_ammo") * frametime * fvel));
+		}
+		else
+			f = 1;
+
+		if (f > 0 && wishvel != '0 0 0')
+		{
+			self.velocity = self.velocity + wishvel * f * frametime;
+			float c;
+			c = self.ammo_cells;
+			self.ammo_cells -= cvar("g_jetpack_ammo") * frametime * fvel * f;
+			if(floor(c / 5) != floor(self.ammo_cells / 5))
+				sprint(self, strcat("jetpack: less than ", ftos(floor(c)), " cells left\n"));
+			else if(self.ammo_cells < 0.01 && cvar("g_jetpack_ammo"))
+				sprint(self, "jetpack: out of fuel\n");
+			self.flags &~= FL_ONGROUND;
+			self.modelflags |= MF_ROCKET;
+		}
+	}
 	else if (self.flags & FL_ONGROUND)
 	{
 		// walking



More information about the nexuiz-commits mailing list