From 3d4a54418c95727e2cf46e581c78babbde7527c6 Mon Sep 17 00:00:00 2001 From: ZioPao Date: Sun, 5 May 2024 18:02:48 +0200 Subject: [PATCH 1/4] Added tests for blood on limbs --- .../client/TOC/Handlers/ProsthesisHandler.lua | 4 +- media/lua/client/TOC/Tests.lua | 44 ++++++++++--------- .../TOC/TimedActions/WashYourselfOverride.lua | 40 +++++++++++++++++ 3 files changed, 65 insertions(+), 23 deletions(-) diff --git a/media/lua/client/TOC/Handlers/ProsthesisHandler.lua b/media/lua/client/TOC/Handlers/ProsthesisHandler.lua index cfb4943..9f7f4be 100644 --- a/media/lua/client/TOC/Handlers/ProsthesisHandler.lua +++ b/media/lua/client/TOC/Handlers/ProsthesisHandler.lua @@ -145,8 +145,8 @@ end local og_ISClothingExtraAction_perform = ISClothingExtraAction.perform function ISClothingExtraAction:perform() - --local extraItem = InventoryItemFactory.CreateItem(self.extra) - local isProst = ProsthesisHandler.SearchAndSetupProsthesis(self.item, true) + local extraItem = InventoryItemFactory.CreateItem(self.extra) + local isProst = ProsthesisHandler.SearchAndSetupProsthesis(extraItem, true) local group if isProst then group = BodyLocations.getGroup("Human") diff --git a/media/lua/client/TOC/Tests.lua b/media/lua/client/TOC/Tests.lua index 27a1e4d..170ef6c 100644 --- a/media/lua/client/TOC/Tests.lua +++ b/media/lua/client/TOC/Tests.lua @@ -156,28 +156,30 @@ end) TestFramework.registerTestModule("Various", "Visuals", function() local Tests = {} - function Tests.AddBloodRightForearm() + function Tests.AddBloodLeftForearm() local playerObj = getPlayer() - -- local wornItems = playerObj:getWornItems() - -- local limbName = "ForeArm_R" - -- local fullType = StaticData.AMPUTATION_CLOTHING_ITEM_BASE .. limbName - - -- for i = 1, wornItems:size() do - -- local it = wornItems:get(i - 1) - -- if it then - -- local wornItem = wornItems:get(i - 1):getItem() - -- TOC_DEBUG.print(wornItem:getFullType()) - -- if wornItem:getFullType() == fullType then - -- TOC_DEBUG.print("Found amputation item for " .. limbName) - - -- -- change it here - -- wornItem:setBloodLevel - -- wornItem:getVisual():setTextureChoice(texId) - -- playerObj:resetModelNextFrame() -- necessary to update the model - -- return - -- end - -- end - -- end + local limbName = "ForeArm_L" + local fullType = StaticData.AMPUTATION_CLOTHING_ITEM_BASE .. limbName + + + local item = playerObj:getInventory():FindAndReturn(fullType) + if instanceof(item, "Clothing") then + + ---@cast item Clothing + + print("Found limb to add blood onto") + item:setBloodLevel(100) + local coveredParts = BloodClothingType.getCoveredParts(item:getBloodClothingType()) + if coveredParts then + for j=0,coveredParts:size()-1 do + item:setBlood(coveredParts:get(j), 100) + item:setDirt(coveredParts:get(j), 100) + end + end + + end + + playerObj:resetModelNextFrame() end return Tests diff --git a/media/lua/client/TOC/TimedActions/WashYourselfOverride.lua b/media/lua/client/TOC/TimedActions/WashYourselfOverride.lua index 471d65d..547c56b 100644 --- a/media/lua/client/TOC/TimedActions/WashYourselfOverride.lua +++ b/media/lua/client/TOC/TimedActions/WashYourselfOverride.lua @@ -3,6 +3,7 @@ local StaticData = require("TOC/StaticData") -- Since amputations are actually clothing items, we need to override ISWashYourself to account for that +-- TODO Clean this up local og_ISWashYourself_perform = ISWashYourself.perform function ISWashYourself:perform() @@ -29,6 +30,11 @@ function ISWashYourself:perform() foundItem:setBloodLevel(0) foundItem:setDirtyness(0) -- TODO Integrate with other dirtyness + local coveredParts = BloodClothingType.getCoveredParts(foundItem:getBloodClothingType()) + for j=0, coveredParts:size() - 1 do + foundItem:setBlood(coveredParts:get(j), 0) + foundItem:setDirt(coveredParts:get(j), 0) + end end end @@ -37,4 +43,38 @@ function ISWashYourself:perform() og_ISWashYourself_perform(self) +end + + +local og_ISWashYourself_GetRequiredWater = ISWashYourself.GetRequiredWater + + +---@param character IsoPlayer +---@return integer +function ISWashYourself.GetRequiredWater(character) + + local units = og_ISWashYourself_GetRequiredWater(character) + local amputatedLimbs = CachedDataHandler.GetAmputatedLimbs(character:getUsername()) + local plInv = character:getInventory() + for limbName, _ in pairs(amputatedLimbs) do + + TOC_DEBUG.print("Checking if " .. limbName .. " is in inventory and washing it") + + -- get clothing item + local item = plInv:FindAndReturn(StaticData.AMPUTATION_CLOTHING_ITEM_BASE .. limbName) + if item and instanceof(item, "Clothing") then + local coveredParts = BloodClothingType.getCoveredParts(item:getBloodClothingType()) + if coveredParts then + for i=1,coveredParts:size() do + local part = coveredParts:get(i-1) + if item:getBlood(part) > 0 then + units = units + 1 + end + end + end + end + + end + + return units end \ No newline at end of file From 2ea03601f588372c8880783713cdf61cc3ab4e29 Mon Sep 17 00:00:00 2001 From: ZioPao Date: Sun, 5 May 2024 18:03:08 +0200 Subject: [PATCH 2/4] Revert "Added tests for blood on limbs" This reverts commit 3d4a54418c95727e2cf46e581c78babbde7527c6. --- .../client/TOC/Handlers/ProsthesisHandler.lua | 4 +- media/lua/client/TOC/Tests.lua | 44 +++++++++---------- .../TOC/TimedActions/WashYourselfOverride.lua | 40 ----------------- 3 files changed, 23 insertions(+), 65 deletions(-) diff --git a/media/lua/client/TOC/Handlers/ProsthesisHandler.lua b/media/lua/client/TOC/Handlers/ProsthesisHandler.lua index 9f7f4be..cfb4943 100644 --- a/media/lua/client/TOC/Handlers/ProsthesisHandler.lua +++ b/media/lua/client/TOC/Handlers/ProsthesisHandler.lua @@ -145,8 +145,8 @@ end local og_ISClothingExtraAction_perform = ISClothingExtraAction.perform function ISClothingExtraAction:perform() - local extraItem = InventoryItemFactory.CreateItem(self.extra) - local isProst = ProsthesisHandler.SearchAndSetupProsthesis(extraItem, true) + --local extraItem = InventoryItemFactory.CreateItem(self.extra) + local isProst = ProsthesisHandler.SearchAndSetupProsthesis(self.item, true) local group if isProst then group = BodyLocations.getGroup("Human") diff --git a/media/lua/client/TOC/Tests.lua b/media/lua/client/TOC/Tests.lua index 170ef6c..27a1e4d 100644 --- a/media/lua/client/TOC/Tests.lua +++ b/media/lua/client/TOC/Tests.lua @@ -156,30 +156,28 @@ end) TestFramework.registerTestModule("Various", "Visuals", function() local Tests = {} - function Tests.AddBloodLeftForearm() + function Tests.AddBloodRightForearm() local playerObj = getPlayer() - local limbName = "ForeArm_L" - local fullType = StaticData.AMPUTATION_CLOTHING_ITEM_BASE .. limbName - - - local item = playerObj:getInventory():FindAndReturn(fullType) - if instanceof(item, "Clothing") then - - ---@cast item Clothing - - print("Found limb to add blood onto") - item:setBloodLevel(100) - local coveredParts = BloodClothingType.getCoveredParts(item:getBloodClothingType()) - if coveredParts then - for j=0,coveredParts:size()-1 do - item:setBlood(coveredParts:get(j), 100) - item:setDirt(coveredParts:get(j), 100) - end - end - - end - - playerObj:resetModelNextFrame() + -- local wornItems = playerObj:getWornItems() + -- local limbName = "ForeArm_R" + -- local fullType = StaticData.AMPUTATION_CLOTHING_ITEM_BASE .. limbName + + -- for i = 1, wornItems:size() do + -- local it = wornItems:get(i - 1) + -- if it then + -- local wornItem = wornItems:get(i - 1):getItem() + -- TOC_DEBUG.print(wornItem:getFullType()) + -- if wornItem:getFullType() == fullType then + -- TOC_DEBUG.print("Found amputation item for " .. limbName) + + -- -- change it here + -- wornItem:setBloodLevel + -- wornItem:getVisual():setTextureChoice(texId) + -- playerObj:resetModelNextFrame() -- necessary to update the model + -- return + -- end + -- end + -- end end return Tests diff --git a/media/lua/client/TOC/TimedActions/WashYourselfOverride.lua b/media/lua/client/TOC/TimedActions/WashYourselfOverride.lua index 547c56b..471d65d 100644 --- a/media/lua/client/TOC/TimedActions/WashYourselfOverride.lua +++ b/media/lua/client/TOC/TimedActions/WashYourselfOverride.lua @@ -3,7 +3,6 @@ local StaticData = require("TOC/StaticData") -- Since amputations are actually clothing items, we need to override ISWashYourself to account for that --- TODO Clean this up local og_ISWashYourself_perform = ISWashYourself.perform function ISWashYourself:perform() @@ -30,11 +29,6 @@ function ISWashYourself:perform() foundItem:setBloodLevel(0) foundItem:setDirtyness(0) -- TODO Integrate with other dirtyness - local coveredParts = BloodClothingType.getCoveredParts(foundItem:getBloodClothingType()) - for j=0, coveredParts:size() - 1 do - foundItem:setBlood(coveredParts:get(j), 0) - foundItem:setDirt(coveredParts:get(j), 0) - end end end @@ -43,38 +37,4 @@ function ISWashYourself:perform() og_ISWashYourself_perform(self) -end - - -local og_ISWashYourself_GetRequiredWater = ISWashYourself.GetRequiredWater - - ----@param character IsoPlayer ----@return integer -function ISWashYourself.GetRequiredWater(character) - - local units = og_ISWashYourself_GetRequiredWater(character) - local amputatedLimbs = CachedDataHandler.GetAmputatedLimbs(character:getUsername()) - local plInv = character:getInventory() - for limbName, _ in pairs(amputatedLimbs) do - - TOC_DEBUG.print("Checking if " .. limbName .. " is in inventory and washing it") - - -- get clothing item - local item = plInv:FindAndReturn(StaticData.AMPUTATION_CLOTHING_ITEM_BASE .. limbName) - if item and instanceof(item, "Clothing") then - local coveredParts = BloodClothingType.getCoveredParts(item:getBloodClothingType()) - if coveredParts then - for i=1,coveredParts:size() do - local part = coveredParts:get(i-1) - if item:getBlood(part) > 0 then - units = units + 1 - end - end - end - end - - end - - return units end \ No newline at end of file From 0d9ee4203c66aeeba004660c7847500a399fe5c8 Mon Sep 17 00:00:00 2001 From: ZioPao Date: Sun, 5 May 2024 18:03:39 +0200 Subject: [PATCH 3/4] Revert "Revert "Added tests for blood on limbs"" This reverts commit 2ea03601f588372c8880783713cdf61cc3ab4e29. --- .../client/TOC/Handlers/ProsthesisHandler.lua | 4 +- media/lua/client/TOC/Tests.lua | 44 ++++++++++--------- .../TOC/TimedActions/WashYourselfOverride.lua | 40 +++++++++++++++++ 3 files changed, 65 insertions(+), 23 deletions(-) diff --git a/media/lua/client/TOC/Handlers/ProsthesisHandler.lua b/media/lua/client/TOC/Handlers/ProsthesisHandler.lua index cfb4943..9f7f4be 100644 --- a/media/lua/client/TOC/Handlers/ProsthesisHandler.lua +++ b/media/lua/client/TOC/Handlers/ProsthesisHandler.lua @@ -145,8 +145,8 @@ end local og_ISClothingExtraAction_perform = ISClothingExtraAction.perform function ISClothingExtraAction:perform() - --local extraItem = InventoryItemFactory.CreateItem(self.extra) - local isProst = ProsthesisHandler.SearchAndSetupProsthesis(self.item, true) + local extraItem = InventoryItemFactory.CreateItem(self.extra) + local isProst = ProsthesisHandler.SearchAndSetupProsthesis(extraItem, true) local group if isProst then group = BodyLocations.getGroup("Human") diff --git a/media/lua/client/TOC/Tests.lua b/media/lua/client/TOC/Tests.lua index 27a1e4d..170ef6c 100644 --- a/media/lua/client/TOC/Tests.lua +++ b/media/lua/client/TOC/Tests.lua @@ -156,28 +156,30 @@ end) TestFramework.registerTestModule("Various", "Visuals", function() local Tests = {} - function Tests.AddBloodRightForearm() + function Tests.AddBloodLeftForearm() local playerObj = getPlayer() - -- local wornItems = playerObj:getWornItems() - -- local limbName = "ForeArm_R" - -- local fullType = StaticData.AMPUTATION_CLOTHING_ITEM_BASE .. limbName - - -- for i = 1, wornItems:size() do - -- local it = wornItems:get(i - 1) - -- if it then - -- local wornItem = wornItems:get(i - 1):getItem() - -- TOC_DEBUG.print(wornItem:getFullType()) - -- if wornItem:getFullType() == fullType then - -- TOC_DEBUG.print("Found amputation item for " .. limbName) - - -- -- change it here - -- wornItem:setBloodLevel - -- wornItem:getVisual():setTextureChoice(texId) - -- playerObj:resetModelNextFrame() -- necessary to update the model - -- return - -- end - -- end - -- end + local limbName = "ForeArm_L" + local fullType = StaticData.AMPUTATION_CLOTHING_ITEM_BASE .. limbName + + + local item = playerObj:getInventory():FindAndReturn(fullType) + if instanceof(item, "Clothing") then + + ---@cast item Clothing + + print("Found limb to add blood onto") + item:setBloodLevel(100) + local coveredParts = BloodClothingType.getCoveredParts(item:getBloodClothingType()) + if coveredParts then + for j=0,coveredParts:size()-1 do + item:setBlood(coveredParts:get(j), 100) + item:setDirt(coveredParts:get(j), 100) + end + end + + end + + playerObj:resetModelNextFrame() end return Tests diff --git a/media/lua/client/TOC/TimedActions/WashYourselfOverride.lua b/media/lua/client/TOC/TimedActions/WashYourselfOverride.lua index 471d65d..547c56b 100644 --- a/media/lua/client/TOC/TimedActions/WashYourselfOverride.lua +++ b/media/lua/client/TOC/TimedActions/WashYourselfOverride.lua @@ -3,6 +3,7 @@ local StaticData = require("TOC/StaticData") -- Since amputations are actually clothing items, we need to override ISWashYourself to account for that +-- TODO Clean this up local og_ISWashYourself_perform = ISWashYourself.perform function ISWashYourself:perform() @@ -29,6 +30,11 @@ function ISWashYourself:perform() foundItem:setBloodLevel(0) foundItem:setDirtyness(0) -- TODO Integrate with other dirtyness + local coveredParts = BloodClothingType.getCoveredParts(foundItem:getBloodClothingType()) + for j=0, coveredParts:size() - 1 do + foundItem:setBlood(coveredParts:get(j), 0) + foundItem:setDirt(coveredParts:get(j), 0) + end end end @@ -37,4 +43,38 @@ function ISWashYourself:perform() og_ISWashYourself_perform(self) +end + + +local og_ISWashYourself_GetRequiredWater = ISWashYourself.GetRequiredWater + + +---@param character IsoPlayer +---@return integer +function ISWashYourself.GetRequiredWater(character) + + local units = og_ISWashYourself_GetRequiredWater(character) + local amputatedLimbs = CachedDataHandler.GetAmputatedLimbs(character:getUsername()) + local plInv = character:getInventory() + for limbName, _ in pairs(amputatedLimbs) do + + TOC_DEBUG.print("Checking if " .. limbName .. " is in inventory and washing it") + + -- get clothing item + local item = plInv:FindAndReturn(StaticData.AMPUTATION_CLOTHING_ITEM_BASE .. limbName) + if item and instanceof(item, "Clothing") then + local coveredParts = BloodClothingType.getCoveredParts(item:getBloodClothingType()) + if coveredParts then + for i=1,coveredParts:size() do + local part = coveredParts:get(i-1) + if item:getBlood(part) > 0 then + units = units + 1 + end + end + end + end + + end + + return units end \ No newline at end of file From 9b1876b23511ac70c18eeed922ae4a75b71b46cc Mon Sep 17 00:00:00 2001 From: ZioPao Date: Sun, 5 May 2024 18:04:10 +0200 Subject: [PATCH 4/4] mod.info and version bump --- media/lua/client/TOC/Main.lua | 2 +- mod.info | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/media/lua/client/TOC/Main.lua b/media/lua/client/TOC/Main.lua index 9da1984..61c3367 100644 --- a/media/lua/client/TOC/Main.lua +++ b/media/lua/client/TOC/Main.lua @@ -6,7 +6,7 @@ require("TOC/Events") ---@class Main local Main = { - _version = "2.0.5" + _version = "2.0.6" } function Main.Start() diff --git a/mod.info b/mod.info index 24b1a14..f5ff42c 100644 --- a/mod.info +++ b/mod.info @@ -4,5 +4,5 @@ description=You've been bitten. You have only two choices. id=TheOnlyCure icon=icon.png url=https://github.com/ZioPao/The-Only-Cure -modversion=2.0.5 +modversion=2.0.6 pzversion=41.65