Cleaning stuff
This commit is contained in:
@@ -51,17 +51,22 @@ function FindTocDataPartNameFromBodyPartType(toc_limbs_data, bodyPartType)
|
||||
end
|
||||
|
||||
|
||||
function FindTocBodyPartNameFromBodyPartType(bodyPartType)
|
||||
if bodyPartType == BodyPartType.Hand_R then return "Right_Hand"
|
||||
elseif bodyPartType == BodyPartType.ForeArm_R then return "Right_LowerArm"
|
||||
elseif bodyPartType == BodyPartType.UpperArm_R then return "Right_UpperArm"
|
||||
elseif bodyPartType == BodyPartType.Hand_L then return "Left_Hand"
|
||||
elseif bodyPartType == BodyPartType.ForeArm_L then return "Left_LowerArm"
|
||||
elseif bodyPartType == BodyPartType.UpperArm_L then return "Left_UpperArm"
|
||||
|
||||
function TocGetPartNameFromBodyPartType(body_part)
|
||||
|
||||
if body_part == BodyPartType.Hand_R then return "Right_Hand"
|
||||
elseif body_part == BodyPartType.ForeArm_R then return "Right_LowerArm"
|
||||
elseif body_part == BodyPartType.UpperArm_R then return "Right_UpperArm"
|
||||
elseif body_part == BodyPartType.Hand_L then return "Left_Hand"
|
||||
elseif body_part == BodyPartType.ForeArm_L then return "Left_LowerArm"
|
||||
elseif body_part == BodyPartType.UpperArm_L then return "Left_UpperArm"
|
||||
else return nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
function TocGetBodyPartTypeFromPartName(part_name)
|
||||
if part_name == "Right_Hand" then return BodyPartType.Hand_R end
|
||||
if part_name == "Right_LowerArm" then return BodyPartType.ForeArm_R end
|
||||
@@ -72,4 +77,36 @@ function TocGetBodyPartTypeFromPartName(part_name)
|
||||
end
|
||||
|
||||
|
||||
function TocFindCorrectClothingProsthesis(item_name, part_name)
|
||||
|
||||
local correct_name = "TOC.Prost_" .. part_name .. "_" .. item_name
|
||||
return correct_name
|
||||
|
||||
end
|
||||
|
||||
local function PartNameToBodyLocation(name)
|
||||
-- This is still correct but naming sucks
|
||||
if name == "Right_Hand" then return "ArmRight_Prot" end
|
||||
if name == "Right_LowerArm" then return "ArmRight_Prot" end
|
||||
if name == "Right_UpperArm" then return "ArmRight_Prot" end
|
||||
if name == "Left_Hand" then return "ArmLeft_Prot" end
|
||||
if name == "Left_LowerArm" then return "ArmLeft_Prot" end
|
||||
if name == "Left_UpperArm" then return "ArmLeft_Prot" end
|
||||
end
|
||||
|
||||
|
||||
function TocFindItemInProstBodyLocation(part_name, patient)
|
||||
-- FIXME this can return even amputated limbs, and we're using it only for prosthetics. This is gonna break sooner or later
|
||||
|
||||
|
||||
|
||||
local worn_items = patient:getWornItems()
|
||||
|
||||
for i=1,worn_items:size()-1 do -- Maybe wornItems:size()-1
|
||||
local item = worn_items:get(i):getItem()
|
||||
if item:getBodyLocation() == PartNameToBodyLocation(part_name) then
|
||||
return item
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -103,7 +103,7 @@ end
|
||||
|
||||
TocContextMenus.DoCut = function(_, patient, surgeon, part_name)
|
||||
|
||||
if GetSawInInventory(surgeon) then
|
||||
if TocGetSawInInventory(surgeon) then
|
||||
ISTimedActionQueue.add(ISCutLimb:new(patient, surgeon, part_name));
|
||||
else
|
||||
surgeon:Say("I don't have a saw on me")
|
||||
|
||||
@@ -2,17 +2,3 @@
|
||||
|
||||
|
||||
|
||||
function GetKitInInventory(surgeon)
|
||||
local playerInv = surgeon:getInventory();
|
||||
local item = playerInv:getItemFromType('TOC.Real_surgeon_kit') or playerInv:getItemFromType('TOC.Surgeon_kit') or playerInv:getItemFromType('TOC.Improvised_surgeon_kit')
|
||||
return item
|
||||
|
||||
end
|
||||
|
||||
|
||||
function GetSawInInventory(surgeon)
|
||||
|
||||
local player_inv = surgeon:getInventory()
|
||||
local item = player_inv:getItemFromType("Saw") or player_inv:getItemFromType("GardenSaw") or player_inv:getItemFromType("Chainsaw")
|
||||
return item
|
||||
end
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
|
||||
|
||||
|
||||
|
||||
-- CutLimb
|
||||
-- TODO if TheONlyCure. triggers an errors
|
||||
function CheckIfStillInfected(part_data)
|
||||
function TocCheckIfStillInfected(part_data)
|
||||
if part_data == nil then
|
||||
return
|
||||
end
|
||||
@@ -77,6 +81,21 @@ function TocDeleteOtherAmputatedLimbs(side)
|
||||
|
||||
end
|
||||
|
||||
function TocGetKitInInventory(surgeon)
|
||||
local playerInv = surgeon:getInventory();
|
||||
local item = playerInv:getItemFromType('TOC.Real_surgeon_kit') or playerInv:getItemFromType('TOC.Surgeon_kit') or playerInv:getItemFromType('TOC.Improvised_surgeon_kit')
|
||||
return item
|
||||
|
||||
end
|
||||
|
||||
|
||||
function TocGetSawInInventory(surgeon)
|
||||
|
||||
local player_inv = surgeon:getInventory()
|
||||
local item = player_inv:getItemFromType("Saw") or player_inv:getItemFromType("GardenSaw") or player_inv:getItemFromType("Chainsaw")
|
||||
return item
|
||||
end
|
||||
|
||||
-- OperateLimb
|
||||
function SetBodyPartsStatusAfterOperation(player, part_data, part_name, use_oven)
|
||||
--for _, v in ipairs(GetBodyParts()) do
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
function TocCutLocal(_, patient, surgeon, part_name)
|
||||
if GetSawInInventory(surgeon) ~= nil then
|
||||
if TocGetSawInInventory(surgeon) ~= nil then
|
||||
ISTimedActionQueue.add(ISCutLimb:new(patient, surgeon, part_name));
|
||||
else
|
||||
surgeon:Say("I don't have a saw on me")
|
||||
@@ -12,7 +12,7 @@ function TocOperateLocal(_, patient, surgeon, part_name, use_oven)
|
||||
if use_oven then
|
||||
ISTimedActionQueue.add(ISOperateLimb:new(patient, surgeon, _, part_name, use_oven));
|
||||
else
|
||||
local kit = GetKitInInventory(surgeon)
|
||||
local kit = TocGetKitInInventory(surgeon)
|
||||
if kit ~= nil then
|
||||
ISTimedActionQueue.add(ISOperateLimb:new(patient, surgeon, kit, part_name, false))
|
||||
else
|
||||
@@ -36,6 +36,6 @@ function TocEquipProsthesisLocal(_, patient, surgeon, part_name)
|
||||
end
|
||||
|
||||
function TocUnequipProsthesisLocal(_, patient, part_name)
|
||||
local equipped_prosthesis = FindTocItemWorn(part_name, patient)
|
||||
local equipped_prosthesis = TocFindItemInProstBodyLocation(part_name, patient)
|
||||
ISTimedActionQueue.add(ISUninstallProsthesis:new(patient, equipped_prosthesis, patient:getBodyDamage():getBodyPart(TocGetBodyPartTypeFromPartName(part_name))))
|
||||
end
|
||||
@@ -369,7 +369,7 @@ end
|
||||
|
||||
function SetupTocDescUI(surgeon, patient, toc_data, part_name)
|
||||
local part_data = toc_data.Limbs[part_name]
|
||||
desc_ui["textTitle"]:setText(TocGetDisplayText(part_name))
|
||||
desc_ui["textTitle"]:setText(getText("UI_ContextMenu_" .. part_name))
|
||||
desc_ui.part_name = part_name
|
||||
desc_ui.surgeon = surgeon
|
||||
desc_ui.patient = patient
|
||||
@@ -441,11 +441,11 @@ function SetupTocDescUI(surgeon, patient, toc_data, part_name)
|
||||
-- TODO add check for cuts and scratches
|
||||
desc_ui["status"]:setText("Not cut")
|
||||
desc_ui["status"]:setColor(1, 1, 1, 1)
|
||||
if GetSawInInventory(surgeon) and not CheckIfProsthesisAlreadyInstalled(toc_data.Limbs, part_name) then
|
||||
if TocGetSawInInventory(surgeon) and not CheckIfProsthesisAlreadyInstalled(toc_data.Limbs, part_name) then
|
||||
desc_ui["b1"]:setVisible(true)
|
||||
desc_ui["b1"]:setText("Cut")
|
||||
desc_ui["b1"]:addArg("option", "Cut")
|
||||
elseif GetSawInInventory(surgeon) and CheckIfProsthesisAlreadyInstalled(toc_data.Limbs, part_name) then
|
||||
elseif TocGetSawInInventory(surgeon) and CheckIfProsthesisAlreadyInstalled(toc_data.Limbs, part_name) then
|
||||
desc_ui["b1"]:setVisible(true)
|
||||
desc_ui["b1"]:setText("Remove prosthesis before")
|
||||
desc_ui["b1"]:addArg("option", "Nothing")
|
||||
@@ -493,7 +493,7 @@ function SendCommandToConfirmUIMP(action, isBitten, userName, partName)
|
||||
confirm_ui_mp:open()
|
||||
|
||||
if action == "Cut" or action == "Operate" then
|
||||
confirm_ui_mp["text4"]:setText("You're gonna " .. action .. " the " .. TocGetDisplayText(partName) .. " of " .. userName)
|
||||
confirm_ui_mp["text4"]:setText("You're gonna " .. action .. " the " .. getText("UI_ContextMenu_" .. partName) .. " of " .. userName)
|
||||
confirm_ui_mp["text2"]:setText("Are you sure?")
|
||||
confirm_ui_mp["text2"]:setColor(1, 0, 0, 0)
|
||||
confirm_ui_mp["b1"]:setVisible(true);
|
||||
|
||||
@@ -18,7 +18,7 @@ function TheOnlyCure.CheckIfPlayerIsInfected(player, toc_data)
|
||||
local body_damage = player:getBodyDamage()
|
||||
|
||||
for _, v in ipairs(GetLimbsBodyPartTypes()) do
|
||||
local part_name = FindTocBodyPartNameFromBodyPartType(v)
|
||||
local part_name = TocGetPartNameFromBodyPartType(v)
|
||||
local part_data = toc_data.Limbs[part_name]
|
||||
|
||||
|
||||
|
||||
@@ -270,7 +270,7 @@ function TheOnlyCure.CutLimb(part_name, surgeon_factor, bandage_table, painkille
|
||||
body_part:setBiteTime(0)
|
||||
|
||||
-- Second check, let's see if there is any other infected limb.
|
||||
if CheckIfStillInfected(part_data) == false then
|
||||
if TocCheckIfStillInfected(part_data) == false then
|
||||
TocCureInfection(body_damage, part_data, part_name)
|
||||
getPlayer():Say("I'm gonna be fine...")
|
||||
else
|
||||
@@ -391,7 +391,7 @@ function TryTocAction(_, part_name, action, surgeon, patient)
|
||||
|
||||
elseif action == "Unequip" then
|
||||
--AskCanUnequipProsthesis(patient, part_name)
|
||||
local equipped_prosthesis = FindTocItemWorn(part_name, patient)
|
||||
local equipped_prosthesis = TocFindItemInProstBodyLocation(part_name, patient)
|
||||
ISTimedActionQueue.add(ISUninstallProsthesis:new(patient, equipped_prosthesis, patient:getBodyDamage():getBodyPart(TocGetBodyPartTypeFromPartName(part_name))))
|
||||
end
|
||||
ui.actionAct = action
|
||||
|
||||
@@ -25,7 +25,7 @@ end
|
||||
function ISCutLimb:start()
|
||||
|
||||
self:setActionAnim("SawLog")
|
||||
local saw_item = GetSawInInventory(self.surgeon)
|
||||
local saw_item = TocGetSawInInventory(self.surgeon)
|
||||
|
||||
|
||||
-- Return whatever object we've got in the inventory
|
||||
|
||||
@@ -51,7 +51,7 @@ function ISUninstallProsthesis:perform()
|
||||
|
||||
for _, v in ipairs(GetAcceptingProsthesisBodyPartTypes()) do
|
||||
if self.bodyPart:getType() == v then
|
||||
local part_name = FindTocBodyPartNameFromBodyPartType(v)
|
||||
local part_name = TocGetPartNameFromBodyPartType(v)
|
||||
|
||||
print("Found prost in " .. part_name)
|
||||
if part_name then
|
||||
|
||||
@@ -1,122 +0,0 @@
|
||||
|
||||
function GetInstallableProsthesisList()
|
||||
|
||||
-- TODO Delete this and re do it
|
||||
|
||||
-- To make it future proof since i'm gonna add stuff, let's cycle through already known prosthesis
|
||||
local prosthesis_list = GetProsthesisList()
|
||||
|
||||
local sides = {"right", "left"}
|
||||
local body_parts = {"Hand", "Forearm", "Arm"}
|
||||
local installed_prosthesis_list = {}
|
||||
|
||||
for _, side in pairs(sides) do
|
||||
for _, prost in pairs(prosthesis_list) do
|
||||
for _, body_part in pairs(body_parts) do
|
||||
local installable_prost = prost .. "_" .. side .. "_no" .. body_part
|
||||
print(installable_prost)
|
||||
table.insert(installed_prosthesis_list, installable_prost)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return installed_prosthesis_list
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
local function PartNameToBodyLocation(name)
|
||||
if name == "Right_Hand" then return "ArmRight_Prot" end
|
||||
if name == "Right_LowerArm" then return "ArmRight_Prot" end
|
||||
if name == "Right_UpperArm" then return "ArmRight_Prot" end
|
||||
if name == "Left_Hand" then return "ArmLeft_Prot" end
|
||||
if name == "Left_LowerArm" then return "ArmLeft_Prot" end
|
||||
if name == "Left_UpperArm" then return "ArmLeft_Prot" end
|
||||
end
|
||||
|
||||
|
||||
-- TODO find a better name, this doesnt check for amputation only for prosthetics
|
||||
function FindTocItemWorn(part_name, patient)
|
||||
local worn_items = patient:getWornItems()
|
||||
|
||||
for i=1,worn_items:size()-1 do -- Maybe wornItems:size()-1
|
||||
local item = worn_items:get(i):getItem();
|
||||
if item:getBodyLocation() == PartNameToBodyLocation(part_name) then
|
||||
return item;
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
function TocGetPartNameFromBodyPartType(body_part)
|
||||
|
||||
if body_part == BodyPartType.Hand_R then return "Right_Hand"
|
||||
elseif body_part == BodyPartType.ForeArm_R then return "Right_LowerArm"
|
||||
elseif body_part == BodyPartType.UpperArm_R then return "Right_UpperArm"
|
||||
elseif body_part == BodyPartType.Hand_L then return "Left_Hand"
|
||||
elseif body_part == BodyPartType.ForeArm_L then return "Left_LowerArm"
|
||||
elseif body_part == BodyPartType.UpperArm_L then return "Left_UpperArm"
|
||||
else return nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- TODO ew
|
||||
function find_clothName_TOC(bodyPart)
|
||||
if bodyPart:getType() == BodyPartType.Hand_R then return "TOC.ArmRight_noHand"
|
||||
elseif bodyPart:getType() == BodyPartType.ForeArm_R then return "TOC.ArmRight_noForearm"
|
||||
elseif bodyPart:getType() == BodyPartType.UpperArm_R then return "TOC.ArmRight_noArm"
|
||||
elseif bodyPart:getType() == BodyPartType.Hand_L then return "TOC.ArmLeft_noHand"
|
||||
elseif bodyPart:getType() == BodyPartType.ForeArm_L then return "TOC.ArmLeft_noForearm"
|
||||
elseif bodyPart:getType() == BodyPartType.UpperArm_L then return "TOC.ArmLeft_noArm"
|
||||
else return nil
|
||||
end
|
||||
end
|
||||
|
||||
function TocGetDisplayText(part_name)
|
||||
return getText("UI_ContextMenu_" .. part_name)
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function TocFindProsthesisFactorFromItem(item)
|
||||
|
||||
local itemType = item:getType()
|
||||
|
||||
-- TODO change this
|
||||
|
||||
|
||||
if string.find(itemType, "WoodenHook") and string.find(itemType, "noHand") then return 1.5
|
||||
elseif string.find(itemType, "WoodenHook") and string.find(itemType, "noForearm") then return 1.65
|
||||
elseif string.find(itemType, "MetalHook") and string.find(itemType, "noHand") then return 1.3
|
||||
elseif string.find(itemType, "MetalHook") and string.find(itemType, "noForearm") then return 1.45
|
||||
elseif string.find(itemType, "MetalHand") and string.find(itemType, "noHand") then return 1.1
|
||||
elseif string.find(itemType, "MetalHand") and string.find(itemType, "noForearm") then return 1.25
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function TocFindCorrectClothingProsthesis(item_name, part_name)
|
||||
|
||||
local correct_name = "TOC.Prost_" .. part_name .. "_" .. item_name
|
||||
return correct_name
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user