Cleaning, bandages handling
This commit is contained in:
@@ -7,10 +7,5 @@ function CommonMethods.GetSide(name)
|
||||
if string.find(name, "_L") then return "L" else return "R" end
|
||||
end
|
||||
|
||||
---comment
|
||||
---@param bodyPart BodyPart
|
||||
function CommonMethods.GetLimbNameFromBodyPart(bodyPart)
|
||||
local bodyPartType = bodyPart:getType()
|
||||
|
||||
end
|
||||
|
||||
return CommonMethods
|
||||
@@ -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
|
||||
@@ -1,6 +1,7 @@
|
||||
require "TimedActions/ISBaseTimedAction"
|
||||
local AmputationHandler = require("TOC/Handlers/AmputationHandler")
|
||||
local CommandsData = require("TOC/CommandsData")
|
||||
local StaticData = require("TOC/StaticData")
|
||||
-----------------------------
|
||||
|
||||
---@class CutLimbAction : ISBaseTimedAction
|
||||
@@ -52,21 +53,19 @@ function CutLimbAction:start()
|
||||
sendClientCommand(CommandsData.modules.TOC_RELAY, CommandsData.server.Relay.RelayDamageDuringAmputation, params )
|
||||
end
|
||||
|
||||
|
||||
-- TODO Check bandages, if there are init a bandage process
|
||||
local bandageItem = ""
|
||||
local bptEnum = StaticData.BODYLOCS_IND_BPT[self.limbName]
|
||||
local bd = self.character:getBodyDamage()
|
||||
local bodyPart = bd:getBodyPart(bptEnum)
|
||||
local bandageAction = ISApplyBandage:new(self.character, self.patient, bandageItem, bodyPart, true)
|
||||
ISTimedActionQueue.addAfter(self, bandageAction)
|
||||
|
||||
|
||||
-- Setup cosmetic stuff
|
||||
self:setActionAnim("SawLog")
|
||||
self:setOverrideHandModels(self.item:getStaticModel())
|
||||
-- if self.character:getPrimaryHandItem() then
|
||||
-- ISTimedActionQueue.add(ISUnequipAction:new(self.character, self.character:getPrimaryHandItem(), 2))
|
||||
-- end
|
||||
-- if self.character:getSecondaryHandItem() and self.character:getSecondaryHandItem() ~= self.character:getPrimaryHandItem() then
|
||||
-- ISTimedActionQueue.add(ISUnequipAction:new(self.character, self.surgeon:getSecondaryHandItem(), 2))
|
||||
-- end
|
||||
|
||||
-- if sawItem then
|
||||
-- self:setOverrideHandModels(sawItem:getStaticModel(), nil)
|
||||
|
||||
-- end
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -90,6 +89,8 @@ function CutLimbAction:perform()
|
||||
local params = {patientNum = self.patient:getOnlineID(), limbName = self.limbName}
|
||||
sendClientCommand(CommandsData.modules.TOC_RELAY, CommandsData.server.Relay.RelayExecuteAmputationAction, params )
|
||||
end
|
||||
|
||||
|
||||
ISBaseTimedAction.perform(self)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user