This commit is contained in:
ZioPao
2023-11-11 03:04:48 +01:00
parent 9459360948
commit 2cf794552f
7 changed files with 19 additions and 52 deletions

View File

@@ -101,25 +101,17 @@ end
local og_ISInventoryPane_refreshContainer = ISInventoryPane.refreshContainer local og_ISInventoryPane_refreshContainer = ISInventoryPane.refreshContainer
---Get the list of items for the container and remove the amputations ---Get the list of items for the container and remove the reference to the amputation items
function ISInventoryPane:refreshContainer() function ISInventoryPane:refreshContainer()
-- Search into the container and remove the reference to the amputation item
og_ISInventoryPane_refreshContainer(self) og_ISInventoryPane_refreshContainer(self)
if TOC_DEBUG.disablePaneMod then return end if TOC_DEBUG.disablePaneMod then return end
for i=1, #self.itemslist do for i=1, #self.itemslist do
local cItem = self.itemslist[i] local cItem = self.itemslist[i]
if cItem and cItem.cat == "Amputation" then if cItem and cItem.cat == "Amputation" then
--print("TOC: current item is an amputation, removing it from the list") --print("TOC: current item is an amputation, removing it from the list")
table.remove(self.itemslist, i) table.remove(self.itemslist, i)
end end
end end
end end
return ItemsHandler return ItemsHandler

View File

@@ -34,7 +34,6 @@ function ModDataHandler:setup(force)
self:createData() self:createData()
end end
-- TODO Check compatibility or do we just skip it at this point? -- TODO Check compatibility or do we just skip it at this point?
end end
function ModDataHandler:createData() function ModDataHandler:createData()
@@ -61,10 +60,8 @@ function ModDataHandler:createData()
modData[StaticData.MOD_NAME][limbName] = {} modData[StaticData.MOD_NAME][limbName] = {}
self:setLimbParams(StaticData.LIMBS_STRINGS[i], defaultParams, 0) self:setLimbParams(StaticData.LIMBS_STRINGS[i], defaultParams, 0)
end end
end end
----------------- -----------------
--* Setters *-- --* Setters *--
@@ -74,7 +71,6 @@ function ModDataHandler:setIsAnyLimbCut(isAnyLimbCut)
self.tocData.isAnyLimbCut = true self.tocData.isAnyLimbCut = true
end end
---Set isCut ---Set isCut
---@param limbName string ---@param limbName string
---@param isCut boolean ---@param isCut boolean
@@ -104,7 +100,6 @@ function ModDataHandler:getIsAnyLimbCut()
return self.tocData.isAnyLimbCut return self.tocData.isAnyLimbCut
end end
---Get isCut ---Get isCut
---@param limbName string ---@param limbName string
---@return boolean ---@return boolean
@@ -124,8 +119,6 @@ function ModDataHandler:getIsVisible(limbName)
return self.tocData[limbName].isVisible return self.tocData[limbName].isVisible
end end
--* Limbs data handling *-- --* Limbs data handling *--
---Set a limb and its dependend limbs as cut ---Set a limb and its dependend limbs as cut
@@ -155,10 +148,8 @@ function ModDataHandler:setCutLimb(limbName, isOperated, isCicatrized, isCauteri
-- Set that a limb has been cut, to activate some functions without having to loop through the parts -- Set that a limb has been cut, to activate some functions without having to loop through the parts
self:setIsAnyLimbCut(true) self:setIsAnyLimbCut(true)
end end
---Internal use only, set a limb data ---Internal use only, set a limb data
---@param limbName string ---@param limbName string
---@param ampStatus partData {isCut, isInfected, isOperated, isCicatrized, isCauterized, isVisible} ---@param ampStatus partData {isCut, isInfected, isOperated, isCicatrized, isCauterized, isVisible}
@@ -176,8 +167,6 @@ function ModDataHandler:setLimbParams(limbName, ampStatus, cicatrizationTime)
if cicatrizationTime ~= nil then limbData.cicatrizationTime = cicatrizationTime end if cicatrizationTime ~= nil then limbData.cicatrizationTime = cicatrizationTime end
end end
---@return ModDataHandler ---@return ModDataHandler
function ModDataHandler.GetInstance() function ModDataHandler.GetInstance()
if ModDataHandler.instance ~= nil then if ModDataHandler.instance ~= nil then
@@ -187,7 +176,4 @@ function ModDataHandler.GetInstance()
end end
end end
return ModDataHandler return ModDataHandler

View File

@@ -66,6 +66,9 @@ function PlayerHandler.AddLocalAmputatedLimb(limbName)
end end
--* Getters *-- --* Getters *--
---Get a table with the strings of the amputated limbs
---@return table
function PlayerHandler.GetAmputatedLimbs() function PlayerHandler.GetAmputatedLimbs()
return PlayerHandler.amputatedLimbs or {} return PlayerHandler.amputatedLimbs or {}
end end
@@ -75,7 +78,6 @@ end
---Check if the player has an infected (as in, zombie infection) body part ---Check if the player has an infected (as in, zombie infection) body part
---@param character IsoGameCharacter ---@param character IsoGameCharacter
function PlayerHandler.CheckInfection(character) function PlayerHandler.CheckInfection(character)
-- This fucking event barely works. Bleeding seems to be the only thing that triggers it -- This fucking event barely works. Bleeding seems to be the only thing that triggers it
if character ~= getPlayer() then return end if character ~= getPlayer() then return end
local bd = character:getBodyDamage() local bd = character:getBodyDamage()
@@ -104,30 +106,12 @@ function PlayerHandler.CheckInfection(character)
PlayerHandler.modDataHandler:setIsIgnoredPartInfected(true) PlayerHandler.modDataHandler:setIsIgnoredPartInfected(true)
end end
end end
end end
Events.OnPlayerGetDamage.Add(PlayerHandler.CheckInfection) Events.OnPlayerGetDamage.Add(PlayerHandler.CheckInfection)
---Handle perks
---@param player IsoPlayer
function PlayerHandler.UpdatePerks(player)
-- TODO If player has an amputated limb, they're gonna level up them while doing normal stuff, getting better at it dynamically
-- TODO We should have a way to check if the player has done any amputation at all instead of having to check manually each time
-- TODO Should be run when player is doing stuff like picking up objects, not randomly --* Overrides *--
for side, _ in pairs(StaticData.SIDES_STRINGS) do
local limbName = "Hand_" .. side
if ModDataHandler.GetInstance():getIsCut(limbName) then
player:getXp():AddXP(Perks["Side_" .. side], 0.1)
end
end
end
--Events.OnPlayerUpdate.Add(PlayerHandler.UpdatePerks)
--* Some overrides *--
local og_ISBaseTimedAction_adjustMaxTime = ISBaseTimedAction.adjustMaxTime local og_ISBaseTimedAction_adjustMaxTime = ISBaseTimedAction.adjustMaxTime
--- Adjust time --- Adjust time
@@ -167,5 +151,4 @@ function ISBaseTimedAction:perform()
end end
return PlayerHandler return PlayerHandler

View File

@@ -76,9 +76,6 @@ for side, _ in pairs(StaticData.SIDES_STRINGS) do
end end
end end
----------------- -----------------
-- Visuals and clothing -- Visuals and clothing

View File

@@ -6,16 +6,23 @@ local ModDataHandler = require("Handlers/TOC_ModDataHandler")
--------------------- ---------------------
---comment ---Check if the item name corresponds to a compatible saw
---@param itemName string ---@param itemName string
local function CheckIfSaw(itemName) local function CheckIfSaw(itemName)
return itemName == "Saw" or itemName == "GardenSaw" or itemName == "Chainsaw" return itemName == "Saw" or itemName == "GardenSaw" or itemName == "Chainsaw"
end end
---Add the action to the queue
---@param limbName string
---@param surgeon IsoPlayer
---@param patient IsoPlayer
local function PerformAction(limbName, surgeon, patient) local function PerformAction(limbName, surgeon, patient)
ISTimedActionQueue.add(CutLimbAction:new(surgeon, patient, limbName)) ISTimedActionQueue.add(CutLimbAction:new(surgeon, patient, limbName))
end end
---Adds the actions to the inventory context menu
---@param surgeonNum number
---@param context ISUIElement
local function AddInventoryAmputationOptions(surgeonNum, context) local function AddInventoryAmputationOptions(surgeonNum, context)
local surgeonObj = getSpecificPlayer(surgeonNum) local surgeonObj = getSpecificPlayer(surgeonNum)
local option = context:addOption(getText("ContextMenu_Amputate"), nil) local option = context:addOption(getText("ContextMenu_Amputate"), nil)
@@ -30,8 +37,12 @@ local function AddInventoryAmputationOptions(surgeonNum, context)
end end
end end
---Handler for OnFillInventoryObjectContextMenu
---@param player number
---@param context ISUIElement
---@param items table
local function AddInventoryAmputationMenu(player, context, items) local function AddInventoryAmputationMenu(player, context, items)
local item = items[1] local item = items[1] -- Selected item
if CheckIfSaw(item.name) then if CheckIfSaw(item.name) then
AddInventoryAmputationOptions(player, context) AddInventoryAmputationOptions(player, context)
end end

View File

@@ -37,9 +37,7 @@ end
--* Modification to handle visible amputation on the health menu *-- --* Modification to handle visible amputation on the health menu *--
function ISHealthPanel.GetHighestAmputation() function ISHealthPanel.GetHighestAmputation()
-- TODO Cache this instead of doing it here!
ISHealthPanel.highestAmputations = {} ISHealthPanel.highestAmputations = {}
for i=1, #PlayerHandler.amputatedLimbs do for i=1, #PlayerHandler.amputatedLimbs do
local limbName = PlayerHandler.amputatedLimbs[i] local limbName = PlayerHandler.amputatedLimbs[i]

View File

@@ -1,4 +1,4 @@
-- Had to cop and paste this stuff from the base game since this is a local only class. Kinda shit, but eh -- Had to copy and paste this stuff from the base game since this is a local only class. Kinda shit, but eh
---@class BaseHandler : ISBaseObject ---@class BaseHandler : ISBaseObject
---@field panel ISUIElement ---@field panel ISUIElement