From 7d82fba1a25540fc6c94bed789ee424f7c4108f1 Mon Sep 17 00:00:00 2001 From: Juhu <5894800-Juhu_@users.noreply.gitlab.com> Date: Mon, 16 Sep 2024 20:44:59 +0200 Subject: [PATCH] strafehud: move minimum hud angle calculation into hud angle function --- qcsrc/client/hud/panel/strafehud.qc | 8 +------- qcsrc/client/hud/panel/strafehud/util.qc | 12 +++++++++++- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/qcsrc/client/hud/panel/strafehud.qc b/qcsrc/client/hud/panel/strafehud.qc index 854197399..ec4893bce 100644 --- a/qcsrc/client/hud/panel/strafehud.qc +++ b/qcsrc/client/hud/panel/strafehud.qc @@ -164,13 +164,7 @@ void HUD_StrafeHUD() float wishangle = StrafeHUD_DetermineWishAngle(movement, keys, islocal); bool strafekeys = fabs(wishangle) > 45; - // determine minimum required angle to display full strafe range - float range_minangle = fabs(wishangle) % 90; // maximum range is 90 degree - if(range_minangle > 45) range_minangle = 45 - fabs(wishangle) % 45; // minimum angle range is 45 - 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 hudangle = StrafeHUD_DetermineHudAngle(range_minangle); + float hudangle = StrafeHUD_DetermineHudAngle(wishangle); // detect air strafe turning static bool turn = false; diff --git a/qcsrc/client/hud/panel/strafehud/util.qc b/qcsrc/client/hud/panel/strafehud/util.qc index 02adbdbc2..74704685e 100644 --- a/qcsrc/client/hud/panel/strafehud/util.qc +++ b/qcsrc/client/hud/panel/strafehud/util.qc @@ -203,7 +203,7 @@ float StrafeHUD_DetermineWishAngle(vector movement, int keys, bool islocal) return wishangle; } -float StrafeHUD_DetermineHudAngle(float range_minangle) +float StrafeHUD_DetermineHudAngle(float wishangle) { float hudangle; if(isnan(autocvar_hud_panel_strafehud_range)) @@ -213,9 +213,19 @@ float StrafeHUD_DetermineHudAngle(float range_minangle) else if(autocvar_hud_panel_strafehud_range == 0) { if(autocvar__hud_configure) + { hudangle = 90; + } else + { + // determine minimum required angle to display full strafe range + float range_minangle = fabs(wishangle) % 90; // maximum range is 90 degree + if(range_minangle > 45) range_minangle = 45 - fabs(wishangle) % 45; // minimum angle range is 45 + 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 + hudangle = range_minangle; // use minimum angle required if dynamically setting hud angle + } } else if(autocvar_hud_panel_strafehud_range < 0) { -- 2.39.2