Fixed Cheats and TOC interactability
This commit is contained in:
@@ -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
|
||||
end
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user