Delete other amputated limbs after cutting same side

This commit is contained in:
Pao
2023-01-18 14:32:12 +01:00
parent 22406dcef5
commit 0f30841978
14 changed files with 72 additions and 52 deletions

View File

@@ -7,9 +7,9 @@
<m_AllowRandomHue>false</m_AllowRandomHue> <m_AllowRandomHue>false</m_AllowRandomHue>
<m_AllowRandomTint>false</m_AllowRandomTint> <m_AllowRandomTint>false</m_AllowRandomTint>
<m_Masks>4</m_Masks> <m_Masks>4</m_Masks>
<textureChoices>Clothes\skin01</textureChoices> <textureChoices>Clothes\skin01b</textureChoices>
<textureChoices>Clothes\skin02</textureChoices> <textureChoices>Clothes\skin02b</textureChoices>
<textureChoices>Clothes\skin03</textureChoices> <textureChoices>Clothes\skin03b</textureChoices>
<textureChoices>Clothes\skin04</textureChoices> <textureChoices>Clothes\skin04b</textureChoices>
<textureChoices>Clothes\skin05</textureChoices> <textureChoices>Clothes\skin05b</textureChoices>
</clothingItem> </clothingItem>

View File

@@ -8,9 +8,9 @@
<m_AllowRandomTint>false</m_AllowRandomTint> <m_AllowRandomTint>false</m_AllowRandomTint>
<m_Masks>3</m_Masks> <m_Masks>3</m_Masks>
<m_Masks>4</m_Masks> <m_Masks>4</m_Masks>
<textureChoices>Clothes\skin01</textureChoices> <textureChoices>Clothes\skin01b</textureChoices>
<textureChoices>Clothes\skin02</textureChoices> <textureChoices>Clothes\skin02b</textureChoices>
<textureChoices>Clothes\skin03</textureChoices> <textureChoices>Clothes\skin03b</textureChoices>
<textureChoices>Clothes\skin04</textureChoices> <textureChoices>Clothes\skin04b</textureChoices>
<textureChoices>Clothes\skin05</textureChoices> <textureChoices>Clothes\skin05b</textureChoices>
</clothingItem> </clothingItem>

View File

@@ -8,9 +8,9 @@
<m_AllowRandomTint>false</m_AllowRandomTint> <m_AllowRandomTint>false</m_AllowRandomTint>
<m_Masks>3</m_Masks> <m_Masks>3</m_Masks>
<m_Masks>4</m_Masks> <m_Masks>4</m_Masks>
<textureChoices>Clothes\skin01</textureChoices> <textureChoices>Clothes\skin01b</textureChoices>
<textureChoices>Clothes\skin02</textureChoices> <textureChoices>Clothes\skin02b</textureChoices>
<textureChoices>Clothes\skin03</textureChoices> <textureChoices>Clothes\skin03b</textureChoices>
<textureChoices>Clothes\skin04</textureChoices> <textureChoices>Clothes\skin04b</textureChoices>
<textureChoices>Clothes\skin05</textureChoices> <textureChoices>Clothes\skin05b</textureChoices>
</clothingItem> </clothingItem>

View File

@@ -6,9 +6,9 @@
<m_AllowRandomHue>false</m_AllowRandomHue> <m_AllowRandomHue>false</m_AllowRandomHue>
<m_AllowRandomTint>false</m_AllowRandomTint> <m_AllowRandomTint>false</m_AllowRandomTint>
<m_Masks>6</m_Masks> <m_Masks>6</m_Masks>
<textureChoices>Clothes\skin01</textureChoices> <textureChoices>Clothes\skin01b</textureChoices>
<textureChoices>Clothes\skin02</textureChoices> <textureChoices>Clothes\skin02b</textureChoices>
<textureChoices>Clothes\skin03</textureChoices> <textureChoices>Clothes\skin03b</textureChoices>
<textureChoices>Clothes\skin04</textureChoices> <textureChoices>Clothes\skin04b</textureChoices>
<textureChoices>Clothes\skin05</textureChoices> <textureChoices>Clothes\skin05b</textureChoices>
</clothingItem> </clothingItem>

View File

@@ -8,9 +8,9 @@
<m_AllowRandomTint>false</m_AllowRandomTint> <m_AllowRandomTint>false</m_AllowRandomTint>
<m_Masks>5</m_Masks> <m_Masks>5</m_Masks>
<m_Masks>6</m_Masks> <m_Masks>6</m_Masks>
<textureChoices>Clothes\skin01</textureChoices> <textureChoices>Clothes\skin01b</textureChoices>
<textureChoices>Clothes\skin02</textureChoices> <textureChoices>Clothes\skin02b</textureChoices>
<textureChoices>Clothes\skin03</textureChoices> <textureChoices>Clothes\skin03b</textureChoices>
<textureChoices>Clothes\skin04</textureChoices> <textureChoices>Clothes\skin04b</textureChoices>
<textureChoices>Clothes\skin05</textureChoices> <textureChoices>Clothes\skin05b</textureChoices>
</clothingItem> </clothingItem>

View File

@@ -8,9 +8,9 @@
<m_AllowRandomTint>false</m_AllowRandomTint> <m_AllowRandomTint>false</m_AllowRandomTint>
<m_Masks>5</m_Masks> <m_Masks>5</m_Masks>
<m_Masks>6</m_Masks> <m_Masks>6</m_Masks>
<textureChoices>Clothes\skin01</textureChoices> <textureChoices>Clothes\skin01b</textureChoices>
<textureChoices>Clothes\skin02</textureChoices> <textureChoices>Clothes\skin02b</textureChoices>
<textureChoices>Clothes\skin03</textureChoices> <textureChoices>Clothes\skin03b</textureChoices>
<textureChoices>Clothes\skin04</textureChoices> <textureChoices>Clothes\skin04b</textureChoices>
<textureChoices>Clothes\skin05</textureChoices> <textureChoices>Clothes\skin05b</textureChoices>
</clothingItem> </clothingItem>

View File

@@ -38,6 +38,21 @@ function CureInfection(body_damage)
end end
function TocDeleteOtherAmputatedLimbs(side)
-- if left hand is cut and we cut left lowerarm, then delete hand
for _, limb in pairs(TOC_limbs) do
local part_name = "TOC.Amputation_" .. side .. "_" .. limb
local amputated_limb = getPlayer():getInventory():FindAndReturn(part_name)
if amputated_limb then
getPlayer():getInventory():Remove(amputated_limb)
end
end
end
-- OperateLimb -- OperateLimb
function SetBodyPartsStatusAfterOperation(player, part_data, part_name, use_oven) function SetBodyPartsStatusAfterOperation(player, part_data, part_name, use_oven)

View File

@@ -1,20 +1,9 @@
-- 6 skin tones or 5? -- 6 skin tones or 5?
function TocSetCorrectTextureForAmputation(item, player) function TocSetCorrectTextureForAmputation(item, player)
local human_visual = player:getHumanVisual() local human_visual = player:getHumanVisual()
local texture_string = human_visual:getSkinTexture() local texture_string = human_visual:getSkinTexture()
print(texture_string)
local matched_index = string.match(texture_string, "%d$") local matched_index = string.match(texture_string, "%d$")
print(matched_index) print("TOC: Setting texture " .. matched_index)
item:getVisual():setTextureChoice(tonumber(matched_index - 1)) -- TODO why is it correct with -1?
item:getVisual():setTextureChoice(tonumber(matched_index))
end end

View File

@@ -2,6 +2,8 @@ if not TheOnlyCure then
TheOnlyCure = {} TheOnlyCure = {}
end end
TOC_sides = {"Left", "Right"}
TOC_limbs = {"Hand", "LowerArm", "UpperArm"}
-- TODO remove this crap -- TODO remove this crap
Left = "Left" Left = "Left"
@@ -155,23 +157,28 @@ function TocSetInitData(mod_data, player)
-- Setup traits -- Setup traits
if player:HasTrait("Amputee_Hand") then if player:HasTrait("Amputee_Hand") then
-- TODO override AddItem so we can change the texture dynamically based on skin color local amputation_clothing_item = player:getInventory():AddItem("TOC.Amputation_Left_Hand")
local amputation_clothing = player:getInventory():AddItem("TOC.Amputation_Left_Hand") TocSetCorrectTextureForAmputation(amputation_clothing_item, player)
player:setWornItem(amputation_clothing:getBodyLocation(), amputation_clothing)
player:setWornItem(amputation_clothing_item:getBodyLocation(), amputation_clothing_item)
mod_data.TOC.Left_Hand.is_cut = true mod_data.TOC.Left_Hand.is_cut = true
mod_data.TOC.Left_Hand.is_operated = true mod_data.TOC.Left_Hand.is_operated = true
mod_data.TOC.Left_Hand.is_amputation_shown = true mod_data.TOC.Left_Hand.is_amputation_shown = true
mod_data.TOC.Left_Hand.is_cicatrized = true mod_data.TOC.Left_Hand.is_cicatrized = true
elseif player:HasTrait("Amputee_LowerArm") then elseif player:HasTrait("Amputee_LowerArm") then
local amputation_clothing = player:getInventory():AddItem("TOC.Amputation_Left_LowerArm") local amputation_clothing_item = player:getInventory():AddItem("TOC.Amputation_Left_LowerArm")
player:setWornItem(amputation_clothing:getBodyLocation(), amputation_clothing) TocSetCorrectTextureForAmputation(amputation_clothing_item, player)
player:setWornItem(amputation_clothing_item:getBodyLocation(), amputation_clothing_item)
mod_data.TOC.Left_LowerArm.is_cut = true mod_data.TOC.Left_LowerArm.is_cut = true
mod_data.TOC.Left_LowerArm.is_operated = true mod_data.TOC.Left_LowerArm.is_operated = true
mod_data.TOC.Left_LowerArm.is_amputation_shown = true mod_data.TOC.Left_LowerArm.is_amputation_shown = true
mod_data.TOC.Left_LowerArm.is_cicatrized = true mod_data.TOC.Left_LowerArm.is_cicatrized = true
elseif player:HasTrait("Amputee_UpperArm") then elseif player:HasTrait("Amputee_UpperArm") then
local amputation_clothing = player:getInventory():AddItem("TOC.Amputation_Left_UpperArm") local amputation_clothing_item = player:getInventory():AddItem("TOC.Amputation_Left_UpperArm")
player:setWornItem(amputation_clothing:getBodyLocation(), amputation_clothing) TocSetCorrectTextureForAmputation(amputation_clothing_item, player)
player:setWornItem(amputation_clothing_item:getBodyLocation(), amputation_clothing_item)
mod_data.TOC.Left_UpperArm.is_cut = true mod_data.TOC.Left_UpperArm.is_cut = true
mod_data.TOC.Left_UpperArm.is_operated = true mod_data.TOC.Left_UpperArm.is_operated = true
mod_data.TOC.Left_UpperArm.is_amputation_shown = true mod_data.TOC.Left_UpperArm.is_amputation_shown = true
@@ -204,12 +211,14 @@ end
----------------------------------------------------------------------- -----------------------------------------------------------------------
function TheOnlyCure.CutLimb(part_name, surgeon_factor, bandage_table, painkiller_table) function TheOnlyCure.CutLimb(part_name, surgeon_factor, bandage_table, painkiller_table)
-- TODO Separate Cut Limb in side and limb instead of single part_name
-- TODO Check if this works in MP through MENU UI -- TODO Check if this works in MP through MENU UI
local player = getPlayer() local player = getPlayer()
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_type = player:getBodyDamage():getBodyPart(TocGetBodyPartTypeFromBodyPart(part_name)) local body_part_type = player:getBodyDamage():getBodyPart(TocGetBodyPartTypeFromBodyPart(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
body_part_type:AddDamage(100 - surgeon_factor) body_part_type:AddDamage(100 - surgeon_factor)
@@ -260,10 +269,17 @@ function TheOnlyCure.CutLimb(part_name, surgeon_factor, bandage_table, painkille
part_data[depended_v].cicatrization_time = part_data[part_name].cicatrization_base_time - surgeon_factor * 50 part_data[depended_v].cicatrization_time = part_data[part_name].cicatrization_base_time - surgeon_factor * 50
end end
--Equip model for amputation -- Check for older amputation models and deletes them from player's inventory
local side = string.match(part_name, '(%w+)_')
TocDeleteOtherAmputatedLimbs(side)
--Equip new model for amputation
local amputation_clothing_item = player:getInventory():AddItem(TocFindAmputatedClothingFromPartName(part_name)) local amputation_clothing_item = player:getInventory():AddItem(TocFindAmputatedClothingFromPartName(part_name))
TocSetCorrectTextureForAmputation(amputation_clothing_item, player) TocSetCorrectTextureForAmputation(amputation_clothing_item, player)
player:setWornItem(amputation_clothing_item:getBodyLocation(), amputation_clothing_item) player:setWornItem(amputation_clothing_item:getBodyLocation(), amputation_clothing_item)
player:transmitModData() player:transmitModData()
end end

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB