From fd18ffb35f8cda80efcdf8c8ba35cfbc65ce0473 Mon Sep 17 00:00:00 2001 From: Pao Date: Tue, 7 Mar 2023 19:38:22 +0100 Subject: [PATCH] Updated rewrite with previous loot all fix --- media/lua/client/TOC_CommonFunctions.lua | 10 ++++++++++ media/lua/client/TOC_OverridenFunctions.lua | 19 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/media/lua/client/TOC_CommonFunctions.lua b/media/lua/client/TOC_CommonFunctions.lua index 7c2677e..deda276 100644 --- a/media/lua/client/TOC_CommonFunctions.lua +++ b/media/lua/client/TOC_CommonFunctions.lua @@ -288,4 +288,14 @@ TOC_Common.FindItemInWornItems = function(player, checkString) return nil +end + +TOC_Common.FindModItem = function(inventory) + for _, partName in pairs(TOC_Common.GetPartNames()) do + if inventory:contains("TOC.Amputation_" .. partName) then + return true + end + end + return false + end \ No newline at end of file diff --git a/media/lua/client/TOC_OverridenFunctions.lua b/media/lua/client/TOC_OverridenFunctions.lua index 7f2b9a5..d6c5689 100644 --- a/media/lua/client/TOC_OverridenFunctions.lua +++ b/media/lua/client/TOC_OverridenFunctions.lua @@ -246,4 +246,23 @@ function ISClothingExtraAction:isValid() end return baseCheck +end + +-- Manages the Loot All button to prevent stuff like picking up the amputation items +local og_ISInventoryPagePrerender = ISInventoryPage.prerender +function ISInventoryPage:prerender() + -- Check if there is any amputated limb here. if there is, just fail and maybe notify the player + og_ISInventoryPagePrerender(self) + if TOC_Common.FindModItem(self.inventory) then + self.canLootAll = false + else + self.canLootAll = true + end +end + +local og_ISInventoryPageLootAll = ISInventoryPage.lootAll +function ISInventoryPage:lootAll() + if self.canLootAll then + og_ISInventoryPageLootAll(self) + end end \ No newline at end of file