Reloadable shotgun: when clip is empty automatically reload regardless of whether...
authorterencehill <piuntn@gmail.com>
Mon, 8 Aug 2022 23:00:46 +0000 (01:00 +0200)
committerterencehill <piuntn@gmail.com>
Tue, 9 Aug 2022 12:28:29 +0000 (14:28 +0200)
Note: WEP_CVAR(shotgun, secondary) < 2 check was wrong because it included secondary mode 0 where secondary attack is off

qcsrc/common/weapons/weapon/shotgun.qc

index 523de5d71b3f40dd3320d5a1b6e04e37ac4f712a..e43aa89aa16344a928276c65eb6d729c95e763e0 100644 (file)
@@ -203,11 +203,13 @@ METHOD(Shotgun, wr_aim, void(entity thiswep, entity actor, .entity weaponentity)
 
 METHOD(Shotgun, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
 {
-    if(WEP_CVAR(shotgun, reload_ammo) && actor.(weaponentity).clip_load < WEP_CVAR_PRI(shotgun, ammo)) // forced reload
+    // force reload weapon when clip is empty or insufficent
+    if(WEP_CVAR(shotgun, reload_ammo) && actor.(weaponentity).clip_load < WEP_CVAR_PRI(shotgun, ammo))
     {
-        // don't force reload an empty shotgun if its melee attack is active
-        if(WEP_CVAR(shotgun, secondary) < 2) {
+        if(actor.(weaponentity).clip_load >= 0 && GetResource(actor, thiswep.ammo_type) > 0)
+        {
             thiswep.wr_reload(thiswep, actor, weaponentity);
+            return;
         }
     }
     else