Fix to cicatrization visuals with traits

This commit is contained in:
ZioPao
2024-05-04 17:11:38 +02:00
parent 4209f690a8
commit be368738ba
2 changed files with 32 additions and 11 deletions

View File

@@ -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

View File

@@ -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)