diff --git a/media/lua/client/TOC/Handlers/AmputationHandler.lua b/media/lua/client/TOC/Handlers/AmputationHandler.lua index f2e4462..741c3a1 100644 --- a/media/lua/client/TOC/Handlers/AmputationHandler.lua +++ b/media/lua/client/TOC/Handlers/AmputationHandler.lua @@ -57,9 +57,6 @@ function AmputationHandler.ApplyDamageDuringAmputation(player, limbName) end function AmputationHandler.HandleBandages(prevAction, limbName, surgeonPl, patientPl, bandageItem) - - -- TODO Will it work? Can we get bodyDamage for another player from here? - local bptEnum = StaticData.BODYLOCS_IND_BPT[limbName] local bd = patientPl:getBodyDamage() local bodyPart = bd:getBodyPart(bptEnum) diff --git a/media/lua/client/TOC/TimedActions/CutLimbAction.lua b/media/lua/client/TOC/TimedActions/CutLimbAction.lua index 6621ef9..b324659 100644 --- a/media/lua/client/TOC/TimedActions/CutLimbAction.lua +++ b/media/lua/client/TOC/TimedActions/CutLimbAction.lua @@ -55,11 +55,15 @@ function CutLimbAction:start() -- TODO Check bandages, if there are init a bandage process - local bandageItem = "" + + --AmputationHandler.HandleBandages(self, self.limbName, self.character, self.patient, ) + local bandageItem = InventoryItemFactory.CreateItem("Base.Bandage") + self.character:getInventory():addItem(bandageItem) + local bptEnum = StaticData.BODYLOCS_IND_BPT[self.limbName] local bd = self.character:getBodyDamage() local bodyPart = bd:getBodyPart(bptEnum) - local bandageAction = ISApplyBandage:new(self.character, self.patient, bandageItem, bodyPart, true) + local bandageAction = ISApplyBandage:new(self.character, self.patient, bandageItem, bodyPart, 100) ISTimedActionQueue.addAfter(self, bandageAction) diff --git a/media/lua/client/TOC/UI/CutLimbInteractions.lua b/media/lua/client/TOC/UI/CutLimbInteractions.lua index 4b601db..6f80e11 100644 --- a/media/lua/client/TOC/UI/CutLimbInteractions.lua +++ b/media/lua/client/TOC/UI/CutLimbInteractions.lua @@ -5,12 +5,15 @@ local ModDataHandler = require("TOC/Handlers/ModDataHandler") --------------------- ----Check if the item name corresponds to a compatible saw ----@param itemName string -local function CheckIfSaw(itemName) - return itemName == "Saw" or itemName == "GardenSaw" or itemName == "Chainsaw" + + +---Check if the item type corresponds to a compatible saw +---@param itemType string +local function CheckIfSaw(itemType) + return itemType:contains(StaticData.SAWS_TYPES_IND_STR.saw) or itemType:contains(StaticData.SAWS_TYPES_IND_STR.gardenSaw) end + ---Add the action to the queue ---@param limbName string ---@param surgeon IsoPlayer @@ -42,8 +45,19 @@ end ---@param context ISContextMenu ---@param items table local function AddInventoryAmputationMenu(player, context, items) - local item = items[1] -- Selected item - if CheckIfSaw(item.name) then + local item + + -- We can't access the item if we don't create the loop and start ipairs. + for _, v in ipairs(items) do + item = v + if not instanceof(v, "InventoryItem") then + item = v.items[1] + end + break + end + + local itemType = item:getType() + if CheckIfSaw(itemType) then AddInventoryAmputationOptions(player, context, item) end end @@ -74,7 +88,9 @@ end ---@param item InventoryItem function CutLimbHandler:checkItem(item) local itemType = item:getType() - if string.contains(itemType, "Saw") then + TOC_DEBUG.print("checkItem: " .. tostring(itemType)) + + if CheckIfSaw(itemType) then self:addItem(self.items.ITEMS, item) end end diff --git a/media/lua/shared/TOC/Debug.lua b/media/lua/shared/TOC/Debug.lua index 0d018c6..6247130 100644 --- a/media/lua/shared/TOC/Debug.lua +++ b/media/lua/shared/TOC/Debug.lua @@ -50,7 +50,24 @@ function TOC_DEBUG.TestBodyDamage(id) end end +function TOC_DEBUG.TestBloodDrop() + local pl = getPlayer() + --IsoZombieGiblets.GibletType.A + --local giblets = IsoZombieGiblets.new(getCell()) + + local sq = pl:getSquare() + local t = IsoZombieGiblets.class.GibletType + + print(t) + --IsoBall.new(getCell(), pl:getX(), pl:) + addBloodSplat(sq, 100) + + + --pl:getChunk():addBloodSplat(pl:getX(), pl:getY(), pl:getZ(), 100) + --IsoZombieGiblets.new(x, getCell(), pl:getX(), pl:getY(), pl:getZ(), 100, 1) + +end --------------------------------- --* Debug server commands *-- diff --git a/media/lua/shared/TOC/StaticData.lua b/media/lua/shared/TOC/StaticData.lua index c317a01..2eaa1a0 100644 --- a/media/lua/shared/TOC/StaticData.lua +++ b/media/lua/shared/TOC/StaticData.lua @@ -159,4 +159,21 @@ StaticData.HEALTH_PANEL_TEXTURES = { StaticData.AMPUTATION_CLOTHING_ITEM_BASE = "TOC.Amputation_" +------------------ +--* Items check + +local sawObj = InventoryItemFactory.CreateItem("Base.Saw") +local gardenSawObj = InventoryItemFactory.CreateItem("Base.GardenSaw") + +StaticData.SAWS_NAMES_IND_STR = { + saw = sawObj:getName(), + gardenSaw = gardenSawObj:getName() +} + +StaticData.SAWS_TYPES_IND_STR = { + saw = sawObj:getType(), + gardenSaw = gardenSawObj:getType() +} + + return StaticData