Added another static table, cicatrization fixes, random bleeding when prost is equipped but isCicatrized is false
This commit is contained in:
@@ -116,6 +116,13 @@ function ModDataHandler:setIsCicatrized(limbName, isCicatrized)
|
||||
self.tocData.limbs[limbName].isCicatrized = isCicatrized
|
||||
end
|
||||
|
||||
---Set isCauterized
|
||||
---@param limbName string
|
||||
---@param isCauterized boolean
|
||||
function ModDataHandler:setIsCauterized(limbName, isCauterized)
|
||||
self.tocData.limbs[limbName].isCauterized = isCauterized
|
||||
end
|
||||
|
||||
---Set cicatrizationTime
|
||||
---@param limbName string
|
||||
---@param cicatrizationTime number
|
||||
@@ -173,6 +180,13 @@ function ModDataHandler:getIsCicatrized(limbName)
|
||||
return self.tocData.limbs[limbName].isCicatrized
|
||||
end
|
||||
|
||||
---Get isCauterized
|
||||
---@param limbName string
|
||||
---@return boolean
|
||||
function ModDataHandler:getIsCauterized(limbName)
|
||||
return self.tocData.limbs[limbName].isCauterized
|
||||
end
|
||||
|
||||
---Get cicatrizationTime
|
||||
---@param limbName string
|
||||
---@return number
|
||||
|
||||
@@ -13,6 +13,7 @@ local StaticData = require("TOC/StaticData")
|
||||
|
||||
---@class PlayerHandler
|
||||
---@field playerObj IsoPlayer
|
||||
---@field username string
|
||||
---@field hasBeenDamaged boolean
|
||||
local PlayerHandler = {}
|
||||
|
||||
@@ -25,6 +26,7 @@ function PlayerHandler.InitializePlayer(playerObj, isForced)
|
||||
|
||||
ModDataHandler:new(username, isForced)
|
||||
PlayerHandler.playerObj = playerObj
|
||||
PlayerHandler.username = username
|
||||
|
||||
-- Calculate amputated limbs and highest point of amputations at startup
|
||||
CachedDataHandler.CalculateAmputatedLimbs(username)
|
||||
@@ -57,6 +59,8 @@ function PlayerHandler.ManageTraits(playerObj)
|
||||
end
|
||||
end
|
||||
|
||||
--* Health management *--
|
||||
|
||||
---Used to heal an area that has been cut previously. There's an exception for bites, those are managed differently
|
||||
---@param bodyPart BodyPart
|
||||
function PlayerHandler.HealArea(bodyPart)
|
||||
@@ -95,6 +99,18 @@ function PlayerHandler.HealZombieInfection(bodyDamage, bodyPart, limbName, modDa
|
||||
modDataHandler:apply()
|
||||
end
|
||||
|
||||
---comment
|
||||
---@param character IsoPlayer
|
||||
---@param limbName string
|
||||
function PlayerHandler.TryRandomBleed(character, limbName)
|
||||
local chance = ZombRand(0,100)
|
||||
if chance > 50 then
|
||||
TOC_DEBUG.print("Triggered bleeding from non cicatrized wound")
|
||||
local adjacentBodyPartType = BodyPartType[StaticData.LIMBS_ADJACENT_IND_STR[limbName]]
|
||||
character:getBodyDamage():getBodyPart(adjacentBodyPartType):setBleeding(true)
|
||||
character:getBodyDamage():getBodyPart(adjacentBodyPartType):setBleedingTime(20)
|
||||
end
|
||||
end
|
||||
-------------------------
|
||||
--* Events *--
|
||||
--- Locks OnPlayerGetDamage event, to prevent it from getting spammed constantly
|
||||
@@ -256,18 +272,26 @@ function ISBaseTimedAction:adjustMaxTime(maxTime)
|
||||
return time
|
||||
end
|
||||
|
||||
|
||||
--* Random bleeding during cicatrization + Perks leveling override *--
|
||||
local og_ISBaseTimedAction_perform = ISBaseTimedAction.perform
|
||||
--- After each action, level up perks
|
||||
---@diagnostic disable-next-line: duplicate-set-field
|
||||
function ISBaseTimedAction:perform()
|
||||
og_ISBaseTimedAction_perform(self)
|
||||
|
||||
local modDataHandler = ModDataHandler.GetInstance()
|
||||
if not modDataHandler:getIsAnyLimbCut() then return end
|
||||
|
||||
if ModDataHandler.GetInstance():getIsAnyLimbCut() then
|
||||
for side, _ in pairs(StaticData.SIDES_IND_STR) do
|
||||
local limbName = "Hand_" .. side
|
||||
if ModDataHandler.GetInstance():getIsCut(limbName) then
|
||||
PlayerHandler.playerObj:getXp():AddXP(Perks["Side_" .. side], 2) -- TODO Make it dynamic
|
||||
local amputatedLimbs = CachedDataHandler.GetAmputatedLimbs(PlayerHandler.username)
|
||||
for i=1, #amputatedLimbs do
|
||||
local limbName = amputatedLimbs[i]
|
||||
if modDataHandler:getIsCut(limbName) then
|
||||
local side = CommonMethods.GetSide(limbName)
|
||||
PlayerHandler.playerObj:getXp():AddXP(Perks["Side_" .. side], 1) -- TODO Make it dynamic
|
||||
local prostGroup = StaticData.LIMBS_TO_PROST_GROUP_MATCH_IND_STR[limbName]
|
||||
if not modDataHandler:getIsCicatrized(limbName) and modDataHandler:getIsProstEquipped(prostGroup) then
|
||||
PlayerHandler.TryRandomBleed(self.character, limbName)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -430,4 +454,5 @@ function ISEquipWeaponAction:perform()
|
||||
end
|
||||
|
||||
|
||||
|
||||
return PlayerHandler
|
||||
@@ -9,8 +9,9 @@ local ProsthesisHandler = {}
|
||||
|
||||
local bodyLocArmProst = StaticData.MOD_BODYLOCS_BASE_IND_STR.TOC_ArmProst
|
||||
|
||||
---comment
|
||||
---Check if the following item is a prosthesis or not
|
||||
---@param item InventoryItem
|
||||
---@return boolean
|
||||
function ProsthesisHandler.CheckIfProst(item)
|
||||
-- TODO Won't be correct when prost for legs are gonna be in
|
||||
return item:getBodyLocation():contains(bodyLocArmProst)
|
||||
|
||||
@@ -2,9 +2,10 @@ local ModDataHandler = require("TOC/Handlers/ModDataHandler")
|
||||
|
||||
---@class SurgeryHandler
|
||||
---@field type string
|
||||
---@field limbName string
|
||||
local SurgeryHandler = {}
|
||||
|
||||
function SurgeryHandler:new(type)
|
||||
function SurgeryHandler:new(type, limbName)
|
||||
local o = {}
|
||||
setmetatable(o, self)
|
||||
self.__index = self
|
||||
@@ -12,15 +13,23 @@ function SurgeryHandler:new(type)
|
||||
|
||||
-- TODO use getjob for this
|
||||
o.type = type
|
||||
o.limbName = limbName
|
||||
|
||||
return o
|
||||
end
|
||||
|
||||
|
||||
-- TODO Should we consider stitching as "operating?"
|
||||
|
||||
function SurgeryHandler:execute()
|
||||
if self.type == "needle" then
|
||||
-- TODO
|
||||
end
|
||||
|
||||
|
||||
if self.type == "oven" then
|
||||
ModDataHandler.GetInstance():setIsCauterized(self.limbName, true)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user