float maxaccel = !autocvar__hud_configure ? maxaccel_phys : 1;
float airstopaccel = PHYS_AIRSTOPACCELERATE(strafeplayer);
float aircontrol = PHYS_AIRCONTROL(strafeplayer);
- bool wturn_no_accel = PHYS_AIRACCEL_QW(strafeplayer) == 1 && aircontrol == 150; // conditions such that W-turning doesn't provide accel
+ bool wturn_no_accel = PHYS_AIRACCEL_QW(strafeplayer) == 1 && aircontrol != 0; // if true, W-turning exists and doesn't provide accel
// change the range from 0° - 360° to -180° - 180° to match how view_angle represents angles
float vel_angle = vectoangles(strafeplayer.velocity).y - (vectoangles(strafeplayer.velocity).y > 180 ? 360 : 0);
float view_angle = PHYS_INPUT_ANGLES(strafeplayer).y;
int keys_fwd;
float wishangle;
int direction;
+ float strafity = 0;
// HUD
int mode;
}
// calculate the maximum air strafe speed and acceleration
- float strafity = 1 - (90 - fabs(wishangle)) / 45;
+ strafity = 1 - (90 - fabs(wishangle)) / 45;
if(PHYS_MAXAIRSTRAFESPEED(strafeplayer) != 0)
maxspeed = min(maxspeed, GeomLerp(PHYS_MAXAIRSPEED(strafeplayer), strafity, PHYS_MAXAIRSTRAFESPEED(strafeplayer)));
range_minangle = 90 - range_minangle; // calculate value which is never >90 or <45
range_minangle *= 2; // multiply to accommodate for both sides of the hud
- float used_range = turn ? autocvar_hud_panel_strafehud_range_cpma : autocvar_hud_panel_strafehud_range;
- if(used_range == 0)
- {
- if(autocvar__hud_configure)
- hudangle = 90;
- else
- hudangle = range_minangle; // use minimum angle required if dynamically setting hud angle
- }
- else
- hudangle = bound(0, fabs(used_range), 360); // limit HUD range to 360 degrees, higher values don't make sense
+ float range_normal = autocvar_hud_panel_strafehud_range;
+ float range_cpma = autocvar_hud_panel_strafehud_range_cpma;
+ if(range_normal == 0)
+ range_normal = autocvar__hud_configure ? 90 : range_minangle; // use minimum angle required if dynamically setting hud angle
+ if(range_cpma == 0)
+ range_cpma = autocvar__hud_configure ? 90 : range_minangle; // ...
+
+ float range_used = GeomLerp(range_normal, strafity, range_cpma);
+ hudangle = bound(0, fabs(range_used), 360); // limit HUD range to 360 degrees, higher values don't make sense
maxaccel *= dt * movespeed;
bestspeed = max(movespeed - maxaccel, 0); // target speed to gain maximum acceleration
* ... but the proper angle can be drawn too if the player wants (autocvar_hud_panel_strafehud_wturn_proper)
* for now this is only enabled if sv_airaccel_qw == 1 && sv_aircontrol == 150, since otherwise W-turning gives acceleration
*/
+ bool wturning = wishangle == 0 && keys_fwd == STRAFEHUD_KEYS_FORWARD;
if(autocvar_hud_panel_strafehud_wturn && wturn_no_accel && !immobile)
{
float wturn_g = 32 * aircontrol * dt;
float wturn_V = 1 - (wturn_g * wturn_g) / (speed * speed);
- if(autocvar_hud_panel_strafehud_wturn_proper && wturn_g > 1 && wturn_V < 1 && wturn_V > -1)
+ if(autocvar_hud_panel_strafehud_wturn_proper == 1 && wturn_g > 1 && wturn_V < 1 && wturn_V > -1)
wturn_bestangle = acos(-speed / wturn_g * (cos((acos(wturn_V) + M_PI * 2) / 3) * 2 + 1)) * RAD2DEG;
else
wturn_bestangle = acos(sqrt(2 / 3)) * RAD2DEG;
real_wturn_bestangle = wturn_bestangle;
- if(fwd && turn) // if not W-turning, need to add 90°/45° so it aligns to where it would be after changing to W-only
- wturn_bestangle += 90;
- else if(fwd && wishangle != 0)
- wturn_bestangle += 45;
- wturn_bestangle -= wishangle;
}
if(direction == STRAFEHUD_DIRECTION_LEFT) // the angle becomes negative in case we strafe left
{
bool wturn_show = autocvar_hud_panel_strafehud_wturn == 3 ? true
: autocvar_hud_panel_strafehud_wturn == 2 ? (fwd && !turn)
- : autocvar_hud_panel_strafehud_wturn == 1 ? (wishangle == 0 && !turn)
- : false;
- // ensure angle isn't in the accelzone
- bool wturn_neutralzone = autocvar_hud_panel_strafehud_wturn_proper
- ? real_wturn_bestangle < real_prebestangle
- : speed * speed * 2 > movespeed * movespeed * 3; // acos(sqrt(2 / 3)) < acos(movepeed / speed)
- if(wturn_show && wturn_neutralzone && !onground)
+ : autocvar_hud_panel_strafehud_wturn == 0 ? false
+ : wturning;
+ if(wturn_show && real_wturn_bestangle < real_prebestangle && !onground)
{
wturn_left_bestangle_offset = wturn_bestangle / hudangle * panel_size.x + panel_size.x / 2;
wturn_right_bestangle_offset = -wturn_bestangle / hudangle * panel_size.x + panel_size.x / 2;