r5064 - in trunk/data: qcsrc/server scripts

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Thu Nov 20 09:18:31 EST 2008


Author: div0
Date: 2008-11-20 09:18:30 -0500 (Thu, 20 Nov 2008)
New Revision: 5064

Modified:
   trunk/data/qcsrc/server/cl_client.qc
   trunk/data/qcsrc/server/cl_physics.qc
   trunk/data/qcsrc/server/g_subs.qc
   trunk/data/qcsrc/server/sv_main.qc
   trunk/data/qcsrc/server/t_items.qc
   trunk/data/scripts/entities.def
Log:
hidden cvar: car-like physics mode; misc_gamemodel: extra spawnflags; properly support scale on SOLID_BSP misc_gamemodels by adjusting mins/maxs


Modified: trunk/data/qcsrc/server/cl_client.qc
===================================================================
--- trunk/data/qcsrc/server/cl_client.qc	2008-11-19 19:22:46 UTC (rev 5063)
+++ trunk/data/qcsrc/server/cl_client.qc	2008-11-20 14:18:30 UTC (rev 5064)
@@ -634,7 +634,10 @@
 
 		self.classname = "player";
 		self.iscreature = TRUE;
-		self.movetype = MOVETYPE_WALK;
+		if(cvar("g_bigrigs"))
+			self.movetype = MOVETYPE_PUSH;
+		else
+			self.movetype = MOVETYPE_WALK;
 		self.solid = SOLID_SLIDEBOX;
 		self.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP;
 		if(independent_players)

Modified: trunk/data/qcsrc/server/cl_physics.qc
===================================================================
--- trunk/data/qcsrc/server/cl_physics.qc	2008-11-19 19:22:46 UTC (rev 5063)
+++ trunk/data/qcsrc/server/cl_physics.qc	2008-11-20 14:18:30 UTC (rev 5064)
@@ -249,7 +249,7 @@
 	if (self.deadflag)
 		return;
 
-	if (!self.fixangle)
+	if (!self.fixangle && self.movetype != MOVETYPE_PUSH)
 	{
 		self.angles_x = 0;
 		self.angles_y = self.v_angle_y;
@@ -331,6 +331,79 @@
 				self.velocity = self.velocity + wishdir * min(f, sv_accelerate*maxspd_mod * frametime * wishspeed);
 		}
 	}
+	else if (self.movetype == MOVETYPE_PUSH)
+	{
+		// using this move type for "big rigs"
+		// the engine does not push the entity!
+
+		float accel, steer, myspeed, steerfactor, accelfactor, upspeed, friction;
+		vector neworigin, up, angles_save;
+
+		accel = self.movement_x / sv_maxspeed;
+		steer = self.movement_y / sv_maxspeed;
+
+		angles_save = self.angles;
+		self.angles_x = 0;
+		self.angles_z = 0;
+		makevectors(self.angles); // new forward direction!
+		myspeed = self.velocity * v_forward;
+		upspeed = self.velocity * v_up;
+		if(myspeed <= 0 && accel < 0)
+			steerfactor = -5000; // LOL
+		else
+			steerfactor = -400 * 400 / (400 + myspeed);
+		accelfactor = 2000 * 400 / (400 + max(myspeed, -myspeed));
+		friction = 5 * 100 / (100 + max(myspeed, -myspeed));
+
+		self.angles_y += steer * frametime * steerfactor; // apply steering
+		makevectors(self.angles); // new forward direction!
+
+		myspeed = myspeed * (1 - frametime * friction);
+		myspeed += accel * accelfactor * frametime;
+		if(myspeed < 0)
+			myspeed = 0;
+
+		self.velocity = v_forward * myspeed;
+		upspeed -= frametime * sv_gravity;
+
+		tracebox(self.origin, self.mins, self.maxs, self.origin + '0 0 1024', MOVE_NORMAL, self);
+		up = trace_endpos - self.origin;
+
+		// can we move?
+		neworigin = trace_endpos + self.velocity * frametime;
+		tracebox(trace_endpos, self.mins, self.maxs, neworigin, MOVE_NORMAL, self);
+
+		// align to surface
+		tracebox(trace_endpos, self.mins, self.maxs, neworigin - up + '0 0 1' * upspeed * frametime, MOVE_NORMAL, self);
+
+		if(trace_fraction >= 0.5)
+			self.origin = trace_endpos;
+		else
+			trace_fraction = 1;
+
+		// now set angles_x so that the car points parallel to the surface
+		if(trace_fraction < 1)
+		{
+			self.angles = vectoangles(normalize(
+				'1 0 0' * v_forward_x * trace_plane_normal_z
+				+
+				'0 1 0' * v_forward_y * trace_plane_normal_z
+				+
+				'0 0 1' * -(v_forward_x * trace_plane_normal_x + v_forward_y * trace_plane_normal_y)
+			));
+			self.flags |= FL_ONGROUND;
+		}
+		else
+		{
+			self.angles_x = angles_save_x;
+			self.angles_z = angles_save_z;
+			self.velocity += '0 0 1' * upspeed;
+			self.flags (-) FL_ONGROUND;
+		}
+
+		// relink
+		setorigin(self, self.origin);
+	}
 	else if (self.waterlevel >= 2)
 	{
 		// swimming

Modified: trunk/data/qcsrc/server/g_subs.qc
===================================================================
--- trunk/data/qcsrc/server/g_subs.qc	2008-11-19 19:22:46 UTC (rev 5063)
+++ trunk/data/qcsrc/server/g_subs.qc	2008-11-20 14:18:30 UTC (rev 5064)
@@ -372,6 +372,7 @@
 .float loddistance1;
 .float loddistance2;
 
+vector NearestPointOnBox(entity box, vector org);
 float LOD_customize()
 {
 	float d;
@@ -389,7 +390,7 @@
 	}
 
 	// TODO csqc network this so it only gets sent once
-	d = vlen(self.origin - other.origin);
+	d = vlen(NearestPointOnBox(self, other.origin) - other.origin);
 	if(d < self.loddistance1)
 		self.modelindex = self.lodmodelindex0;
 	else if(!self.lodmodelindex2 || d < self.loddistance2)
@@ -468,7 +469,10 @@
 		InitializeEntity(self, LODmodel_attach, INITPRIO_FINDTARGET);
  	}
 	setorigin(self, self.origin);
-	setsize(self, self.mins, self.maxs);
+	if(self.scale)
+		setsize(self, self.mins * self.scale, self.maxs * self.scale);
+	else
+		setsize(self, self.mins, self.maxs);
 }
 
 /*

Modified: trunk/data/qcsrc/server/sv_main.qc
===================================================================
--- trunk/data/qcsrc/server/sv_main.qc	2008-11-19 19:22:46 UTC (rev 5063)
+++ trunk/data/qcsrc/server/sv_main.qc	2008-11-20 14:18:30 UTC (rev 5064)
@@ -143,6 +143,7 @@
 	UncustomizeEntitiesRun();
 	InitializeEntitiesRun();
 
+	sv_gravity = cvar("sv_gravity");
 	sv_maxairspeed = cvar("sv_maxairspeed");
 	sv_maxspeed = cvar ("sv_maxspeed");
 	sv_friction = cvar ("sv_friction");

Modified: trunk/data/qcsrc/server/t_items.qc
===================================================================
--- trunk/data/qcsrc/server/t_items.qc	2008-11-19 19:22:46 UTC (rev 5063)
+++ trunk/data/qcsrc/server/t_items.qc	2008-11-20 14:18:30 UTC (rev 5064)
@@ -948,6 +948,25 @@
 	self.use = func_wall_use;
 }
 
+void gamemodel_drop()
+{
+	if(self.spawnflags & 3 == 1) // ALIGN_ORIGIN
+	{
+		traceline(self.origin, self.origin - '0 0 1024', MOVE_NOMONSTERS, self);
+		setorigin(self, trace_endpos);
+	}
+	else if(self.spawnflags & 3 == 2) // ALIGN_BOTTOM
+	{
+		tracebox(self.origin, self.mins, self.maxs, self.origin - '0 0 1024', MOVE_NOMONSTERS, self);
+		setorigin(self, trace_endpos);
+	}
+	else if(self.spawnflags & 3 == 3) // ALIGN_ORIGIN | ALIGN_BOTTOM
+	{
+		traceline(self.origin, self.origin - '0 0 1024', MOVE_NOMONSTERS, self);
+		setorigin(self, trace_endpos - '0 0 1' * self.mins_z);
+	}
+}
+
 .float modelscale;
 void spawnfunc_misc_gamemodel (void)
 {
@@ -955,6 +974,8 @@
 		self.scale = self.modelscale;
 	SetBrushEntityModel();
 	self.use = func_wall_use;
+
+	InitializeEntity(self, gamemodel_drop, INITPRIO_DROPTOFLOOR);
 }
 
 float target_item_func_set(float a, float b)

Modified: trunk/data/scripts/entities.def
===================================================================
--- trunk/data/scripts/entities.def	2008-11-19 19:22:46 UTC (rev 5063)
+++ trunk/data/scripts/entities.def	2008-11-20 14:18:30 UTC (rev 5064)
@@ -552,7 +552,7 @@
 EXTRUDE_TERRAIN: always extrude downwards (for terrain)
 */
 
-/*QUAKED misc_gamemodel (0 .5 .8) (-8 -8 -8) (8 8 8)
+/*QUAKED misc_gamemodel (0 .5 .8) (-8 -8 -8) (8 8 8) ALIGN_ORIGIN ALIGN_BOTTOM
 A way to load models from a map by the engine (e.g. self-animated zym models).
 Is non-solid by default.
 The keys below actually apply to most engine-loaded model entities as they are engine features; however, they are described here as they aren't overridden by game code in misc_models. Its q3map2 keys below will work on any brush entity!
@@ -579,6 +579,9 @@
 _castshadows: Allows per-entity control over shadow casting. Defaults to 0 on entities, 1 on world. 0 = no shadow casting. 1 = cast shadows on world. > 1 = cast shadows on entities with _rs (or _receiveshadows) with the corresponding value, AND world. Negative values imply same, but DO NOT cast shadows on world.
 targetname: if targeted by a misc_model, its brushes get inserted into this
 _celshader: Sets the cel shader used for this geometry. Note: omit the "textures/" prefix.
+-------- SPAWNFLAGS --------
+ALIGN_ORIGN: align the origin to the surface below the model
+ALIGN_BOTTOM: align the bottom of the model to the surface below it
 */
 
 /*QUAKED func_illusionary (0 .5 .8) ? 




More information about the nexuiz-commits mailing list