From b62d65bbddcc6b00929f09d4cb0cbd474e356174 Mon Sep 17 00:00:00 2001 From: terencehill Date: Tue, 9 Aug 2022 01:00:46 +0200 Subject: [PATCH] Reloadable shotgun: when clip is empty automatically reload regardless of whether melee attack is available or not, and make sure player has some some ammo left 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 | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/qcsrc/common/weapons/weapon/shotgun.qc b/qcsrc/common/weapons/weapon/shotgun.qc index 523de5d71..e43aa89aa 100644 --- a/qcsrc/common/weapons/weapon/shotgun.qc +++ b/qcsrc/common/weapons/weapon/shotgun.qc @@ -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 -- 2.39.2