[nexuiz-commits] r8590 - trunk/data/qcsrc/server
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Sat Jan 30 03:08:08 EST 2010
Author: div0
Date: 2010-01-30 03:07:59 -0500 (Sat, 30 Jan 2010)
New Revision: 8590
Modified:
trunk/data/qcsrc/server/cl_physics.qc
Log:
alternate physics mode
Modified: trunk/data/qcsrc/server/cl_physics.qc
===================================================================
--- trunk/data/qcsrc/server/cl_physics.qc 2010-01-29 16:52:27 UTC (rev 8589)
+++ trunk/data/qcsrc/server/cl_physics.qc 2010-01-30 08:07:59 UTC (rev 8590)
@@ -407,6 +407,12 @@
self.velocity_z = zspeed;
}
+var float speedclamp_mode = 0;
+// example config for alternate speed clamping:
+// sv_airaccel_qw 0.8
+// sv_airaccel_sideways_friction 0
+// prvm_globalset server speedclamp_mode 1
+// (or 2)
void PM_Accelerate(vector wishdir, float wishspeed, float wishspeed0, float accel, float accelqw, float sidefric)
{
float vel_straight;
@@ -424,35 +430,56 @@
vel_z = self.velocity_z;
vel_perpend = self.velocity - vel_straight * wishdir - vel_z * '0 0 1';
-#if 0
- if(cvar("sv_gameplayfix_alternatespeedclamp"))
+ if(wishspeed0)
{
- // 1. move as normal, but fake a forward move to get the maximum ALLOWED speed
- float vel_xy;
- vel_xy = sqrt(vel_straight * vel_straight + vel_perpend * vel_perpend);
- addspeed = wishspeed - vel_xy;
- if(addspeed > 0)
- vel_xy = vel_xy + min(addspeed, accel * frametime * wishspeed0) * accelqw;
- if(wishspeed > 0)
- vel_xy = vel_xy + accel * frametime * wishspeed0 * (1 - accelqw);
- // 2. accelerate actually, using our acceleration factor and the max allowed forward speed we derived
- // we may add at most a vector length of min(wishspeed, accel * frametime * wishspeed0)
- // however, the absolute value must not exceed vel_xy
- addspeed = accel * frametime * wishspeed0;
- addspeed = bound(0, sqrt(vel_xy * vel_xy - vel_perpend * vel_perpend) - vel_straight, addspeed);
- // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- // this is how much we can add without exceeding vel_xy
- vel_straight += addspeed;
+ if(speedclamp_mode)
+ {
+ // 1. move as normal, but fake a forward move to get the maximum ALLOWED speed
+ float vel_xy;
+ vel_xy = sqrt(vel_straight * vel_straight + vel_perpend * vel_perpend);
+ addspeed = wishspeed - vel_xy;
+ if(addspeed > 0)
+ vel_xy = vel_xy + min(addspeed, accel * frametime * wishspeed0) * accelqw;
+ if(wishspeed > 0)
+ vel_xy = vel_xy + accel * frametime * wishspeed0 * (1 - accelqw);
+ if(speedclamp_mode == 2)
+ {
+ // havoc style:
+ // accelerate normally, then clamp the total velocity to the just calculated maxspeed
+ addspeed = wishspeed - vel_straight;
+ if(addspeed > 0)
+ vel_straight = vel_straight + min(addspeed, accel * frametime * wishspeed0) * accelqw;
+ if(wishspeed > 0)
+ vel_straight = vel_straight + accel * frametime * wishspeed0 * (1 - accelqw);
+ vel_xy = vel_xy / sqrt(vel_straight * vel_straight + vel_perpend * vel_perpend);
+ if(vel_xy < 1)
+ {
+ vel_straight = vel_straight * vel_xy;
+ vel_perpend = vel_perpend * vel_xy;
+ }
+ }
+ else
+ {
+ // div0 style:
+ // 2. accelerate actually, using our acceleration factor and the max allowed forward speed we derived
+ // we may add at most a vector length of min(wishspeed, accel * frametime * wishspeed0)
+ // however, the absolute value must not exceed vel_xy
+ addspeed = accel * frametime * wishspeed0;
+ addspeed = bound(0, sqrt(vel_xy * vel_xy - vel_perpend * vel_perpend) - vel_straight, addspeed);
+ // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ // this is how much we can add without exceeding vel_xy
+ vel_straight += addspeed;
+ }
+ }
+ else
+ {
+ addspeed = wishspeed - vel_straight;
+ if(addspeed > 0)
+ vel_straight = vel_straight + min(addspeed, accel * frametime * wishspeed0) * accelqw;
+ if(wishspeed > 0)
+ vel_straight = vel_straight + accel * frametime * wishspeed0 * (1 - accelqw);
+ }
}
- else
-#endif
- {
- addspeed = wishspeed - vel_straight;
- if(addspeed > 0)
- vel_straight = vel_straight + min(addspeed, accel * frametime * wishspeed0) * accelqw;
- if(wishspeed > 0)
- vel_straight = vel_straight + accel * frametime * wishspeed0 * (1 - accelqw);
- }
if(sidefric < 0 && (vel_perpend*vel_perpend))
{
More information about the nexuiz-commits
mailing list