Added adjacent parts to put the damage

This commit is contained in:
ZioPao
2023-11-16 15:30:34 +01:00
parent 34570cd013
commit e7119cf032
4 changed files with 31 additions and 19 deletions

View File

@@ -5,13 +5,6 @@ local PlayerHandler = require("TOC/Handlers/PlayerHandler")
local StaticData = require("TOC/StaticData")
---------------------------
--Triggered when a limb has been amputated
---@class Events
---@field OnAmputatedLimb any
LuaEventManager.AddEvent("OnAmputatedLimb")
--------------
-- TODO Add Bandages, Torniquet, etc.
--- Manages an amputation. Will be run on the patient client
---@class AmputationHandler
@@ -111,13 +104,17 @@ function AmputationHandler:damageDuringAmputation()
bodyDamagePart:setBleedingTime(ZombRand(10, 20))
end
---Set the damage to the amputated area
---Set the damage to the adjacent part of the cut area
---@param surgeonFactor number
function AmputationHandler:damageAfterAmputation(surgeonFactor)
-- TODO Torniquet should reduce the damage in total, less blood loss
TOC_DEBUG.print("Applying damage after amputation")
local patientStats = self.patientPl:getStats()
local bd = self.patientPl:getBodyDamage()
local bodyPart = bd:getBodyPart(self.bodyPartType)
local adjacentLimb = StaticData.LIMBS_ADJACENT_IND_STR[self.limbName]
local bodyPart = bd:getBodyPart(BodyPartType[adjacentLimb])
local baseDamage = StaticData.LIMBS_BASE_DAMAGE_IND_NUM[self.limbName]
bodyPart:AddDamage(baseDamage - surgeonFactor)

View File

@@ -29,10 +29,8 @@ function PlayerHandler.InitializePlayer(playerObj, isForced)
CachedDataHandler.CalculateAmputatedLimbs(username)
CachedDataHandler.CalculateHighestAmputatedLimbs(username)
-- TODO Check if there are cut limbs and that needs cicatrization. If yes, then enable the loop
if ModDataHandler.GetInstance(username):getIsAnyLimbCut() then
CommonMethods.SafeStartEvent("EveryHours", PlayerHandler.UpdateCicatrization)
end
--Setup the CicatrizationUpdate event
Events.OnAmputatedLimb.Add(PlayerHandler.ToggleCicatrizationUpdate)
-- Since isForced is used to reset an existing player data, we're gonna clean their ISHealthPanel table too
if isForced then
@@ -120,6 +118,7 @@ function PlayerHandler.CheckDamage(character, damageType, damageAmount)
if modDataHandler:getIsCut(limbName) then
-- Generic injury, let's heal it since they already cut the limb off
--FIXME conflicts with the other thing... Ah fuck wait I'm retarded
if bodyPart:HasInjury() then
PlayerHandler.HealArea(bodyPart)
end
@@ -171,10 +170,12 @@ function PlayerHandler.UpdateCicatrization()
if not isCicatrized then
needsUpdate = true
local cicTime = modDataHandler:getCicatrizationTime(limbName)
TOC_DEBUG.print("updating cicatrization for " .. tostring(limbName))
if cicTime > 0 then
cicTime = cicTime - 60 -- 1 per minute, each cicatrizationTime is divisible by 60
modDataHandler:setCicatrizationTime(limbName, cicTime)
TOC_DEBUG.print("new cicatrization time: " .. tostring(cicTime))
if cicTime < 0 then
modDataHandler:setIsCicatrized(limbName, true)
end
@@ -193,12 +194,10 @@ end
---Starts safely the loop to update cicatrzation
function PlayerHandler.ToggleCicatrizationUpdate()
TOC_DEBUG.print("activating cicatrization loop (if it wasn't active before)")
CommonMethods.SafeStartEvent("EveryHours", PlayerHandler.UpdateCicatrization)
end
Events.OnAmputatedLimb.Add(PlayerHandler.ToggleCicatrizationUpdate)
------------------------------------------
--* OVERRIDES *--