float bestangle;
float prebestangle;
float odd_bestangle;
- float bestangle_offset;
- float switch_bestangle_offset;
+ float bestangle_offset = 0;
+ float switch_bestangle_offset = 0;
bool odd_angles = false;
float odd_bestangle_offset = 0;
float switch_odd_bestangle_offset = 0;
- float switch_bestangle_width;
+ float switch_bestangle_width = 0;
float wturn_bestangle = 0;
float wturn_left_bestangle_offset = 0;
float wturn_right_bestangle_offset = 0;
float overturn_offset;
float overturn_width;
float slickdetector_height;
- vector direction_size_vertical;
- vector direction_size_horizontal;
+ vector direction_size_vertical = '0 0 0';
+ vector direction_size_horizontal = '0 0 0';
float range_minangle;
float text_offset_top = 0;
float text_offset_bottom = 0;
* ... but this very quickly loses accuracy -- should be a strictly decreasing function, yet it increases at only speed=722 with 125 fps
* also note this is only valid when such angle is not in the accelzone, formula taking acceleration into account is unfathomably complicated
* afaik there's no simplified version of this formula that doesn't involve complex numbers, other than one valid for only speed<27.1 roughly
- * furthermore, this function quite rapidly approaches its asymptote of ~35.26°, e.g. being ~0.68° away when at only speed=600
+ * furthermore, this function quite rapidly approaches its asymptote of ~35.26, e.g. being ~0.68 away when at only speed=600
* this asymptote is independent of whether the player is crouching or has haste, although they must be airborne
- * thus, the best option is to just draw the asymptote (±acos(sqrt(2/3))),
+ * thus, the best option is to just draw the asymptote (acos(sqrt(2/3))),
* ... 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
*/
- if(wturn_no_accel && !immobile)
+ if(autocvar_hud_panel_strafehud_wturn && wturn_no_accel && !immobile)
{
float wturn_g = 32 * aircontrol * dt;
float wturn_V = 1 - (wturn_g * wturn_g) / (speed * speed);
else
wturn_bestangle = acos(sqrt(2 / 3)) * RAD2DEG;
real_wturn_bestangle = wturn_bestangle;
- if(fwd && turn) // if not W-turning, need to add 45/90° so it aligns to where it would be after changing to W-only
+ if(fwd && turn) // if not W-turning, need to add 90°/45° so it aligns to where it would be after changing to W-only
wturn_bestangle += 90;
else if(fwd && wishangle != 0)
wturn_bestangle += 45;
currentangle_offset = bound(-hudangle / 2, angle, hudangle / 2) / hudangle * panel_size.x + panel_size.x / 2;
// best strafe acceleration angle
- bestangle_offset = bestangle / hudangle * panel_size.x + panel_size.x / 2;
- switch_bestangle_offset = -bestangle / hudangle * panel_size.x + panel_size.x / 2;
- switch_bestangle_width = panel_size.x * autocvar_hud_panel_strafehud_switch_width;
- if(!autocvar_hud_panel_strafehud_uncapped)
- switch_bestangle_width = max(switch_bestangle_width, 1);
-
- if((angle > -wishangle && direction == STRAFEHUD_DIRECTION_LEFT) || (angle < -wishangle && direction == STRAFEHUD_DIRECTION_RIGHT))
+ if(autocvar_hud_panel_strafehud_switch && speed >= minspeed)
{
- odd_angles = true;
- odd_bestangle_offset = odd_bestangle / hudangle * panel_size.x + panel_size.x / 2;
- switch_odd_bestangle_offset = (odd_bestangle + bestangle * 2) / hudangle * panel_size.x + panel_size.x / 2;
+ bestangle_offset = bestangle / hudangle * panel_size.x + panel_size.x / 2;
+ switch_bestangle_offset = -bestangle / hudangle * panel_size.x + panel_size.x / 2;
+ switch_bestangle_width = panel_size.x * autocvar_hud_panel_strafehud_switch_width;
+ if(!autocvar_hud_panel_strafehud_uncapped)
+ switch_bestangle_width = max(switch_bestangle_width, 1);
+
+ if((angle > -wishangle && direction == STRAFEHUD_DIRECTION_LEFT) || (angle < -wishangle && direction == STRAFEHUD_DIRECTION_RIGHT))
+ {
+ odd_angles = true;
+ odd_bestangle_offset = odd_bestangle / hudangle * panel_size.x + panel_size.x / 2;
+ switch_odd_bestangle_offset = (odd_bestangle + bestangle * 2) / hudangle * panel_size.x + panel_size.x / 2;
+ }
}
// best angle to aim at when W-turning to maximally rotate velocity vector
- if(wturn_no_accel && !immobile)
+ if(autocvar_hud_panel_strafehud_wturn && wturn_no_accel && !immobile)
{
bool wturn_show = autocvar_hud_panel_strafehud_wturn == 3 ? true
: autocvar_hud_panel_strafehud_wturn == 2 ? (fwd && !turn)
}
}
- // direction indicator
- direction_size_vertical.x = autocvar_hud_panel_strafehud_direction_width;
- if(!autocvar_hud_panel_strafehud_uncapped)
- direction_size_vertical.x = min(direction_size_vertical.x, 1);
- direction_size_vertical.x *= panel_size.y;
- if(!autocvar_hud_panel_strafehud_uncapped)
- direction_size_vertical.x = max(direction_size_vertical.x, 1);
- direction_size_vertical.y = panel_size.y + direction_size_vertical.x * 2;
- direction_size_vertical.z = 0;
- direction_size_horizontal.x = panel_size.x * min(autocvar_hud_panel_strafehud_direction_length, .5);
- direction_size_horizontal.y = direction_size_vertical.x;
- direction_size_horizontal.z = 0;
-
// the neutral zone fills the whole strafe bar
if(immobile)
{
autocvar_hud_panel_strafehud_bar_neutral_alpha * panel_fg_alpha,
autocvar_hud_panel_strafehud_style, STRAFEHUD_GRADIENT_NONE, false);
- // only draw indicators if minspeed is reached
- if(autocvar_hud_panel_strafehud_switch && speed >= minspeed && switch_bestangle_width > 0 && autocvar_hud_panel_strafehud_switch_alpha > 0)
+ // only draw switch indicators if minspeed is reached (switch_bestangle_width init to 0)
+ if(autocvar_hud_panel_strafehud_switch && switch_bestangle_width > 0 && autocvar_hud_panel_strafehud_switch_alpha > 0)
{
// 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 == STRAFEHUD_DIRECTION_LEFT)
- {
- if(!odd_angles)
- offset -= switch_bestangle_width;
- else
- switch_offset -= switch_bestangle_width;
- }
- else
- {
- if(!odd_angles)
- switch_offset -= switch_bestangle_width;
- else
- offset -= switch_bestangle_width;
- }
-
HUD_Panel_DrawStrafeHUD(
switch_offset, switch_bestangle_width, hidden_width,
autocvar_hud_panel_strafehud_switch_color,
autocvar_hud_panel_strafehud_switch_alpha * panel_fg_alpha,
- STRAFEHUD_STYLE_DRAWFILL, STRAFEHUD_GRADIENT_NONE, false);
+ STRAFEHUD_STYLE_DRAWFILL, STRAFEHUD_GRADIENT_NONE, true);
if(direction == STRAFEHUD_DIRECTION_NONE)
HUD_Panel_DrawStrafeHUD(
offset, switch_bestangle_width, hidden_width,
autocvar_hud_panel_strafehud_switch_color,
autocvar_hud_panel_strafehud_switch_alpha * panel_fg_alpha,
- STRAFEHUD_STYLE_DRAWFILL, STRAFEHUD_GRADIENT_NONE, false);
+ STRAFEHUD_STYLE_DRAWFILL, STRAFEHUD_GRADIENT_NONE, true);
}
- // only draw indicators if conditions were met (wturn_bestangle_width init to 0)
+ // only draw wturn indicators if conditions were met (wturn_bestangle_width init to 0)
if(autocvar_hud_panel_strafehud_wturn && wturn_bestangle_width > 0 && autocvar_hud_panel_strafehud_wturn_alpha > 0)
{
// draw the wturn indicators
text_offset_top = text_offset_bottom = slickdetector_height;
}
+ // direction indicator
+ if(autocvar_hud_panel_strafehud_direction)
+ {
+ direction_size_vertical.x = autocvar_hud_panel_strafehud_direction_width;
+ if(!autocvar_hud_panel_strafehud_uncapped)
+ direction_size_vertical.x = min(direction_size_vertical.x, 1);
+ direction_size_vertical.x *= panel_size.y;
+ if(!autocvar_hud_panel_strafehud_uncapped)
+ direction_size_vertical.x = max(direction_size_vertical.x, 1);
+ direction_size_vertical.y = panel_size.y + direction_size_vertical.x * 2;
+ direction_size_vertical.z = 0;
+ direction_size_horizontal.x = panel_size.x * min(autocvar_hud_panel_strafehud_direction_length, .5);
+ direction_size_horizontal.y = direction_size_vertical.x;
+ direction_size_horizontal.z = 0;
+ }
+
if(autocvar_hud_panel_strafehud_direction &&
direction != STRAFEHUD_DIRECTION_NONE &&
direction_size_vertical.x > 0 &&