From 5280004b1f70347d4e95e920286ec54a426dcff9 Mon Sep 17 00:00:00 2001 From: Marco Cawthorne Date: Sat, 15 Apr 2023 17:21:13 -0700 Subject: [PATCH] Weapons will now auto-switch to the next best available weapon when empty. --- src/shared/w_grenadelauncher.qc | 4 +++- src/shared/w_lightning.qc | 4 +++- src/shared/w_nailgun.qc | 4 +++- src/shared/w_rocketlauncher.qc | 4 +++- src/shared/w_shotgun.qc | 4 +++- src/shared/w_supernailgun.qc | 5 +++++ src/shared/w_supershotgun.qc | 4 +++- 7 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/shared/w_grenadelauncher.qc b/src/shared/w_grenadelauncher.qc index cc9a32d..81a1948 100644 --- a/src/shared/w_grenadelauncher.qc +++ b/src/shared/w_grenadelauncher.qc @@ -147,8 +147,10 @@ w_grenadelauncher_primary(player pl) { if (pl.w_attack_next > 0.0) return; - if (pl.ammo_rockets <= 0) + if (pl.ammo_rockets <= 0) { + Weapons_SwitchBest(pl, 0); return; + } /* fire the actual projectile (on the server) */ #ifdef SERVER diff --git a/src/shared/w_lightning.qc b/src/shared/w_lightning.qc index 422b0ec..b0eaa27 100644 --- a/src/shared/w_lightning.qc +++ b/src/shared/w_lightning.qc @@ -92,8 +92,10 @@ w_lightning_primary(player pl) { if (pl.w_attack_next > 0.0) return; - if (pl.ammo_cells <= 0) + if (pl.ammo_cells <= 0) { + Weapons_SwitchBest(pl, 0); return; + } pl.ammo_cells--; diff --git a/src/shared/w_nailgun.qc b/src/shared/w_nailgun.qc index 74db683..a3a261a 100644 --- a/src/shared/w_nailgun.qc +++ b/src/shared/w_nailgun.qc @@ -91,8 +91,10 @@ w_nailgun_primary(player pl) { if (pl.w_attack_next > 0.0) return; - if (pl.ammo_nails <= 0) + if (pl.ammo_nails <= 0) { + Weapons_SwitchBest(pl, 0); return; + } pl.ammo_nails--; diff --git a/src/shared/w_rocketlauncher.qc b/src/shared/w_rocketlauncher.qc index 603c762..3827df0 100644 --- a/src/shared/w_rocketlauncher.qc +++ b/src/shared/w_rocketlauncher.qc @@ -92,8 +92,10 @@ w_rocketlauncher_primary(player pl) { if (pl.w_attack_next > 0.0) return; - if (pl.ammo_rockets <= 0) + if (pl.ammo_rockets <= 0) { + Weapons_SwitchBest(pl, 0); return; + } /* visual fluff */ Weapons_ViewAnimation(pl, RPG_SHOOT); diff --git a/src/shared/w_shotgun.qc b/src/shared/w_shotgun.qc index a24bce0..04d91ab 100644 --- a/src/shared/w_shotgun.qc +++ b/src/shared/w_shotgun.qc @@ -124,8 +124,10 @@ w_shotgun_primary(player pl) { if (pl.w_attack_next > 0.0) return; - if (pl.ammo_shells <= 0) + if (pl.ammo_shells <= 0) { + Weapons_SwitchBest(pl, 0); return; + } #ifdef SERVER /* Singleplayer is more accurate */ diff --git a/src/shared/w_supernailgun.qc b/src/shared/w_supernailgun.qc index 7686b41..fee58bf 100644 --- a/src/shared/w_supernailgun.qc +++ b/src/shared/w_supernailgun.qc @@ -96,6 +96,11 @@ w_supernailgun_primary(player pl) if (pl.w_attack_next > 0.0f) return; + if (pl.ammo_nails < 1) { + Weapons_SwitchBest(pl, 0); + return; + } + pl.ammo_nails--; Weapons_ViewAnimation(pl, SUPERNAIL_SHOOT); Weapons_ViewPunchAngle(pl, [-2,0,0]); diff --git a/src/shared/w_supershotgun.qc b/src/shared/w_supershotgun.qc index a9e3e09..6cc6a1c 100644 --- a/src/shared/w_supershotgun.qc +++ b/src/shared/w_supershotgun.qc @@ -138,8 +138,10 @@ w_supershotgun_primary(player pl) if (pl.w_attack_next > 0.0) return; - if (pl.ammo_shells < 2) + if (pl.ammo_shells < 2) { + Weapons_SwitchBest(pl, 0); return; + } /* actual firing */ pl.ammo_shells -= 2;