Time action handling

This commit is contained in:
ZioPao
2023-11-10 01:11:00 +01:00
parent c8cd318f2d
commit 7557a13544
5 changed files with 108 additions and 32 deletions

View File

@@ -2,7 +2,7 @@ local StaticData = require("TOC_StaticData")
---------------- ----------------
---@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 tocModData {Hand_L : partData, ForeArm_L : partData, UpperArm_L : partData, Hand_R : partData, ForeArm_R : partData, UpperArm_R : partData, isIgnoredPartInfected : boolean} ---@alias tocModData {Hand_L : partData, ForeArm_L : partData, UpperArm_L : partData, Hand_R : partData, ForeArm_R : partData, UpperArm_R : partData, isIgnoredPartInfected : boolean, isAnyLimbCut : boolean}
---------------- ----------------
-- TODO This class should handle all the stuff related to the mod data -- TODO This class should handle all the stuff related to the mod data
@@ -44,7 +44,8 @@ function ModDataHandler:createData()
modData[StaticData.MOD_NAME] = { modData[StaticData.MOD_NAME] = {
-- Generic stuff that does not belong anywhere else -- Generic stuff that does not belong anywhere else
isIgnoredPartInfected = false isIgnoredPartInfected = false,
isAnyLimbCut = false
} }
---@type partData ---@type partData
@@ -65,7 +66,14 @@ end
----------------- -----------------
--* Setters *-- --* Setters *--
---Set isCut ---Set a generic boolean that toggles varies function of the mod
---@param isAnyLimbCut boolean
function ModDataHandler:setIsAnyLimbCut(isAnyLimbCut)
self.tocData.isAnyLimbCut = true
end
---Set isCut
---@param limbName string ---@param limbName string
---@param isCut boolean ---@param isCut boolean
function ModDataHandler:setIsCut(limbName, isCut) function ModDataHandler:setIsCut(limbName, isCut)
@@ -87,6 +95,14 @@ end
----------------- -----------------
--* Getters *-- --* Getters *--
---Set a generic boolean that toggles varies function of the mod
---@return boolean
function ModDataHandler:getIsAnyLimbCut()
return self.tocData.isAnyLimbCut
end
---Get isCut ---Get isCut
---@param limbName string ---@param limbName string
---@return boolean ---@return boolean
@@ -134,6 +150,9 @@ function ModDataHandler:setCutLimb(limbName, isOperated, isCicatrized, isCauteri
self:setLimbParams(dependedLimbName, {isCut = true, isInfected = false, isVisible = false}, 0) self:setLimbParams(dependedLimbName, {isCut = true, isInfected = false, isVisible = false}, 0)
end end
-- Set that a limb has been cut, to activate some functions without having to loop through the parts
self:setIsAnyLimbCut(true)
-- Set the highest amputation and caches them. -- Set the highest amputation and caches them.
ISHealthPanel.GetHighestAmputation() ISHealthPanel.GetHighestAmputation()
end end

View File

@@ -1,6 +1,7 @@
local ModDataHandler = require("Handlers/TOC_ModDataHandler") local ModDataHandler = require("Handlers/TOC_ModDataHandler")
local AmputationHandler = require("Handlers/TOC_AmputationHandler") local AmputationHandler = require("Handlers/TOC_AmputationHandler")
local ItemsHandler = require("Handlers/TOC_ItemsHandler") local ItemsHandler = require("Handlers/TOC_ItemsHandler")
local CommonMethods = require("TOC_Common")
local StaticData = require("TOC_StaticData") local StaticData = require("TOC_StaticData")
----------- -----------
@@ -51,7 +52,6 @@ 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()
if bd == nil then return end -- Not sure why sometimes we get no BodyDamage, so just return this for now
for i=1, #StaticData.LIMBS_STRINGS do for i=1, #StaticData.LIMBS_STRINGS do
local limbName = StaticData.LIMBS_STRINGS[i] local limbName = StaticData.LIMBS_STRINGS[i]
local bptEnum = StaticData.BODYPARTSTYPES_ENUM[limbName] local bptEnum = StaticData.BODYPARTSTYPES_ENUM[limbName]
@@ -82,7 +82,7 @@ end
Events.OnPlayerGetDamage.Add(PlayerHandler.CheckInfection) Events.OnPlayerGetDamage.Add(PlayerHandler.CheckInfection)
---comment ---Handle perks
---@param player IsoPlayer ---@param player IsoPlayer
function PlayerHandler.UpdatePerks(player) 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 If player has an amputated limb, they're gonna level up them while doing normal stuff, getting better at it dynamically
@@ -92,11 +92,50 @@ function PlayerHandler.UpdatePerks(player)
for side, _ in pairs(StaticData.SIDES_STRINGS) do for side, _ in pairs(StaticData.SIDES_STRINGS) do
local limbName = "Hand_" .. side local limbName = "Hand_" .. side
if ModDataHandler.GetInstance():getIsCut(limbName) then if ModDataHandler.GetInstance():getIsCut(limbName) then
player:getXp():AddXP(Perks[limbName], 0.1) player:getXp():AddXP(Perks["Side_" .. side], 0.1)
end end
end end
end end
Events.OnPlayerUpdate.Add(PlayerHandler.UpdatePerks) Events.OnPlayerUpdate.Add(PlayerHandler.UpdatePerks)
local og_ISBaseTimedAction_adjustMaxTime = ISBaseTimedAction.adjustMaxTime
function ISBaseTimedAction:adjustMaxTime(maxTime)
local time = og_ISBaseTimedAction_adjustMaxTime(self, maxTime)
local modDataHandler = ModDataHandler.GetInstance()
if time ~= -1 and modDataHandler and modDataHandler:getIsAnyLimbCut() then
local pl = getPlayer()
for i=1, #StaticData.LIMBS_STRINGS do
local limbName = StaticData.LIMBS_STRINGS[i]
if modDataHandler:getIsCut(limbName) then
--print("TOC: cut limb " .. limbName)
--print("TOC: cTime" .. tostring(time))
local perk = Perks["Side_" .. CommonMethods.GetSide(limbName)]
local perkLevel = pl:getPerkLevel(perk)
local perkLevelScaled
if perkLevel ~= 0 then
perkLevelScaled = perkLevel / 10
else
perkLevelScaled = 0
end
--print("TOC: perk level for this side: " .. tonumber(perkLevel))
--print("TOC: perk scaling for this side: " .. tonumber(perkLevelScaled))
time = time * (StaticData.LIMBS_TIME_MULTIPLIER[limbName] - perkLevelScaled)
end
end
--print("TOC: new time " .. tostring(time))
end
return time
end
return PlayerHandler return PlayerHandler

View File

@@ -9,7 +9,8 @@ StaticData.PARTS_STRINGS = {
UpperArm = "UpperArm" UpperArm = "UpperArm"
} }
StaticData.IGNORED_PARTS_STRINGS = { "Foot_L", "Foot_R", "Groin", "Head", "LowerLeg_L", "LowerLeg_R", "MAX", "Neck", "Torso_Lower", "Torso_Upper", "UpperLeg_L", "UpperLeg_R" } -- No "MAX" here.
StaticData.IGNORED_PARTS_STRINGS = { "Foot_L", "Foot_R", "Groin", "Head", "LowerLeg_L", "LowerLeg_R", "Neck", "Torso_Lower", "Torso_Upper", "UpperLeg_L", "UpperLeg_R" }
StaticData.SIDES_STRINGS = { StaticData.SIDES_STRINGS = {
R = "R", R = "R",
@@ -22,6 +23,7 @@ StaticData.BODYPARTSTYPES_ENUM = {}
StaticData.LIMBS_DEPENDENCIES = {} StaticData.LIMBS_DEPENDENCIES = {}
StaticData.LIMBS_CICATRIZATION_TIME = {} StaticData.LIMBS_CICATRIZATION_TIME = {}
StaticData.LIMBS_BASE_DAMAGE = {} StaticData.LIMBS_BASE_DAMAGE = {}
StaticData.LIMBS_TIME_MULTIPLIER = {}
-- Link a trait to a specific body part -- Link a trait to a specific body part
@@ -31,6 +33,30 @@ StaticData.TRAITS_BP = {
AmputeeUpeerArm = "UpperArm_L" AmputeeUpeerArm = "UpperArm_L"
} }
local function AssembleHandData(assembledName)
StaticData.LIMBS_BASE_DAMAGE[assembledName] = 60
StaticData.LIMBS_CICATRIZATION_TIME[assembledName] = 1700
StaticData.LIMBS_TIME_MULTIPLIER[assembledName] = 2
StaticData.LIMBS_DEPENDENCIES[assembledName] = {}
end
local function AssembleForearmData(assembledName, side)
StaticData.LIMBS_BASE_DAMAGE[assembledName] = 80
StaticData.LIMBS_CICATRIZATION_TIME[assembledName] = 1800
StaticData.LIMBS_TIME_MULTIPLIER[assembledName] = 3
StaticData.LIMBS_DEPENDENCIES[assembledName] = { StaticData.PARTS_STRINGS.Hand .. "_" .. side }
end
local function AssembleUpperarmData(assembledName, side)
StaticData.LIMBS_BASE_DAMAGE[assembledName] = 100
StaticData.LIMBS_CICATRIZATION_TIME[assembledName] = 2000
StaticData.LIMBS_TIME_MULTIPLIER[assembledName] = 4
StaticData.LIMBS_DEPENDENCIES[assembledName] = { StaticData.PARTS_STRINGS.Hand .. "_" .. side,
StaticData.PARTS_STRINGS.ForeArm .. "_" .. side }
end
for side, _ in pairs(StaticData.SIDES_STRINGS) do for side, _ in pairs(StaticData.SIDES_STRINGS) do
for part, _ in pairs(StaticData.PARTS_STRINGS) do for part, _ in pairs(StaticData.PARTS_STRINGS) do
local assembledName = part .. "_" .. side local assembledName = part .. "_" .. side
@@ -41,22 +67,21 @@ for side, _ in pairs(StaticData.SIDES_STRINGS) do
-- Dependencies and cicatrization time -- Dependencies and cicatrization time
if part == StaticData.PARTS_STRINGS.Hand then if part == StaticData.PARTS_STRINGS.Hand then
StaticData.LIMBS_BASE_DAMAGE[assembledName] = 60 AssembleHandData(assembledName)
StaticData.LIMBS_CICATRIZATION_TIME[assembledName] = 1700
StaticData.LIMBS_DEPENDENCIES[assembledName] = {}
elseif part == StaticData.PARTS_STRINGS.ForeArm then elseif part == StaticData.PARTS_STRINGS.ForeArm then
StaticData.LIMBS_BASE_DAMAGE[assembledName] = 80 AssembleForearmData(assembledName, side)
StaticData.LIMBS_CICATRIZATION_TIME[assembledName] = 1800
StaticData.LIMBS_DEPENDENCIES[assembledName] = { StaticData.PARTS_STRINGS.Hand .. "_" .. side, }
elseif part == StaticData.PARTS_STRINGS.UpperArm then elseif part == StaticData.PARTS_STRINGS.UpperArm then
StaticData.LIMBS_BASE_DAMAGE[assembledName] = 100 AssembleUpperarmData(assembledName, side)
StaticData.LIMBS_CICATRIZATION_TIME[assembledName] = 2000
StaticData.LIMBS_DEPENDENCIES[assembledName] = { StaticData.PARTS_STRINGS.Hand .. "_" .. side,
StaticData.PARTS_STRINGS.ForeArm .. "_" .. side }
end end
end end
end end
-----------------
-- Visuals and clothing
--- Textures --- Textures
-- TODO We need male variations -- TODO We need male variations
StaticData.HEALTH_PANEL_TEXTURES = { StaticData.HEALTH_PANEL_TEXTURES = {
@@ -73,13 +98,6 @@ StaticData.HEALTH_PANEL_TEXTURES = {
} }
-----------------
-- Visuals and clothing
StaticData.AMPUTATION_CLOTHING_ITEM_BASE = "TOC.Amputation_" StaticData.AMPUTATION_CLOTHING_ITEM_BASE = "TOC.Amputation_"

View File

@@ -1,7 +1,7 @@
IG_UI_EN = { IG_UI_EN = {
IGUI_perks_Amputations = "Amputations", IGUI_perks_Amputations = "Amputations",
IGUI_perks_Hand_R = "Right Hand", IGUI_perks_Side_R = "Right Side",
IGUI_perks_Hand_L = "Left Hand", IGUI_perks_Side_L = "Left Side",
IGUI_perks_Prosthesis = "Prosthesis", IGUI_perks_Prosthesis = "Prosthesis",
IGUI_perks_ProstFamiliarity= "Familiarity", IGUI_perks_ProstFamiliarity= "Familiarity",

View File

@@ -16,11 +16,11 @@ perk Amputations
xp9 = 0, xp9 = 0,
xp10 = 0, xp10 = 0,
} }
perk Hand_L perk Side_L
{ {
parent = Amputations, parent = Amputations,
name = Hand_L, name = Side_L,
translation = Hand_L, translation = Side_L,
passive = false, passive = false,
xp1 = 50, xp1 = 50,
xp2 = 100, xp2 = 100,
@@ -33,11 +33,11 @@ perk Hand_L
xp9 = 7000, xp9 = 7000,
xp10 = 9000, xp10 = 9000,
} }
perk Hand_R perk Side_R
{ {
parent = Amputations, parent = Amputations,
name = Hand_R, name = Side_R,
translation = Hand_R, translation = Side_R,
passive = false, passive = false,
xp1 = 50, xp1 = 50,
xp2 = 100, xp2 = 100,