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
|
self.tocData.limbs[limbName].isCicatrized = isCicatrized
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---Set isCauterized
|
||||||
|
---@param limbName string
|
||||||
|
---@param isCauterized boolean
|
||||||
|
function ModDataHandler:setIsCauterized(limbName, isCauterized)
|
||||||
|
self.tocData.limbs[limbName].isCauterized = isCauterized
|
||||||
|
end
|
||||||
|
|
||||||
---Set cicatrizationTime
|
---Set cicatrizationTime
|
||||||
---@param limbName string
|
---@param limbName string
|
||||||
---@param cicatrizationTime number
|
---@param cicatrizationTime number
|
||||||
@@ -173,6 +180,13 @@ function ModDataHandler:getIsCicatrized(limbName)
|
|||||||
return self.tocData.limbs[limbName].isCicatrized
|
return self.tocData.limbs[limbName].isCicatrized
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---Get isCauterized
|
||||||
|
---@param limbName string
|
||||||
|
---@return boolean
|
||||||
|
function ModDataHandler:getIsCauterized(limbName)
|
||||||
|
return self.tocData.limbs[limbName].isCauterized
|
||||||
|
end
|
||||||
|
|
||||||
---Get cicatrizationTime
|
---Get cicatrizationTime
|
||||||
---@param limbName string
|
---@param limbName string
|
||||||
---@return number
|
---@return number
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ local StaticData = require("TOC/StaticData")
|
|||||||
|
|
||||||
---@class PlayerHandler
|
---@class PlayerHandler
|
||||||
---@field playerObj IsoPlayer
|
---@field playerObj IsoPlayer
|
||||||
|
---@field username string
|
||||||
---@field hasBeenDamaged boolean
|
---@field hasBeenDamaged boolean
|
||||||
local PlayerHandler = {}
|
local PlayerHandler = {}
|
||||||
|
|
||||||
@@ -25,6 +26,7 @@ function PlayerHandler.InitializePlayer(playerObj, isForced)
|
|||||||
|
|
||||||
ModDataHandler:new(username, isForced)
|
ModDataHandler:new(username, isForced)
|
||||||
PlayerHandler.playerObj = playerObj
|
PlayerHandler.playerObj = playerObj
|
||||||
|
PlayerHandler.username = username
|
||||||
|
|
||||||
-- Calculate amputated limbs and highest point of amputations at startup
|
-- Calculate amputated limbs and highest point of amputations at startup
|
||||||
CachedDataHandler.CalculateAmputatedLimbs(username)
|
CachedDataHandler.CalculateAmputatedLimbs(username)
|
||||||
@@ -57,6 +59,8 @@ function PlayerHandler.ManageTraits(playerObj)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--* Health management *--
|
||||||
|
|
||||||
---Used to heal an area that has been cut previously. There's an exception for bites, those are managed differently
|
---Used to heal an area that has been cut previously. There's an exception for bites, those are managed differently
|
||||||
---@param bodyPart BodyPart
|
---@param bodyPart BodyPart
|
||||||
function PlayerHandler.HealArea(bodyPart)
|
function PlayerHandler.HealArea(bodyPart)
|
||||||
@@ -95,6 +99,18 @@ function PlayerHandler.HealZombieInfection(bodyDamage, bodyPart, limbName, modDa
|
|||||||
modDataHandler:apply()
|
modDataHandler:apply()
|
||||||
end
|
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 *--
|
--* Events *--
|
||||||
--- Locks OnPlayerGetDamage event, to prevent it from getting spammed constantly
|
--- Locks OnPlayerGetDamage event, to prevent it from getting spammed constantly
|
||||||
@@ -256,18 +272,26 @@ function ISBaseTimedAction:adjustMaxTime(maxTime)
|
|||||||
return time
|
return time
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--* Random bleeding during cicatrization + Perks leveling override *--
|
||||||
local og_ISBaseTimedAction_perform = ISBaseTimedAction.perform
|
local og_ISBaseTimedAction_perform = ISBaseTimedAction.perform
|
||||||
--- After each action, level up perks
|
--- After each action, level up perks
|
||||||
---@diagnostic disable-next-line: duplicate-set-field
|
---@diagnostic disable-next-line: duplicate-set-field
|
||||||
function ISBaseTimedAction:perform()
|
function ISBaseTimedAction:perform()
|
||||||
og_ISBaseTimedAction_perform(self)
|
og_ISBaseTimedAction_perform(self)
|
||||||
|
|
||||||
|
local modDataHandler = ModDataHandler.GetInstance()
|
||||||
|
if not modDataHandler:getIsAnyLimbCut() then return end
|
||||||
|
|
||||||
if ModDataHandler.GetInstance():getIsAnyLimbCut() then
|
local amputatedLimbs = CachedDataHandler.GetAmputatedLimbs(PlayerHandler.username)
|
||||||
for side, _ in pairs(StaticData.SIDES_IND_STR) do
|
for i=1, #amputatedLimbs do
|
||||||
local limbName = "Hand_" .. side
|
local limbName = amputatedLimbs[i]
|
||||||
if ModDataHandler.GetInstance():getIsCut(limbName) then
|
if modDataHandler:getIsCut(limbName) then
|
||||||
PlayerHandler.playerObj:getXp():AddXP(Perks["Side_" .. side], 2) -- TODO Make it dynamic
|
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
|
end
|
||||||
end
|
end
|
||||||
@@ -430,4 +454,5 @@ function ISEquipWeaponAction:perform()
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return PlayerHandler
|
return PlayerHandler
|
||||||
@@ -9,8 +9,9 @@ local ProsthesisHandler = {}
|
|||||||
|
|
||||||
local bodyLocArmProst = StaticData.MOD_BODYLOCS_BASE_IND_STR.TOC_ArmProst
|
local bodyLocArmProst = StaticData.MOD_BODYLOCS_BASE_IND_STR.TOC_ArmProst
|
||||||
|
|
||||||
---comment
|
---Check if the following item is a prosthesis or not
|
||||||
---@param item InventoryItem
|
---@param item InventoryItem
|
||||||
|
---@return boolean
|
||||||
function ProsthesisHandler.CheckIfProst(item)
|
function ProsthesisHandler.CheckIfProst(item)
|
||||||
-- TODO Won't be correct when prost for legs are gonna be in
|
-- TODO Won't be correct when prost for legs are gonna be in
|
||||||
return item:getBodyLocation():contains(bodyLocArmProst)
|
return item:getBodyLocation():contains(bodyLocArmProst)
|
||||||
|
|||||||
@@ -2,9 +2,10 @@ local ModDataHandler = require("TOC/Handlers/ModDataHandler")
|
|||||||
|
|
||||||
---@class SurgeryHandler
|
---@class SurgeryHandler
|
||||||
---@field type string
|
---@field type string
|
||||||
|
---@field limbName string
|
||||||
local SurgeryHandler = {}
|
local SurgeryHandler = {}
|
||||||
|
|
||||||
function SurgeryHandler:new(type)
|
function SurgeryHandler:new(type, limbName)
|
||||||
local o = {}
|
local o = {}
|
||||||
setmetatable(o, self)
|
setmetatable(o, self)
|
||||||
self.__index = self
|
self.__index = self
|
||||||
@@ -12,15 +13,23 @@ function SurgeryHandler:new(type)
|
|||||||
|
|
||||||
-- TODO use getjob for this
|
-- TODO use getjob for this
|
||||||
o.type = type
|
o.type = type
|
||||||
|
o.limbName = limbName
|
||||||
|
|
||||||
return o
|
return o
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- TODO Should we consider stitching as "operating?"
|
||||||
|
|
||||||
function SurgeryHandler:execute()
|
function SurgeryHandler:execute()
|
||||||
if self.type == "needle" then
|
if self.type == "needle" then
|
||||||
-- TODO
|
-- TODO
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
if self.type == "oven" then
|
||||||
|
ModDataHandler.GetInstance():setIsCauterized(self.limbName, true)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
---@alias partData { isCut : boolean?, isInfected : boolean?, isOperated : boolean?, isCicatrized : boolean?, isCauterized : boolean?, isVisible : boolean?, cicatrizationTime : number }
|
---@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 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 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 }
|
---@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.LIMBS_TIME_MULTIPLIER_IND_NUM = {}
|
||||||
StaticData.BODYLOCS_IND_BPT = {}
|
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
|
-- CicatrizationBaseTime should be mod 60 since we're using EveryHours to update the cicatrizationTime
|
||||||
|
|
||||||
---@param assembledName string
|
---@param assembledName string
|
||||||
@@ -129,6 +131,35 @@ for side, _ in pairs(StaticData.SIDES_IND_STR) do
|
|||||||
end
|
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
|
--* Traits
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user