From 3bc4ce471fdc8a082405f5a5c44f2f9aca1c9c2f Mon Sep 17 00:00:00 2001 From: ZioPao Date: Mon, 13 Nov 2023 17:30:14 +0100 Subject: [PATCH] Fixes --- .../client/TOC/Handlers/AmputationHandler.lua | 24 ++++------------ .../lua/client/TOC/UI/CutLimbInteractions.lua | 28 ++++++++----------- media/lua/client/TOC/UI/HealthPanel.lua | 2 +- .../lua/client/TOC/UI/SurgeryInteractions.lua | 4 +-- 4 files changed, 21 insertions(+), 37 deletions(-) diff --git a/media/lua/client/TOC/Handlers/AmputationHandler.lua b/media/lua/client/TOC/Handlers/AmputationHandler.lua index 6787f6c..6e569d4 100644 --- a/media/lua/client/TOC/Handlers/AmputationHandler.lua +++ b/media/lua/client/TOC/Handlers/AmputationHandler.lua @@ -24,7 +24,11 @@ function AmputationHandler:new(limbName, surgeonPl) o.patientPl = getPlayer() o.limbName = limbName - o.bodyPartType = BodyPartType[self.limbName] + o.bodyPartType = BodyPartType[limbName] + + -- TOC_DEBUG.print("limbName = " .. o.limbName) + -- TOC_DEBUG.print("bodyPartType = " .. tostring(o.bodyPartType)) + if surgeonPl then o.surgeonPl = surgeonPl else @@ -38,26 +42,10 @@ end --* Main methods *-- ----Starts bleeding from the point where the saw is being used. Static since this could be used for online ----comment ----@param patientPl IsoPlayer ----@param bodyPartType BodyPartType -function AmputationHandler.DamageDuringAmputation(patientPl, bodyPartType) - TOC_DEBUG.print("damage patient") - local bodyDamage = patientPl:getBodyDamage() - local bodyDamagePart = bodyDamage:getBodyPart(bodyPartType) - - bodyDamagePart:setBleeding(true) - bodyDamagePart:setCut(true) - bodyDamagePart:setBleedingTime(ZombRand(10, 20)) - - - -end function AmputationHandler:damageDuringAmputation() - TOC_DEBUG.print("damage patient") local bodyDamage = self.patientPl:getBodyDamage() local bodyDamagePart = bodyDamage:getBodyPart(self.bodyPartType) + TOC_DEBUG.print("damage patient - " .. tostring(self.bodyPartType)) bodyDamagePart:setBleeding(true) bodyDamagePart:setCut(true) diff --git a/media/lua/client/TOC/UI/CutLimbInteractions.lua b/media/lua/client/TOC/UI/CutLimbInteractions.lua index d09448a..86ea36a 100644 --- a/media/lua/client/TOC/UI/CutLimbInteractions.lua +++ b/media/lua/client/TOC/UI/CutLimbInteractions.lua @@ -76,19 +76,15 @@ end ---@param context ISContextMenu function CutLimbHandler:addToMenu(context) - --local types = self:getAllItemTypes(self.items.ITEMS) - --if #types > 0 then - local option = context:addOption(getText("ContextMenu_Amputate"), nil) - local subMenu = context:getNew(context) - context:addSubMenu(option, subMenu) - for i = 1, #StaticData.LIMBS_STRINGS do - local limbName = StaticData.LIMBS_STRINGS[i] + + --TOC_DEBUG.print("addToMenu running") + local limbName = BodyPartType.ToString(self.bodyPart:getType()) + --TOC_DEBUG.print(limbName) + if StaticData.BODYPARTSTYPES_ENUM[limbName] then if not ModDataHandler.GetInstance():getIsCut(limbName) then - local limbTranslatedName = getText("ContextMenu_Limb_" .. limbName) - subMenu:addOption(limbTranslatedName, self.onMenuOptionSelected, nil) + context:addOption(getText("ContextMenu_Amputate"), self, self.onMenuOptionSelected) end end - --end end function CutLimbHandler:dropItems(items) @@ -101,17 +97,17 @@ function CutLimbHandler:dropItems(items) end function CutLimbHandler:isValid(itemType) - return self:getItemOfType(self.items.ITEMS, itemType) + return true -- TODO Workaround for now end function CutLimbHandler:perform(previousAction, itemType) - TOC_DEBUG.print("perform CutLimbHandler") - local item = self:getItemOfType(self.items.ITEMS, itemType) - previousAction = self:toPlayerInventory(item, previousAction) + --local item = self:getItemOfType(self.items.ITEMS, itemType) + --previousAction = self:toPlayerInventory(item, previousAction) - local limbName = BodyPartType.getDisplayName(self.bodyPart:getType()) -- TODO Test this + local limbName = BodyPartType.ToString(self.bodyPart:getType()) + TOC_DEBUG.print("perform CutLimbHandler on " .. limbName) local action = CutLimbAction:new(self:getPatient(), self:getDoctor(), limbName) - ISTimedActionQueue.addAfter(previousAction, action) + ISTimedActionQueue.add(action) end return CutLimbHandler diff --git a/media/lua/client/TOC/UI/HealthPanel.lua b/media/lua/client/TOC/UI/HealthPanel.lua index d46e3bb..644d61c 100644 --- a/media/lua/client/TOC/UI/HealthPanel.lua +++ b/media/lua/client/TOC/UI/HealthPanel.lua @@ -33,7 +33,7 @@ function ISHealthPanel:doBodyPartContextMenu(bodyPart, x, y) local playerNum = self.otherPlayer and self.otherPlayer:getPlayerNum() or self.character:getPlayerNum() -- To not recreate it but reuse the one that has been created in the original method - local context = getPlayerContextMenu(playerNum) + local context = getPlayerContextMenu(playerNum) local cutLimbHandler = CutLimbHandler:new(self, bodyPart) cutLimbHandler:addToMenu(context) end diff --git a/media/lua/client/TOC/UI/SurgeryInteractions.lua b/media/lua/client/TOC/UI/SurgeryInteractions.lua index 531a395..89a45e8 100644 --- a/media/lua/client/TOC/UI/SurgeryInteractions.lua +++ b/media/lua/client/TOC/UI/SurgeryInteractions.lua @@ -1,4 +1,4 @@ -local PlayerHandler = require("TOC/Handlers/PlayerHandler") +local CachedDataHandler = require("TOC/Handlers/CachedDataHandler") local ModDataHandler = require("TOC/Handlers/ModDataHandler") --------------- @@ -27,7 +27,7 @@ local function AddOvenContextMenu(playerNum, context, worldObjects, test) local pl = getSpecificPlayer(playerNum) if not ModDataHandler.GetInstance():getIsAnyLimbCut() then return end - local amputatedLimbs = PlayerHandler.GetAmputatedLimbs() + local amputatedLimbs = CachedDataHandler.GetAmputatedLimbs(pl:getUsername()) local stoveObj = nil for _, obj in pairs(worldObjects) do