Fixing healing mechanisms
This commit is contained in:
@@ -7,6 +7,4 @@ function CommonMethods.GetSide(name)
|
|||||||
if string.find(name, "_L") then return "L" else return "R" end
|
if string.find(name, "_L") then return "L" else return "R" end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return CommonMethods
|
return CommonMethods
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
local ModDataHandler = require("TOC/Handlers/ModDataHandler")
|
local ModDataHandler = require("TOC/Handlers/ModDataHandler")
|
||||||
local ItemsHandler = require("TOC/Handlers/ItemsHandler")
|
local ItemsHandler = require("TOC/Handlers/ItemsHandler")
|
||||||
local CachedDataHandler = require("TOC/Handlers/CachedDataHandler")
|
local CachedDataHandler = require("TOC/Handlers/CachedDataHandler")
|
||||||
|
local PlayerHandler = require("TOC/Handlers/PlayerHandler")
|
||||||
local StaticData = require("TOC/StaticData")
|
local StaticData = require("TOC/StaticData")
|
||||||
---------------------------
|
---------------------------
|
||||||
|
|
||||||
@@ -135,6 +136,11 @@ function AmputationHandler:execute(damagePlayer)
|
|||||||
modDataHandler:setCutLimb(self.limbName, false, false, false, surgeonFactor)
|
modDataHandler:setCutLimb(self.limbName, false, false, false, surgeonFactor)
|
||||||
modDataHandler:apply() -- This will force rechecking the cached amputated limbs on the other client
|
modDataHandler:apply() -- This will force rechecking the cached amputated limbs on the other client
|
||||||
|
|
||||||
|
-- Heal the area, we're gonna re-set the damage after (if it's enabled)
|
||||||
|
local bd = self.patientPl:getBodyDamage()
|
||||||
|
local bodyPart = bd:getBodyPart(self.bodyPartType)
|
||||||
|
PlayerHandler.HealArea(bodyPart)
|
||||||
|
|
||||||
-- Give the player the correct amputation item
|
-- Give the player the correct amputation item
|
||||||
ItemsHandler.Player.DeleteOldAmputationItem(self.patientPl, self.limbName)
|
ItemsHandler.Player.DeleteOldAmputationItem(self.patientPl, self.limbName)
|
||||||
ItemsHandler.Player.SpawnAmputationItem(self.patientPl, self.limbName)
|
ItemsHandler.Player.SpawnAmputationItem(self.patientPl, self.limbName)
|
||||||
@@ -144,9 +150,13 @@ function AmputationHandler:execute(damagePlayer)
|
|||||||
CachedDataHandler.AddAmputatedLimb(username, self.limbName)
|
CachedDataHandler.AddAmputatedLimb(username, self.limbName)
|
||||||
CachedDataHandler.CalculateHighestAmputatedLimbs(username)
|
CachedDataHandler.CalculateHighestAmputatedLimbs(username)
|
||||||
|
|
||||||
|
-- If the part was actually infected, heal the player
|
||||||
|
if bodyPart:IsInfected() and not modDataHandler:getIsIgnoredPartInfected() then
|
||||||
|
PlayerHandler.HealZombieInfection(bd, bodyPart, self.limbName, modDataHandler)
|
||||||
|
end
|
||||||
|
|
||||||
-- The last part is to handle the damage that the player will receive after the amputation
|
-- The last part is to handle the damage that the player will receive after the amputation
|
||||||
if not damagePlayer then return end
|
if not damagePlayer then return end
|
||||||
|
|
||||||
self:damageAfterAmputation(surgeonFactor)
|
self:damageAfterAmputation(surgeonFactor)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -53,14 +53,52 @@ function PlayerHandler.ManageTraits(playerObj)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---Used to heal an area that has been cut previously. There's an exception for bites, those are managed differently
|
||||||
|
---@param bodyPart BodyPart
|
||||||
|
function PlayerHandler.HealArea(bodyPart)
|
||||||
|
bodyPart:setBleeding(false)
|
||||||
|
bodyPart:setBleedingTime(0)
|
||||||
|
|
||||||
|
bodyPart:SetBitten(false)
|
||||||
|
bodyPart:setBiteTime(0)
|
||||||
|
|
||||||
|
bodyPart:setCut(false)
|
||||||
|
bodyPart:setCutTime(0)
|
||||||
|
|
||||||
|
bodyPart:setDeepWounded(false)
|
||||||
|
bodyPart:setDeepWoundTime(0)
|
||||||
|
|
||||||
|
bodyPart:setHaveBullet(false, 0)
|
||||||
|
bodyPart:setHaveGlass(false)
|
||||||
|
bodyPart:setSplint(false, 0)
|
||||||
|
end
|
||||||
|
|
||||||
|
---comment
|
||||||
|
---@param bodyDamage BodyDamage
|
||||||
|
---@param bodyPart BodyPart
|
||||||
|
---@param limbName string
|
||||||
|
---@param modDataHandler ModDataHandler
|
||||||
|
function PlayerHandler.HealZombieInfection(bodyDamage, bodyPart, limbName, modDataHandler)
|
||||||
|
if bodyDamage:isInfected() == false then return end
|
||||||
|
|
||||||
|
bodyDamage:setInfected(false)
|
||||||
|
bodyDamage:setInfectionMortalityDuration(0)
|
||||||
|
bodyDamage:setInfectionTime(0)
|
||||||
|
bodyDamage:setInfectionLevel(0)
|
||||||
|
bodyPart:SetInfected(false)
|
||||||
|
|
||||||
|
modDataHandler:setIsInfected(limbName, false)
|
||||||
|
modDataHandler:apply()
|
||||||
|
end
|
||||||
|
|
||||||
-------------------------
|
-------------------------
|
||||||
--* Events *--
|
--* Events *--
|
||||||
|
|
||||||
---Check if the player has an infected (as in, zombie infection) body part
|
---Check if the player has in infected body part or if they have been hit in a cut area
|
||||||
---@param character IsoGameCharacter
|
---@param character IsoGameCharacter
|
||||||
---@param damageType string
|
---@param damageType string
|
||||||
---@param damageAmount number
|
---@param damageAmount number
|
||||||
function PlayerHandler.CheckInfection(character, damageType, damageAmount)
|
function PlayerHandler.CheckDamage(character, damageType, damageAmount)
|
||||||
|
|
||||||
-- TODO This fucking event barely works. Bleeding seems to be the only thing that triggers it. use this to trigger something else and then do not let it keep going
|
-- TODO This fucking event barely works. Bleeding seems to be the only thing that triggers it. use this to trigger something else and then do not let it keep going
|
||||||
|
|
||||||
@@ -69,17 +107,27 @@ function PlayerHandler.CheckInfection(character, damageType, damageAmount)
|
|||||||
if character ~= getPlayer() then return end
|
if character ~= getPlayer() then return end
|
||||||
local bd = character:getBodyDamage()
|
local bd = character:getBodyDamage()
|
||||||
local modDataHandler = ModDataHandler.GetInstance()
|
local modDataHandler = ModDataHandler.GetInstance()
|
||||||
|
|
||||||
for i=1, #StaticData.LIMBS_STR do
|
for i=1, #StaticData.LIMBS_STR do
|
||||||
local limbName = StaticData.LIMBS_STR[i]
|
local limbName = StaticData.LIMBS_STR[i]
|
||||||
local bptEnum = StaticData.BODYLOCS_IND_BPT[limbName]
|
local bptEnum = StaticData.BODYLOCS_IND_BPT[limbName]
|
||||||
local bodyPart = bd:getBodyPart(bptEnum)
|
local bodyPart = bd:getBodyPart(bptEnum)
|
||||||
|
|
||||||
if bodyPart:bitten() or bodyPart:IsInfected() then
|
if modDataHandler:getIsCut(limbName) then
|
||||||
if modDataHandler:getIsCut(limbName) then
|
|
||||||
bodyPart:SetBitten(false)
|
-- Generic injury, let's heal it since they already cut the limb off
|
||||||
else
|
if bodyPart:HasInjury() then
|
||||||
|
PlayerHandler.HealArea(bodyPart)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Special case for bites\zombie infections
|
||||||
|
if bodyPart:IsInfected() then
|
||||||
|
TOC_DEBUG.print("Healed from zombie infection " .. tostring(bodyPart))
|
||||||
|
PlayerHandler.HealZombieInfection(bd, bodyPart, limbName, modDataHandler)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if bodyPart:bitten() or bodyPart:IsInfected() then
|
||||||
modDataHandler:setIsInfected(limbName, true)
|
modDataHandler:setIsInfected(limbName, true)
|
||||||
|
modDataHandler:apply()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -95,9 +143,11 @@ function PlayerHandler.CheckInfection(character, damageType, damageAmount)
|
|||||||
ModDataHandler.GetInstance():setIsIgnoredPartInfected(true)
|
ModDataHandler.GetInstance():setIsIgnoredPartInfected(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- TODO in theory we should sync modData, but it's gonna be expensive as fuck. Figure it out
|
||||||
end
|
end
|
||||||
|
|
||||||
Events.OnPlayerGetDamage.Add(PlayerHandler.CheckInfection)
|
Events.OnPlayerGetDamage.Add(PlayerHandler.CheckDamage)
|
||||||
|
|
||||||
|
|
||||||
---Updates the cicatrization process, run when a limb has been cut
|
---Updates the cicatrization process, run when a limb has been cut
|
||||||
|
|||||||
@@ -165,6 +165,7 @@ function CutLimbHandler:checkItem(item)
|
|||||||
TOC_DEBUG.print("checkItem: " .. tostring(itemType))
|
TOC_DEBUG.print("checkItem: " .. tostring(itemType))
|
||||||
|
|
||||||
if CheckIfSaw(itemType) then
|
if CheckIfSaw(itemType) then
|
||||||
|
TOC_DEBUG.print("added to list -> " .. itemType)
|
||||||
self:addItem(self.items.ITEMS, item)
|
self:addItem(self.items.ITEMS, item)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user