- Fixed bug that could cause bit status to amputated limbs
- Optimizations to various functions
This commit is contained in:
@@ -20,14 +20,10 @@ function TocCheckIfStillInfected(limbs_data)
|
||||
return check
|
||||
end
|
||||
|
||||
function TocCureInfection(body_damage, limbs_data, part_name)
|
||||
function TocCureInfection(body_damage, 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(limbs_data, part_name) then
|
||||
body_damage:setInfected(false)
|
||||
body_part_type:SetInfected(false)
|
||||
body_damage:setInfectionMortalityDuration(-1)
|
||||
@@ -40,8 +36,6 @@ function TocCureInfection(body_damage, limbs_data, part_name)
|
||||
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
|
||||
@@ -50,11 +44,6 @@ function TocCureInfection(body_damage, limbs_data, part_name)
|
||||
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
|
||||
|
||||
function TocDeleteOtherAmputatedLimbs(side)
|
||||
@@ -89,8 +78,6 @@ function TocGetSawInInventory(surgeon)
|
||||
return item
|
||||
end
|
||||
|
||||
|
||||
|
||||
function TocDamagePlayerDuringAmputation(patient, part_name)
|
||||
local body_part_type = TocGetBodyPartTypeFromPartName(part_name)
|
||||
local body_damage = patient:getBodyDamage()
|
||||
@@ -103,21 +90,7 @@ function TocDamagePlayerDuringAmputation(patient, part_name)
|
||||
end
|
||||
|
||||
-- OperateLimb
|
||||
function SetBodyPartsStatusAfterOperation(player, limbs_data, part_name, use_oven)
|
||||
--for _, v in ipairs(GetBodyParts()) do
|
||||
|
||||
|
||||
local body_part_type = player:getBodyDamage():getBodyPart(TocGetBodyPartTypeFromPartName(part_name))
|
||||
FixSingleBodyPartType(body_part_type, use_oven)
|
||||
|
||||
for _, v in ipairs(limbs_data[part_name].depends_on) do
|
||||
local depended_body_part_type = player:getBodyDamage():getBodyPart(TocGetBodyPartTypeFromPartName(v))
|
||||
FixSingleBodyPartType(depended_body_part_type, use_oven)
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
function FixSingleBodyPartType(body_part_type, use_oven)
|
||||
local function FixSingleBodyPartType(body_part_type, use_oven)
|
||||
body_part_type:setDeepWounded(false) --Basically like stitching
|
||||
body_part_type:setDeepWoundTime(0)
|
||||
if use_oven then
|
||||
@@ -133,6 +106,21 @@ function FixSingleBodyPartType(body_part_type, use_oven)
|
||||
end
|
||||
end
|
||||
|
||||
function SetBodyPartsStatusAfterOperation(player, limbs_data, part_name, use_oven)
|
||||
--for _, v in ipairs(GetBodyParts()) do
|
||||
|
||||
|
||||
local body_part_type = player:getBodyDamage():getBodyPart(TocGetBodyPartTypeFromPartName(part_name))
|
||||
FixSingleBodyPartType(body_part_type, use_oven)
|
||||
|
||||
for _, v in ipairs(limbs_data[part_name].depends_on) do
|
||||
local depended_body_part_type = player:getBodyDamage():getBodyPart(TocGetBodyPartTypeFromPartName(v))
|
||||
FixSingleBodyPartType(depended_body_part_type, use_oven)
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
-- Unequip Prosthesis
|
||||
@@ -147,8 +135,6 @@ local function PartNameToBodyLocationProsthesis(name)
|
||||
if name == "Left_UpperArm" then return "ArmLeft_Prot" end
|
||||
end
|
||||
|
||||
|
||||
|
||||
local function PartNameToBodyLocationAmputation(name)
|
||||
-- This is still correct but naming sucks
|
||||
if name == "Right_Hand" then return "ArmRight" end
|
||||
|
||||
@@ -1,20 +1,4 @@
|
||||
-- Helper for DropItem
|
||||
function TheOnlyCure.CheckIfCanPickUpItem(toc_data, side, limb, secondary_limb)
|
||||
|
||||
|
||||
-- TODO we can use this when uninstall prost or when cutting
|
||||
local full_primary_limb = side .. limb
|
||||
local full_secondary_limb = side .. secondary_limb
|
||||
|
||||
|
||||
return toc_data[full_primary_limb].is_cut and
|
||||
not (toc_data[full_primary_limb].is_prosthesis_equipped or toc_data[full_secondary_limb]) or
|
||||
(toc_data[full_secondary_limb].is_cut and not toc_data[full_secondary_limb].is_prosthesis_equipped)
|
||||
|
||||
|
||||
end
|
||||
|
||||
function TheOnlyCure.CheckIfPlayerIsInfected(player, toc_data)
|
||||
local function CheckIfPlayerIsInfected(player, toc_data)
|
||||
|
||||
local body_damage = player:getBodyDamage()
|
||||
|
||||
@@ -48,26 +32,11 @@ function TheOnlyCure.CheckIfPlayerIsInfected(player, toc_data)
|
||||
end
|
||||
end
|
||||
|
||||
function TheOnlyCure.UpdatePlayerHealth(player, part_data)
|
||||
local body_damage = player:getBodyDamage()
|
||||
|
||||
|
||||
|
||||
if player:HasTrait("Insensitive") then body_damage:setPainReduction(49) end
|
||||
|
||||
for i, part_name in pairs(GetBodyParts()) do
|
||||
if part_data[part_name].is_cut then
|
||||
TheOnlyCure.SetHealthStatusForBodyPart(part_data, part_name, player)
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
--Helper function for UpdatePlayerHealth
|
||||
function TheOnlyCure.SetHealthStatusForBodyPart(part_data, part_name, player)
|
||||
local function SetHealthStatusForBodyPart(part_data, part_name, player)
|
||||
|
||||
-- TODO this can be moved away from updates
|
||||
|
||||
@@ -133,24 +102,25 @@ function TheOnlyCure.SetHealthStatusForBodyPart(part_data, part_name, player)
|
||||
--body_part_type:setBandaged(true, bandage_life, false, bandage_type)
|
||||
end
|
||||
|
||||
--Helper function for UpdatePlayerHealth
|
||||
function TheOnlyCure.CheckIfOtherLimbsAreInfected(limbs_data, part_name)
|
||||
|
||||
local function UpdatePlayerHealth(player, part_data)
|
||||
local body_damage = player:getBodyDamage()
|
||||
|
||||
|
||||
local body_parts = GetBodyParts()
|
||||
body_parts[part_name] = nil
|
||||
|
||||
for _, v in pairs(body_parts) do
|
||||
if limbs_data[v].is_infected then
|
||||
return true
|
||||
if player:HasTrait("Insensitive") then body_damage:setPainReduction(49) end
|
||||
|
||||
for _, part_name in pairs(GetBodyParts()) do
|
||||
if part_data[part_name].is_cut then
|
||||
SetHealthStatusForBodyPart(part_data, part_name, player)
|
||||
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
-- MAIN UPDATE FUNCTIONS
|
||||
|
||||
function TheOnlyCure.UpdateEveryOneMinute()
|
||||
local function TocUpdateEveryOneMinute()
|
||||
|
||||
local player = getPlayer()
|
||||
-- To prevent errors during loading
|
||||
@@ -161,8 +131,8 @@ function TheOnlyCure.UpdateEveryOneMinute()
|
||||
local toc_data = player:getModData().TOC
|
||||
|
||||
if toc_data ~= nil then
|
||||
TheOnlyCure.CheckIfPlayerIsInfected(player, toc_data)
|
||||
TheOnlyCure.UpdatePlayerHealth(player, toc_data.Limbs)
|
||||
CheckIfPlayerIsInfected(player, toc_data)
|
||||
UpdatePlayerHealth(player, toc_data.Limbs)
|
||||
end
|
||||
|
||||
|
||||
@@ -177,7 +147,7 @@ function TheOnlyCure.UpdateEveryOneMinute()
|
||||
|
||||
end
|
||||
|
||||
function TheOnlyCure.UpdateEveryTenMinutes()
|
||||
local function TocUpdateEveryTenMinutes()
|
||||
|
||||
local player = getPlayer()
|
||||
|
||||
@@ -204,5 +174,5 @@ function TheOnlyCure.UpdateEveryTenMinutes()
|
||||
|
||||
end
|
||||
|
||||
Events.EveryTenMinutes.Add(TheOnlyCure.UpdateEveryTenMinutes)
|
||||
Events.EveryOneMinute.Add(TheOnlyCure.UpdateEveryOneMinute)
|
||||
Events.EveryTenMinutes.Add(TocUpdateEveryTenMinutes)
|
||||
Events.EveryOneMinute.Add(TocUpdateEveryOneMinute)
|
||||
|
||||
@@ -275,7 +275,7 @@ function TheOnlyCure.CutLimb(part_name, surgeon_factor, bandage_table, painkille
|
||||
|
||||
-- Second check, let's see if there is any other infected limb.
|
||||
if TocCheckIfStillInfected(limbs_data) == false then
|
||||
TocCureInfection(body_damage, limbs_data, part_name)
|
||||
TocCureInfection(body_damage, part_name)
|
||||
getPlayer():Say("I'm gonna be fine...")
|
||||
else
|
||||
getPlayer():Say("I'm still gonna die...")
|
||||
|
||||
Reference in New Issue
Block a user