From be368738ba7986cc07b437d720d119283b8eb0d1 Mon Sep 17 00:00:00 2001 From: ZioPao Date: Sat, 4 May 2024 17:11:38 +0200 Subject: [PATCH] Fix to cicatrization visuals with traits --- .../TOC/Controllers/LocalPlayerController.lua | 35 ++++++++++++++----- .../TOC/TimedActions/CauterizeAction.lua | 8 +++-- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/media/lua/client/TOC/Controllers/LocalPlayerController.lua b/media/lua/client/TOC/Controllers/LocalPlayerController.lua index b13b1e4..24bdc65 100644 --- a/media/lua/client/TOC/Controllers/LocalPlayerController.lua +++ b/media/lua/client/TOC/Controllers/LocalPlayerController.lua @@ -50,13 +50,16 @@ end ---Handles the traits ---@param playerObj IsoPlayer function LocalPlayerController.ManageTraits(playerObj) - local AmputationHandler = require("Handlers/TOC_AmputationHandler") + local AmputationHandler = require("TOC/Handlers/AmputationHandler") for k, v in pairs(StaticData.TRAITS_BP) do if playerObj:HasTrait(k) then - -- Once we find one, we should be done. - local tempHandler = AmputationHandler:new(v) + -- Once we find one, we should be done since they're exclusive + local tempHandler = AmputationHandler:new(v, playerObj) tempHandler:execute(false) -- No damage tempHandler:close() + + -- The wound should be already cicatrized + LocalPlayerController.HandleSetCicatrization(DataController.GetInstance(), playerObj, v) return end end @@ -260,14 +263,11 @@ function LocalPlayerController.UpdateAmputations() cicTime = cicTime - cicDec - dcInst:setCicatrizationTime(limbName, cicTime) TOC_DEBUG.print("New cicatrization time: " .. tostring(cicTime)) if cicTime <= 0 then - TOC_DEBUG.print(tostring(limbName) .. " is cicatrized") - dcInst:setIsCicatrized(limbName, true) - -- Set visual - local ItemsController = require("TOC/Controllers/ItemsController") - ItemsController.Player.OverrideAmputationItemVisuals(pl, limbName, true) + LocalPlayerController.HandleSetCicatrization(dcInst, pl, limbName) + else + dcInst:setCicatrizationTime(limbName, cicTime) end end end @@ -288,6 +288,23 @@ function LocalPlayerController.ToggleUpdateAmputations() CommonMethods.SafeStartEvent("EveryHours", LocalPlayerController.UpdateAmputations) end + +--* Cicatrization and cicatrization visuals *-- + +---Set the boolean and cicTime in DCINST and the visuals for the amputated limb +---@param dcInst DataController +---@param playerObj IsoPlayer +---@param limbName string +function LocalPlayerController.HandleSetCicatrization(dcInst, playerObj, limbName) + TOC_DEBUG.print(tostring(limbName) .. " is cicatrized") + dcInst:setIsCicatrized(limbName, true) + dcInst:setCicatrizationTime(limbName, 0) + + -- Set visuals for the amputation + local ItemsController = require("TOC/Controllers/ItemsController") + ItemsController.Player.OverrideAmputationItemVisuals(playerObj, limbName, true) +end + --* Object drop handling when amputation occurs diff --git a/media/lua/client/TOC/TimedActions/CauterizeAction.lua b/media/lua/client/TOC/TimedActions/CauterizeAction.lua index a27333b..5b1b454 100644 --- a/media/lua/client/TOC/TimedActions/CauterizeAction.lua +++ b/media/lua/client/TOC/TimedActions/CauterizeAction.lua @@ -1,5 +1,6 @@ require "TimedActions/ISBaseTimedAction" local DataController = require("TOC/Controllers/DataController") +local LocalPlayerController = require("TOC/Controllers/LocalPlayerController") --------------- ---@class CauterizeAction : ISBaseTimedAction @@ -72,11 +73,14 @@ function CauterizeAction:perform() local dcInst = DataController.GetInstance() dcInst:setCicatrizationTime(self.limbName, 0) - dcInst:setIsCicatrized(self.limbName, true) dcInst:setIsCauterized(self.limbName, true) - -- we don't care about the depended limbs, since they're alread "cicatrized" + -- Set isCicatrized and the visuals in one go, since this action is gonna be run only on a single client + LocalPlayerController.HandleSetCicatrization(dcInst, self.character, self.limbName) + -- TODO Add specific visuals for cauterization + + -- we don't care about the depended limbs, since they're alread "cicatrized" dcInst:apply() ISBaseTimedAction.perform(self)