bunch of cleaning

This commit is contained in:
Pao
2023-03-13 23:38:39 +01:00
parent 8a42b25f9d
commit 8b5284955c
8 changed files with 31 additions and 26 deletions

View File

@@ -60,7 +60,7 @@ end
local function DeleteOtherAmputatedLimbs(side) local function DeleteOtherAmputatedLimbs(side)
-- if left hand is cut and we cut left lowerarm, then delete hand -- if left hand is cut and we cut left lowerarm, then delete hand
for _, limb in pairs(TOC.limbNames) do for _, limb in pairs(TOC.limbNames) do
local partName = "TOC.Amputation_" .. side .. "_" .. limb local partName = "TOC.Amputation_" .. TOC_Common.ConcatPartName(side, limb)
local amputatedLimbItem = getPlayer():getInventory():FindAndReturn(partName) local amputatedLimbItem = getPlayer():getInventory():FindAndReturn(partName)
if amputatedLimbItem then if amputatedLimbItem then
getPlayer():getInventory():Remove(amputatedLimbItem) getPlayer():getInventory():Remove(amputatedLimbItem)
@@ -175,7 +175,7 @@ TOC.CutLimb = function(partName, surgeonFactor, bandageTable, painkillerTable)
if tourniquetItem ~= nil then if tourniquetItem ~= nil then
baseDamageValue = 50 -- TODO Decrease mostly blood and damage, add pain, not everything else baseDamageValue = 50 -- TODO Decrease mostly blood and damage, add pain, not everything else
if partName == side .. "_UpperArm" then if partName == TOC_Common.ConcatPartName(side, "UpperArm") then
player:removeWornItem(tourniquetItem) player:removeWornItem(tourniquetItem)
end end
end end

View File

@@ -15,7 +15,7 @@ TOC_Common.GeneratePartNames = function()
local partNamesTable = {} local partNamesTable = {}
for _, side in ipairs(TOC.sideNames) do for _, side in ipairs(TOC.sideNames) do
for _, limb in ipairs(TOC.limbNames) do for _, limb in ipairs(TOC.limbNames) do
local tempPartName = side .. "_" .. limb local tempPartName = TOC_Common.ConcatPartName(side, limb)
table.insert(partNamesTable, tempPartName) table.insert(partNamesTable, tempPartName)
end end
end end
@@ -42,6 +42,11 @@ TOC_Common.GetSideFromPartName = function(partName)
end end
TOC_Common.ConcatPartName = function(side, limb)
return side .. "_" .. limb
end
--------------------------------- ---------------------------------
TOC_Common.GetAcceptableBodyPartTypes = function() TOC_Common.GetAcceptableBodyPartTypes = function()
@@ -157,9 +162,6 @@ end
----------------------------------- -----------------------------------
-- Online Handling checks -- Online Handling checks
-----------------------------------------
-- MP HANDLING CHECKS
TOC_Common.CheckIfCanBeCut = function(partName, limbsData) TOC_Common.CheckIfCanBeCut = function(partName, limbsData)
if limbsData == nil then if limbsData == nil then
@@ -246,7 +248,7 @@ TOC_Common.CheckIfProsthesisAlreadyInstalled = function(limbsData, partName)
for _, side in pairs(TOC.sideNames) do for _, side in pairs(TOC.sideNames) do
if string.find(partName, side) then if string.find(partName, side) then
return (limbsData[side .. "_Hand"].isProsthesisEquipped or limbsData[side .. "_LowerArm"].isProsthesisEquipped) return (limbsData[TOC_Common.ConcatPartName(side, "Hand")].isProsthesisEquipped or limbsData[TOC_Common.ConcatPartName(side, "LowerArm")].isProsthesisEquipped)
end end
end end
@@ -259,12 +261,12 @@ TOC_Common.GetCanBeHeldTable = function(limbs_data)
for _, side in pairs(TOC.sideNames) do for _, side in pairs(TOC.sideNames) do
canBeHeld[side] = true canBeHeld[side] = true
if limbs_data[side .. "_Hand"].isCut then if limbs_data[TOC_Common.ConcatPartName(side, "Hand")].isCut then
if limbs_data[side .. "_LowerArm"].isCut then if limbs_data[TOC_Common.ConcatPartName(side, "LowerArm")].isCut then
if not limbs_data[side .. "_LowerArm"].isProsthesisEquipped then if not limbs_data[TOC_Common.ConcatPartName(side, "LowerArm")].isProsthesisEquipped then
canBeHeld[side] = false canBeHeld[side] = false
end end
elseif not limbs_data[side .. "_Hand"].isProsthesisEquipped then elseif not limbs_data[TOC_Common.ConcatPartName(side, "Hand")].isProsthesisEquipped then
canBeHeld[side] = false canBeHeld[side] = false
end end
end end

View File

@@ -93,7 +93,7 @@ TOC.SetInitData = function(modData, player)
} }
for _, side in pairs(TOC.sideNames) do for _, side in pairs(TOC.sideNames) do
for _, limb in pairs(TOC.limbNames) do for _, limb in pairs(TOC.limbNames) do
local partName = side .. "_" .. limb local partName = TOC_Common.ConcatPartName(side, limb)
TOC.InitPart(modData.TOC.limbs, partName) TOC.InitPart(modData.TOC.limbs, partName)
end end
end end
@@ -145,7 +145,7 @@ local function InitializeTheOnlyCure()
TOC.limbParameters = {} TOC.limbParameters = {}
for _, side in pairs(TOC.sideNames) do for _, side in pairs(TOC.sideNames) do
for _, limb in pairs(TOC.limbNames) do for _, limb in pairs(TOC.limbNames) do
local partName = side .. "_" .. limb local partName = TOC_Common.ConcatPartName(side, limb)
TOC.limbParameters[partName] = {} TOC.limbParameters[partName] = {}
if limb == "Hand" then if limb == "Hand" then
@@ -153,10 +153,10 @@ local function InitializeTheOnlyCure()
TOC.limbParameters[partName].dependsOn = {} TOC.limbParameters[partName].dependsOn = {}
elseif limb == "LowerArm" then elseif limb == "LowerArm" then
TOC.limbParameters[partName].cicatrizationBaseTime = 1800 TOC.limbParameters[partName].cicatrizationBaseTime = 1800
TOC.limbParameters[partName].dependsOn = { side .. "_Hand", } TOC.limbParameters[partName].dependsOn = { TOC_Common.ConcatPartName(side, "Hand") }
elseif limb == "UpperArm" then elseif limb == "UpperArm" then
TOC.limbParameters[partName].cicatrizationBaseTime = 2000 TOC.limbParameters[partName].cicatrizationBaseTime = 2000
TOC.limbParameters[partName].dependsOn = { side .. "_Hand", side .. "_LowerArm", } TOC.limbParameters[partName].dependsOn = { TOC_Common.ConcatPartName(side, "Hand"), TOC_Common.ConcatPartName(side, "LowerArm"), }
elseif limb == "Foot" then elseif limb == "Foot" then
TOC.limbParameters[partName].cicatrizationBaseTime = 1700 TOC.limbParameters[partName].cicatrizationBaseTime = 1700
TOC.limbParameters[partName].dependsOn = {} TOC.limbParameters[partName].dependsOn = {}

View File

@@ -70,3 +70,6 @@ end
TOC_Compat.getHands = function(player) TOC_Compat.getHands = function(player)
return ((TOC_Compat.hasArm(player, parts[1], parts[3]) and 1) or 0) + ((TOC_Compat.hasArm(player, parts[2], parts[4]) and 10) or 0) return ((TOC_Compat.hasArm(player, parts[1], parts[3]) and 1) or 0) + ((TOC_Compat.hasArm(player, parts[2], parts[4]) and 10) or 0)
end end
return TOC_Compat

View File

@@ -235,7 +235,7 @@ function ISClothingExtraAction:isValid()
for _, side in pairs (TOC.sideNames) do for _, side in pairs (TOC.sideNames) do
if location == side .. "Wrist" then if location == side .. "Wrist" then
if limbsData[side .. "_LowerArm"].isCut then if limbsData[TOC_Common.ConcatPartName(side, "LowerArm")].isCut then
return false return false
end end
end end

View File

@@ -8,7 +8,7 @@
-- Side functions -- Side functions
local function TocGetAmputationFullTypeFromInventory(player, side, limb) local function TocGetAmputationFullTypeFromInventory(player, side, limb)
local player_inventory = player:getInventory() local player_inventory = player:getInventory()
local item_name = "TOC.Amputation_" .. side .. "_" .. limb local item_name = "TOC.Amputation_" .. TOC_Common.ConcatPartName(side, limb)
local found_item = player_inventory:FindAndReturn(item_name) local found_item = player_inventory:FindAndReturn(item_name)
if found_item then if found_item then
return found_item:getFullType() return found_item:getFullType()
@@ -18,12 +18,12 @@ local function TocGetAmputationFullTypeFromInventory(player, side, limb)
end end
local function TocGetEquippedProsthesisFullTypeFromInventory(player, side, limb) local function TocGetEquippedProsthesisFullTypeFromInventory(player, side, limb)
local player_inventory = player:getInventory() local playerInventory = player:getInventory()
for _, prost in ipairs(GetProsthesisList()) do for _, prost in ipairs(GetProsthesisList()) do
local item_name = TocFindCorrectClothingProsthesis(prost, side .."_" .. limb) local itemName = TocFindCorrectClothingProsthesis(prost, TOC_Common.ConcatPartName(side, limb))
local found_item = player_inventory:FindAndReturn(item_name) local foundItem = playerInventory:FindAndReturn(itemName)
if found_item then if foundItem then
return found_item:getFullType() return foundItem:getFullType()
end end
end end
end end
@@ -44,7 +44,7 @@ function TocResetClothingItemBodyLocation(player, side, limb)
player:removeWornItem(amputationItem) player:removeWornItem(amputationItem)
player:getInventory():Remove(amputationItem) player:getInventory():Remove(amputationItem)
amputationItem = playerInv:AddItem(amputationItemName) amputationItem = playerInv:AddItem(amputationItemName)
TOC_Visuals.SetTextureForAmputation(amputationItem, player, limbsData[side .. "_" .. limb].is_cicatrized) TOC_Visuals.SetTextureForAmputation(amputationItem, player, limbsData[TOC_Common.ConcatPartName(side, limb)].isCicatrized)
player:setWornItem(amputationItem:getBodyLocation(), amputationItem) player:setWornItem(amputationItem:getBodyLocation(), amputationItem)
end end
amputationItem = nil -- reset it amputationItem = nil -- reset it

View File

@@ -191,8 +191,8 @@ TOC.UpdateEveryTenMinutes = function()
--Experience for prosthesis user --Experience for prosthesis user
for _, side in pairs(TOC.sideNames) do for _, side in pairs(TOC.sideNames) do
if partData[side .. "_Hand"].isProsthesisEquipped or partData[side .. "_LowerArm"].isProsthesisEquipped then if partData[TOC_Common.ConcatPartName(side, "Hand")].isProsthesisEquipped or partData[TOC_Common.ConcatPartName(side, "LowerArm")].isProsthesisEquipped then
player:getXp():AddXP(Perks[side .. "_Hand"], 4) player:getXp():AddXP(Perks[TOC_Common.ConcatPartName(side, "Hand")], 4)
end end
end end