Cleaning stuff

This commit is contained in:
Pao
2023-01-22 04:04:02 +01:00
parent 318c34bb9b
commit b6b010705a
11 changed files with 77 additions and 157 deletions

View File

@@ -51,17 +51,22 @@ function FindTocDataPartNameFromBodyPartType(toc_limbs_data, bodyPartType)
end end
function FindTocBodyPartNameFromBodyPartType(bodyPartType)
if bodyPartType == BodyPartType.Hand_R then return "Right_Hand" function TocGetPartNameFromBodyPartType(body_part)
elseif bodyPartType == BodyPartType.ForeArm_R then return "Right_LowerArm"
elseif bodyPartType == BodyPartType.UpperArm_R then return "Right_UpperArm" if body_part == BodyPartType.Hand_R then return "Right_Hand"
elseif bodyPartType == BodyPartType.Hand_L then return "Left_Hand" elseif body_part == BodyPartType.ForeArm_R then return "Right_LowerArm"
elseif bodyPartType == BodyPartType.ForeArm_L then return "Left_LowerArm" elseif body_part == BodyPartType.UpperArm_R then return "Right_UpperArm"
elseif bodyPartType == BodyPartType.UpperArm_L then return "Left_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 else return nil
end end
end end
function TocGetBodyPartTypeFromPartName(part_name) function TocGetBodyPartTypeFromPartName(part_name)
if part_name == "Right_Hand" then return BodyPartType.Hand_R end if part_name == "Right_Hand" then return BodyPartType.Hand_R end
if part_name == "Right_LowerArm" then return BodyPartType.ForeArm_R end if part_name == "Right_LowerArm" then return BodyPartType.ForeArm_R end
@@ -72,4 +77,36 @@ function TocGetBodyPartTypeFromPartName(part_name)
end 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

View File

@@ -103,7 +103,7 @@ end
TocContextMenus.DoCut = function(_, patient, surgeon, part_name) TocContextMenus.DoCut = function(_, patient, surgeon, part_name)
if GetSawInInventory(surgeon) then if TocGetSawInInventory(surgeon) then
ISTimedActionQueue.add(ISCutLimb:new(patient, surgeon, part_name)); ISTimedActionQueue.add(ISCutLimb:new(patient, surgeon, part_name));
else else
surgeon:Say("I don't have a saw on me") surgeon:Say("I don't have a saw on me")

View File

@@ -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

View File

@@ -1,6 +1,10 @@
-- CutLimb -- CutLimb
-- TODO if TheONlyCure. triggers an errors -- TODO if TheONlyCure. triggers an errors
function CheckIfStillInfected(part_data) function TocCheckIfStillInfected(part_data)
if part_data == nil then if part_data == nil then
return return
end end
@@ -77,6 +81,21 @@ function TocDeleteOtherAmputatedLimbs(side)
end 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 -- OperateLimb
function SetBodyPartsStatusAfterOperation(player, part_data, part_name, use_oven) function SetBodyPartsStatusAfterOperation(player, part_data, part_name, use_oven)
--for _, v in ipairs(GetBodyParts()) do --for _, v in ipairs(GetBodyParts()) do

View File

@@ -1,5 +1,5 @@
function TocCutLocal(_, patient, surgeon, part_name) function TocCutLocal(_, patient, surgeon, part_name)
if GetSawInInventory(surgeon) ~= nil then if TocGetSawInInventory(surgeon) ~= nil then
ISTimedActionQueue.add(ISCutLimb:new(patient, surgeon, part_name)); ISTimedActionQueue.add(ISCutLimb:new(patient, surgeon, part_name));
else else
surgeon:Say("I don't have a saw on me") 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 if use_oven then
ISTimedActionQueue.add(ISOperateLimb:new(patient, surgeon, _, part_name, use_oven)); ISTimedActionQueue.add(ISOperateLimb:new(patient, surgeon, _, part_name, use_oven));
else else
local kit = GetKitInInventory(surgeon) local kit = TocGetKitInInventory(surgeon)
if kit ~= nil then if kit ~= nil then
ISTimedActionQueue.add(ISOperateLimb:new(patient, surgeon, kit, part_name, false)) ISTimedActionQueue.add(ISOperateLimb:new(patient, surgeon, kit, part_name, false))
else else
@@ -36,6 +36,6 @@ function TocEquipProsthesisLocal(_, patient, surgeon, part_name)
end end
function TocUnequipProsthesisLocal(_, patient, part_name) 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)))) ISTimedActionQueue.add(ISUninstallProsthesis:new(patient, equipped_prosthesis, patient:getBodyDamage():getBodyPart(TocGetBodyPartTypeFromPartName(part_name))))
end end

View File

@@ -369,7 +369,7 @@ end
function SetupTocDescUI(surgeon, patient, toc_data, part_name) function SetupTocDescUI(surgeon, patient, toc_data, part_name)
local part_data = toc_data.Limbs[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.part_name = part_name
desc_ui.surgeon = surgeon desc_ui.surgeon = surgeon
desc_ui.patient = patient desc_ui.patient = patient
@@ -441,11 +441,11 @@ function SetupTocDescUI(surgeon, patient, toc_data, part_name)
-- TODO add check for cuts and scratches -- TODO add check for cuts and scratches
desc_ui["status"]:setText("Not cut") desc_ui["status"]:setText("Not cut")
desc_ui["status"]:setColor(1, 1, 1, 1) 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"]:setVisible(true)
desc_ui["b1"]:setText("Cut") desc_ui["b1"]:setText("Cut")
desc_ui["b1"]:addArg("option", "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"]:setVisible(true)
desc_ui["b1"]:setText("Remove prosthesis before") desc_ui["b1"]:setText("Remove prosthesis before")
desc_ui["b1"]:addArg("option", "Nothing") desc_ui["b1"]:addArg("option", "Nothing")
@@ -493,7 +493,7 @@ function SendCommandToConfirmUIMP(action, isBitten, userName, partName)
confirm_ui_mp:open() confirm_ui_mp:open()
if action == "Cut" or action == "Operate" then 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"]:setText("Are you sure?")
confirm_ui_mp["text2"]:setColor(1, 0, 0, 0) confirm_ui_mp["text2"]:setColor(1, 0, 0, 0)
confirm_ui_mp["b1"]:setVisible(true); confirm_ui_mp["b1"]:setVisible(true);

View File

@@ -18,7 +18,7 @@ function TheOnlyCure.CheckIfPlayerIsInfected(player, toc_data)
local body_damage = player:getBodyDamage() local body_damage = player:getBodyDamage()
for _, v in ipairs(GetLimbsBodyPartTypes()) do for _, v in ipairs(GetLimbsBodyPartTypes()) do
local part_name = FindTocBodyPartNameFromBodyPartType(v) local part_name = TocGetPartNameFromBodyPartType(v)
local part_data = toc_data.Limbs[part_name] local part_data = toc_data.Limbs[part_name]

View File

@@ -270,7 +270,7 @@ function TheOnlyCure.CutLimb(part_name, surgeon_factor, bandage_table, painkille
body_part:setBiteTime(0) body_part:setBiteTime(0)
-- Second check, let's see if there is any other infected limb. -- 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) TocCureInfection(body_damage, part_data, part_name)
getPlayer():Say("I'm gonna be fine...") getPlayer():Say("I'm gonna be fine...")
else else
@@ -391,7 +391,7 @@ function TryTocAction(_, part_name, action, surgeon, patient)
elseif action == "Unequip" then elseif action == "Unequip" then
--AskCanUnequipProsthesis(patient, part_name) --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)))) ISTimedActionQueue.add(ISUninstallProsthesis:new(patient, equipped_prosthesis, patient:getBodyDamage():getBodyPart(TocGetBodyPartTypeFromPartName(part_name))))
end end
ui.actionAct = action ui.actionAct = action

View File

@@ -25,7 +25,7 @@ end
function ISCutLimb:start() function ISCutLimb:start()
self:setActionAnim("SawLog") self:setActionAnim("SawLog")
local saw_item = GetSawInInventory(self.surgeon) local saw_item = TocGetSawInInventory(self.surgeon)
-- Return whatever object we've got in the inventory -- Return whatever object we've got in the inventory

View File

@@ -51,7 +51,7 @@ function ISUninstallProsthesis:perform()
for _, v in ipairs(GetAcceptingProsthesisBodyPartTypes()) do for _, v in ipairs(GetAcceptingProsthesisBodyPartTypes()) do
if self.bodyPart:getType() == v then if self.bodyPart:getType() == v then
local part_name = FindTocBodyPartNameFromBodyPartType(v) local part_name = TocGetPartNameFromBodyPartType(v)
print("Found prost in " .. part_name) print("Found prost in " .. part_name)
if part_name then if part_name then

View File

@@ -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