]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
strafehud: the correct friction value is now used if you are on a non-slick surface...
authorJuhu <5894800-Juhu_@users.noreply.gitlab.com>
Sun, 12 Jan 2025 13:58:43 +0000 (14:58 +0100)
committerJuhu <5894800-Juhu_@users.noreply.gitlab.com>
Sun, 12 Jan 2025 14:11:23 +0000 (15:11 +0100)
qcsrc/client/hud/panel/strafehud.qc
qcsrc/client/hud/panel/strafehud/extra.qc

index 45e7bad2bb01a91ef478383d896eddd0ae6dd74e..a1375ee54b44a558927035c4e668c6f3a736f26c 100644 (file)
@@ -96,17 +96,10 @@ void HUD_StrafeHUD()
        static bool onslick_last = false;
        if(onground)
        {
-               if(PHYS_FRICTION(strafeplayer) == 0)
-               {
-                       onslick = true;
-               }
-               else // do not use IS_ONSLICK(), it only works for the local player and only if client prediction is enabled
-               {
-                       trace_dphitq3surfaceflags = 0;
-                       tracebox(strafeplayer.origin, strafeplayer.mins, strafeplayer.maxs, strafeplayer.origin - '0 0 1', MOVE_NOMONSTERS, strafeplayer);
-                       onslick = trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK;
-               }
-               real_onslick = onslick;
+               // do not use IS_ONSLICK(), it only works for the local player and only if client prediction is enabled
+               trace_dphitq3surfaceflags = 0;
+               tracebox(strafeplayer.origin, strafeplayer.mins, strafeplayer.maxs, strafeplayer.origin - '0 0 1', MOVE_NOMONSTERS, strafeplayer);
+               real_onslick = onslick = trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK;
 
                onground_lasttime = time;
                onslick_last = onslick;
@@ -547,7 +540,8 @@ void HUD_StrafeHUD()
 
        float text_offset_top;
        float text_offset_bottom;
-       text_offset_top = text_offset_bottom = StrafeHUD_DrawSlickDetector(strafeplayer, real_onslick);
+       bool all_slick = PHYS_FRICTION(strafeplayer) == 0;
+       text_offset_top = text_offset_bottom = StrafeHUD_DrawSlickDetector(strafeplayer, all_slick && real_onground ? true : real_onslick);
 
        if(autocvar_hud_panel_strafehud_direction)
                StrafeHUD_DrawDirectionIndicator(direction, opposite_direction, fwd);
index 356303e89708943091f3ad08de6aa18547363a88..0d12a035f6f327051be34dc8130944ecc1d89ed0 100644 (file)
@@ -20,7 +20,7 @@
 // slick detector
 // scans for slick in every direction downwards from the player's feet
 // may cause performance issues on slower machines
-float StrafeHUD_DrawSlickDetector(entity e, bool onslick)
+float StrafeHUD_DrawSlickDetector(entity e, bool already_detected)
 {
        float slickdetector_height = bound(0, autocvar_hud_panel_strafehud_slickdetector_height, 1);
        slickdetector_height *= panel_size.y;
@@ -37,7 +37,7 @@ float StrafeHUD_DrawSlickDetector(entity e, bool onslick)
                slicksteps = 90 * DEG2RAD / 2 ** slicksteps;
 
                // don't need to traceline if already touching slick
-               slickdetected = onslick;
+               slickdetected = already_detected;
 
                // coordinates at the bottom center of the player bbox
                vector traceorigin = e.origin + eZ * e.mins.z;