]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
while dropping in battle royale limit the horizontal wishdir to 90 degrees to make...
authorJuhu <5894800-Juhu_@users.noreply.gitlab.com>
Sat, 27 May 2023 18:45:31 +0000 (20:45 +0200)
committerJuhu <5894800-Juhu_@users.noreply.gitlab.com>
Sat, 27 May 2023 18:45:31 +0000 (20:45 +0200)
qcsrc/common/gamemodes/gamemode/br/sv_br.qc

index 41bbcbe08b5b00e3f929948336d7f0d27f478036..e166f3aca9586e3d6d9f81ffd30fb4e335487f8b 100644 (file)
@@ -589,7 +589,21 @@ MUTATOR_HOOKFUNCTION(br, PM_Physics)
                 makevectors(player.v_angle);
                 // horizontal wishvel as usual
                 vector wishvel = v_forward * CS(player).movement.x + v_right * CS(player).movement.y;
-                wishvel = normalize(wishvel) * min(1, vlen(wishvel) / maxairspeed);
+
+                // except make turning backwards easier by limiting the maximum turning angle to 90 degrees
+                vector wish_angles = vectoangles(vec2(wishvel));
+                vector vel_angles = vectoangles(vec2(player.velocity));
+
+                float diff_angle = wish_angles.y - vel_angles.y;
+                if(diff_angle > 180)
+                    diff_angle -= 360;
+                if(diff_angle < -180)
+                    diff_angle += 360;
+
+                wish_angles.y = (vel_angles.y + bound(-90, diff_angle, 90) + 360) % 360;
+                makevectors(wish_angles);
+
+                wishvel = normalize(v_forward) * min(1, vlen(wishvel) / maxairspeed);
                 // vertical wishvel using forward movement and the previously calculated ratio
                 wishvel.z = pitch_ratio_wish * bound(0, CS(player).movement.x / maxairspeed, 1);
                 // apply turn acceleration to wishvel