]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix MachineGun and Arc burst attacks not respecting IT_UNLIMITED_AMMO
authorMario <mario.mario@y7mail.com>
Tue, 30 Jul 2024 02:48:05 +0000 (12:48 +1000)
committerMario <mario.mario@y7mail.com>
Tue, 30 Jul 2024 02:48:05 +0000 (12:48 +1000)
qcsrc/common/weapons/weapon/arc.qc
qcsrc/common/weapons/weapon/machinegun.qc

index d12310c189bd810ad6b14737f0c1e4e37f66c536..d1c7fbe2797e676eb91d8c72d5bc2042d435f6b1 100644 (file)
@@ -644,15 +644,19 @@ METHOD(Arc, wr_think, void(entity thiswep, entity actor, .entity weaponentity, i
                 w_ready(thiswep, actor, weaponentity, fire);
                 return;
             }
-            float ammo_available = GetResource(actor, thiswep.ammo_type);
-            // We don't want to shoot 3 rounds if there's 2 left in the mag, so we'll use a fraction.
-            // Also keep the fraction <= 1 otherwise we'd mag dump in one burst.
-            float burst_fraction = min(1, ammo_available / WEP_CVAR(arc, bolt_ammo));
-            int to_shoot = floor(WEP_CVAR(arc, bolt_count) * burst_fraction);
-
-            // We also don't want to use 3 rounds if there's only 2 left.
-            int to_use = min(WEP_CVAR(arc, bolt_ammo), ammo_available);
-            W_DecreaseAmmo(thiswep, actor, to_use, weaponentity);
+            int to_shoot = WEP_CVAR(arc, bolt_count);
+            if(!(actor.items & IT_UNLIMITED_AMMO))
+            {
+                float ammo_available = GetResource(actor, thiswep.ammo_type);
+                // We don't want to shoot 3 rounds if there's 2 left in the mag, so we'll use a fraction.
+                // Also keep the fraction <= 1 otherwise we'd mag dump in one burst.
+                float burst_fraction = min(1, ammo_available / WEP_CVAR(arc, bolt_ammo));
+                to_shoot = floor(to_shoot * burst_fraction);
+
+                // We also don't want to use 3 rounds if there's only 2 left.
+                int to_use = min(WEP_CVAR(arc, bolt_ammo), ammo_available);
+                W_DecreaseAmmo(thiswep, actor, to_use, weaponentity);
+            }
 
             // Bursting counts up to 0 from a negative.
             actor.(weaponentity).misc_bulletcounter = -to_shoot;
index efb4913c005ea7abd84a338ea7d67727b5933956..5414ed9d9475f678b6ef89f1c793ec197ecf9894 100644 (file)
@@ -208,14 +208,18 @@ METHOD(MachineGun, wr_think, void(entity thiswep, entity actor, .entity weaponen
                 ammo_available = GetResource(actor, thiswep.ammo_type);
             }
 
-            // We don't want to shoot 3 rounds if there's 2 left in the mag, so we'll use a fraction.
-            // Also keep the fraction <= 1 otherwise we'd mag dump in one burst.
-            float burst_fraction = min(1, ammo_available / WEP_CVAR(machinegun, burst_ammo));
-            int to_shoot = floor(WEP_CVAR(machinegun, burst) * burst_fraction);
-
-            // We also don't want to use 3 rounds if there's only 2 left.
-            int to_use = min(WEP_CVAR(machinegun, burst_ammo), ammo_available);
-            W_DecreaseAmmo(thiswep, actor, to_use, weaponentity);
+            int to_shoot = WEP_CVAR(machinegun, burst);
+            if(!(actor.items & IT_UNLIMITED_AMMO))
+            {
+                // We don't want to shoot 3 rounds if there's 2 left in the mag, so we'll use a fraction.
+                // Also keep the fraction <= 1 otherwise we'd mag dump in one burst.
+                float burst_fraction = min(1, ammo_available / WEP_CVAR(machinegun, burst_ammo));
+                to_shoot = floor(to_shoot * burst_fraction);
+
+                // We also don't want to use 3 rounds if there's only 2 left.
+                int to_use = min(WEP_CVAR(machinegun, burst_ammo), ammo_available);
+                W_DecreaseAmmo(thiswep, actor, to_use, weaponentity);
+            }
 
             // Bursting counts up to 0 from a negative.
             actor.(weaponentity).misc_bulletcounter = -to_shoot;