Bandage handling and bug fixes

This commit is contained in:
ZioPao
2023-11-15 18:28:37 +01:00
parent c9b41838be
commit f7c9047457
5 changed files with 63 additions and 12 deletions

View File

@@ -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)

View File

@@ -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)

View File

@@ -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