Fixed Cheats and TOC interactability

This commit is contained in:
ZioPao
2024-05-02 12:46:47 +02:00
parent b1adefe8f3
commit 5dc328ebc2
6 changed files with 43 additions and 12 deletions

View File

@@ -1,4 +1,6 @@
local CommandsData = require("TOC/CommandsData") local CommandsData = require("TOC/CommandsData")
local StaticData = require("TOC/StaticData")
local DataController = require("TOC/Controllers/DataController")
------------------- -------------------
---@param playerNum number ---@param playerNum number
@@ -50,14 +52,33 @@ Events.OnFillWorldObjectContextMenu.Add(AddAdminTocOptions)
local og_ISHealthPanel_onCheatCurrentPlayer = ISHealthPanel.onCheatCurrentPlayer 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) function ISHealthPanel.onCheatCurrentPlayer(bodyPart, action, player)
og_ISHealthPanel_onCheatCurrentPlayer(bodyPart, action, player) og_ISHealthPanel_onCheatCurrentPlayer(bodyPart, action, player)
local bptString = BodyPartType.ToString(bodyPart:getType())
if action == "healthFullBody" then 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 end
if action == "healthFull" then 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
end end

View File

@@ -143,7 +143,7 @@ function LocalPlayerController.HandleDamage(character)
local modDataNeedsUpdate = false local modDataNeedsUpdate = false
for i = 1, #StaticData.LIMBS_STR do for i = 1, #StaticData.LIMBS_STR do
local limbName = StaticData.LIMBS_STR[i] 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) local bodyPart = bd:getBodyPart(bptEnum)
if dcInst:getIsCut(limbName) then if dcInst:getIsCut(limbName) then
-- Generic injury, let's heal it since they already cut the limb off -- Generic injury, let's heal it since they already cut the limb off

View File

@@ -89,7 +89,7 @@ end
---@param stitchesItem InventoryItem ---@param stitchesItem InventoryItem
---@return ISStitch ---@return ISStitch
function AmputationHandler.PrepareStitchesAction(prevAction, limbName, surgeonPl, patientPl, stitchesItem) 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 bd = patientPl:getBodyDamage()
local bodyPart = bd:getBodyPart(bptEnum) local bodyPart = bd:getBodyPart(bptEnum)
local stitchesAction = ISStitch:new(surgeonPl, patientPl, stitchesItem, bodyPart, true) local stitchesAction = ISStitch:new(surgeonPl, patientPl, stitchesItem, bodyPart, true)
@@ -106,7 +106,7 @@ end
---@param bandageItem InventoryItem ---@param bandageItem InventoryItem
---@return ISApplyBandage ---@return ISApplyBandage
function AmputationHandler.PrepareBandagesAction(prevAction, limbName, surgeonPl, patientPl, bandageItem) 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 bd = patientPl:getBodyDamage()
local bodyPart = bd:getBodyPart(bptEnum) local bodyPart = bd:getBodyPart(bptEnum)
local bandageAction = ISApplyBandage:new(surgeonPl, patientPl, bandageItem, bodyPart, true) local bandageAction = ISApplyBandage:new(surgeonPl, patientPl, bandageItem, bodyPart, true)

View File

@@ -219,7 +219,7 @@ function CutLimbInteractionHandler:addToMenu(context)
--TOC_DEBUG.print("CutLimbInteractionHandler addToMenu") --TOC_DEBUG.print("CutLimbInteractionHandler addToMenu")
local types = self:getAllItemTypes(self.items.ITEMS) local types = self:getAllItemTypes(self.items.ITEMS)
local patientUsername = self:getPatient():getUsername() 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") TOC_DEBUG.print("addToMenu, types > 0")
for i=1, #types do for i=1, #types do
context:addOption(getText("ContextMenu_Amputate"), self, self.onMenuOptionSelected, types[i]) context:addOption(getText("ContextMenu_Amputate"), self, self.onMenuOptionSelected, types[i])
@@ -229,7 +229,7 @@ end
function CutLimbInteractionHandler:dropItems(items) function CutLimbInteractionHandler:dropItems(items)
local types = self:getAllItemTypes(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]) self:onMenuOptionSelected(types[1])
return true return true
end end

View File

@@ -63,7 +63,7 @@ function TOC_DEBUG.TestBodyDamage(id)
if bd then if bd then
TOC_DEBUG.print("bd for " .. pl:getUsername() .. " exists") 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) local bodyPart = bd:getBodyPart(bptEnum)
bodyPart:setBleeding(true) bodyPart:setBleeding(true)

View File

@@ -68,9 +68,12 @@ StaticData.LIMBS_ADJACENT_IND_STR = {}
StaticData.LIMBS_CICATRIZATION_TIME_IND_NUM = {} StaticData.LIMBS_CICATRIZATION_TIME_IND_NUM = {}
StaticData.LIMBS_BASE_DAMAGE_IND_NUM = {} StaticData.LIMBS_BASE_DAMAGE_IND_NUM = {}
StaticData.LIMBS_TIME_MULTIPLIER_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 -- 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 -- 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 -- Assembled strings
table.insert(StaticData.LIMBS_STR, assembledName) -- We need a table like this to cycle through it easily table.insert(StaticData.LIMBS_STR, assembledName) -- We need a table like this to cycle through it easily
StaticData.LIMBS_IND_STR[assembledName] = assembledName 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 -- Dependencies and cicatrization time
if part == StaticData.PARTS_IND_STR.Hand then 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 -- 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 = {} StaticData.LIMBS_TO_AMP_GROUPS_MATCH_IND_STR = {}
for side, _ in pairs(StaticData.SIDES_IND_STR) do for side, _ in pairs(StaticData.SIDES_IND_STR) do