From 5b3e10c0dbca4f6e93de1c20072c56b512e1b202 Mon Sep 17 00:00:00 2001 From: Pao Date: Wed, 18 Jan 2023 02:56:09 +0100 Subject: [PATCH] I think I got almost everything. Now to check it --- media/lua/client/TOC_CommonFunctions.lua | 39 +-- media/lua/client/TOC_Test.lua | 230 +++++++++--------- media/lua/client/TOC_UI.lua | 46 ++-- media/lua/client/TOC_Update.lua | 20 +- media/lua/client/TOC_main.lua | 222 +++++++++-------- .../TimedActions/ISInstallProsthesis.lua | 8 +- .../TimedActions/ISUninstallProsthesis.lua | 4 +- .../TimedActions/OverridenFunctions.lua | 11 +- media/lua/client/Utils/UsefulFunctions.lua | 127 +++------- media/lua/shared/NPCs/ExtraBodyLocations.lua | 1 + media/lua/shared/translate/EN/IG_UI_EN.txt | 6 +- media/lua/shared/translate/EN/UI_EN.txt | 12 +- media/perks.txt | 4 +- 13 files changed, 352 insertions(+), 378 deletions(-) diff --git a/media/lua/client/TOC_CommonFunctions.lua b/media/lua/client/TOC_CommonFunctions.lua index e64f6a6..db94d18 100644 --- a/media/lua/client/TOC_CommonFunctions.lua +++ b/media/lua/client/TOC_CommonFunctions.lua @@ -1,5 +1,6 @@ function GetBodyParts() - local bodyparts = { "RightHand", "RightForearm", "RightArm", "LeftHand", "LeftForearm", "LeftArm"} + local bodyparts = { "Right_Hand", "Right_LowerArm", "Right_UpperArm", + "Left_Hand", "Left_LowerArm", "Left_UpperArm"} return bodyparts end @@ -18,25 +19,35 @@ function GetOtherBodyPartTypes() end -function FindTocDataPartNameFromBodyPartType(toc_data, bodyPartType) - if bodyPartType == BodyPartType.Hand_R then return toc_data.RightHand - elseif bodyPartType == BodyPartType.ForeArm_R then return toc_data.RightForearm - elseif bodyPartType == BodyPartType.UpperArm_R then return toc_data.RightArm - elseif bodyPartType == BodyPartType.Hand_L then return toc_data.LeftHand - elseif bodyPartType == BodyPartType.ForeArm_L then return toc_data.LeftForearm - elseif bodyPartType == BodyPartType.UpperArm_L then return toc_data.LeftArm +function GetAcceptingProsthesisBodyPartTypes() + + + return {BodyPartType.Hand_R, BodyPartType.ForeArm_R, + BodyPartType.Hand_L, BodyPartType.ForeArm_L} + + +end + +-- TODO Change name +function FindTocDataPartNameFromBodyPartType(toc_limbs_data, bodyPartType) + if bodyPartType == BodyPartType.Hand_R then return toc_limbs_data.Right_Hand + elseif bodyPartType == BodyPartType.ForeArm_R then return toc_limbs_data.Right_LowerArm + elseif bodyPartType == BodyPartType.UpperArm_R then return toc_limbs_data.Right_UpperArm + elseif bodyPartType == BodyPartType.Hand_L then return toc_limbs_data.Left_Hand + elseif bodyPartType == BodyPartType.ForeArm_L then return toc_limbs_data.Left_LowerArm + elseif bodyPartType == BodyPartType.UpperArm_L then return toc_limbs_data.Left_UpperArm else return nil end end function FindTocBodyPartNameFromBodyPartType(bodyPartType) - if bodyPartType == BodyPartType.Hand_R then return "RightHand" - elseif bodyPartType == BodyPartType.ForeArm_R then return "RightForearm" - elseif bodyPartType == BodyPartType.UpperArm_R then return "RightArm" - elseif bodyPartType == BodyPartType.Hand_L then return "LeftHand" - elseif bodyPartType == BodyPartType.ForeArm_L then return "LeftForearm" - elseif bodyPartType == BodyPartType.UpperArm_L then return "LeftArm" + 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" else return nil end end diff --git a/media/lua/client/TOC_Test.lua b/media/lua/client/TOC_Test.lua index 1c3bfd6..769e296 100644 --- a/media/lua/client/TOC_Test.lua +++ b/media/lua/client/TOC_Test.lua @@ -4,121 +4,131 @@ function TestStuffToc() local mod_data = player:getModData().TOC - mod_data.TOC = {} + + if mod_data.TOC == nil then + mod_data.TOC = {} - mod_data.TOC = { - - Limbs = {}, - Prosthesis = {}, - Generic = {}, - } - - - - - -------- - -- NEW NAMING SCHEME - - ---- Amputations - - -- Amputation_Left_Hand - -- Amputation_Right_UpperArm - - - ---- Prosthesis to equip - -- Prost_Left_Hand_MetalHook - -- Prost_Right_Forearm_WoodenHook - - --- Objects - -- Prost_Object_WoddenHook - - - local sides = {"Left", "Right"} - local limbs = {"Hand", "LowerArm", "UpperArm"} -- Let's follow their naming - - - local prosthesis_list = {"WoodenHook", "MetalHook", "MetalHand"} - - - - local accepted_prosthesis_hand = {"WoodenHook", "MetalHook", "MetalHand"} - local accepted_prosthesis_lowerarm = {"WoodenHook", "MetalHook", "MetalHand"} - local accepted_prosthesis_upperarm = {} -- For future stuff - - - - - - for _, side in ipairs(sides) do - for _, limb in ipairs(limbs) do - - local part_name = side .. "_" .. limb - - mod_data.TOC.Limbs[part_name].is_cut = false - mod_data.TOC.Limbs[part_name].is_infected = false - mod_data.TOC.Limbs[part_name].is_operated = false - mod_data.TOC.Limbs[part_name].is_cicatrized = false - mod_data.TOC.Limbs[part_name].is_cauterized = false - mod_data.TOC.Limbs[part_name].is_amputation_shown = false + mod_data.TOC = { - mod_data.TOC.Limbs[part_name].cicatrization_time = 0 - - - mod_data.TOC.Limbs[part_name].is_prosthesis_equipped = false - mod_data.TOC.Limbs[part_name].prosthesis_factor = 1.0 - mod_data.TOC.Limbs[part_name].prosthesis_material_id = nil - - - -- Even if there are some duplicates, this is just easier in the end since we're gonna get fairly easily part_name - if limb == "Hand" then - mod_data.TOC.Limbs[part_name].cicatrization_base_time = 1700 - mod_data.TOC.Limbs[part_name].depends_on = {} - mod_data.TOC.Prosthesis.AcceptedProsthesis[part_name] = accepted_prosthesis_hand - elseif limb == "LowerArm" then - mod_data.TOC.Limbs[part_name].cicatrization_base_time = 1800 - mod_data.TOC.Limbs[part_name].depends_on = {side .. "_Hand",} - mod_data.TOC.Prosthesis.AcceptedProsthesis[part_name] = accepted_prosthesis_lowerarm - elseif limb == "UpperArm" then - mod_data.TOC.Limbs[part_name].cicatrization_base_time = 2000 - mod_data.TOC.Limbs[part_name].depends_on = {side .. "_Hand", side .. "_LowerArm",} - mod_data.TOC.Prosthesis.AcceptedProsthesis[part_name] = accepted_prosthesis_upperarm - end - - end - end - - for _, v in ipairs(prosthesis_list) do + Limbs = {}, + Prosthesis = {}, + Generic = {}, + } + + + + + -------- + -- NEW NAMING SCHEME + + ---- Amputations + + -- Amputation_Left_Hand + -- Amputation_Right_UpperArm + + + ---- Prosthesis to equip + -- Prost_Left_Hand_MetalHook + -- Prost_Right_Forearm_WoodenHook + + --- Objects + -- Prost_Object_WoddenHook + + + local sides = {"Left", "Right"} + local limbs = {"Hand", "LowerArm", "UpperArm"} -- Let's follow their naming + + + local prosthesis_list = {"WoodenHook", "MetalHook", "MetalHand"} + + + + local accepted_prosthesis_hand = {"WoodenHook", "MetalHook", "MetalHand"} + local accepted_prosthesis_lowerarm = {"WoodenHook", "MetalHook", "MetalHand"} + local accepted_prosthesis_upperarm = {} -- For future stuff + + + + + + for _, side in ipairs(sides) do + for _, limb in ipairs(limbs) do + + local part_name = side .. "_" .. limb + + mod_data.TOC.Limbs[part_name].is_cut = false + mod_data.TOC.Limbs[part_name].is_infected = false + mod_data.TOC.Limbs[part_name].is_operated = false + mod_data.TOC.Limbs[part_name].is_cicatrized = false + mod_data.TOC.Limbs[part_name].is_cauterized = false + mod_data.TOC.Limbs[part_name].is_amputation_shown = false - mod_data.TOC.Prosthesis[v].prosthesis_factor = 1.0 -- Default - mod_data.TOC.Limbs[v].prosthesis_material_id = nil -- Set texture? - - -- TODO Something else? + mod_data.TOC.Limbs[part_name].cicatrization_time = 0 + + + mod_data.TOC.Limbs[part_name].is_prosthesis_equipped = false + mod_data.TOC.Limbs[part_name].prosthesis_factor = 1.0 + mod_data.TOC.Limbs[part_name].prosthesis_material_id = nil + + + -- Even if there are some duplicates, this is just easier in the end since we're gonna get fairly easily part_name + + + if limb == "Hand" then + mod_data.TOC.Limbs[part_name].cicatrization_base_time = 1700 + mod_data.TOC.Limbs[part_name].depends_on = {} + + mod_data.TOC.Prosthesis.AcceptedProsthesis[part_name] = accepted_prosthesis_hand + mod_data.TOC.Prosthesis["WoodenHook"][part_name].prosthesis_factor = 1.5 + mod_data.TOC.Prosthesis["MetalHook"][part_name].prosthesis_factor = 1.3 + mod_data.TOC.Prosthesis["MetalHand"][part_name].prosthesis_factor = 1.1 + + + elseif limb == "LowerArm" then + mod_data.TOC.Limbs[part_name].cicatrization_base_time = 1800 + mod_data.TOC.Limbs[part_name].depends_on = {side .. "_Hand",} + mod_data.TOC.Prosthesis.AcceptedProsthesis[part_name] = accepted_prosthesis_lowerarm + + mod_data.TOC.Prosthesis["WoodenHook"][part_name].prosthesis_factor = 1.65 + mod_data.TOC.Prosthesis["MetalHook"][part_name].prosthesis_factor = 1.45 + mod_data.TOC.Prosthesis["MetalHand"][part_name].prosthesis_factor = 1.25 + elseif limb == "UpperArm" then + mod_data.TOC.Limbs[part_name].cicatrization_base_time = 2000 + mod_data.TOC.Limbs[part_name].depends_on = {side .. "_Hand", side .. "_LowerArm",} + mod_data.TOC.Prosthesis.AcceptedProsthesis[part_name] = accepted_prosthesis_upperarm + end + + end + end + + -- Setup traits + if player:HasTrait("Amputee_Hand") then + + -- TODO override AddItem so we can change the texture dynamically based on skin color + local amputation_clothing = player:getInventory():AddItem("TOC.Amputation_Left_Hand") + player:setWornItem(amputation_clothing:getBodyLocation(), amputation_clothing) + mod_data.TOC.Left_Hand.is_cut = true + mod_data.TOC.Left_Hand.is_operated = true + mod_data.TOC.Left_Hand.is_amputation_shown = true + mod_data.TOC.Left_Hand.is_cicatrized = true + elseif player:HasTrait("Amputee_LowerArm") then + local amputation_clothing = player:getInventory():AddItem("TOC.Amputation_Left_LowerArm") + player:setWornItem(amputation_clothing:getBodyLocation(), amputation_clothing) + mod_data.TOC.Left_LowerArm.is_cut = true + mod_data.TOC.Left_LowerArm.is_operated = true + mod_data.TOC.Left_LowerArm.is_amputation_shown = true + mod_data.TOC.Left_LowerArm.is_cicatrized = true + elseif player:HasTrait("Amputee_UpperArm") then + local amputation_clothing = player:getInventory():AddItem("TOC.Amputation_Left_UpperArm") + player:setWornItem(amputation_clothing:getBodyLocation(), amputation_clothing) + mod_data.TOC.Left_UpperArm.is_cut = true + mod_data.TOC.Left_UpperArm.is_operated = true + mod_data.TOC.Left_UpperArm.is_amputation_shown = true + mod_data.TOC.Left_UpperArm.is_cicatrized = true + end end - - -- Setup traits - if player:HasTrait("Amputee_Hand") then - local amputation_clothing = player:getInventory():AddItem("TOC.Amputation_Left_Hand") - player:setWornItem(amputation_clothing:getBodyLocation(), amputation_clothing) - mod_data.TOC.Left_Hand.is_cut = true - mod_data.TOC.Left_Hand.is_operated = true - mod_data.TOC.Left_Hand.is_amputation_shown = true - mod_data.TOC.Left_Hand.is_cicatrized = true - elseif player:HasTrait("Amputee_LowerArm") then - local amputation_clothing = player:getInventory():AddItem("TOC.Amputation_Left_LowerArm") - player:setWornItem(amputation_clothing:getBodyLocation(), amputation_clothing) - mod_data.TOC.Left_LowerArm.is_cut = true - mod_data.TOC.Left_LowerArm.is_operated = true - mod_data.TOC.Left_LowerArm.is_amputation_shown = true - mod_data.TOC.Left_LowerArm.is_cicatrized = true - elseif player:HasTrait("Amputee_UpperArm") then - local amputation_clothing = player:getInventory():AddItem("TOC.Amputation_Left_UpperArm") - player:setWornItem(amputation_clothing:getBodyLocation(), amputation_clothing) - mod_data.TOC.Left_UpperArm.is_cut = true - mod_data.TOC.Left_UpperArm.is_operated = true - mod_data.TOC.Left_UpperArm.is_amputation_shown = true - mod_data.TOC.Left_UpperArm.is_cicatrized = true - end + end diff --git a/media/lua/client/TOC_UI.lua b/media/lua/client/TOC_UI.lua index 0c9859a..235f367 100644 --- a/media/lua/client/TOC_UI.lua +++ b/media/lua/client/TOC_UI.lua @@ -36,11 +36,11 @@ end ------------------------------ -- UI Visible stuff functions local function GetImageName(part_name, toc_data) - local part_data = toc_data[part_name]; + local part_data = toc_data.Limbs[part_name] local name = "" if part_data.is_cut and part_data.is_cicatrized and part_data.is_prosthesis_equipped then -- Cut and equip - if part_name == "RightHand" or part_name == "LeftHand" then + if part_name == "Right_Hand" or part_name == "Left_Hand" then name = "media/ui/TOC/" .. part_name .. "/Hook.png" else name = "media/ui/TOC/" .. part_name .. "/Prothesis.png" @@ -60,12 +60,12 @@ local function GetImageName(part_name, toc_data) end -- If foreaerm equip, change hand - if part_name == "RightHand" and toc_data["RightForearm"].is_prosthesis_equipped then + if part_name == "Right_Hand" and toc_data["Right_LowerArm"].is_prosthesis_equipped then name = "media/ui/TOC/" .. part_name .. "/Hook.png" - elseif part_name == "LeftHand" and toc_data["LeftForearm"].is_prosthesis_equipped then + elseif part_name == "Left_Hand" and toc_data["Left_LowerArm"].is_prosthesis_equipped then name = "media/ui/TOC/" .. part_name .. "/Hook.png" end - return name; + return name end @@ -221,28 +221,28 @@ function CreateTocMainUI() main_ui:setWidthPercent(0.1) main_ui:addImageButton("b11", "", OnClickTocMainUI) - main_ui["b11"]:addArg("part_name", "RightArm") + main_ui["b11"]:addArg("part_name", "Right_UpperArm") main_ui:addImageButton("b12", "", OnClickTocMainUI) - main_ui["b12"]:addArg("part_name", "LeftArm") + main_ui["b12"]:addArg("part_name", "Left_UpperArm") main_ui:nextLine() main_ui:addImageButton("b21", "", OnClickTocMainUI) - main_ui["b21"]:addArg("part_name", "RightForearm") + main_ui["b21"]:addArg("part_name", "Right_LowerArm") main_ui:addImageButton("b22", "", OnClickTocMainUI) - main_ui["b22"]:addArg("part_name", "LeftForearm") + main_ui["b22"]:addArg("part_name", "Left_LowerArm") main_ui:nextLine() main_ui:addImageButton("b31", "", OnClickTocMainUI) - main_ui["b31"]:addArg("part_name", "RightHand") + main_ui["b31"]:addArg("part_name", "Right_Hand") main_ui:addImageButton("b32", "", OnClickTocMainUI) - main_ui["b32"]:addArg("part_name", "LeftHand") + main_ui["b32"]:addArg("part_name", "Left_Hand") main_ui:saveLayout() @@ -353,14 +353,14 @@ function SetupTocMainUI(surgeon, patient, toc_data) main_ui["b31"]:addArg("toc_data", toc_data) main_ui["b32"]:addArg("toc_data", toc_data) - main_ui["b11"]:setPath(GetImageName("RightArm", toc_data)) - main_ui["b12"]:setPath(GetImageName("LeftArm", toc_data)) + main_ui["b11"]:setPath(GetImageName("Right_UpperArm", toc_data)) + main_ui["b12"]:setPath(GetImageName("Left_UpperArm", toc_data)) - main_ui["b21"]:setPath(GetImageName("RightForearm", toc_data)) - main_ui["b22"]:setPath(GetImageName("LeftForearm", toc_data)) + main_ui["b21"]:setPath(GetImageName("Right_LowerArm", toc_data)) + main_ui["b22"]:setPath(GetImageName("Left_LowerArm", toc_data)) - main_ui["b31"]:setPath(GetImageName("RightHand", toc_data)) - main_ui["b32"]:setPath(GetImageName("LeftHand", toc_data)) + main_ui["b31"]:setPath(GetImageName("Right_Hand", toc_data)) + main_ui["b32"]:setPath(GetImageName("Left_Hand", toc_data)) end @@ -368,7 +368,7 @@ function SetupTocMainUI(surgeon, patient, toc_data) end function SetupTocDescUI(surgeon, patient, toc_data, part_name) - local part_data = toc_data[part_name] + local part_data = toc_data.Limbs[part_name] desc_ui["textTitle"]:setText(TocGetDisplayText(part_name)) desc_ui.part_name = part_name desc_ui.surgeon = surgeon @@ -387,7 +387,7 @@ function SetupTocDescUI(surgeon, patient, toc_data, part_name) desc_ui["status"]:setColor(1, 0, 1, 0) -- Another check for UpperArm - if part_name == "RightArm" or part_name == "LeftArm" then + if part_name == "Right_UpperArm" or part_name == "Left_UpperArm" then desc_ui["b1"]:setVisible(false) else desc_ui["b1"]:setText("Equip") @@ -458,18 +458,18 @@ function SetupTocDescUI(surgeon, patient, toc_data, part_name) -- Prosthesis Level if string.find(part_name, "Right") then - local lv = patient:getPerkLevel(Perks.RightHand) + 1 + local lv = patient:getPerkLevel(Perks.Right_Hand) + 1 desc_ui["textLV2"]:setText("Level: " .. lv .. " / 10") - local xp = patient:getXp():getXP(Perks.RightHand) + local xp = patient:getXp():getXP(Perks.Right_Hand) local min, max = FindMinMax(lv) desc_ui["pbarNLV"]:setMinMax(min, max) desc_ui["pbarNLV"]:setValue(xp) else - local lv = patient:getPerkLevel(Perks.LeftHand) + 1 + local lv = patient:getPerkLevel(Perks.Left_Hand) + 1 desc_ui["textLV2"]:setText("Level: " .. lv .. " / 10") - local xp = patient:getXp():getXP(Perks.LeftHand) + local xp = patient:getXp():getXP(Perks.Left_Hand) local min, max = FindMinMax(lv) desc_ui["pbarNLV"]:setMinMax(min, max) desc_ui["pbarNLV"]:setValue(xp) diff --git a/media/lua/client/TOC_Update.lua b/media/lua/client/TOC_Update.lua index ca43c3e..e4f6dd8 100644 --- a/media/lua/client/TOC_Update.lua +++ b/media/lua/client/TOC_Update.lua @@ -33,7 +33,7 @@ function TheOnlyCure.CheckIfPlayerIsInfected(player, toc_data) local body_damage = player:getBodyDamage() for _, v in ipairs(GetLimbsBodyPartTypes()) do - local toc_bodypart = FindTocDataPartNameFromBodyPartType(toc_data, v) + local toc_bodypart = FindTocDataPartNameFromBodyPartType(toc_data.Limbs, v) if body_damage:getBodyPart(v):bitten() and toc_bodypart ~= nil then if toc_bodypart.is_cut == false then toc_bodypart.is_infected = true @@ -212,17 +212,21 @@ function TheOnlyCure.UpdateEveryTenMinutes() if player == nil then return end - local toc_data = player:getModData().TOC + local part_data = player:getModData().TOC.Limbs - --Experience for prosthesis - if toc_data.RightHand.is_prosthesis_equipped or toc_data.RightForearm.is_prosthesis_equipped then player:getXp():AddXP(Perks.RightHand, 4) end - if toc_data.LeftHand.is_prosthesis_equipped or toc_data.LeftForearm.is_prosthesis_equipped then player:getXp():AddXP(Perks.LeftHand, 4) end + --Experience for prosthesis user + for _, side in ipairs({"Left", "Right"}) do + if part_data[side .. "_Hand"].is_prosthesis_equipped or part_data[side .. "_LowerArm"].is_prosthesis_equipped then + player:getXp():AddXP(Perks[side .. "_Hand"], 4) + end - -- Updates the cicatrization timesssss + end + + -- Updates the cicatrization time for _, part_name in pairs(GetBodyParts()) do - if toc_data[part_name].is_cut and not toc_data[part_name].is_cicatrized then - toc_data[part_name].cicatrization_time = toc_data[part_name].cicatrization_time - 1 -- TODO Make it more "dynamic" + if part_data[part_name].is_cut and not part_data[part_name].is_cicatrized then + part_data[part_name].cicatrization_time = part_data[part_name].cicatrization_time - 1 -- TODO Make it more "dynamic" end diff --git a/media/lua/client/TOC_main.lua b/media/lua/client/TOC_main.lua index 8856c10..eb67180 100644 --- a/media/lua/client/TOC_main.lua +++ b/media/lua/client/TOC_main.lua @@ -14,124 +14,142 @@ Arm = "Arm" function TheOnlyCure.InitTheOnlyCure(_, player) local mod_data = player:getModData() - --local toc_data = player:getModData().TOC if mod_data.TOC == nil then - mod_data.TOC = {} - print("CREATING NEW TOC STUF") - - local rightHand = "RightHand" - local rightForearm = "RightForearm" - local rightArm = "RightArm" - - local leftHand = "LeftHand" - local leftForearm = "LeftForearm" - local leftArm = "LeftArm" - - - local prothesis_list = {"WoodenHook", "MetalHook", "MetalHand"} - + mod_data.TOC = { - RightHand = {}, - RightForearm = {}, - RightArm = {}, - - LeftHand = {}, - LeftForearm = {}, - LeftArm = {}, - - is_other_bodypart_infected = false + + Limbs = {}, + Prosthesis = {}, + Generic = {}, } - - for _ ,v in pairs(GetBodyParts()) do - mod_data.TOC[v].is_cut = false - mod_data.TOC[v].is_infected = false - mod_data.TOC[v].is_operated = false - mod_data.TOC[v].is_cicatrized = false - mod_data.TOC[v].is_cauterized = false - mod_data.TOC[v].is_amputation_shown = false - - mod_data.TOC[v].cicatrization_time = 0 - - - mod_data.TOC[v].is_prosthesis_equipped = false - mod_data.TOC[v].prosthesis_factor = 1.0 - mod_data.TOC[v].prosthesis_material_id = nil - end - - - -- Manual stuff, just a temporary fix since this is kinda awful - mod_data.TOC[rightHand].depends_on = {} - mod_data.TOC[rightForearm].depends_on = {rightHand} - mod_data.TOC[rightArm].depends_on = { rightHand, rightForearm } + -------- + -- NEW NAMING SCHEME + + ---- Amputations + + -- Amputation_Left_Hand + -- Amputation_Right_UpperArm + + + ---- Prosthesis to equip + -- Prost_Left_Hand_MetalHook + -- Prost_Right_Forearm_WoodenHook + + --- Objects + -- Prost_Object_WoddenHook + + + local sides = {"Left", "Right"} + local limbs = {"Hand", "LowerArm", "UpperArm"} -- Let's follow their naming + + + local prosthesis_list = {"WoodenHook", "MetalHook", "MetalHand"} + + + + local accepted_prosthesis_hand = {"WoodenHook", "MetalHook", "MetalHand"} + local accepted_prosthesis_lowerarm = {"WoodenHook", "MetalHook", "MetalHand"} + local accepted_prosthesis_upperarm = {} -- For future stuff + + + + + + for _, side in ipairs(sides) do + for _, limb in ipairs(limbs) do + + local part_name = side .. "_" .. limb + + mod_data.TOC.Limbs[part_name].is_cut = false + mod_data.TOC.Limbs[part_name].is_infected = false + mod_data.TOC.Limbs[part_name].is_operated = false + mod_data.TOC.Limbs[part_name].is_cicatrized = false + mod_data.TOC.Limbs[part_name].is_cauterized = false + mod_data.TOC.Limbs[part_name].is_amputation_shown = false - mod_data.TOC[leftHand].depends_on = {} - mod_data.TOC[leftForearm].depends_on = { leftHand } - mod_data.TOC[leftArm].depends_on = { leftHand, leftForearm } + mod_data.TOC.Limbs[part_name].cicatrization_time = 0 + + + mod_data.TOC.Limbs[part_name].is_prosthesis_equipped = false + mod_data.TOC.Limbs[part_name].equipped_prosthesis = {} - - -- Setup cicatrization times - mod_data.TOC[rightHand].cicatrization_base_time = 1700 - mod_data.TOC[leftHand].cicatrization_base_time = 1700 - mod_data.TOC[rightForearm].cicatrization_base_time = 1800 - mod_data.TOC[leftForearm].cicatrization_base_time = 1800 - mod_data.TOC[rightArm].cicatrization_base_time = 2000 - mod_data.TOC[leftArm].cicatrization_base_time = 2000 + -- Even if there are some duplicates, this is just easier in the end since we're gonna get fairly easily part_name + + + if limb == "Hand" then + mod_data.TOC.Limbs[part_name].cicatrization_base_time = 1700 + mod_data.TOC.Limbs[part_name].depends_on = {} - - -- Setup a table with all the acceptable prosthesis - mod_data.TOC.prosthesis_table = {} - - for _, v in ipairs(prothesis_list) do - mod_data.TOC.prosthesis_table[v] = { - material_id = 1, - something = "Something" - } - + mod_data.TOC.Prosthesis.AcceptedProsthesis[part_name] = accepted_prosthesis_hand + mod_data.TOC.Prosthesis["WoodenHook"][part_name].prosthesis_factor = 1.5 + mod_data.TOC.Prosthesis["MetalHook"][part_name].prosthesis_factor = 1.3 + mod_data.TOC.Prosthesis["MetalHand"][part_name].prosthesis_factor = 1.1 + + + elseif limb == "LowerArm" then + mod_data.TOC.Limbs[part_name].cicatrization_base_time = 1800 + mod_data.TOC.Limbs[part_name].depends_on = {side .. "_Hand",} + mod_data.TOC.Prosthesis.AcceptedProsthesis[part_name] = accepted_prosthesis_lowerarm + + mod_data.TOC.Prosthesis["WoodenHook"][part_name].prosthesis_factor = 1.65 + mod_data.TOC.Prosthesis["MetalHook"][part_name].prosthesis_factor = 1.45 + mod_data.TOC.Prosthesis["MetalHand"][part_name].prosthesis_factor = 1.25 + elseif limb == "UpperArm" then + mod_data.TOC.Limbs[part_name].cicatrization_base_time = 2000 + mod_data.TOC.Limbs[part_name].depends_on = {side .. "_Hand", side .. "_LowerArm",} + mod_data.TOC.Prosthesis.AcceptedProsthesis[part_name] = accepted_prosthesis_upperarm + end + + end + end + + -- Setup traits + if player:HasTrait("Amputee_Hand") then + + -- TODO override AddItem so we can change the texture dynamically based on skin color + local amputation_clothing = player:getInventory():AddItem("TOC.Amputation_Left_Hand") + player:setWornItem(amputation_clothing:getBodyLocation(), amputation_clothing) + mod_data.TOC.Left_Hand.is_cut = true + mod_data.TOC.Left_Hand.is_operated = true + mod_data.TOC.Left_Hand.is_amputation_shown = true + mod_data.TOC.Left_Hand.is_cicatrized = true + elseif player:HasTrait("Amputee_LowerArm") then + local amputation_clothing = player:getInventory():AddItem("TOC.Amputation_Left_LowerArm") + player:setWornItem(amputation_clothing:getBodyLocation(), amputation_clothing) + mod_data.TOC.Left_LowerArm.is_cut = true + mod_data.TOC.Left_LowerArm.is_operated = true + mod_data.TOC.Left_LowerArm.is_amputation_shown = true + mod_data.TOC.Left_LowerArm.is_cicatrized = true + elseif player:HasTrait("Amputee_UpperArm") then + local amputation_clothing = player:getInventory():AddItem("TOC.Amputation_Left_UpperArm") + player:setWornItem(amputation_clothing:getBodyLocation(), amputation_clothing) + mod_data.TOC.Left_UpperArm.is_cut = true + mod_data.TOC.Left_UpperArm.is_operated = true + mod_data.TOC.Left_UpperArm.is_amputation_shown = true + mod_data.TOC.Left_UpperArm.is_cicatrized = true end - - - -- Traits setup - if player:HasTrait("amputee1") then - local cloth = player:getInventory():AddItem("TOC.ArmLeft_noHand") - player:setWornItem(cloth:getBodyLocation(), cloth) - mod_data.TOC.LeftHand.is_cut=true; mod_data.TOC.LeftHand.is_operated=true; mod_data.TOC.LeftHand.is_amputation_shown=true; mod_data.TOC.LeftHand.is_cicatrized=true - player:getInventory():AddItem("TOC.MetalHook") - end - if player:HasTrait("amputee2") then - local cloth = player:getInventory():AddItem("TOC.ArmLeft_noForearm") - player:setWornItem(cloth:getBodyLocation(), cloth) - mod_data.TOC.LeftHand.is_cut=true; mod_data.TOC.LeftHand.is_operated=true - mod_data.TOC.LeftForearm.is_cut=true; mod_data.TOC.LeftForearm.is_operated=true; mod_data.TOC.LeftForearm.is_amputation_shown=true; mod_data.TOC.LeftForearm.is_cicatrized=true - player:getInventory():AddItem("TOC.MetalHook") - end - if player:HasTrait("amputee3") then - local cloth = player:getInventory():AddItem("TOC.ArmLeft_noArm") - player:setWornItem(cloth:getBodyLocation(), cloth) - mod_data.TOC.LeftHand.is_cut=true; mod_data.TOC.LeftHand.is_operated=true - mod_data.TOC.LeftForearm.is_cut=true; mod_data.TOC.LeftForearm.is_operated=true - mod_data.TOC.LeftArm.is_cut=true; mod_data.TOC.LeftArm.is_operated=true; mod_data.TOC.LeftArm.is_amputation_shown=true; mod_data.TOC.LeftArm.is_cicatrized=true - player:getInventory():AddItem("TOC.MetalHook") - end - - player:transmitModData() end + end function TheOnlyCure.DeclareTraits() - local amp1 = TraitFactory.addTrait("amputee1", getText("UI_trait_Amputee1"), -8, getText("UI_trait_Amputee1desc"), false, false) - amp1:addXPBoost(Perks.LeftHand, 4) - local amp2 = TraitFactory.addTrait("amputee2", getText("UI_trait_Amputee2"), -10, getText("UI_trait_Amputee2desc"), false, false) - amp2:addXPBoost(Perks.LeftHand, 4) - local amp3 = TraitFactory.addTrait("amputee3", getText("UI_trait_Amputee3"), -20, getText("UI_trait_Amputee3desc"), false, false) - amp3:addXPBoost(Perks.LeftHand, 4) + local amp1 = TraitFactory.addTrait("Amputee_Hand", getText("UI_trait_Amputee_Hand"), -8, getText("UI_trait_Amputee_Hand_desc"), false, false) + amp1:addXPBoost(Perks.Left_Hand, 4) + + local amp2 = TraitFactory.addTrait("Amputee_LowerArm", getText("UI_trait_Amputee_LowerArm"), -10, getText("UI_trait_Amputee_LowerArm_desc"), false, false) + amp2:addXPBoost(Perks.Left_Hand, 4) + + local amp3 = TraitFactory.addTrait("Amputee_UpperArm", getText("UI_trait_Amputee_UpperArm"), -20, getText("UI_trait_Amputee_UpperArm_desc"), false, false) + amp3:addXPBoost(Perks.Left_Hand, 4) + TraitFactory.addTrait("Insensitive", getText("UI_trait_Insensitive"), 6, getText("UI_trait_Insensitivedesc"), false, false) - TraitFactory.setMutualExclusive("amputee1", "amputee2") - TraitFactory.setMutualExclusive("amputee1", "amputee3") - TraitFactory.setMutualExclusive("amputee2", "amputee3") + TraitFactory.setMutualExclusive("Amputee_Hand", "Amputee_LowerArm") + TraitFactory.setMutualExclusive("Amputee_Hand", "Amputee_UpperArm") + TraitFactory.setMutualExclusive("Amputee_LowerArm", "Amputee_UpperArm") end diff --git a/media/lua/client/TimedActions/ISInstallProsthesis.lua b/media/lua/client/TimedActions/ISInstallProsthesis.lua index 6692a53..bc93fbf 100644 --- a/media/lua/client/TimedActions/ISInstallProsthesis.lua +++ b/media/lua/client/TimedActions/ISInstallProsthesis.lua @@ -40,16 +40,16 @@ function ISInstallProsthesis:perform() return end - local prosthesis_name =TocFindCorrectClothingProsthesis(self.item:getType(), part_name) + local prosthesis_name =TocFindCorrectClothingProsthesis(prosthesis_base_name, part_name) self.cloth = self.character:getInventory():AddItem(prosthesis_name) if self.cloth ~= nil then if part_name then - toc_data[part_name].is_prosthesis_equipped = true -- TODO should we show that the hand has a prost too if it's installed in the forearm? - toc_data[part_name].prosthesis_factor = TocFindProsthesisFactorFromItem(self.cloth) - + toc_data.Limbs[part_name].is_prosthesis_equipped = true -- TODO should we show that the hand has a prost too if it's installed in the forearm? + toc_data.Limbs[part_name].equipped_prosthesis = toc_data.Prosthesis[prosthesis_base_name][part_name] + self.character:getInventory():Remove(self.item) self.character:setWornItem(self.cloth:getBodyLocation(), self.cloth) end diff --git a/media/lua/client/TimedActions/ISUninstallProsthesis.lua b/media/lua/client/TimedActions/ISUninstallProsthesis.lua index 3ca1129..53054e4 100644 --- a/media/lua/client/TimedActions/ISUninstallProsthesis.lua +++ b/media/lua/client/TimedActions/ISUninstallProsthesis.lua @@ -55,8 +55,8 @@ function ISUninstallProsthesis:perform() print("Found prost in " .. part_name) if part_name then - toc_data[part_name].is_prosthesis_equipped = false - toc_data[part_name].prosthesis_factor = 1 + toc_data.Limbs[part_name].is_prosthesis_equipped = false + --toc_data.Limbs[part_name].prosthesis_factor = 1 -- TODO This is wrong --local side = string.gsub(part_name, "Hand" or "Forearm", "") local item_full_type = self.item:getFullType() diff --git a/media/lua/client/TimedActions/OverridenFunctions.lua b/media/lua/client/TimedActions/OverridenFunctions.lua index f758c7f..815c731 100644 --- a/media/lua/client/TimedActions/OverridenFunctions.lua +++ b/media/lua/client/TimedActions/OverridenFunctions.lua @@ -22,21 +22,22 @@ function ISBaseTimedAction:adjustMaxTime(maxTime) for _, part_name in ipairs(all_body_parts) do - if toc_data[part_name].is_cut then + if toc_data.Limbs[part_name].is_cut then - if toc_data[part_name].is_prosthesis_equipped then - modified_max_time = modified_max_time * toc_data[part_name].prosthesis_factor + if toc_data.Limbs[part_name].is_prosthesis_equipped then + modified_max_time = modified_max_time * toc_data.Limbs[part_name].equipped_prosthesis.prosthesis_factor + else modified_max_time = modified_max_time * 2 end - if toc_data[part_name].is_cauterized then + if toc_data.Limbs[part_name].is_cauterized then modified_max_time = modified_max_time * burn_factor end -- Perk scaling - if part_name == "RightHand" or part_name == "LeftHand" then + if part_name == "Right_Hand" or part_name == "Left_Hand" then modified_max_time = modified_max_time * (1 + (9 - self.character:getPerkLevel(Perks[part_name])) / 20 ) end diff --git a/media/lua/client/Utils/UsefulFunctions.lua b/media/lua/client/Utils/UsefulFunctions.lua index 5866bc1..1206dd3 100644 --- a/media/lua/client/Utils/UsefulFunctions.lua +++ b/media/lua/client/Utils/UsefulFunctions.lua @@ -1,9 +1,3 @@ -function GetBodyParts() - local bodyparts = { "RightHand", "RightForearm", "RightArm", "LeftHand", "LeftForearm", "LeftArm"} - return bodyparts -end - - -- TODO Find a better name function GetProsthesisLisHumanReadable() return {"WoodenHook", "MetalHook", "MetalHand"} @@ -21,6 +15,8 @@ end 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() @@ -45,53 +41,17 @@ function GetInstallableProsthesisList() end -function GetLimbsBodyPartTypes() - - return {BodyPartType.Hand_R, BodyPartType.ForeArm_R, BodyPartType.UpperArm_R, - BodyPartType.Hand_L, BodyPartType.ForeArm_L, BodyPartType.UpperArm_L} - -end - -function GetOtherBodyPartTypes() - - return {BodyPartType.Torso_Upper, BodyPartType.Torso_Lower, BodyPartType.Head, BodyPartType.Neck, - BodyPartType.Groin, BodyPartType.UpperLeg_L, BodyPartType.UpperLeg_R, BodyPartType.LowerLeg_L, - BodyPartType.LowerLeg_R, BodyPartType.Foot_L, BodyPartType.Foot_R, BodyPartType.Back} - -end -function GetAcceptingProsthesisBodyPartTypes() - - - return {BodyPartType.Hand_R, BodyPartType.ForeArm_R, - BodyPartType.Hand_L, BodyPartType.ForeArm_L} - - -end - -function GetAcceptingProsthesisBodyParts() - return {"RightHand", "RightForearm", "LeftHand", "LeftForearm"} -end - -function GetNonAcceptingProsthesisBodyParts() - return {"RightArm", "LeftArm"} -end - -function GetAmputatedLimbFullTypes() - - return {"TOC.ArmRight_noHand", "TOC.ArmRight_noForearm", "TOC.ArmRight_noArm", - "TOC.ArmLeft_noHand", "TOC.ArmLeft_noForearm", "TOC.ArmLeft_noArm"} -end local function PartNameToBodyLocation(name) - if name == "RightHand" then return "ArmRight_Prot" end - if name == "RightForearm" then return "ArmRight_Prot" end - if name == "RightArm" then return "ArmRight_Prot" end - if name == "LeftHand" then return "ArmLeft_Prot" end - if name == "LeftForearm" then return "ArmLeft_Prot" end - if name == "LeftArm" then return "ArmLeft_Prot" end + 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 @@ -111,12 +71,12 @@ end function TocGetPartNameFromBodyPartType(body_part) - if body_part == BodyPartType.Hand_R then return "RightHand" - elseif body_part == BodyPartType.ForeArm_R then return "RightForearm" - elseif body_part == BodyPartType.UpperArm_R then return "RightArm" - elseif body_part == BodyPartType.Hand_L then return "LeftHand" - elseif body_part == BodyPartType.ForeArm_L then return "LeftForearm" - elseif body_part == BodyPartType.UpperArm_L then return "LeftArm" + 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 @@ -143,33 +103,23 @@ function find_clothName_TOC(bodyPart) end function TocGetDisplayText(part_name) - if part_name == "RightHand" then return getText("UI_ContextMenu_RightHand") end - if part_name == "RightForearm" then return getText("UI_ContextMenu_RightForearm") end - if part_name == "RightArm" then return getText("UI_ContextMenu_RightArm") end - if part_name == "LeftHand" then return getText("UI_ContextMenu_LeftHand") end - if part_name == "LeftForearm" then return getText("UI_ContextMenu_LeftForearm") end - if part_name == "LeftArm" then return getText("UI_ContextMenu_LeftArm") end + return getText("UI_ContextMenu_" .. part_name) + end function TocGetBodyPartTypeFromBodyPart(part_name) - if part_name == "RightHand" then return BodyPartType.Hand_R end - if part_name == "RightForearm" then return BodyPartType.ForeArm_R end - if part_name == "RightArm" then return BodyPartType.UpperArm_R end - if part_name == "LeftHand" then return BodyPartType.Hand_L end - if part_name == "LeftForearm" then return BodyPartType.ForeArm_L end - if part_name == "LeftArm" then return BodyPartType.UpperArm_L 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_UpperArm" then return BodyPartType.UpperArm_R end + if part_name == "Left_Hand" then return BodyPartType.Hand_L end + if part_name == "Left_LowerArm" then return BodyPartType.ForeArm_L end + if part_name == "Left_UpperArm" then return BodyPartType.UpperArm_L end end function TocFindAmputatedClothingFromPartName(part_name) - if part_name == "RightHand" then return "TOC.ArmRight_noHand" end - if part_name == "RightForearm" then return "TOC.ArmRight_noForearm" end - if part_name == "RightArm" then return "TOC.ArmRight_noArm" end - if part_name == "LeftHand" then return "TOC.ArmLeft_noHand" end - if part_name == "LeftForearm" then return "TOC.ArmLeft_noForearm" end - if part_name == "LeftArm" then return "TOC.ArmLeft_noArm" end - + return "TOC.Amputation_" .. part_name end -- TODO finish this @@ -190,6 +140,10 @@ 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 @@ -202,32 +156,7 @@ end function TocFindCorrectClothingProsthesis(item_name, part_name) - - -- for _, v in ipairs(GetProsthesisList()) do - -- if string.find(item, v) - - -- end - - local lowered_part_name = string.lower(part_name) - local side = string.match(lowered_part_name, "left") - - if side == nil then - side = "right" - end - - local limb = string.match(part_name, "Hand") - if limb == nil then - limb = "Forearm" - end - - - -- Just to accomodate this horrendous naming scheme, let's have Hand or Forearm again... Jesus dude - -- if limb then - -- limb = limb:gsub("^%l", string.upper) - -- end - - local correct_name = "TOC." .. item_name .. "_" .. side .. "_no" .. limb - + local correct_name = "TOC." .. item_name .. "_" .. part_name return correct_name end \ No newline at end of file diff --git a/media/lua/shared/NPCs/ExtraBodyLocations.lua b/media/lua/shared/NPCs/ExtraBodyLocations.lua index dc2cc26..5fad650 100644 --- a/media/lua/shared/NPCs/ExtraBodyLocations.lua +++ b/media/lua/shared/NPCs/ExtraBodyLocations.lua @@ -7,6 +7,7 @@ local group = BodyLocations.getGroup("Human") +-- TODO Change these names too, jesus they suck so bad group:getOrCreateLocation("ArmRight") group:getOrCreateLocation("ArmLeft") group:getOrCreateLocation("LegRight") diff --git a/media/lua/shared/translate/EN/IG_UI_EN.txt b/media/lua/shared/translate/EN/IG_UI_EN.txt index 2272f38..a09800d 100644 --- a/media/lua/shared/translate/EN/IG_UI_EN.txt +++ b/media/lua/shared/translate/EN/IG_UI_EN.txt @@ -12,7 +12,7 @@ IGUI_EN = { IGUI_char_Hand_multi = "Time multi due to amp/tot", - IGUI_perks_RightHand = "Right hand", - IGUI_perks_LeftHand = "Left hand", - IGUI_perks_Protheses = "Protheses skills", + IGUI_perks_Right_Hand = "Right hand", + IGUI_perks_Left_Hand = "Left hand", + IGUI_perks_Prosthesis_Skill_desc = "Prosthesis skills", } \ No newline at end of file diff --git a/media/lua/shared/translate/EN/UI_EN.txt b/media/lua/shared/translate/EN/UI_EN.txt index 7697212..24800ce 100644 --- a/media/lua/shared/translate/EN/UI_EN.txt +++ b/media/lua/shared/translate/EN/UI_EN.txt @@ -17,12 +17,12 @@ UI_EN = { UI_trait_Insensitive = "Insensitive to pain", UI_trait_Insensitivedesc = "Reduces maximum pain.", - UI_ContextMenu_RightHand = "Right hand", - UI_ContextMenu_RightForearm = "Right forearm", - UI_ContextMenu_RightArm = "Right arm", - UI_ContextMenu_LeftHand = "Left hand", - UI_ContextMenu_LeftForearm = "Left forearm", - UI_ContextMenu_LeftArm = "Left arm", + UI_ContextMenu_Right_Hand = "Right hand", + UI_ContextMenu_Right_LowerArm = "Right forearm", + UI_ContextMenu_Right_UpperArm = "Right arm", + UI_ContextMenu_Left_Hand = "Left hand", + UI_ContextMenu_Left_LowerArm = "Left forearm", + UI_ContextMenu_Left_UpperArm = "Left arm", UI_ContextMenu_My = "My ", UI_ContextMenu_Now_cut = " is now healed!", diff --git a/media/perks.txt b/media/perks.txt index a63733d..3cb4ec3 100644 --- a/media/perks.txt +++ b/media/perks.txt @@ -17,7 +17,7 @@ perk Protheses xp10 = 0, } -perk LeftHand +perk Left_Hand { parent = Protheses, name = LeftHand, @@ -35,7 +35,7 @@ perk LeftHand xp10 = 9000, } -perk RightHand +perk Right_Hand { parent = Protheses, name = RightHand,