// draw left acceleration zone
HUD_Panel_drawStrafeHUD(
- accelzone_left_startangle, accelzone_left_startangle + accelzone_offsetangle,
+ accelzone_left_startangle, accelzone_offsetangle,
autocvar_hud_panel_strafehud_bar_accel_color,
autocvar_hud_panel_strafehud_bar_accel_alpha * panel_fg_alpha,
autocvar_hud_panel_strafehud_style, STRAFEHUD_GRADIENT_LEFT,
if(autocvar_hud_panel_strafehud_bar_preaccel)
HUD_Panel_drawStrafeHUD(
- preaccelzone_left_startangle, preaccelzone_left_startangle + preaccelzone_offsetangle,
+ preaccelzone_left_startangle, preaccelzone_offsetangle,
autocvar_hud_panel_strafehud_bar_accel_color,
autocvar_hud_panel_strafehud_bar_accel_alpha * panel_fg_alpha,
autocvar_hud_panel_strafehud_style, STRAFEHUD_GRADIENT_RIGHT,
// draw right acceleration zone
HUD_Panel_drawStrafeHUD(
- accelzone_right_startangle, accelzone_right_startangle + accelzone_offsetangle,
+ accelzone_right_startangle, accelzone_offsetangle,
autocvar_hud_panel_strafehud_bar_accel_color,
autocvar_hud_panel_strafehud_bar_accel_alpha * panel_fg_alpha,
autocvar_hud_panel_strafehud_style, STRAFEHUD_GRADIENT_RIGHT,
if(autocvar_hud_panel_strafehud_bar_preaccel)
HUD_Panel_drawStrafeHUD(
- preaccelzone_right_startangle, preaccelzone_right_startangle + preaccelzone_offsetangle,
+ preaccelzone_right_startangle, preaccelzone_offsetangle,
autocvar_hud_panel_strafehud_bar_accel_color,
autocvar_hud_panel_strafehud_bar_accel_alpha * panel_fg_alpha,
autocvar_hud_panel_strafehud_style, STRAFEHUD_GRADIENT_LEFT,
// acceleration decreases at 90 degrees but speed loss happens a little bit after 90 degrees,
// however due to sv_airstopaccelerate that's hard to calculate
HUD_Panel_drawStrafeHUD(
- overturn_startangle, overturn_startangle + 180, // overturning area spans 180°
+ overturn_startangle, 180, // overturning area spans 180°
autocvar_hud_panel_strafehud_bar_overturn_color,
autocvar_hud_panel_strafehud_bar_overturn_alpha * panel_fg_alpha,
autocvar_hud_panel_strafehud_style, STRAFEHUD_GRADIENT_BOTH,
// draw neutral zone
HUD_Panel_drawStrafeHUD(
- neutral_startangle, neutral_startangle + neutral_endangle,
+ neutral_startangle, neutral_endangle,
autocvar_hud_panel_strafehud_bar_neutral_color,
autocvar_hud_panel_strafehud_bar_neutral_alpha * panel_fg_alpha,
autocvar_hud_panel_strafehud_style, STRAFEHUD_GRADIENT_NONE,
}
HUD_Panel_drawStrafeHUD(
- offsetangle, offsetangle + StrafeHUD_offsetToAngle(bestangle_width, hudangle),
+ offsetangle, StrafeHUD_offsetToAngle(bestangle_width, hudangle),
autocvar_hud_panel_strafehud_switch_color,
autocvar_hud_panel_strafehud_switch_alpha * panel_fg_alpha,
STRAFEHUD_STYLE_DRAWFILL, STRAFEHUD_GRADIENT_NONE,
if(direction == STRAFEHUD_DIRECTION_NONE)
HUD_Panel_drawStrafeHUD(
- opposite_offsetangle, opposite_offsetangle + StrafeHUD_offsetToAngle(bestangle_width, hudangle),
+ opposite_offsetangle, StrafeHUD_offsetToAngle(bestangle_width, hudangle),
autocvar_hud_panel_strafehud_switch_color,
autocvar_hud_panel_strafehud_switch_alpha * panel_fg_alpha,
STRAFEHUD_STYLE_DRAWFILL, STRAFEHUD_GRADIENT_NONE,
#include <client/draw.qh>
// functions to make hud elements align perfectly in the hud area
-void HUD_Panel_drawStrafeHUD(float fromangle, float toangle, vector color, float alpha, int type, int gradientType, bool doProject, float range)
+void HUD_Panel_drawStrafeHUD(float startangle, float offsetangle, vector color, float alpha, int type, int gradientType, bool doProject, float range)
{
- if(toangle < fromangle)
- {
- float tmp = fromangle;
- fromangle = toangle;
- toangle = tmp;
- }
-
- float offset = StrafeHUD_angleToOffset(fromangle % 360, range);
- float width = StrafeHUD_angleToOffset(toangle, range) - StrafeHUD_angleToOffset(fromangle, range);
+ float offset = StrafeHUD_angleToOffset(startangle % 360, range);
+ float width = StrafeHUD_angleToWidth(offsetangle, range);
float mirror_offset, mirror_width;
vector size = panel_size;
#include <common/physics/player.qh>
#include <common/physics/movetypes/movetypes.qh>
+float StrafeHUD_angleToWidth(float angle, float range)
+{
+ return angle / range * panel_size.x;
+}
+
float StrafeHUD_angleToOffset(float angle, float range)
{
- return angle / range * panel_size.x + panel_size.x / 2;
+ return StrafeHUD_angleToWidth(angle, range) + panel_size.x / 2;
}
float StrafeHUD_offsetToAngle(float offset, float range)
return STRAFEHUD_DIRECTION_NONE;
}
}
+
+// try to ignore if track_canjump is enabled, does not work in spectator mode if spectated player uses +jetpack or cl_movement_track_canjump
+bool DetectJumpHeld(entity e, int keys, bool islocal)
+{
+ if(islocal)
+ {
+ if((PHYS_INPUT_BUTTON_JUMP(e) || PHYS_INPUT_BUTTON_JETPACK(e)) && !PHYS_CL_TRACK_CANJUMP(e))
+ return true;
+ }
+ else
+ {
+ if((keys & KEY_JUMP) && !PHYS_TRACK_CANJUMP(e))
+ return true;
+ }
+
+ return false;
+}
float StrafeHUD_projectAngle(float, float, bool);
float StrafeHUD_projectOffset(float, float, bool);
float StrafeHUD_projectWidth(float, float, float);
+float StrafeHUD_angleToWidth(float, float);
float StrafeHUD_angleToOffset(float, float);
float StrafeHUD_offsetToAngle(float, float);
float DetectWaterLevel(entity);
float DetectWishAngle(vector, int, bool);
float StrafeHUD_determineHudAngle(float);
float StrafeHUD_determineDirection(float, float, float);
+bool DetectJumpHeld(entity, int, bool);