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
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
---@alias partData { isCut : boolean?, isInfected : boolean?, isOperated : boolean?, isCicatrized : boolean?, isCauterized : boolean?, isVisible : boolean?, cicatrizationTime : number }
|
||||
---@alias limbsTable {Hand_L : partData, ForeArm_L : partData, UpperArm_L : partData, Hand_R : partData, ForeArm_R : partData, UpperArm_R : partData }
|
||||
---@alias prosthesisData {isProstEquipped : boolean, prostFactor : number }
|
||||
---@alias prosthesesTable {top : prosthesisData, bottom : prosthesisData }
|
||||
---@alias prosthesesTable {Top_L : prosthesisData, Top_R : prosthesisData } -- TODO add Bottom_L and Bottom_R
|
||||
---@alias tocModData { limbs : limbsTable, prostheses : prosthesesTable, isIgnoredPartInfected : boolean, isAnyLimbCut : boolean }
|
||||
---------------------------
|
||||
|
||||
@@ -56,6 +56,8 @@ StaticData.LIMBS_BASE_DAMAGE_IND_NUM = {}
|
||||
StaticData.LIMBS_TIME_MULTIPLIER_IND_NUM = {}
|
||||
StaticData.BODYLOCS_IND_BPT = {}
|
||||
|
||||
|
||||
-- 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
|
||||
|
||||
---@param assembledName string
|
||||
@@ -129,6 +131,35 @@ for side, _ in pairs(StaticData.SIDES_IND_STR) do
|
||||
end
|
||||
|
||||
|
||||
-- TODO We can do this in one pass if we do it before
|
||||
|
||||
StaticData.PROST_TO_LIMBS_GROUP_MATCH_IND_STR = {} -- THis is probably unnecessary
|
||||
StaticData.LIMBS_TO_PROST_GROUP_MATCH_IND_STR = {}
|
||||
|
||||
for side, _ in pairs(StaticData.SIDES_IND_STR) do
|
||||
for part, _ in pairs(StaticData.PARTS_IND_STR) do
|
||||
local limbName = part .. "_" .. side
|
||||
local group
|
||||
if part == StaticData.PARTS_IND_STR.Hand or part == StaticData.PARTS_IND_STR.ForeArm or part == StaticData.PARTS_IND_STR.UpperArm then
|
||||
group = StaticData.PROSTHESES_GROUPS_BASE_IND_STR.Top
|
||||
else
|
||||
group = StaticData.PROSTHESES_GROUPS_BASE_IND_STR.Bottom
|
||||
end
|
||||
|
||||
local sidedGroup = group .. "_" .. side
|
||||
if StaticData.PROST_TO_LIMBS_GROUP_MATCH_IND_STR[sidedGroup] == nil then
|
||||
StaticData.PROST_TO_LIMBS_GROUP_MATCH_IND_STR[sidedGroup] = {}
|
||||
end
|
||||
table.insert(StaticData.PROST_TO_LIMBS_GROUP_MATCH_IND_STR[sidedGroup], limbName)
|
||||
|
||||
StaticData.LIMBS_TO_PROST_GROUP_MATCH_IND_STR[limbName] = sidedGroup
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
-----------------
|
||||
--* Traits
|
||||
|
||||
|
||||
Reference in New Issue
Block a user