seta hud_panel_strafehud_wturn_alpha "1" "opacity of the W-turn indicators"
seta hud_panel_strafehud_wturn_width "0.003" "width of the W-turn indicators (relative to the strafe bar width)"
seta hud_panel_strafehud_wturn_proper "0" "use the proper formula to calculate W-turn indicators (warning: loses accuracy at high speeds)"
+seta hud_panel_strafehud_wturn_unrestricted "0" "set to \"1\" to enable the W-turn indicators even when W-turning gives acceleration (warning: not completely accurate)"
seta hud_panel_strafehud_direction "0" "set to \"1\" to enable the direction caps to see in which direction you are currently strafing"
seta hud_panel_strafehud_direction_color "0 0.5 1" "color of the direction caps which indicate the direction the player is currently strafing towards"
seta hud_panel_strafehud_direction_alpha "1" "opacity of the direction caps which indicate the direction the player is currently strafing towards"
float maxaccel = !autocvar__hud_configure ? maxaccel_phys : 1;
float airstopaccel = PHYS_AIRSTOPACCELERATE(strafeplayer);
float aircontrol = PHYS_AIRCONTROL(strafeplayer);
- bool aircontrol_backwards = PHYS_AIRCONTROL_BACKWARDS(strafeplayer);
- bool wturn_no_accel = PHYS_AIRACCEL_QW(strafeplayer) == 1 && aircontrol != 0; // if true, W-turning exists and doesn't provide accel
+ bool aircontrol_backwards = PHYS_AIRCONTROL_BACKWARDS(strafeplayer) == 1;
+ bool airaccel_qw = PHYS_AIRACCEL_QW(strafeplayer) == 1;
// 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;
// case 1: normal. case 2: low speed, best angle is forwards
}
{
+ // needed later if autocvar_hud_panel_strafehud_wturn != 0, so calculate even if autocvar_hud_panel_strafehud_bar_preaccel == 0
float prebestangle_sqrt = movespeed * movespeed + strafespeed * strafespeed - speed * speed;
// delta_min = acos(sqrt(s^2 - v_f^2 + v^2) / v_f), or just acos(s / v) in air
prebestangle = (prebestangle_sqrt > 0 && strafespeed > sqrt(prebestangle_sqrt))
{
// these conditions occur when you land at high speed (above max onground speed), such that every wishangle will result in a speed loss due to friction
// the latter condition should only ever happen when onground, but check for sanity
- // if these conditions are met, prebestangle will be less than bestangle, all 3 cases deal with that
+ // if these conditions are met, prebestangle will be greater than than bestangle. all 3 cases deal with that
if(autocvar_hud_panel_strafehud_onground_mode == 0)
{
// make overturn fill the whole strafe bar
* ... 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 || (aircontrol_backwards && keys_fwd == STRAFEHUD_KEYS_BACKWARD));
- if(autocvar_hud_panel_strafehud_wturn && wturn_no_accel && !immobile)
+ bool wturning = wishangle == 0 && (keys_fwd == STRAFEHUD_KEYS_FORWARD || (aircontrol_backwards && keys_fwd == STRAFEHUD_KEYS_BACKWARD));
+ bool wturn_check = autocvar_hud_panel_strafehud_wturn && !immobile && aircontrol && (autocvar_hud_panel_strafehud_wturn_unrestricted == 1 || airaccel_qw);
+ if(wturn_check)
{
float wturn_g = 32 * aircontrol * dt;
float wturn_V = 1 - (wturn_g * wturn_g) / (speed * speed);
}
// best angle to aim at when W-turning to maximally rotate velocity vector
- if(autocvar_hud_panel_strafehud_wturn && wturn_no_accel && !immobile)
+ if(wturn_check)
{
bool wturn_show = autocvar_hud_panel_strafehud_wturn == 3 ? true
: autocvar_hud_panel_strafehud_wturn == 2 ? ((fwd || aircontrol_backwards) && !turn)