]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Allow showing strafehud W-turn indicators when sv_airaccel_qw == 0
authorotta8634 <k9wolf@pm.me>
Thu, 5 Sep 2024 05:46:45 +0000 (13:46 +0800)
committerotta8634 <k9wolf@pm.me>
Thu, 5 Sep 2024 05:46:45 +0000 (13:46 +0800)
Done with _wturn_unrestricted 1
Also added/fixed some comments

_hud_common.cfg
qcsrc/client/hud/panel/strafehud.qc
qcsrc/client/hud/panel/strafehud.qh

index a6c2f0bfadeb5d050e5257229a1d81cb72acff62..554a332ca9bb5a938b54bb63119a6936828af6d0 100644 (file)
@@ -206,6 +206,7 @@ seta hud_panel_strafehud_wturn_color "0 1 1" "color of the W-turn indicators"
 seta hud_panel_strafehud_wturn_alpha "1" "opacity of the W-turn indicators"
 seta hud_panel_strafehud_wturn_width "0.003" "width of the W-turn indicators (relative to the strafe bar width)"
 seta hud_panel_strafehud_wturn_proper "0" "use the proper formula to calculate W-turn indicators (warning: loses accuracy at high speeds)"
+seta hud_panel_strafehud_wturn_unrestricted "0" "set to \"1\" to enable the W-turn indicators even when W-turning gives acceleration (warning: not completely accurate)"
 seta hud_panel_strafehud_direction "0" "set to \"1\" to enable the direction caps to see in which direction you are currently strafing"
 seta hud_panel_strafehud_direction_color "0 0.5 1" "color of the direction caps which indicate the direction the player is currently strafing towards"
 seta hud_panel_strafehud_direction_alpha "1" "opacity of the direction caps which indicate the direction the player is currently strafing towards"
index 75ca8fbc8b46b5fec0a532ca0177cde78cb82ef6..2cd8b9747ff0d9338921f6f626e6b5366135bf9d 100644 (file)
@@ -142,8 +142,8 @@ void HUD_StrafeHUD()
                float  maxaccel                      = !autocvar__hud_configure ? maxaccel_phys : 1;
                float  airstopaccel                  = PHYS_AIRSTOPACCELERATE(strafeplayer);
                float  aircontrol                    = PHYS_AIRCONTROL(strafeplayer);
-               bool   aircontrol_backwards          = PHYS_AIRCONTROL_BACKWARDS(strafeplayer);
-               bool   wturn_no_accel                = PHYS_AIRACCEL_QW(strafeplayer) == 1 && aircontrol != 0; // if true, W-turning exists and doesn't provide accel
+               bool   aircontrol_backwards          = PHYS_AIRCONTROL_BACKWARDS(strafeplayer) == 1;
+               bool   airaccel_qw                   = PHYS_AIRACCEL_QW(strafeplayer) == 1;
                // change the range from 0° - 360° to -180° - 180° to match how view_angle represents angles
                float  vel_angle                     = vectoangles(strafeplayer.velocity).y - (vectoangles(strafeplayer.velocity).y > 180 ? 360 : 0);
                float  view_angle                    = PHYS_INPUT_ANGLES(strafeplayer).y;
@@ -565,6 +565,7 @@ void HUD_StrafeHUD()
                                // case 1: normal. case 2: low speed, best angle is forwards
                        }
                        {
+                               // needed later if autocvar_hud_panel_strafehud_wturn != 0, so calculate even if autocvar_hud_panel_strafehud_bar_preaccel == 0
                                float prebestangle_sqrt = movespeed * movespeed + strafespeed * strafespeed - speed * speed;
                                // delta_min = acos(sqrt(s^2 - v_f^2 + v^2) / v_f), or just acos(s / v) in air
                                prebestangle = (prebestangle_sqrt > 0 && strafespeed > sqrt(prebestangle_sqrt))
@@ -592,7 +593,7 @@ void HUD_StrafeHUD()
                        {
                                // these conditions occur when you land at high speed (above max onground speed), such that every wishangle will result in a speed loss due to friction
                                // the latter condition should only ever happen when onground, but check for sanity
-                               // if these conditions are met, prebestangle will be less than bestangle, all 3 cases deal with that
+                               // if these conditions are met, prebestangle will be greater than than bestangle. all 3 cases deal with that
                                if(autocvar_hud_panel_strafehud_onground_mode == 0)
                                {
                                        // make overturn fill the whole strafe bar
@@ -638,8 +639,9 @@ void HUD_StrafeHUD()
                 * ... 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
                 */
-               bool wturning = wishangle == 0 && (keys_fwd == STRAFEHUD_KEYS_FORWARD || (aircontrol_backwards && keys_fwd == STRAFEHUD_KEYS_BACKWARD));
-               if(autocvar_hud_panel_strafehud_wturn && wturn_no_accel && !immobile)
+               bool wturning    = wishangle == 0 && (keys_fwd == STRAFEHUD_KEYS_FORWARD || (aircontrol_backwards && keys_fwd == STRAFEHUD_KEYS_BACKWARD));
+               bool wturn_check = autocvar_hud_panel_strafehud_wturn && !immobile && aircontrol && (autocvar_hud_panel_strafehud_wturn_unrestricted == 1 || airaccel_qw);
+               if(wturn_check)
                {
                        float wturn_g = 32 * aircontrol * dt;
                        float wturn_V = 1 - (wturn_g * wturn_g) / (speed * speed);
@@ -708,7 +710,7 @@ void HUD_StrafeHUD()
                }
 
                // best angle to aim at when W-turning to maximally rotate velocity vector
-               if(autocvar_hud_panel_strafehud_wturn && wturn_no_accel && !immobile)
+               if(wturn_check)
                {
                        bool wturn_show = autocvar_hud_panel_strafehud_wturn == 3 ? true
                                : autocvar_hud_panel_strafehud_wturn == 2 ? ((fwd || aircontrol_backwards) && !turn)
index 8e884713243cb266da0bd79a55082bba13332c8b..e3a9116cc1acbcccac8d62522ee3797a4fee8a06 100644 (file)
@@ -44,6 +44,7 @@ vector autocvar_hud_panel_strafehud_wturn_color = '0 1 1';
 float autocvar_hud_panel_strafehud_wturn_alpha = 1;
 float autocvar_hud_panel_strafehud_wturn_width = 0.003;
 bool autocvar_hud_panel_strafehud_wturn_proper = false;
+bool autocvar_hud_panel_strafehud_wturn_unrestricted = false;
 bool autocvar_hud_panel_strafehud_direction = false;
 vector autocvar_hud_panel_strafehud_direction_color = '0 0.5 1';
 float autocvar_hud_panel_strafehud_direction_alpha = 1;