]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
strafehud: add timeout values for left/right strafe to account for more variations...
authorJuhu <5894800-Juhu_@users.noreply.gitlab.com>
Tue, 23 Jun 2020 01:05:51 +0000 (03:05 +0200)
committerJuhu <5894800-Juhu_@users.noreply.gitlab.com>
Tue, 23 Jun 2020 01:05:51 +0000 (03:05 +0200)
_hud_common.cfg
qcsrc/client/autocvars.qh
qcsrc/client/hud/panel/strafehud.qc

index 6e57f5b7e4251dcb3464ae90742fc060d97a7ed1..201f19b5d4222deaf437dd5456f9fbf145ade3fb 100644 (file)
@@ -146,7 +146,8 @@ seta hud_panel_strafehud_direction_width "0.0075" "direction indicator width"
 seta hud_panel_strafehud_timeout_air "0" "time after take off before changing strafehud mode (prevents flickering on slick ramps)"
 seta hud_panel_strafehud_timeout_ground "0.03333333" "time after landing before changing strafehud mode (prevents flickering on regular strafe turns)"
 seta hud_panel_strafehud_timeout_strafe "0.1" "time after releasing the strafe keys before changing mode (prevents flickering when switching between left/right strafe turning)"
-seta hud_panel_strafehud_timeout_direction "0.5" "time it takes until direction changes (forward or backward strafe) are detected"
+seta hud_panel_strafehud_timeout_fwd_bkwd "0.5" "time it takes until direction changes (forward or backward movement) are detected"
+seta hud_panel_strafehud_timeout_left_right "0" "time it takes until direction changes (left or right movement) are detected"
 seta hud_panel_strafehud_unstyled "0" "don't apply any progressbar styles to the strafehud"
 seta hud_panel_strafehud_antiflicker_angle "0.01" "how many degrees from 0° to 180° the hud ignores if it could cause visual disturbances otherwise"
 seta hud_panel_strafehud_antiflicker_speed "0.0001" "how many qu/s the hud ignores if it could cause visual disturbances otherwise"
index 9361f2bd764fb28417eff6fb9289570e8ed7f837..4ed427baa1ae4e2fe415e585182a41652fd29b1f 100644 (file)
@@ -344,7 +344,8 @@ float autocvar_hud_panel_strafehud_direction_width = 0.0075;
 float autocvar_hud_panel_strafehud_timeout_air = 0;
 float autocvar_hud_panel_strafehud_timeout_ground = 0.03333333;
 float autocvar_hud_panel_strafehud_timeout_strafe = 0.1;
-float autocvar_hud_panel_strafehud_timeout_direction = 0.5;
+float autocvar_hud_panel_strafehud_timeout_fwd_bkwd = 0.5;
+float autocvar_hud_panel_strafehud_timeout_left_right = 0;
 bool autocvar_hud_panel_strafehud_unstyled = false;
 float autocvar_hud_panel_strafehud_antiflicker_angle = 0.01;
 float autocvar_hud_panel_strafehud_antiflicker_speed = 0.0001;
index 689417bd4dfacaf58204185524ab2dd566dcd544..7cdae87b869aebaab64aaff018a66bfe6da78ade 100644 (file)
@@ -21,11 +21,15 @@ void HUD_StrafeHUD_Export(int fh)
 bool fwd = true;
 bool state_fwd = true;
 bool state_fwd_prev = true;
+int direction = 0;
+bool state_direction = true;
+bool state_direction_prev = true;
 float demo_angle = -37;
 float demo_direction = 1;
 float demo_time = 0;
 float state_onground_time = 0;
 float state_strafekeys_time = 0;
+float state_fwd_time = 0;
 float state_direction_time = 0;
 bool state_onground = false;
 bool state_strafekeys = false;
@@ -94,7 +98,6 @@ void HUD_StrafeHUD()
         float  vel_angle                     = vectoangles(strafeplayer.velocity).y;
         float  view_angle                    = view_angles.y + 180;
         float  angle;
-        float  direction;
         vector movement                      = PHYS_INPUT_MOVEVALUES(strafeplayer);
         int    keys                          = STAT(PRESSED_KEYS);
         int    keys_fwd;
@@ -343,11 +346,11 @@ void HUD_StrafeHUD()
 
                 if(state_fwd_prev != state_fwd)
                 {
-                    state_direction_time = time;
+                    state_fwd_time = time;
                 }
                 state_fwd_prev = state_fwd;
 
-                if((time - state_direction_time) >= autocvar_hud_panel_strafehud_timeout_direction || speed < maxspeed) // timeout when changing between forwards and backwards strafe
+                if((time - state_fwd_time) >= autocvar_hud_panel_strafehud_timeout_fwd_bkwd || speed < maxspeed) // timeout when changing between forwards and backwards movement
                 {
                     fwd = state_fwd;
                 }
@@ -409,13 +412,29 @@ void HUD_StrafeHUD()
 
         moveangle = angle + wishangle;
 
+        // determine whether the player is strafing left or right
         if(wishangle != 0)
         {
-            direction = wishangle > 0 ? 1 : -1;
+            state_direction = wishangle > 0 ? 1 : -1;
         }
         else
         {
-            direction = (angle > antiflicker_angle && angle < (180 - antiflicker_angle)) ? 1 : (angle < -antiflicker_angle && angle > (-180 + antiflicker_angle)) ? -1 : 0;
+            state_direction = (angle > antiflicker_angle && angle < (180 - antiflicker_angle)) ? 1 : (angle < -antiflicker_angle && angle > (-180 + antiflicker_angle)) ? -1 : 0;
+        }
+
+        if(state_direction_prev != state_direction)
+        {
+            state_direction_time = time;
+        }
+        state_direction_prev = state_direction;
+
+        if((time - state_direction_time) >= autocvar_hud_panel_strafehud_timeout_left_right || speed < maxspeed || direction == 0) // timeout when changing between left and right movement
+        {
+            direction = state_direction;
+        }
+        if(direction != 0)
+        {
+            wishangle = direction * fabs(wishangle);
         }
 
         // decelerating at this angle