diff --git a/media/lua/client/TOC/Admin.lua b/media/lua/client/TOC/Admin.lua index 0c53760..b5825c9 100644 --- a/media/lua/client/TOC/Admin.lua +++ b/media/lua/client/TOC/Admin.lua @@ -1,4 +1,6 @@ local CommandsData = require("TOC/CommandsData") +local StaticData = require("TOC/StaticData") +local DataController = require("TOC/Controllers/DataController") ------------------- ---@param playerNum number @@ -50,14 +52,33 @@ Events.OnFillWorldObjectContextMenu.Add(AddAdminTocOptions) local og_ISHealthPanel_onCheatCurrentPlayer = ISHealthPanel.onCheatCurrentPlayer +---Override to onCheatCurrentPlayer to fix behaviour with TOC +---@param bodyPart BodyPart +---@param action any +---@param player IsoPlayer function ISHealthPanel.onCheatCurrentPlayer(bodyPart, action, player) og_ISHealthPanel_onCheatCurrentPlayer(bodyPart, action, player) + local bptString = BodyPartType.ToString(bodyPart:getType()) if action == "healthFullBody" then - -- todo loop all limbs and reset them if infected + -- loop all limbs and reset them if infected + local dcInst = DataController.GetInstance() + + for i = 1, #StaticData.LIMBS_STR do + local limbName = StaticData.LIMBS_STR[i] + + dcInst:setIsInfected(limbName, false) + end + + dcInst:apply() end if action == "healthFull" then - -- todo get limbname from bodypart + -- Get the limbName for that BodyPart and fix the values in TOC Data + local limbName = StaticData.BODYLOCS_TO_LIMBS_IND_STR[bptString] + local dcInst = DataController.GetInstance() + + dcInst:setIsInfected(limbName, false) + dcInst:apply() end -end \ No newline at end of file +end diff --git a/media/lua/client/TOC/Controllers/LocalPlayerController.lua b/media/lua/client/TOC/Controllers/LocalPlayerController.lua index a0ee4a7..dd18409 100644 --- a/media/lua/client/TOC/Controllers/LocalPlayerController.lua +++ b/media/lua/client/TOC/Controllers/LocalPlayerController.lua @@ -143,7 +143,7 @@ function LocalPlayerController.HandleDamage(character) local modDataNeedsUpdate = false for i = 1, #StaticData.LIMBS_STR do local limbName = StaticData.LIMBS_STR[i] - local bptEnum = StaticData.BODYLOCS_IND_BPT[limbName] + local bptEnum = StaticData.LIMBS_TO_BODYLOCS_IND_BPT[limbName] local bodyPart = bd:getBodyPart(bptEnum) if dcInst:getIsCut(limbName) then -- Generic injury, let's heal it since they already cut the limb off diff --git a/media/lua/client/TOC/Handlers/AmputationHandler.lua b/media/lua/client/TOC/Handlers/AmputationHandler.lua index 0dfbbd4..97a776a 100644 --- a/media/lua/client/TOC/Handlers/AmputationHandler.lua +++ b/media/lua/client/TOC/Handlers/AmputationHandler.lua @@ -89,7 +89,7 @@ end ---@param stitchesItem InventoryItem ---@return ISStitch function AmputationHandler.PrepareStitchesAction(prevAction, limbName, surgeonPl, patientPl, stitchesItem) - local bptEnum = StaticData.BODYLOCS_IND_BPT[limbName] + local bptEnum = StaticData.LIMBS_TO_BODYLOCS_IND_BPT[limbName] local bd = patientPl:getBodyDamage() local bodyPart = bd:getBodyPart(bptEnum) local stitchesAction = ISStitch:new(surgeonPl, patientPl, stitchesItem, bodyPart, true) @@ -106,7 +106,7 @@ end ---@param bandageItem InventoryItem ---@return ISApplyBandage function AmputationHandler.PrepareBandagesAction(prevAction, limbName, surgeonPl, patientPl, bandageItem) - local bptEnum = StaticData.BODYLOCS_IND_BPT[limbName] + local bptEnum = StaticData.LIMBS_TO_BODYLOCS_IND_BPT[limbName] local bd = patientPl:getBodyDamage() local bodyPart = bd:getBodyPart(bptEnum) local bandageAction = ISApplyBandage:new(surgeonPl, patientPl, bandageItem, bodyPart, true) diff --git a/media/lua/client/TOC/UI/Interactions/CutLimbInteractionHandler.lua b/media/lua/client/TOC/UI/Interactions/CutLimbInteractionHandler.lua index 9099bc6..76a9d07 100644 --- a/media/lua/client/TOC/UI/Interactions/CutLimbInteractionHandler.lua +++ b/media/lua/client/TOC/UI/Interactions/CutLimbInteractionHandler.lua @@ -219,7 +219,7 @@ function CutLimbInteractionHandler:addToMenu(context) --TOC_DEBUG.print("CutLimbInteractionHandler addToMenu") local types = self:getAllItemTypes(self.items.ITEMS) local patientUsername = self:getPatient():getUsername() - if #types > 0 and StaticData.BODYLOCS_IND_BPT[self.limbName] and not DataController.GetInstance(patientUsername):getIsCut(self.limbName) then + if #types > 0 and StaticData.LIMBS_TO_BODYLOCS_IND_BPT[self.limbName] and not DataController.GetInstance(patientUsername):getIsCut(self.limbName) then TOC_DEBUG.print("addToMenu, types > 0") for i=1, #types do context:addOption(getText("ContextMenu_Amputate"), self, self.onMenuOptionSelected, types[i]) @@ -229,7 +229,7 @@ end function CutLimbInteractionHandler:dropItems(items) local types = self:getAllItemTypes(items) - if #self.items.ITEMS > 0 and #types == 1 and StaticData.BODYLOCS_IND_BPT[self.limbName] then + if #self.items.ITEMS > 0 and #types == 1 and StaticData.LIMBS_TO_BODYLOCS_IND_BPT[self.limbName] then self:onMenuOptionSelected(types[1]) return true end diff --git a/media/lua/shared/TOC/Debug.lua b/media/lua/shared/TOC/Debug.lua index 82b7747..9b0deba 100644 --- a/media/lua/shared/TOC/Debug.lua +++ b/media/lua/shared/TOC/Debug.lua @@ -63,7 +63,7 @@ function TOC_DEBUG.TestBodyDamage(id) if bd then TOC_DEBUG.print("bd for " .. pl:getUsername() .. " exists") - local bptEnum = StaticData.BODYLOCS_IND_BPT["Hand_L"] + local bptEnum = StaticData.LIMBS_TO_BODYLOCS_IND_BPT["Hand_L"] local bodyPart = bd:getBodyPart(bptEnum) bodyPart:setBleeding(true) diff --git a/media/lua/shared/TOC/StaticData.lua b/media/lua/shared/TOC/StaticData.lua index 14c4349..053266e 100644 --- a/media/lua/shared/TOC/StaticData.lua +++ b/media/lua/shared/TOC/StaticData.lua @@ -68,9 +68,12 @@ StaticData.LIMBS_ADJACENT_IND_STR = {} StaticData.LIMBS_CICATRIZATION_TIME_IND_NUM = {} StaticData.LIMBS_BASE_DAMAGE_IND_NUM = {} StaticData.LIMBS_TIME_MULTIPLIER_IND_NUM = {} -StaticData.BODYLOCS_IND_BPT = {} + +StaticData.LIMBS_TO_BODYLOCS_IND_BPT = {} -- {limbName = bodyLoc} +StaticData.BODYLOCS_TO_LIMBS_IND_STR = {} -- {bodyLoc = limbName} + -- FIXME You weren't considering surgeonFactor, which decreases that base time. Fuck mod 60 -- CicatrizationBaseTime should be mod 60 since we're using EveryHours to update the cicatrizationTime @@ -112,7 +115,14 @@ for side, _ in pairs(StaticData.SIDES_IND_STR) do -- Assembled strings table.insert(StaticData.LIMBS_STR, assembledName) -- We need a table like this to cycle through it easily StaticData.LIMBS_IND_STR[assembledName] = assembledName - StaticData.BODYLOCS_IND_BPT[assembledName] = BodyPartType[assembledName] + + + -- BodyParts stuff + local bptString = BodyPartType.ToString(BodyPartType[assembledName]:getType()) + + + StaticData.LIMBS_TO_BODYLOCS_IND_BPT[assembledName] = BodyPartType[assembledName] + StaticData.BODYLOCS_TO_LIMBS_IND_STR[bptString] = assembledName -- Dependencies and cicatrization time if part == StaticData.PARTS_IND_STR.Hand then @@ -147,7 +157,7 @@ end -- TODO We can do this in one pass if we do it before -StaticData.AMP_GROUP_TO_LIMBS_MATCH_IND_STR = {} -- THis is probably unnecessary +StaticData.AMP_GROUP_TO_LIMBS_MATCH_IND_STR = {} -- This is probably unnecessary StaticData.LIMBS_TO_AMP_GROUPS_MATCH_IND_STR = {} for side, _ in pairs(StaticData.SIDES_IND_STR) do