float sv_airstopaccelerate;
float sv_airstrafeaccelerate;
float sv_maxairstrafespeed;
+float sv_airstrafeaccel_qw;
float sv_aircontrol;
float sv_aircontrol_power;
float sv_warsowbunny_airforwardaccel;
{
if(mv_x == 0 && mv_y == 0)
return 0; // avoid division by zero
- angle = RAD2DEG * atan2(mv_y, mv_x);
+ angle -= RAD2DEG * atan2(mv_y, mv_x);
angle = remainder(angle, 360) / 45;
if(angle > 1)
return 0;
return 1 - fabs(angle);
}
+float GeomLerp(float a, float lerp, float b)
+{
+ if(a == 0)
+ {
+ if(lerp < 1)
+ return 0;
+ else
+ return b;
+ }
+ if(b == 0)
+ {
+ if(lerp > 0)
+ return 0;
+ else
+ return a;
+ }
+ return a * pow(fabs(b / a), lerp);
+}
+
void CPM_PM_Aircontrol(vector wishdir, float wishspeed)
{
float zspeed, xyspeed, dot, k;
float accelerating;
float wishspeed2;
float airaccelqw;
+ float strafity;
airaccelqw = sv_airaccel_qw;
accelerating = (self.velocity * wishdir > 0);
// this doesn't play well with analog input, but can't r
// fixed like the AirControl can. So, don't set the maxa
// cvars when you want to support analog input.
- if(self.movement_x == 0 && self.movement_y != 0)
- {
- if(sv_maxairstrafespeed)
- {
- wishspeed = min(wishspeed, sv_maxairstrafespeed*maxspd_mod);
- if(sv_maxairstrafespeed < sv_maxairspeed)
- airaccelqw = 1;
- }
- if(sv_airstrafeaccelerate)
- {
- airaccel = sv_airstrafeaccelerate*maxspd_mod;
- if(sv_airstrafeaccelerate > sv_airaccelerate)
- airaccelqw = 1;
- }
- }
+ // note that for straight forward jumping:
+ // step = accel * frametime * wishspeed0;
+ // accel = bound(0, wishspeed - vel_xy_current, step) * accelqw + step * (1 - accelqw);
+ // -->
+ // dv/dt = accel * maxspeed (when slow)
+ // dv/dt = accel * maxspeed * (1 - accelqw) (when fast)
+ // log dv/dt = logaccel + logmaxspeed (when slow)
+ // log dv/dt = logaccel + logmaxspeed + log(1 - accelqw) (when fast)
+ strafity = IsMoveInDirection(self.movement, -90) + IsMoveInDirection(self.movement, +90); // if one is nonzero, other is always zero
+ if(sv_maxairstrafespeed)
+ wishspeed = min(wishspeed, GeomLerp(sv_maxairspeed*maxspd_mod, strafity, sv_maxairstrafespeed*maxspd_mod));
+ if(sv_airstrafeaccelerate)
+ airaccel = GeomLerp(airaccel, strafity, sv_airstrafeaccelerate*maxspd_mod);
+ if(sv_airstrafeaccel_qw)
+ airaccelqw = sign((strafity > 0.5) ? sv_airstrafeaccel_qw : sv_airaccel_qw) * (1-GeomLerp(1-fabs(airaccelqw), strafity, 1-fabs(sv_airstrafeaccel_qw)));
// !CPM
if(sv_warsowbunny_turnaccel && accelerating && self.movement_y == 0 && self.movement_x != 0)