From 1a09586a002e5eee047b5d008f86195a5c7c529f Mon Sep 17 00:00:00 2001 From: otta8634 Date: Thu, 5 Sep 2024 13:46:45 +0800 Subject: [PATCH] Allow showing strafehud W-turn indicators when sv_airaccel_qw == 0 Done with _wturn_unrestricted 1 Also added/fixed some comments --- _hud_common.cfg | 1 + qcsrc/client/hud/panel/strafehud.qc | 14 ++++++++------ qcsrc/client/hud/panel/strafehud.qh | 1 + 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/_hud_common.cfg b/_hud_common.cfg index a6c2f0bfa..554a332ca 100644 --- a/_hud_common.cfg +++ b/_hud_common.cfg @@ -206,6 +206,7 @@ seta hud_panel_strafehud_wturn_color "0 1 1" "color of the W-turn indicators" 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" diff --git a/qcsrc/client/hud/panel/strafehud.qc b/qcsrc/client/hud/panel/strafehud.qc index 75ca8fbc8..2cd8b9747 100644 --- a/qcsrc/client/hud/panel/strafehud.qc +++ b/qcsrc/client/hud/panel/strafehud.qc @@ -142,8 +142,8 @@ void HUD_StrafeHUD() 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; @@ -565,6 +565,7 @@ void HUD_StrafeHUD() // 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)) @@ -592,7 +593,7 @@ void HUD_StrafeHUD() { // 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 @@ -638,8 +639,9 @@ void HUD_StrafeHUD() * ... 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); @@ -708,7 +710,7 @@ void HUD_StrafeHUD() } // 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) diff --git a/qcsrc/client/hud/panel/strafehud.qh b/qcsrc/client/hud/panel/strafehud.qh index 8e8847132..e3a9116cc 100644 --- a/qcsrc/client/hud/panel/strafehud.qh +++ b/qcsrc/client/hud/panel/strafehud.qh @@ -44,6 +44,7 @@ vector autocvar_hud_panel_strafehud_wturn_color = '0 1 1'; float autocvar_hud_panel_strafehud_wturn_alpha = 1; float autocvar_hud_panel_strafehud_wturn_width = 0.003; bool autocvar_hud_panel_strafehud_wturn_proper = false; +bool autocvar_hud_panel_strafehud_wturn_unrestricted = false; bool autocvar_hud_panel_strafehud_direction = false; vector autocvar_hud_panel_strafehud_direction_color = '0 0.5 1'; float autocvar_hud_panel_strafehud_direction_alpha = 1; -- 2.39.2