Added sandbox var for wound dirtyness

This commit is contained in:
ZioPao
2024-01-02 15:04:43 -05:00
parent f2007d56a9
commit 49832092b4
4 changed files with 25 additions and 13 deletions

View File

@@ -33,8 +33,8 @@ function PlayerHandler.InitializePlayer(playerObj, isForced)
CachedDataHandler.CalculateHighestAmputatedLimbs(username) CachedDataHandler.CalculateHighestAmputatedLimbs(username)
--Setup the CicatrizationUpdate event and triggers it once --Setup the CicatrizationUpdate event and triggers it once
Events.OnAmputatedLimb.Add(PlayerHandler.ToggleCicatrizationUpdate) Events.OnAmputatedLimb.Add(PlayerHandler.ToggleUpdateAmputations)
PlayerHandler.ToggleCicatrizationUpdate() PlayerHandler.ToggleUpdateAmputations()
-- Since isForced is used to reset an existing player data, we're gonna clean their ISHealthPanel table too -- Since isForced is used to reset an existing player data, we're gonna clean their ISHealthPanel table too
if isForced then if isForced then
@@ -203,10 +203,10 @@ end
Events.OnPlayerGetDamage.Add(PlayerHandler.OnGetDamage) Events.OnPlayerGetDamage.Add(PlayerHandler.OnGetDamage)
---Updates the cicatrization process, run when a limb has been cut. Run it every 1 hour ---Updates the cicatrization process, run when a limb has been cut. Run it every 1 hour
function PlayerHandler.UpdateCicatrization() function PlayerHandler.UpdateAmputations()
local modDataHandler = ModDataHandler.GetInstance() local modDataHandler = ModDataHandler.GetInstance()
if modDataHandler:getIsAnyLimbCut() == false then if modDataHandler:getIsAnyLimbCut() == false then
Events.EveryHours.Remove(PlayerHandler.UpdateCicatrization) Events.EveryHours.Remove(PlayerHandler.UpdateAmputations)
end end
local pl = PlayerHandler.playerObj local pl = PlayerHandler.playerObj
@@ -234,7 +234,8 @@ function PlayerHandler.UpdateCicatrization()
local bbptEnum = BloodBodyPartType[limbName] local bbptEnum = BloodBodyPartType[limbName]
--local bodyPart = bd:getBodyPart(bptEnum) --local bodyPart = bd:getBodyPart(bptEnum)
local dirtyness = visual:getDirt(bbptEnum) + visual:getBlood(bbptEnum) + modDataHandler:getWoundDirtyness(limbName) + 0.01 -- TODO Make it customizable local modifier = 0.01 * SandboxVars.TOC.WoundDirtynessMultiplier
local dirtyness = visual:getDirt(bbptEnum) + visual:getBlood(bbptEnum) + modDataHandler:getWoundDirtyness(limbName) + modifier
if dirtyness > 1 then if dirtyness > 1 then
dirtyness = 1 dirtyness = 1
@@ -258,17 +259,17 @@ function PlayerHandler.UpdateCicatrization()
TOC_DEBUG.print("updating modData from cicatrization loop") TOC_DEBUG.print("updating modData from cicatrization loop")
modDataHandler:apply() -- TODO This is gonna be heavy. Not entirely sure modDataHandler:apply() -- TODO This is gonna be heavy. Not entirely sure
else else
TOC_DEBUG.print("Removing UpdateCicatrizationF") TOC_DEBUG.print("Removing UpdateAmputations")
Events.EveryHours.Remove(PlayerHandler.UpdateCicatrization) -- We can remove it safely, no cicatrization happening here boys Events.EveryHours.Remove(PlayerHandler.UpdateAmputations) -- We can remove it safely, no cicatrization happening here boys
end end
TOC_DEBUG.print("updating cicatrization!") TOC_DEBUG.print("updating cicatrization and wound dirtyness!")
end end
---Starts safely the loop to update cicatrzation ---Starts safely the loop to update cicatrzation
function PlayerHandler.ToggleCicatrizationUpdate() function PlayerHandler.ToggleUpdateAmputations()
TOC_DEBUG.print("activating cicatrization loop (if it wasn't active before)") TOC_DEBUG.print("activating amputation handling loop (if it wasn't active before)")
CommonMethods.SafeStartEvent("EveryHours", PlayerHandler.UpdateCicatrization) CommonMethods.SafeStartEvent("EveryHours", PlayerHandler.UpdateAmputations)
end end

View File

@@ -118,7 +118,7 @@ local PerfTest = require("PerfTest/main") -- SHould be global anyway
local CachedDataHandler = require("TOC/Handlers/CachedDataHandler") local CachedDataHandler = require("TOC/Handlers/CachedDataHandler")
PerfTest.RegisterMethod("PlayerHandler", PlayerHandler, "InitializePlayer") PerfTest.RegisterMethod("PlayerHandler", PlayerHandler, "InitializePlayer")
PerfTest.RegisterMethod("PlayerHandler", PlayerHandler, "UpdateCicatrization") PerfTest.RegisterMethod("PlayerHandler", PlayerHandler, "UpdateAmputations")
PerfTest.RegisterMethod("CachedDataHandler", CachedDataHandler, "CalculateHighestAmputatedLimbs") PerfTest.RegisterMethod("CachedDataHandler", CachedDataHandler, "CalculateHighestAmputatedLimbs")
PerfTest.RegisterMethod("ISHealthPanel", ISHealthPanel, "render") PerfTest.RegisterMethod("ISHealthPanel", ISHealthPanel, "render")

View File

@@ -1,6 +1,7 @@
Sandbox_EN = { Sandbox_EN = {
Sandbox_TOC = "The Only Cure", Sandbox_TOC = "The Only Cure",
Sandbox_TOC_CicatrizationSpeed = "Cicatrization Speed", Sandbox_TOC_CicatrizationSpeed = "Cicatrization Speed",
Sandbox_TOC_WoundDirtynessMultiplier = "Wound Dirtyness Multiplier",
Sandbox_TOC_SurgeonAbilityImportance = "Relevance of surgeon doctor ability", Sandbox_TOC_SurgeonAbilityImportance = "Relevance of surgeon doctor ability",
} }

View File

@@ -9,6 +9,15 @@ option TOC.CicatrizationSpeed
translation = TOC_CicatrizationSpeed, translation = TOC_CicatrizationSpeed,
} }
option TOC.WoundDirtynessMultiplier
{
type = integer,
min = 0,
max = 5,
default = 1,
page = TOC,
translation = TOC_WoundDirtynessMultiplier,
}
option TOC.SurgeonAbilityImportance option TOC.SurgeonAbilityImportance
{ {
type = integer, type = integer,
@@ -18,3 +27,4 @@ option TOC.SurgeonAbilityImportance
page = TOC, page = TOC,
translation = TOC_SurgeonAbilityImportance, translation = TOC_SurgeonAbilityImportance,
} }