From 9d64040c9051a16f1c12a9c645317d183c3bdaf8 Mon Sep 17 00:00:00 2001 From: otta8634 Date: Sun, 1 Sep 2024 15:03:03 +0800 Subject: [PATCH] Add CPMA turning-specific strafehud options Allows changing _range only when CPMA turning (A/D keys only) Allows showing the _bestangle markers only for CPMA turning --- _hud_common.cfg | 3 +- qcsrc/client/hud/panel/strafehud.qc | 49 +++++++++++++++-------------- qcsrc/client/hud/panel/strafehud.qh | 3 +- 3 files changed, 29 insertions(+), 26 deletions(-) diff --git a/_hud_common.cfg b/_hud_common.cfg index 614b8cde0..fb2f22780 100644 --- a/_hud_common.cfg +++ b/_hud_common.cfg @@ -168,6 +168,7 @@ seta hud_panel_scoreboard_itemstats_showdelay_minpos 0.75 "delay displaying the seta _hud_panel_strafehud_demo "0" "strafehud changes angle during configure" seta hud_panel_strafehud_mode "0" "strafehud mode which controls whether the strafehud is centered at \"0\" = view angle, \"1\" = velocity angle" seta hud_panel_strafehud_range "90" "the angle range up to 360 degrees displayed on the strafehud, \"0\" = dynamic (chooses the minimum range required to still see the whole area needed for accelerating)" +seta hud_panel_strafehud_range_cpma "90" "the angle range up to 360 degrees displayed on the strafehud when CPMA turning, \"0\" = dynamic (chooses the minimum range required to still see the whole area needed for accelerating)" seta hud_panel_strafehud_style "2" "\"0\" = no styling, \"1\" = progress bar style for the strafe bar, \"2\" = gradient for the strafe bar" seta hud_panel_strafehud_unit_show "1" "show units" seta hud_panel_strafehud_uncapped "0" "set to \"1\" to remove some safety restrictions, useful to set thinner indicator lines down to 1px or for trying out higher values for some performance degrading operations (warning: elements may turn invisible if too thin, other configurations may crash your game or look horribly ugly)" @@ -191,7 +192,7 @@ seta hud_panel_strafehud_angle_accel_color "0 1 1" "color of the indicator showi seta hud_panel_strafehud_angle_overturn_color "1 0 1" "color of the indicator showing the player's current angle if it is within the overturn zone" seta hud_panel_strafehud_angle_arrow "1" "set the angle indicator's arrow style: 0 = none, 1 = top, 2 = bottom, 3 = both" seta hud_panel_strafehud_angle_arrow_size "0.5" "size of the arrow (relative to the panel height)" -seta hud_panel_strafehud_bestangle "1" "set to \"1\" to enable a ghost angle indicator showing the best angle to gain maximum acceleration" +seta hud_panel_strafehud_bestangle "1" "set to \"1\" to enable a ghost angle indicator showing the best angle to gain maximum acceleration, 2 = only when CPMA turning" seta hud_panel_strafehud_bestangle_color "1 1 1" "color of the indicator showing the best angle to gain maximum acceleration" seta hud_panel_strafehud_bestangle_alpha "0.5" "opacity of the indicator showing the best angle to gain maximum acceleration" seta hud_panel_strafehud_switch "1" "set to \"1\" to enable the switch indicator showing the angle to move to when switching sides" diff --git a/qcsrc/client/hud/panel/strafehud.qc b/qcsrc/client/hud/panel/strafehud.qc index 3c428dde4..a0147b2e7 100644 --- a/qcsrc/client/hud/panel/strafehud.qc +++ b/qcsrc/client/hud/panel/strafehud.qc @@ -350,25 +350,8 @@ void HUD_StrafeHUD() wishangle = 0; // wraps at 180° } - strafekeys = fabs(wishangle) > 45; - - // determine minimum required angle to display full strafe range - 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 - - if(autocvar_hud_panel_strafehud_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(autocvar_hud_panel_strafehud_range), 360); // limit HUD range to 360 degrees, higher values don't make sense - } + float real_wishangle = fabs(wishangle); // unmodified by CPMA turning + strafekeys = real_wishangle > 45; // detect air strafe turning if((!strafekeys && vlen(vec2(movement)) > 0) || onground || autocvar__hud_configure) @@ -409,6 +392,23 @@ void HUD_StrafeHUD() } } + // determine minimum required angle to display full strafe range + range_minangle = real_wishangle % 90; // maximum range is 90 degree + if(range_minangle > 45) range_minangle = 45 - real_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 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 + maxaccel *= dt * movespeed; bestspeed = max(movespeed - maxaccel, 0); // target speed to gain maximum acceleration @@ -984,7 +984,8 @@ void HUD_StrafeHUD() float angleheight_offset = currentangle_size.y; float ghost_offset = 0; - if(autocvar_hud_panel_strafehud_bestangle && direction != STRAFEHUD_DIRECTION_NONE) + bool draw_bestangle = autocvar_hud_panel_strafehud_bestangle && (autocvar_hud_panel_strafehud_bestangle == 1 || turn) && direction != STRAFEHUD_DIRECTION_NONE; + if(draw_bestangle) ghost_offset = bound(0, (odd_angles ? odd_bestangle_offset : bestangle_offset), panel_size.x); switch(autocvar_hud_panel_strafehud_angle_style) @@ -992,7 +993,7 @@ void HUD_StrafeHUD() case STRAFEHUD_INDICATOR_SOLID: if(currentangle_size.x > 0 && currentangle_size.y > 0) { - if(autocvar_hud_panel_strafehud_bestangle && direction != STRAFEHUD_DIRECTION_NONE) + if(draw_bestangle) drawfill( panel_pos - eY * ((currentangle_size.y - panel_size.y) / 2) + eX * (ghost_offset - currentangle_size.x / 2), currentangle_size, autocvar_hud_panel_strafehud_bestangle_color, @@ -1014,7 +1015,7 @@ void HUD_StrafeHUD() { if(i + line_size.y * 2 >= currentangle_size.y) line_size.y = currentangle_size.y - i; - if(autocvar_hud_panel_strafehud_bestangle && direction != STRAFEHUD_DIRECTION_NONE) + if(draw_bestangle) drawfill( panel_pos - eY * ((currentangle_size.y - panel_size.y) / 2 - i) + eX * (ghost_offset - line_size.x / 2), line_size, autocvar_hud_panel_strafehud_bestangle_color, @@ -1049,7 +1050,7 @@ void HUD_StrafeHUD() { if(autocvar_hud_panel_strafehud_angle_arrow == 1 || autocvar_hud_panel_strafehud_angle_arrow >= 3) { - if(autocvar_hud_panel_strafehud_bestangle && direction != STRAFEHUD_DIRECTION_NONE) + if(draw_bestangle) StrafeHUD_drawStrafeArrow( panel_pos + eY * ((panel_size.y - angleheight_offset) / 2) + eX * ghost_offset, arrow_size, autocvar_hud_panel_strafehud_bestangle_color, @@ -1063,7 +1064,7 @@ void HUD_StrafeHUD() } if(autocvar_hud_panel_strafehud_angle_arrow >= 2) { - if(autocvar_hud_panel_strafehud_bestangle && direction != STRAFEHUD_DIRECTION_NONE) + if(draw_bestangle) StrafeHUD_drawStrafeArrow( panel_pos + eY * ((panel_size.y - angleheight_offset) / 2 + angleheight_offset) + eX * ghost_offset, arrow_size, autocvar_hud_panel_strafehud_bestangle_color, diff --git a/qcsrc/client/hud/panel/strafehud.qh b/qcsrc/client/hud/panel/strafehud.qh index dded346ec..ef205d778 100644 --- a/qcsrc/client/hud/panel/strafehud.qh +++ b/qcsrc/client/hud/panel/strafehud.qh @@ -6,6 +6,7 @@ bool autocvar__hud_panel_strafehud_demo = false; bool autocvar_hud_panel_strafehud_dynamichud = true; int autocvar_hud_panel_strafehud_mode = 0; float autocvar_hud_panel_strafehud_range = 90; +float autocvar_hud_panel_strafehud_range_cpma = 90; int autocvar_hud_panel_strafehud_style = 2; bool autocvar_hud_panel_strafehud_unit_show = true; bool autocvar_hud_panel_strafehud_uncapped = false; @@ -29,7 +30,7 @@ vector autocvar_hud_panel_strafehud_angle_accel_color = '0 1 1'; vector autocvar_hud_panel_strafehud_angle_overturn_color = '1 0 1'; int autocvar_hud_panel_strafehud_angle_arrow = 1; float autocvar_hud_panel_strafehud_angle_arrow_size = 0.5; -bool autocvar_hud_panel_strafehud_bestangle = true; +int autocvar_hud_panel_strafehud_bestangle = 1; vector autocvar_hud_panel_strafehud_bestangle_color = '1 1 1'; float autocvar_hud_panel_strafehud_bestangle_alpha = 0.5; bool autocvar_hud_panel_strafehud_switch = true; -- 2.39.2