From 3470edb6481de7b065f27c0bf53491e8ef3a0211 Mon Sep 17 00:00:00 2001 From: Pao Date: Tue, 28 Feb 2023 12:01:18 +0100 Subject: [PATCH] Fixed wrist thing --- .vscode/settings.json | 3 +- .../client/ActionsMethods/JCIO_CutLimb.lua | 6 ++- media/lua/client/JCIO_OverridenFunctions.lua | 44 +++++++++++++------ 3 files changed, 36 insertions(+), 17 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index d7dccb0..c7c22da 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -55,6 +55,7 @@ "SandboxVars", "getClassField", "ISWearClothing", - "SyncXp" + "SyncXp", + "ISClothingExtraAction" ] } \ No newline at end of file diff --git a/media/lua/client/ActionsMethods/JCIO_CutLimb.lua b/media/lua/client/ActionsMethods/JCIO_CutLimb.lua index 8ba1c80..de33109 100644 --- a/media/lua/client/ActionsMethods/JCIO_CutLimb.lua +++ b/media/lua/client/ActionsMethods/JCIO_CutLimb.lua @@ -175,7 +175,7 @@ JCIO.CutLimb = function(partName, surgeonFactor, bandageTable, painkillerTable) if tourniquetItem ~= nil then baseDamageValue = 50 -- TODO Decrease mostly blood and damage, add pain, not everything else - if partName == "Left_UpperArm" or partName == "Right_UpperArm" then + if partName == side .. "_UpperArm" then player:removeWornItem(tourniquetItem) end end @@ -185,7 +185,9 @@ JCIO.CutLimb = function(partName, surgeonFactor, bandageTable, painkillerTable) local wristWatchItem = FindWristWatchInWornItems(player, side) if wristWatchItem ~= nil then - player:removeWornItem(wristWatchItem) + if partName == side .. "_LowerArm" or partName == side .. "_UpperArm" then + player:removeWornItem(wristWatchItem) + end end diff --git a/media/lua/client/JCIO_OverridenFunctions.lua b/media/lua/client/JCIO_OverridenFunctions.lua index a25e4f7..3606078 100644 --- a/media/lua/client/JCIO_OverridenFunctions.lua +++ b/media/lua/client/JCIO_OverridenFunctions.lua @@ -190,30 +190,46 @@ end -- Make the player unable to equip a tourniquet or watches on an already fully amputated limb local og_ISWearClothingIsValid = ISWearClothing.isValid function ISWearClothing:isValid() - + local baseCheck = og_ISWearClothingIsValid(self) local itemFullType = self.item:getFullType() local limbsData = self.character:getModData().JCIO.limbs - local itemsToBeChecked = { - "Surgery_%1_Tourniquet", -- 1 - "Watch_%1" -- 2 - } + local itemToCheck = "Surgery_%s_Tourniquet" for _, side in pairs(JCIO.sideNames) do - for indexItem, itemName in pairs(itemsToBeChecked) do - local formattedItemName = string.format(itemName, side) - if string.find(itemFullType, formattedItemName) then - if indexItem == 1 and limbsData[side .. "_UpperArm"].isCut then - return false - elseif indexItem == 2 and limbsData[side .. "_Hand"].isCut then - return false - end + local formattedItemName = string.format(itemToCheck, side) + + if string.find(itemFullType, formattedItemName) then + if limbsData[side .. "_UpperArm"].isCut then + return false end end end return baseCheck - end + +local og_ISWearClothingExtraAction = ISClothingExtraAction.isValid + +function ISClothingExtraAction:isValid() + local baseCheck = og_ISWearClothingExtraAction(self) + local itemToCheck = "Watch_%s" + local itemFullType = self.item:getFullType() + local limbsData = self.character:getModData().JCIO.limbs + + + for _, side in pairs(JCIO.sideNames) do + + local formattedItemName = string.format(itemToCheck, side) + + if string.find(itemFullType, formattedItemName) then + if limbsData[side .. "_LowerArm"].isCut then + return false + end + end + end + + return baseCheck +end \ No newline at end of file