still more stuff

This commit is contained in:
Pao
2023-02-26 20:00:22 +01:00
parent 7c13ed30c9
commit a2e906b318
13 changed files with 149 additions and 125 deletions

View File

@@ -3,29 +3,31 @@
------------------------------------------
--------- OPERATE LIMB FUNCTIONS ---------
local function FixSingleBodyPartType(body_part_type, use_oven)
body_part_type:setDeepWounded(false) --Basically like stitching
body_part_type:setDeepWoundTime(0)
if use_oven then
body_part_type:AddDamage(100)
body_part_type:setAdditionalPain(100);
body_part_type:setBleeding(false)
body_part_type:setBleedingTime(0) -- no bleeding since it's been cauterized
local function FixSingleBodyPartType(bodyPartType, useOven)
bodyPartType:setDeepWounded(false) --Basically like stitching
bodyPartType:setDeepWoundTime(0)
if useOven then
bodyPartType:AddDamage(100)
bodyPartType:setAdditionalPain(100);
bodyPartType:setBleeding(false)
bodyPartType:setBleedingTime(0) -- no bleeding since it's been cauterized
else
-- TODO Think a little better about this, do we want to trigger bleeding or not?
body_part_type:setBleeding(false)
bodyPartType:setBleeding(false)
--body_part_type:setBleedingTime(ZombRand(1, 5)) -- Reset the bleeding, maybe make it random
end
end
local function SetBodyPartsStatusAfterOperation(player, limbs_data, part_name, use_oven)
local body_part_type = player:getBodyDamage():getBodyPart(TocGetAdjacentBodyPartFromPartName(part_name))
FixSingleBodyPartType(body_part_type, use_oven)
local function SetBodyPartsStatusAfterOperation(player, limbParameters, partName, useOven)
for _, v in pairs(limbs_data[part_name].depends_on) do
local depended_body_part_type = player:getBodyDamage():getBodyPart(TocGetAdjacentBodyPartFromPartName(v))
FixSingleBodyPartType(depended_body_part_type, use_oven)
local bodyPartType = player:getBodyDamage():getBodyPart(TocGetAdjacentBodyPartFromPartName(partName))
FixSingleBodyPartType(bodyPartType, useOven)
for _, v in pairs(limbParameters[partName].dependsOn) do
local dependedBodyPartType = player:getBodyDamage():getBodyPart(TocGetAdjacentBodyPartFromPartName(v))
FixSingleBodyPartType(dependedBodyPartType, useOven)
end
end
@@ -34,33 +36,37 @@ end
---Main function to operate a limb after amputation
---@param part_name any
---@param surgeon_factor any
---@param use_oven boolean wheter using oven instead of a kit or not
function TocOperateLimb(part_name, surgeon_factor, use_oven)
---@param partName any
---@param surgeonFactor any
---@param useOven boolean wheter using oven instead of a kit or not
function JCIO.OperateLimb(partName, surgeonFactor, useOven)
local player = getPlayer()
local limbs_data = player:getModData().TOC.Limbs
if use_oven then
local jcioModData = player:getModData().JCIO
local limbParameters = jcioModData.limbParameters
local limbsData = jcioModData.limbs
if useOven then
local stats = player:getStats()
stats:setEndurance(100)
stats:setStress(100)
end
if limbs_data[part_name].is_operated == false and limbs_data[part_name].is_cut == true then
limbs_data[part_name].is_operated = true
limbs_data[part_name].cicatrization_time = limbs_data[part_name].cicatrization_time - (surgeon_factor * 200)
if use_oven then limbs_data[part_name].is_cauterized = true end
for _, depended_v in pairs(limbs_data[part_name].depends_on) do
limbs_data[depended_v].is_operated = true
limbs_data[depended_v].cicatrization_time = limbs_data[depended_v].cicatrization_time -
(surgeon_factor * 200)
if use_oven then limbs_data[depended_v].is_cauterized = true end -- TODO does this make sense?
if limbsData[partName].isOperated == false and limbsData[partName].isCut == true then
limbsData[partName].isOperated = true
limbsData[partName].cicatrizationTime = limbsData[partName].cicatrizationTime - (surgeonFactor * 200)
if useOven then limbsData[partName].is_cauterized = true end
for _, depended_v in pairs(limbParameters[partName].depends_on) do
limbsData[depended_v].isOperated = true
limbsData[depended_v].cicatrizationTime = limbsData[depended_v].cicatrizationTime -
(surgeonFactor * 200)
if useOven then limbsData[depended_v].isCauterized = true end
end
end
SetBodyPartsStatusAfterOperation(player, limbs_data, part_name, use_oven)
SetBodyPartsStatusAfterOperation(player, limbParameters, partName, useOven)
end

View File

@@ -5,36 +5,42 @@
---Equip a prosthesis transforming a normal item into a clothing item
---@param part_name string
---@param prosthesis_item any the prosthesis item
---@param prosthesis_base_name string
function TocEquipProsthesis(part_name, prosthesis_item, prosthesis_base_name)
---@param partName string
---@param prosthesisItem any the prosthesis item
---@param prosthesisBaseName string
function JCIO.EquipProsthesis(partName, prosthesisItem, prosthesisBaseName)
-- TODO probably will have to move this from the TOC menu to classic equip to have dynamic durability
-- TODO We need to pass the original item so we can get its data!
local player = getPlayer()
local toc_data = player:getModData().TOC
local jcioModData = player:getModData().JCIO
local equipped_prosthesis = GenerateEquippedProsthesis(prosthesis_item, player:getInventory(), "Hand")
local equippedProsthesis = GenerateEquippedProsthesis(prosthesisItem, player:getInventory(), "Hand")
--print("TOC: Test durability new item " .. added_prosthesis_mod_data.TOC.durability)
-- TODO equippedProsthesis must have something like the ProsthesisFactor from before!!!
if partName ~= nil then
if equippedProsthesis ~= nil then
jcioModData.limbs[partName].isProsthesisEquipped = true
if part_name ~= nil then
-- Fill equippedProsthesis with the correct stuff
-- TODO For prosthetics we should fetch the data from a modData INSIDE them!
if equipped_prosthesis ~= nil then
toc_data.Limbs[part_name].is_prosthesis_equipped = true
toc_data.Limbs[part_name].equipped_prosthesis = toc_data.Prosthesis[prosthesis_base_name][part_name] -- TODO Change this, it's old
-- TODO Change the value passed, it's wrong
--jcioModData.limbs[partName].equippedProsthesis = jcioModData.Prosthesis[prosthesisBaseName][partName]
if player:isFemale() then
equipped_prosthesis:getVisual():setTextureChoice(1)
equippedProsthesis:getVisual():setTextureChoice(1)
else
equipped_prosthesis:getVisual():setTextureChoice(0)
equippedProsthesis:getVisual():setTextureChoice(0)
end
player:setWornItem(equipped_prosthesis:getBodyLocation(), equipped_prosthesis)
player:setWornItem(equippedProsthesis:getBodyLocation(), equippedProsthesis)
@@ -44,37 +50,36 @@ end
---Unequip a prosthesis clothing item and returns it to the inventory as a normal item
---@param part_name string
function TocUnequipProsthesis(patient, part_name, equipped_prosthesis)
---@param partName string
function JCIO.UnequipProsthesis(patient, partName, equippedProsthesis)
-- TODO Pass the parameters generated from EquipProsthesis to the re-generated normal item
local toc_data = patient:getModData().TOC
toc_data.Limbs[part_name].is_prosthesis_equipped = false
local jcioModData = patient:getModData().JCIO
jcioModData.limbs[partName].isProsthesisEquipped = false
local equipped_prosthesis_full_type = equipped_prosthesis:getFullType()
local equippedProstFullType = equippedProsthesis:getFullType()
for _, prost_v in ipairs(GetProsthesisList()) do
local prosthesis_name = string.match(equipped_prosthesis_full_type, prost_v)
if prosthesis_name then
for _, prostValue in ipairs(GetProsthesisList()) do
local prostName = string.match(equippedProstFullType, prostValue)
if prostName then
-- Get mod data from equipped prosthesis so we can get its parameters
local equipped_prosthesis_mod_data = equipped_prosthesis:getModData()
local equippedProstModData = equippedProsthesis:getModData()
local base_prosthesis_item = patient:getInventory():AddItem("TOC." .. prosthesis_name)
local base_prosthesis_item_mod_data = base_prosthesis_item.getModData()
base_prosthesis_item_mod_data.TOC = {
durability = equipped_prosthesis_mod_data.TOC.durability,
speed = equipped_prosthesis_mod_data.TOC.speed
local baseProstItem = patient:getInventory():AddItem("JCIO." .. prostName)
local baseProstItemModData = baseProstItem.getModData()
baseProstItemModData.JCIO = {
durability = equippedProstModData.JCIO.durability,
speed = equippedProstModData.JCIO.speed
}
patient:setWornItem(equipped_prosthesis:getBodyLocation(), nil)
patient:getInventory():Remove(equipped_prosthesis)
toc_data.Limbs[part_name].equipped_prosthesis = nil
patient:setWornItem(equippedProsthesis:getBodyLocation(), nil)
patient:getInventory():Remove(equippedProsthesis)
jcioModData.Limbs[partName].equipped_prosthesis = nil
end
end
end