From 81e1cd5336b7309eb728e5c72ac981f954090f41 Mon Sep 17 00:00:00 2001 From: otta8634 Date: Sat, 5 Oct 2024 03:10:01 +0800 Subject: [PATCH] W-turn indicator fixes Fixed conditions for displaying the indicators. Fixed the check for if aiming at the angle would put you in the accel zone, while side strafing. Made it blue rather than light-blue, so it's not confused with the angle indicator, which is also light-blue by default when in an accel zone. --- _hud_common.cfg | 2 +- qcsrc/client/hud/panel/strafehud.qc | 15 ++++++++++----- qcsrc/client/hud/panel/strafehud.qh | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/_hud_common.cfg b/_hud_common.cfg index 35b53e928..a26769440 100644 --- a/_hud_common.cfg +++ b/_hud_common.cfg @@ -201,7 +201,7 @@ seta hud_panel_strafehud_switch_minspeed "-1" "minimum speed in qu/s at which an seta hud_panel_strafehud_switch_color "1 1 0" "color of the strafe angle indicators for changing strafe direction" seta hud_panel_strafehud_switch_alpha "0.5" "opacity of the strafe angle indicators for changing strafe direction" seta hud_panel_strafehud_wturn "1" "enable the W-turn indicators showing the angle to rotate your velocity as fast as possible, 1 = only if W-turning, 2 = also while strafing normally, 3 = also while side strafing" -seta hud_panel_strafehud_wturn_color "0 1 1" "color of the W-turn indicators" +seta hud_panel_strafehud_wturn_color "0 0 1" "color of the W-turn indicators" seta hud_panel_strafehud_wturn_alpha "0.5" "opacity of the W-turn indicators" 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)" diff --git a/qcsrc/client/hud/panel/strafehud.qc b/qcsrc/client/hud/panel/strafehud.qc index 6159f022b..45a8fb319 100644 --- a/qcsrc/client/hud/panel/strafehud.qc +++ b/qcsrc/client/hud/panel/strafehud.qc @@ -402,7 +402,8 @@ void HUD_StrafeHUD() float absolute_overturnangle = overturnangle; float aircontrol = PHYS_AIRCONTROL(strafeplayer); - bool aircontrol_backwards = PHYS_AIRCONTROL_BACKWARDS(strafeplayer) == 1; + bool aircontrol_backwards = PHYS_AIRCONTROL_BACKWARDS(strafeplayer); + bool is_aircontrol_keys = keys_fwd == STRAFEHUD_KEYS_FORWARD || (aircontrol_backwards && keys_fwd == STRAFEHUD_KEYS_BACKWARD); bool is_aircontrol_direction = fwd || aircontrol_backwards; bool airaccel_qw = PHYS_AIRACCEL_QW(strafeplayer) == 1; @@ -421,7 +422,7 @@ void HUD_StrafeHUD() * ... so the angle will only be shown with hud_panel_strafehud_wturn_proper 0 * this doesn't have support for sv_aircontrol_sideways == 1 */ - bool wturning = (wishangle == 0) && !onground && is_aircontrol_direction; + bool wturning = (wishangle == 0) && !onground && is_aircontrol_keys; bool wturn_valid = false; float wturn_bestangle = 0; if(autocvar_hud_panel_strafehud_wturn && moving && @@ -449,9 +450,10 @@ void HUD_StrafeHUD() // draw the switch indicators as if strafing normally (W+A style), while W-turning or side strafing float n_bestangle = 0; + float absolute_n_prebestangle = 0; // also needed for W-turn angles bool draw_normal = ((autocvar_hud_panel_strafehud_switch >= STRAFEHUD_SWITCH_NORMAL && wturning) || (autocvar_hud_panel_strafehud_switch == STRAFEHUD_SWITCH_SIDESTRAFE && turn)); - if(draw_normal) + if(draw_normal || wturn_valid) { // recalculate bestangle as if strafing normally float n_maxspeed = PHYS_MAXAIRSPEED(strafeplayer) * maxspeed_mod; @@ -461,6 +463,9 @@ void HUD_StrafeHUD() n_bestangle = speed > n_bestspeed ? acos(n_bestspeed / speed) * RAD2DEG - 45 : -45; + absolute_n_prebestangle = speed > n_movespeed + ? acos(n_movespeed / speed) * RAD2DEG + : 0; } float hudangle = StrafeHUD_DetermineHudAngle(absolute_wishangle, absolute_overturnangle, strafity); @@ -661,9 +666,9 @@ void HUD_StrafeHUD() } // only draw wturn indicators if conditions were met - if(wturn_valid && is_aircontrol_direction && !onground && + if(wturn_valid && !onground && is_aircontrol_direction && autocvar_hud_panel_strafehud_wturn_alpha > 0 && - absolute_wturn_bestangle < absolute_prebestangle && + absolute_wturn_bestangle < absolute_n_prebestangle && ((autocvar_hud_panel_strafehud_wturn && wturning) || (autocvar_hud_panel_strafehud_wturn == STRAFEHUD_WTURN_NORMAL && !turn) || (autocvar_hud_panel_strafehud_wturn == STRAFEHUD_WTURN_SIDESTRAFE))) diff --git a/qcsrc/client/hud/panel/strafehud.qh b/qcsrc/client/hud/panel/strafehud.qh index eefb6b66f..bfc25ad79 100644 --- a/qcsrc/client/hud/panel/strafehud.qh +++ b/qcsrc/client/hud/panel/strafehud.qh @@ -43,7 +43,7 @@ float autocvar_hud_panel_strafehud_switch_minspeed = -1; vector autocvar_hud_panel_strafehud_switch_color = '1 1 0'; float autocvar_hud_panel_strafehud_switch_alpha = 0.5; int autocvar_hud_panel_strafehud_wturn = 1; -vector autocvar_hud_panel_strafehud_wturn_color = '0 1 1'; +vector autocvar_hud_panel_strafehud_wturn_color = '0 0 1'; float autocvar_hud_panel_strafehud_wturn_alpha = 0.5; bool autocvar_hud_panel_strafehud_wturn_proper = false; bool autocvar_hud_panel_strafehud_wturn_unrestricted = false; -- 2.39.2