Moved function from update to a normal function
This commit is contained in:
@@ -22,8 +22,55 @@ function CheckIfStillInfected(part_data)
|
||||
end
|
||||
|
||||
|
||||
|
||||
function TocCureInfection(body_damage, part_data, part_name)
|
||||
|
||||
local body_part_type = body_damage:getBodyPart(TocGetBodyPartTypeFromPartName(part_name))
|
||||
|
||||
-- Check if we can heal the infection
|
||||
local is_other_bodypart_infected = getPlayer():getModData().TOC.Limbs.is_other_bodypart_infected
|
||||
|
||||
if not is_other_bodypart_infected and not TheOnlyCure.CheckIfOtherLimbsAreInfected(part_data, part_name) then
|
||||
body_damage:setInfected(false)
|
||||
body_part_type:SetInfected(false)
|
||||
body_damage:setInfectionMortalityDuration(-1)
|
||||
body_damage:setInfectionTime(-1)
|
||||
body_damage:setInfectionLevel(0)
|
||||
local body_part_types = body_damage:getBodyParts()
|
||||
|
||||
-- TODO I think this is enough... we should just cycle if with everything instead of that crap up there
|
||||
for i=body_part_types:size()-1, 0, -1 do
|
||||
local bodyPart = body_part_types:get(i);
|
||||
bodyPart:SetInfected(false);
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if body_part_type:scratched() then body_part_type:setScratched(false, false) end
|
||||
if body_part_type:haveGlass() then body_part_type:setHaveGlass(false) end
|
||||
if body_part_type:haveBullet() then body_part_type:setHaveBullet(false, 0) end
|
||||
if body_part_type:isInfectedWound() then body_part_type:setInfectedWound(false) end
|
||||
if body_part_type:isBurnt() then body_part_type:setBurnTime(0) end
|
||||
if body_part_type:isCut() then body_part_type:setCut(false, false) end --Lacerations
|
||||
if body_part_type:getFractureTime()>0 then body_part_type:setFractureTime(0) end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- TODO this triggers an error
|
||||
function CureInfection(body_damage)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
body_damage:setInfected(false)
|
||||
body_damage:setInfectionMortalityDuration(-1)
|
||||
body_damage:setInfectionTime(-1)
|
||||
|
||||
@@ -81,6 +81,7 @@ end
|
||||
--Helper function for UpdatePlayerHealth
|
||||
function TheOnlyCure.HealSpecificPart(part_data, part_name, player)
|
||||
|
||||
-- TODO this can be moved away from updates
|
||||
|
||||
local body_damage = player:getBodyDamage()
|
||||
local body_part_type = body_damage:getBodyPart(TocGetBodyPartTypeFromPartName(part_name))
|
||||
@@ -119,34 +120,34 @@ function TheOnlyCure.HealSpecificPart(part_data, part_name, player)
|
||||
|
||||
|
||||
-- Check if we can heal the infection
|
||||
if body_part_type:bitten() then
|
||||
body_part_type:SetBitten(false)
|
||||
-- if body_part_type:bitten() then
|
||||
-- body_part_type:SetBitten(false)
|
||||
|
||||
|
||||
local is_other_bodypart_infected = player:getModData().TOC.Limbs.is_other_bodypart_infected
|
||||
-- local is_other_bodypart_infected = player:getModData().TOC.Limbs.is_other_bodypart_infected
|
||||
|
||||
if not is_other_bodypart_infected and not TheOnlyCure.CheckIfOtherLimbsAreInfected(part_data, part_name) then
|
||||
body_part_type:setInfected(false)
|
||||
body_part_type:setInfectionMortalityDuration(-1)
|
||||
body_part_type:setInfectionTime(-1)
|
||||
body_part_type:setInfectionLevel(0)
|
||||
local body_part_types = body_damage:getBodyParts()
|
||||
-- if not is_other_bodypart_infected and not TheOnlyCure.CheckIfOtherLimbsAreInfected(part_data, part_name) then
|
||||
-- body_part_type:SetInfected(false)
|
||||
-- body_damage:setInfectionMortalityDuration(-1)
|
||||
-- body_damage:setInfectionTime(-1)
|
||||
-- body_damage:setInfectionLevel(0)
|
||||
-- local body_part_types = body_damage:getBodyParts()
|
||||
|
||||
-- TODO I think this is enough... we should just cycle if with everything instead of that crap up there
|
||||
for i=body_part_types:size()-1, 0, -1 do
|
||||
local bodyPart = body_part_types:get(i);
|
||||
bodyPart:SetInfected(false);
|
||||
end
|
||||
end
|
||||
end
|
||||
-- -- TODO I think this is enough... we should just cycle if with everything instead of that crap up there
|
||||
-- for i=body_part_types:size()-1, 0, -1 do
|
||||
-- local bodyPart = body_part_types:get(i);
|
||||
-- bodyPart:SetInfected(false);
|
||||
-- end
|
||||
-- end
|
||||
-- end
|
||||
|
||||
if body_part_type:scratched() then body_part_type:setScratched(false, false) end
|
||||
if body_part_type:haveGlass() then body_part_type:setHaveGlass(false) end
|
||||
if body_part_type:haveBullet() then body_part_type:setHaveBullet(false, 0) end
|
||||
if body_part_type:isInfectedWound() then body_part_type:setInfectedWound(false) end
|
||||
if body_part_type:isBurnt() then body_part_type:setBurnTime(0) end
|
||||
if body_part_type:isCut() then body_part_type:setCut(false, false) end --Lacerations
|
||||
if body_part_type:getFractureTime()>0 then body_part_type:setFractureTime(0) end
|
||||
-- if body_part_type:scratched() then body_part_type:setScratched(false, false) end
|
||||
-- if body_part_type:haveGlass() then body_part_type:setHaveGlass(false) end
|
||||
-- if body_part_type:haveBullet() then body_part_type:setHaveBullet(false, 0) end
|
||||
-- if body_part_type:isInfectedWound() then body_part_type:setInfectedWound(false) end
|
||||
-- if body_part_type:isBurnt() then body_part_type:setBurnTime(0) end
|
||||
-- if body_part_type:isCut() then body_part_type:setCut(false, false) end --Lacerations
|
||||
-- if body_part_type:getFractureTime()>0 then body_part_type:setFractureTime(0) end
|
||||
|
||||
-- Cicatrization check
|
||||
if part_data[part_name].is_cut and not part_data[part_name].is_cicatrized then
|
||||
|
||||
@@ -253,10 +253,11 @@ function TheOnlyCure.CutLimb(part_name, surgeon_factor, bandage_table, painkille
|
||||
if part_data[part_name].is_infected and body_damage:getInfectionLevel() < 20 then
|
||||
part_data[part_name].is_infected = false
|
||||
body_part:SetBitten(false)
|
||||
body_part:setBiteTime(0)
|
||||
|
||||
-- Second check, let's see if there is any other infected limb.
|
||||
if CheckIfStillInfected(part_data) == false then
|
||||
CureInfection(body_damage)
|
||||
TocCureInfection(body_damage, part_data, part_name)
|
||||
getPlayer():Say("I'm gonna be fine")
|
||||
else
|
||||
getPlayer():Say("I'm still gonna die...")
|
||||
@@ -270,8 +271,9 @@ function TheOnlyCure.CutLimb(part_name, surgeon_factor, bandage_table, painkille
|
||||
part_data[depended_v].cicatrization_time = part_data[part_name].cicatrization_base_time - surgeon_factor * 50
|
||||
end
|
||||
|
||||
-- Check for older amputation models and deletes them from player's inventory
|
||||
|
||||
|
||||
-- Check for older amputation models and deletes them from player's inventory
|
||||
local side = string.match(part_name, '(%w+)_')
|
||||
|
||||
TocDeleteOtherAmputatedLimbs(side)
|
||||
|
||||
Reference in New Issue
Block a user