Moved more stuff

This commit is contained in:
Pao
2023-01-20 02:22:13 +01:00
parent 8deaec2bbe
commit 8073680118
11 changed files with 33 additions and 209 deletions

View File

@@ -7,7 +7,6 @@ end
----------------------------------------- -----------------------------------------
-- MP HANDLING CHECKS -- MP HANDLING CHECKS
function CheckIfCanBeCut(part_name) function CheckIfCanBeCut(part_name)
-- This is just for MP handling... Not enough to check everything
local toc_data = getPlayer():getModData().TOC local toc_data = getPlayer():getModData().TOC
local check = (not toc_data.Limbs[part_name].is_cut) and (not CheckIfProsthesisAlreadyInstalled(toc_data.Limbs, part_name)) local check = (not toc_data.Limbs[part_name].is_cut) and (not CheckIfProsthesisAlreadyInstalled(toc_data.Limbs, part_name))

View File

@@ -9,7 +9,7 @@ Commands["ResponseCanAct"] = function(arg)
ui.responsePartName = arg["toSend"][1] ui.responsePartName = arg["toSend"][1]
ui.responseCan = arg["toSend"][3] ui.responseCan = arg["toSend"][3]
ui.responseUserName = getPlayerByOnlineID(arg["From"]):getUsername() ui.responseUserName = getPlayerByOnlineID(arg["From"]):getUsername()
ui.responseActionIsBitten = getPlayerByOnlineID(arg["From"]):getBodyDamage():getBodyPart(TocGetBodyPartTypeFromBodyPart(ui.responsePartName)):bitten() ui.responseActionIsBitten = getPlayerByOnlineID(arg["From"]):getBodyDamage():getBodyPart(TocGetBodyPartTypeFromPartName(ui.responsePartName)):bitten()
end end

View File

@@ -4,6 +4,16 @@ function GetBodyParts()
return bodyparts return bodyparts
end end
function GetProsthesisList()
return {"TOC.WoodenHook", "TOC.MetalHook", "TOC.MetalHand"}
end
function TocFindAmputatedClothingFromPartName(part_name)
return "TOC.Amputation_" .. part_name
end
function GetLimbsBodyPartTypes() function GetLimbsBodyPartTypes()
return {BodyPartType.Hand_R, BodyPartType.ForeArm_R, BodyPartType.UpperArm_R, return {BodyPartType.Hand_R, BodyPartType.ForeArm_R, BodyPartType.UpperArm_R,
@@ -52,3 +62,14 @@ function FindTocBodyPartNameFromBodyPartType(bodyPartType)
end end
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
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

View File

@@ -30,10 +30,6 @@ function TocMapOldDataToNew(mod_data)
local backup_old_data = mod_data.TOC local backup_old_data = mod_data.TOC
-- for _, v in ipairs(map_names) do -- for _, v in ipairs(map_names) do
-- print("TOC: Looping old names...") -- print("TOC: Looping old names...")
-- print(k) -- print(k)

View File

@@ -59,11 +59,11 @@ function SetBodyPartsStatusAfterOperation(player, part_data, part_name, use_oven
--for _, v in ipairs(GetBodyParts()) do --for _, v in ipairs(GetBodyParts()) do
local body_part_type = player:getBodyDamage():getBodyPart(TocGetBodyPartTypeFromBodyPart(part_name)) local body_part_type = player:getBodyDamage():getBodyPart(TocGetBodyPartTypeFromPartName(part_name))
FixSingleBodyPartType(body_part_type, use_oven) FixSingleBodyPartType(body_part_type, use_oven)
for _, v in ipairs(part_data[part_name].depends_on) do for _, v in ipairs(part_data[part_name].depends_on) do
local depended_body_part_type = player:getBodyDamage():getBodyPart(TocGetBodyPartTypeFromBodyPart(v)) local depended_body_part_type = player:getBodyDamage():getBodyPart(TocGetBodyPartTypeFromPartName(v))
FixSingleBodyPartType(depended_body_part_type, use_oven) FixSingleBodyPartType(depended_body_part_type, use_oven)
end end

View File

@@ -29,7 +29,7 @@ function TocEquipProsthesisLocal(_, patient, surgeon, part_name)
surgeon_inventory:getItemFromType('TOC.MetalHook') or surgeon_inventory:getItemFromType('TOC.MetalHook') or
surgeon_inventory:getItemFromType('TOC.WoodenHook') surgeon_inventory:getItemFromType('TOC.WoodenHook')
if prosthesis_to_equip then if prosthesis_to_equip then
ISTimedActionQueue.add(ISInstallProsthesis:new(patient, prosthesis_to_equip, patient:getBodyDamage():getBodyPart(TocGetBodyPartTypeFromBodyPart(part_name)))) ISTimedActionQueue.add(ISInstallProsthesis:new(patient, prosthesis_to_equip, patient:getBodyDamage():getBodyPart(TocGetBodyPartTypeFromPartName(part_name))))
else else
surgeon:Say("I need a prosthesis") surgeon:Say("I need a prosthesis")
end end
@@ -37,5 +37,5 @@ end
function TocUnequipProsthesisLocal(_, patient, part_name) function TocUnequipProsthesisLocal(_, patient, part_name)
local equipped_prosthesis = FindTocItemWorn(part_name, patient) local equipped_prosthesis = FindTocItemWorn(part_name, patient)
ISTimedActionQueue.add(ISUninstallProsthesis:new(patient, equipped_prosthesis, patient:getBodyDamage():getBodyPart(TocGetBodyPartTypeFromBodyPart(part_name)))) ISTimedActionQueue.add(ISUninstallProsthesis:new(patient, equipped_prosthesis, patient:getBodyDamage():getBodyPart(TocGetBodyPartTypeFromPartName(part_name))))
end end

View File

@@ -1,192 +0,0 @@
-- TODO Rewrite how all prosthesis are handled
function TestStuffToc()
local mod_data = player:getModData().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.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
end
function TheOnlyCure.DeclareTraits2()
local amp1 = TraitFactory.addTrait("Amputee_Hand", getText("UI_trait_Amputee_Hand"), -8, getText("UI_trait_Amputee_Hand_desc"), false, false)
amp1:addXPBoost(Perks.LeftHand, 4)
local amp2 = TraitFactory.addTrait("Amputee_LowerArm", getText("UI_trait_Amputee_LowerArm"), -10, getText("UI_trait_Amputee_LowerArm_desc"), false, false)
amp2:addXPBoost(Perks.LeftHand, 4)
local amp3 = TraitFactory.addTrait("Amputee_UpperArm", getText("UI_trait_Amputee_UpperArm"), -20, getText("UI_trait_Amputee_UpperArm_desc"), false, false)
amp3:addXPBoost(Perks.LeftHand, 4)
TraitFactory.addTrait("Insensitive", getText("UI_trait_Insensitive"), 6, getText("UI_trait_Insensitivedesc"), false, false)
TraitFactory.setMutualExclusive("Amputee_Hand", "Amputee_LowerArm")
TraitFactory.setMutualExclusive("Amputee_Hand", "Amputee_UpperArm")
TraitFactory.setMutualExclusive("Amputee_LowerArm", "Amputee_UpperArm")
end
function Test2Toc(part_name, prosthetic_name)
--------
-- 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
-- First value side, second value limb
local part_name_table = {}
for v in part_name:gmatch("([^_]+)") do
table.insert(part_name_table, v)
end
-- TODO Probably add TOC. before prost_
local prost_to_equip_name = "Prost_" .. part_name_table[1] .. "_" .. part_name_table[2] .. "_" .. prosthetic_name
return prost_to_equip_name
end

View File

@@ -53,7 +53,7 @@ local function GetImageName(part_name, toc_data)
name = "media/ui/TOC/" .. part_name .. "/Operate.png" name = "media/ui/TOC/" .. part_name .. "/Operate.png"
elseif part_data.is_cut and not part_data.is_amputation_shown then -- Empty (like hand if forearm cut) elseif part_data.is_cut and not part_data.is_amputation_shown then -- Empty (like hand if forearm cut)
name = "media/ui/TOC/Empty.png" name = "media/ui/TOC/Empty.png"
elseif not part_data.is_cut and getPlayer():getBodyDamage():getBodyPart(TocGetBodyPartTypeFromBodyPart(part_name)):bitten() then -- Not cut but bitten elseif not part_data.is_cut and getPlayer():getBodyDamage():getBodyPart(TocGetBodyPartTypeFromPartName(part_name)):bitten() then -- Not cut but bitten
name = "media/ui/TOC/" .. part_name .. "/Bite.png" name = "media/ui/TOC/" .. part_name .. "/Bite.png"
else -- Not cut else -- Not cut
name = "media/ui/TOC/" .. part_name .. "/Base.png" name = "media/ui/TOC/" .. part_name .. "/Base.png"
@@ -96,7 +96,7 @@ end
local function IsPartBitten(part_data, part_name) local function IsPartBitten(part_data, part_name)
return not part_data.is_cut and getPlayer():getBodyDamage():getBodyPart(TocGetBodyPartTypeFromBodyPart(part_name)):bitten() return not part_data.is_cut and getPlayer():getBodyDamage():getBodyPart(TocGetBodyPartTypeFromPartName(part_name)):bitten()
end end

View File

@@ -83,7 +83,7 @@ function TheOnlyCure.HealSpecificPart(part_data, part_name, player)
local body_damage = player:getBodyDamage() local body_damage = player:getBodyDamage()
local body_part_type = body_damage:getBodyPart(TocGetBodyPartTypeFromBodyPart(part_name)) local body_part_type = body_damage:getBodyPart(TocGetBodyPartTypeFromPartName(part_name))
if not body_part_type then if not body_part_type then
print("TOC ERROR : Can't update health of " .. part_name); print("TOC ERROR : Can't update health of " .. part_name);
return false return false

View File

@@ -218,7 +218,7 @@ function TheOnlyCure.CutLimb(part_name, surgeon_factor, bandage_table, painkille
local toc_data = player:getModData().TOC local toc_data = player:getModData().TOC
local part_data = toc_data.Limbs local part_data = toc_data.Limbs
local body_part = player:getBodyDamage():getBodyPart(TocGetBodyPartTypeFromBodyPart(part_name)) local body_part = player:getBodyDamage():getBodyPart(TocGetBodyPartTypeFromPartName(part_name))
local stats = player:getStats() local stats = player:getStats()
-- Set damage, stress, and low endurance after amputation -- Set damage, stress, and low endurance after amputation
@@ -365,7 +365,7 @@ function TryTocAction(_, part_name, action, surgeon, patient)
surgeon_inventory:getItemFromType('TOC.MetalHook') or surgeon_inventory:getItemFromType('TOC.MetalHook') or
surgeon_inventory:getItemFromType('TOC.WoodenHook') surgeon_inventory:getItemFromType('TOC.WoodenHook')
if prosthesis_to_equip then if prosthesis_to_equip then
ISTimedActionQueue.add(ISInstallProsthesis:new(patient, prosthesis_to_equip, patient:getBodyDamage():getBodyPart(TocGetBodyPartTypeFromBodyPart(part_name)))) ISTimedActionQueue.add(ISInstallProsthesis:new(patient, prosthesis_to_equip, patient:getBodyDamage():getBodyPart(TocGetBodyPartTypeFromPartName(part_name))))
else else
surgeon:Say("I need a prosthesis") surgeon:Say("I need a prosthesis")
end end
@@ -377,7 +377,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 = FindTocItemWorn(part_name, patient)
ISTimedActionQueue.add(ISUninstallProsthesis:new(patient, equipped_prosthesis, patient:getBodyDamage():getBodyPart(TocGetBodyPartTypeFromBodyPart(part_name)))) ISTimedActionQueue.add(ISUninstallProsthesis:new(patient, equipped_prosthesis, patient:getBodyDamage():getBodyPart(TocGetBodyPartTypeFromPartName(part_name))))
end end
ui.actionAct = action ui.actionAct = action
ui.partNameAct = part_name ui.partNameAct = part_name

View File

@@ -44,7 +44,7 @@ function ISCutLimb:start()
-- TODO this doesn't work when doing it on another player -- TODO this doesn't work when doing it on another player
local body_part_type = TocGetBodyPartTypeFromBodyPart(self.part_name) local body_part_type = TocGetBodyPartTypeFromPartName(self.part_name)
local body_damage = self.patient:getBodyDamage() local body_damage = self.patient:getBodyDamage()
local body_damage_part = body_damage:getBodyPart(body_part_type) local body_damage_part = body_damage:getBodyPart(body_part_type)