Cleaning, bandages handling
This commit is contained in:
@@ -56,6 +56,16 @@ function AmputationHandler.ApplyDamageDuringAmputation(player, limbName)
|
||||
bodyDamagePart:setBleedingTime(ZombRand(10, 20))
|
||||
end
|
||||
|
||||
function AmputationHandler.HandleBandages(prevAction, limbName, surgeonPl, patientPl, bandageItem)
|
||||
|
||||
-- TODO Will it work? Can we get bodyDamage for another player from here?
|
||||
|
||||
local bptEnum = StaticData.BODYLOCS_IND_BPT[limbName]
|
||||
local bd = patientPl:getBodyDamage()
|
||||
local bodyPart = bd:getBodyPart(bptEnum)
|
||||
local bandageAction = ISApplyBandage:new(surgeonPl, patientPl, bandageItem, bodyPart, true)
|
||||
ISTimedActionQueue.addAfter(prevAction, bandageAction)
|
||||
end
|
||||
--* Main methods *--
|
||||
|
||||
|
||||
@@ -73,6 +83,7 @@ end
|
||||
---Set the damage to the amputated area
|
||||
---@param surgeonFactor number
|
||||
function AmputationHandler:damageAfterAmputation(surgeonFactor)
|
||||
-- TODO Torniquet should reduce the damage in total, less blood loss
|
||||
local patientStats = self.patientPl:getStats()
|
||||
local bd = self.patientPl:getBodyDamage()
|
||||
local bodyPart = bd:getBodyPart(self.bodyPartType)
|
||||
@@ -95,9 +106,6 @@ function AmputationHandler:execute(damagePlayer)
|
||||
-- TODO Calculate surgeonStats
|
||||
-- TODO Cap it to a certain amount, it shouldn't be more than ...?
|
||||
local surgeonFactor = 1
|
||||
if damagePlayer then
|
||||
self:damageAfterAmputation(surgeonFactor)
|
||||
end
|
||||
|
||||
-- Set the data in modData
|
||||
local modDataHandler = ModDataHandler.GetInstance()
|
||||
@@ -112,6 +120,11 @@ function AmputationHandler:execute(damagePlayer)
|
||||
local username = self.patientPl:getUsername()
|
||||
CachedDataHandler.AddAmputatedLimb(username, self.limbName)
|
||||
CachedDataHandler.CalculateHighestAmputatedLimbs(username)
|
||||
|
||||
-- The last part is to handle the damage that the player will receive after the amputation
|
||||
if not damagePlayer then return end
|
||||
|
||||
self:damageAfterAmputation(surgeonFactor)
|
||||
end
|
||||
|
||||
---Deletes the instance
|
||||
|
||||
@@ -6,7 +6,7 @@ local CommonMethods = require("TOC/CommonMethods")
|
||||
---@class CachedDataHandler
|
||||
local CachedDataHandler = {}
|
||||
|
||||
---comment
|
||||
---Reset everything cache related for that specific user
|
||||
---@param username string
|
||||
function CachedDataHandler.Reset(username)
|
||||
CachedDataHandler.amputatedLimbs[username] = {}
|
||||
@@ -17,7 +17,7 @@ end
|
||||
CachedDataHandler.amputatedLimbs = {}
|
||||
-- TODO Add an indexable table too!
|
||||
|
||||
---Calcualte the currently amputated limbs for a certain player
|
||||
---Calculate the currently amputated limbs for a certain player
|
||||
---@param username string
|
||||
function CachedDataHandler.CalculateAmputatedLimbs(username)
|
||||
CachedDataHandler.amputatedLimbs[username] = {}
|
||||
@@ -30,7 +30,7 @@ function CachedDataHandler.CalculateAmputatedLimbs(username)
|
||||
end
|
||||
end
|
||||
|
||||
---Add an amputated limb to the cached list
|
||||
---Add an amputated limb to the cached list for that user
|
||||
---@param username string
|
||||
---@param limbName string
|
||||
function CachedDataHandler.AddAmputatedLimb(username, limbName)
|
||||
|
||||
@@ -24,7 +24,7 @@ function ModDataHandler:new(username, isResetForced)
|
||||
ModData.request(key)
|
||||
o.tocData = ModData.get(key)
|
||||
|
||||
if isResetForced or o.tocData == nil or o.tocData.limbs.Hand_L == nil or o.tocData.limbs.Hand_L.isCut == nil then
|
||||
if isResetForced or o.tocData == nil or o.tocData.limbs == nil or o.tocData.limbs.Hand_L == nil or o.tocData.limbs.Hand_L.isCut == nil then
|
||||
TOC_DEBUG.print("tocData in ModDataHandler for " .. username .. " is nil, creating it now")
|
||||
o:setup(key)
|
||||
end
|
||||
|
||||
@@ -1,10 +1,35 @@
|
||||
local ModDataHandler = require("TOC/Handlers/ModDataHandler")
|
||||
|
||||
---@class SurgeryHandler
|
||||
---@field type string
|
||||
local SurgeryHandler = {}
|
||||
|
||||
function SurgeryHandler.InstallProsthesis()
|
||||
-- TODO Set stuff in mod data
|
||||
|
||||
function SurgeryHandler:new(type)
|
||||
local o = {}
|
||||
setmetatable(o, self)
|
||||
self.__index = self
|
||||
|
||||
|
||||
-- TODO use getjob for this
|
||||
o.type = type
|
||||
|
||||
return o
|
||||
end
|
||||
|
||||
|
||||
function SurgeryHandler:execute()
|
||||
if self.type == "needle" then
|
||||
-- TODO
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- Cauterize
|
||||
|
||||
|
||||
-- Needle and stitching (scrap surgery kits and crap like that)
|
||||
|
||||
|
||||
|
||||
|
||||
return SurgeryHandler
|
||||
Reference in New Issue
Block a user