From 99850ea216ef13d56fb6e65e927aabd76d91b601 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Lu=C3=ADs=20Vaz=20Silva?= Date: Sat, 8 Jul 2023 23:47:11 -0300 Subject: [PATCH] fix the ammocount parameter in Weapon.CheckAmmo --- wadsrc/static/zscript/actors/inventory/weapons.zs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/wadsrc/static/zscript/actors/inventory/weapons.zs b/wadsrc/static/zscript/actors/inventory/weapons.zs index d4aa0e57d..72f31b1f9 100644 --- a/wadsrc/static/zscript/actors/inventory/weapons.zs +++ b/wadsrc/static/zscript/actors/inventory/weapons.zs @@ -932,6 +932,7 @@ class Weapon : StateProvider int count1, count2; int enough, enoughmask; int lAmmoUse1; + int lAmmoUse2 = AmmoUse2; if (sv_infiniteammo || (Owner.FindInventory ('PowerInfiniteAmmo', true) != null)) { @@ -957,20 +958,21 @@ class Weapon : StateProvider count1 = (Ammo1 != null) ? Ammo1.Amount : 0; count2 = (Ammo2 != null) ? Ammo2.Amount : 0; - if (bDehAmmo && Ammo1 == null) - { - lAmmoUse1 = 0; - } - else if (ammocount >= 0 && bDehAmmo) + if (ammocount >= 0) { lAmmoUse1 = ammocount; + lAmmoUse2 = ammocount; + } + else if (bDehAmmo && Ammo1 == null) + { + lAmmoUse1 = 0; } else { lAmmoUse1 = AmmoUse1; } - enough = (count1 >= lAmmoUse1) | ((count2 >= AmmoUse2) << 1); + enough = (count1 >= lAmmoUse1) | ((count2 >= lAmmoUse2) << 1); if (useboth) { enoughmask = 3;