diff --git a/media/clothing/clothingItems/Amputation_Left_Hand.xml b/media/clothing/clothingItems/Amputation_Left_Hand.xml
index 39329c8..5aa0b52 100644
--- a/media/clothing/clothingItems/Amputation_Left_Hand.xml
+++ b/media/clothing/clothingItems/Amputation_Left_Hand.xml
@@ -7,9 +7,9 @@
false
false
4
- Clothes\skin01
- Clothes\skin02
- Clothes\skin03
- Clothes\skin04
- Clothes\skin05
+ Clothes\skin01b
+ Clothes\skin02b
+ Clothes\skin03b
+ Clothes\skin04b
+ Clothes\skin05b
\ No newline at end of file
diff --git a/media/clothing/clothingItems/Amputation_Left_LowerArm.xml b/media/clothing/clothingItems/Amputation_Left_LowerArm.xml
index dd3bf57..802c173 100644
--- a/media/clothing/clothingItems/Amputation_Left_LowerArm.xml
+++ b/media/clothing/clothingItems/Amputation_Left_LowerArm.xml
@@ -8,9 +8,9 @@
false
3
4
- Clothes\skin01
- Clothes\skin02
- Clothes\skin03
- Clothes\skin04
- Clothes\skin05
+ Clothes\skin01b
+ Clothes\skin02b
+ Clothes\skin03b
+ Clothes\skin04b
+ Clothes\skin05b
\ No newline at end of file
diff --git a/media/clothing/clothingItems/Amputation_Left_UpperArm.xml b/media/clothing/clothingItems/Amputation_Left_UpperArm.xml
index 5bbe578..bbedaa4 100644
--- a/media/clothing/clothingItems/Amputation_Left_UpperArm.xml
+++ b/media/clothing/clothingItems/Amputation_Left_UpperArm.xml
@@ -8,9 +8,9 @@
false
3
4
- Clothes\skin01
- Clothes\skin02
- Clothes\skin03
- Clothes\skin04
- Clothes\skin05
+ Clothes\skin01b
+ Clothes\skin02b
+ Clothes\skin03b
+ Clothes\skin04b
+ Clothes\skin05b
\ No newline at end of file
diff --git a/media/clothing/clothingItems/Amputation_Right_Hand.xml b/media/clothing/clothingItems/Amputation_Right_Hand.xml
index 402cfcb..d15ba88 100644
--- a/media/clothing/clothingItems/Amputation_Right_Hand.xml
+++ b/media/clothing/clothingItems/Amputation_Right_Hand.xml
@@ -6,9 +6,9 @@
false
false
6
- Clothes\skin01
- Clothes\skin02
- Clothes\skin03
- Clothes\skin04
- Clothes\skin05
+ Clothes\skin01b
+ Clothes\skin02b
+ Clothes\skin03b
+ Clothes\skin04b
+ Clothes\skin05b
\ No newline at end of file
diff --git a/media/clothing/clothingItems/Amputation_Right_LowerArm.xml b/media/clothing/clothingItems/Amputation_Right_LowerArm.xml
index f96e63b..d0372a9 100644
--- a/media/clothing/clothingItems/Amputation_Right_LowerArm.xml
+++ b/media/clothing/clothingItems/Amputation_Right_LowerArm.xml
@@ -8,9 +8,9 @@
false
5
6
- Clothes\skin01
- Clothes\skin02
- Clothes\skin03
- Clothes\skin04
- Clothes\skin05
+ Clothes\skin01b
+ Clothes\skin02b
+ Clothes\skin03b
+ Clothes\skin04b
+ Clothes\skin05b
\ No newline at end of file
diff --git a/media/clothing/clothingItems/Amputation_Right_UpperArm.xml b/media/clothing/clothingItems/Amputation_Right_UpperArm.xml
index 8c1a73c..9ffa658 100644
--- a/media/clothing/clothingItems/Amputation_Right_UpperArm.xml
+++ b/media/clothing/clothingItems/Amputation_Right_UpperArm.xml
@@ -8,9 +8,9 @@
false
5
6
- Clothes\skin01
- Clothes\skin02
- Clothes\skin03
- Clothes\skin04
- Clothes\skin05
+ Clothes\skin01b
+ Clothes\skin02b
+ Clothes\skin03b
+ Clothes\skin04b
+ Clothes\skin05b
\ No newline at end of file
diff --git a/media/lua/client/TOC_HelperFunctions.lua b/media/lua/client/TOC_HelperFunctions.lua
index 23c73cc..589a3a9 100644
--- a/media/lua/client/TOC_HelperFunctions.lua
+++ b/media/lua/client/TOC_HelperFunctions.lua
@@ -38,6 +38,21 @@ function CureInfection(body_damage)
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
function SetBodyPartsStatusAfterOperation(player, part_data, part_name, use_oven)
diff --git a/media/lua/client/TOC_Visuals.lua b/media/lua/client/TOC_Visuals.lua
index 2b40b45..ca6ee01 100644
--- a/media/lua/client/TOC_Visuals.lua
+++ b/media/lua/client/TOC_Visuals.lua
@@ -1,20 +1,9 @@
-- 6 skin tones or 5?
function TocSetCorrectTextureForAmputation(item, player)
-
local human_visual = player:getHumanVisual()
-
local texture_string = human_visual:getSkinTexture()
- print(texture_string)
-
-
local matched_index = string.match(texture_string, "%d$")
- print(matched_index)
-
-
- item:getVisual():setTextureChoice(tonumber(matched_index))
-
-
-
-
+ print("TOC: Setting texture " .. matched_index)
+ item:getVisual():setTextureChoice(tonumber(matched_index - 1)) -- TODO why is it correct with -1?
end
\ No newline at end of file
diff --git a/media/lua/client/TOC_main.lua b/media/lua/client/TOC_main.lua
index bcd3a06..f9baf5e 100644
--- a/media/lua/client/TOC_main.lua
+++ b/media/lua/client/TOC_main.lua
@@ -2,6 +2,8 @@ if not TheOnlyCure then
TheOnlyCure = {}
end
+TOC_sides = {"Left", "Right"}
+TOC_limbs = {"Hand", "LowerArm", "UpperArm"}
-- TODO remove this crap
Left = "Left"
@@ -155,23 +157,28 @@ function TocSetInitData(mod_data, player)
-- 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)
+ local amputation_clothing_item = player:getInventory():AddItem("TOC.Amputation_Left_Hand")
+ TocSetCorrectTextureForAmputation(amputation_clothing_item, player)
+
+ player:setWornItem(amputation_clothing_item:getBodyLocation(), amputation_clothing_item)
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)
+ local amputation_clothing_item = player:getInventory():AddItem("TOC.Amputation_Left_LowerArm")
+ 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_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)
+ local amputation_clothing_item = player:getInventory():AddItem("TOC.Amputation_Left_UpperArm")
+ 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_operated = 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)
+ -- TODO Separate Cut Limb in side and limb instead of single part_name
+
-- TODO Check if this works in MP through MENU UI
local player = getPlayer()
local toc_data = player:getModData().TOC
local part_data = toc_data.Limbs
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
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
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))
TocSetCorrectTextureForAmputation(amputation_clothing_item, player)
player:setWornItem(amputation_clothing_item:getBodyLocation(), amputation_clothing_item)
+
player:transmitModData()
end
diff --git a/media/textures/Clothes/skin01b.png b/media/textures/Clothes/skin01b.png
new file mode 100644
index 0000000..856e1e2
Binary files /dev/null and b/media/textures/Clothes/skin01b.png differ
diff --git a/media/textures/Clothes/skin02b.png b/media/textures/Clothes/skin02b.png
new file mode 100644
index 0000000..a92dd71
Binary files /dev/null and b/media/textures/Clothes/skin02b.png differ
diff --git a/media/textures/Clothes/skin03b.png b/media/textures/Clothes/skin03b.png
new file mode 100644
index 0000000..db2dcfa
Binary files /dev/null and b/media/textures/Clothes/skin03b.png differ
diff --git a/media/textures/Clothes/skin04b.png b/media/textures/Clothes/skin04b.png
new file mode 100644
index 0000000..7e0b0c0
Binary files /dev/null and b/media/textures/Clothes/skin04b.png differ
diff --git a/media/textures/Clothes/skin05b.png b/media/textures/Clothes/skin05b.png
new file mode 100644
index 0000000..b993ce0
Binary files /dev/null and b/media/textures/Clothes/skin05b.png differ