From 23a9e21ebac6c288c4ba1628f624b4eba882d1cf Mon Sep 17 00:00:00 2001 From: dastrukar <3derid@gmail.com> Date: Sat, 30 Sep 2023 01:40:51 +0800 Subject: [PATCH] medical: Fix trauma kit not consuming items properly --- .../module/traumakit/traumakit_supplies.zsc | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/medical/module/traumakit/traumakit_supplies.zsc b/medical/module/traumakit/traumakit_supplies.zsc index ee9c3250..d764313a 100644 --- a/medical/module/traumakit/traumakit_supplies.zsc +++ b/medical/module/traumakit/traumakit_supplies.zsc @@ -58,12 +58,28 @@ extend class UaS_TraumaKit { // Copied from HD to avoid inheritance chain // Thanks to MarinaGryphon (jade-2562) for figuring this out void TakeInjector(class injectortype) { - let mmm=HDMagAmmo(owner.findinventory(injectortype)); - if(mmm){ - mmm.amount--; - if(mmm.amount<1)mmm.destroy(); - else if(mmm.mags.size())mmm.mags.pop(); + // for pre-injector overhaul + let mmm = HDMagAmmo(owner.FindInventory(injectortype)); + if (mmm) { + mmm.Amount--; + if (mmm.Amount < 1) { mmm.Destroy(); } + else if (mmm.Mags.Size()) { mmm.Mags.Pop(); } + return; } + + // for post-injector overhaul + let spw = SpareWeapons(owner.FindInventory("SpareWeapons")); + if (HDWeapon.GetActualAmount(owner, injectortype.GetClassName()) == 1 || !spw) { + let item = owner.FindInventory(injectortype); + item.Destroy(); + return; + } + + int i = spw.weapontype.Find(injectortype.GetClassName()); + if (i == spw.weapontype.Size()) { return; } + spw.weapontype.Delete(i); + spw.weaponbulk.Delete(i); + spw.weaponstatus.Delete(i); } void HandleSupplies() {