From 6bcc8eb41315ae945f803f547986667b710d20f7 Mon Sep 17 00:00:00 2001 From: Juhu <5894800-Juhu_@users.noreply.gitlab.com> Date: Sat, 27 Mar 2021 08:58:26 +0100 Subject: [PATCH] strafehud: add a ghost angle indicator showing the best angle to gain maximum acceleration --- _hud_common.cfg | 3 +++ qcsrc/client/hud/panel/strafehud.qc | 42 ++++++++++++++++++++--------- qcsrc/client/hud/panel/strafehud.qh | 3 +++ 3 files changed, 35 insertions(+), 13 deletions(-) diff --git a/_hud_common.cfg b/_hud_common.cfg index 0297d71e4..ca6e7fb02 100644 --- a/_hud_common.cfg +++ b/_hud_common.cfg @@ -158,6 +158,9 @@ 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 "0" "set to \"1\" to enable a ghost angle indicator showing the best angle to gain maximum acceleration" +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_minspeed "-1" "minimum speed in qu/s at which switch indicator(s) which are used to aid changing strafe direction will be shown (set to -1 for dynamic minspeed)" seta hud_panel_strafehud_switch_color "1 1 0" "color of the switch indicator" seta hud_panel_strafehud_switch_alpha "1" "opacity of the switch indicator" diff --git a/qcsrc/client/hud/panel/strafehud.qc b/qcsrc/client/hud/panel/strafehud.qc index f88f54a48..64ff1c7a5 100644 --- a/qcsrc/client/hud/panel/strafehud.qc +++ b/qcsrc/client/hud/panel/strafehud.qc @@ -570,18 +570,6 @@ void HUD_StrafeHUD() neutral_width = 360/hudangle * panel_size.x - accelzone_width*2 - preaccelzone_width*2 - overturn_width; neutral_offset = direction < 0 ? preaccelzone_left_offset + preaccelzone_width : -neutral_width; - // remove switch indicator width from offset - if(direction < 0) - { - bestangle_offset -= bestangle_width; - switch_odd_bestangle_offset -= bestangle_width; - } - else - { - switch_bestangle_offset -= bestangle_width; - odd_bestangle_offset -= bestangle_width; - } - // shift hud if operating in view angle centered mode if(mode == 0) { @@ -639,6 +627,23 @@ void HUD_StrafeHUD() // draw the switch indicator(s) float offset = !odd_angles ? bestangle_offset : odd_bestangle_offset; float switch_offset = !odd_angles ? switch_bestangle_offset : switch_odd_bestangle_offset; + + // remove switch indicator width from offset + if(direction < 0) + { + if(!odd_angles) + offset -= bestangle_width; + else + switch_offset -= bestangle_width; + } + else + { + if(!odd_angles) + switch_offset -= bestangle_width; + else + offset -= bestangle_width; + } + HUD_Panel_DrawStrafeHUD(switch_offset, bestangle_width, autocvar_hud_panel_strafehud_switch_color, autocvar_hud_panel_strafehud_switch_alpha * panel_fg_alpha, 0, 0); if(direction == 0) HUD_Panel_DrawStrafeHUD(offset, bestangle_width, autocvar_hud_panel_strafehud_switch_color, autocvar_hud_panel_strafehud_switch_alpha * panel_fg_alpha, 0, 0); } @@ -762,7 +767,11 @@ void HUD_StrafeHUD() switch(autocvar_hud_panel_strafehud_angle_style) { case 1: - if(currentangle_size.x > 0 && currentangle_size.y > 0) drawfill(panel_pos - eY * ((currentangle_size.y - panel_size.y) / 2) + eX * (currentangle_offset - currentangle_size.x/2), currentangle_size, currentangle_color, autocvar_hud_panel_strafehud_angle_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); + if(currentangle_size.x > 0 && currentangle_size.y > 0) + { + if(autocvar_hud_panel_strafehud_bestangle && direction != 0) drawfill(panel_pos - eY * ((currentangle_size.y - panel_size.y) / 2) + eX * ((!odd_angles ? bestangle_offset : odd_bestangle_offset) - currentangle_size.x/2), currentangle_size, autocvar_hud_panel_strafehud_bestangle_color, autocvar_hud_panel_strafehud_bestangle_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); + drawfill(panel_pos - eY * ((currentangle_size.y - panel_size.y) / 2) + eX * (currentangle_offset - currentangle_size.x/2), currentangle_size, currentangle_color, autocvar_hud_panel_strafehud_angle_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); + } break; case 2: if(currentangle_size.x > 0 && currentangle_size.y > 0) @@ -772,6 +781,7 @@ void HUD_StrafeHUD() for(float i = 0; i < currentangle_size.y; i += line_size.y*2) { if(i + line_size.y*2 >= currentangle_size.y) line_size.y = currentangle_size.y - i; + if(autocvar_hud_panel_strafehud_bestangle && direction != 0) drawfill(panel_pos - eY * ((currentangle_size.y - panel_size.y) / 2 - i) + eX * ((!odd_angles ? bestangle_offset : odd_bestangle_offset) - line_size.x/2), line_size, autocvar_hud_panel_strafehud_bestangle_color, autocvar_hud_panel_strafehud_bestangle_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); drawfill(panel_pos - eY * ((currentangle_size.y - panel_size.y) / 2 - i) + eX * (currentangle_offset - line_size.x/2), line_size, currentangle_color, autocvar_hud_panel_strafehud_angle_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); } } @@ -785,9 +795,15 @@ void HUD_StrafeHUD() if(arrow_size > 0) { if(autocvar_hud_panel_strafehud_angle_arrow == 1 || autocvar_hud_panel_strafehud_angle_arrow >= 3) + { + if(autocvar_hud_panel_strafehud_bestangle && direction != 0) StrafeHUD_drawStrafeArrow(panel_pos + eY * ((panel_size.y - currentangle_size.y) / 2) + eX * (!odd_angles ? bestangle_offset : odd_bestangle_offset), arrow_size, autocvar_hud_panel_strafehud_bestangle_color, autocvar_hud_panel_strafehud_bestangle_alpha * panel_fg_alpha, true); StrafeHUD_drawStrafeArrow(panel_pos + eY * ((panel_size.y - currentangle_size.y) / 2) + eX * currentangle_offset, arrow_size, currentangle_color, autocvar_hud_panel_strafehud_angle_alpha * panel_fg_alpha, true); + } if(autocvar_hud_panel_strafehud_angle_arrow >= 2) + { + if(autocvar_hud_panel_strafehud_bestangle && direction != 0) StrafeHUD_drawStrafeArrow(panel_pos + eY * ((panel_size.y - currentangle_size.y) / 2 + currentangle_size.y) + eX * (!odd_angles ? bestangle_offset : odd_bestangle_offset), arrow_size, autocvar_hud_panel_strafehud_bestangle_color, autocvar_hud_panel_strafehud_bestangle_alpha * panel_fg_alpha, false); StrafeHUD_drawStrafeArrow(panel_pos + eY * ((panel_size.y - currentangle_size.y) / 2 + currentangle_size.y) + eX * currentangle_offset, arrow_size, currentangle_color, autocvar_hud_panel_strafehud_angle_alpha * panel_fg_alpha, false); + } } } } diff --git a/qcsrc/client/hud/panel/strafehud.qh b/qcsrc/client/hud/panel/strafehud.qh index 33330e834..fb438ec41 100644 --- a/qcsrc/client/hud/panel/strafehud.qh +++ b/qcsrc/client/hud/panel/strafehud.qh @@ -28,6 +28,9 @@ 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 = false; +vector autocvar_hud_panel_strafehud_bestangle_color = '1 1 1'; +float autocvar_hud_panel_strafehud_bestangle_alpha = 0.5; 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 = 1; -- 2.39.2