diff --git a/media/clothing/clothingItems/Test_Tourniquet_Left.xml b/media/clothing/clothingItems/Test_Tourniquet_Left.xml new file mode 100644 index 0000000..a432ecb --- /dev/null +++ b/media/clothing/clothingItems/Test_Tourniquet_Left.xml @@ -0,0 +1,10 @@ + + + test_left_tourniquet + test_left_tourniquet + afbab35d-8bd4-4d61-87c7-054651ead1bd + false + false + false + Prosthesis\wood_base + \ No newline at end of file diff --git a/media/fileGuidTable.xml b/media/fileGuidTable.xml index 107fff3..508557f 100644 --- a/media/fileGuidTable.xml +++ b/media/fileGuidTable.xml @@ -76,4 +76,11 @@ media/clothing/clothingItems/Prost_Left_LowerArm_MetalHand.xml 0405a4c0-f71b-45a8-9edc-489fc81dca39 + + + media/clothing/clothingItems/Test_Tourniquet_Left.xml + afbab35d-8bd4-4d61-87c7-054651ead1bd + + + \ No newline at end of file diff --git a/media/lua/client/ActionsMethods/TOC_CutLimb.lua b/media/lua/client/ActionsMethods/TOC_CutLimb.lua index b1f6d8c..b90ed93 100644 --- a/media/lua/client/ActionsMethods/TOC_CutLimb.lua +++ b/media/lua/client/ActionsMethods/TOC_CutLimb.lua @@ -98,6 +98,20 @@ function TocDamagePlayerDuringAmputation(patient, part_name) body_damage_part:setBleedingTime(ZombRand(10, 20)) end +local function FindTourniquetInWornItems(patient, side) + local worn_items = patient:getWornItems() + + for i = 1, worn_items:size() - 1 do -- Maybe wornItems:size()-1 + local item = worn_items:get(i):getItem() + local item_full_type = item:getFullType() + if string.find(item_full_type, "Test_Tourniquet_" .. side) then + return item + end + end + + return nil + +end ---------------------------------------------------------------------------------- --- Main function for cutting a limb @@ -116,13 +130,9 @@ function TocCutLimb(part_name, surgeon_factor, bandage_table, painkiller_table) local limbs_data = toc_data.Limbs - - -- TODO Stop for a bit, - -- Cut Hand -> Damage in forearm -- Cut Forearm -> Damage in Upperarm -- Cut UpperArm -> Damage to torso - local body_damage = player:getBodyDamage() local body_part = body_damage:getBodyPart(TocGetBodyPartFromPartName(part_name)) local adiacent_body_part = player:getBodyDamage():getBodyPart(TocGetAdiacentBodyPartFromPartName(part_name)) @@ -135,18 +145,33 @@ function TocCutLimb(part_name, surgeon_factor, bandage_table, painkiller_table) -- The bit will be checked later since we're not sure if the player is not infected from another wound TocSetParametersForMissingLimb(body_part, false) + -- Use a tourniquet if available + local tourniquet_item = FindTourniquetInWornItems(player, TocGetSideFromPartName(part_name)) + + local base_damage_value = 100 + + if tourniquet_item ~= nil then + base_damage_value = 50 + + if part_name == "Left_UpperArm" or part_name == "Right_UpperArm" then + player:removeWornItem(tourniquet_item) + end + + end + -- Set damage, stress, and low endurance after amputation - adiacent_body_part:AddDamage(100 - surgeon_factor) - adiacent_body_part:setAdditionalPain(100 - surgeon_factor) + adiacent_body_part:AddDamage(base_damage_value - surgeon_factor) + adiacent_body_part:setAdditionalPain(base_damage_value - surgeon_factor) adiacent_body_part:setBleeding(true) - adiacent_body_part:setBleedingTime(100 - surgeon_factor) + adiacent_body_part:setBleedingTime(base_damage_value - surgeon_factor) adiacent_body_part:setDeepWounded(true) - adiacent_body_part:setDeepWoundTime(100 - surgeon_factor) + adiacent_body_part:setDeepWoundTime(base_damage_value - surgeon_factor) stats:setEndurance(surgeon_factor) - stats:setStress(100 - surgeon_factor) + stats:setStress(base_damage_value - surgeon_factor) -- Set malus for strength and fitness + -- TODO Make it more "random" with just some XP scaling down instead of a whole level, depending on the limb that we're cutting player:LoseLevel(Perks.Fitness) player:LoseLevel(Perks.Strength) @@ -161,8 +186,9 @@ function TocCutLimb(part_name, surgeon_factor, bandage_table, painkiller_table) -- If painkillers are available, use them -- TODO add painkiller support - -- Use a tourniquet if available - -- TODO add tourniquet + + + -- A check for is_cut shouldn't be necessary here since if we've got here we've already checked it out enough if limbs_data[part_name].is_cut == false then limbs_data[part_name].is_cut = true diff --git a/media/lua/client/TOC_CommonFunctions.lua b/media/lua/client/TOC_CommonFunctions.lua index fcb472e..21356ec 100644 --- a/media/lua/client/TOC_CommonFunctions.lua +++ b/media/lua/client/TOC_CommonFunctions.lua @@ -109,3 +109,13 @@ function TocGetSawInInventory(surgeon) player_inv:getItemFromType("Chainsaw") return item end + +function TocGetSideFromPartName(part_name) + + if string.find(part_name, "Left") then + return "Left" + else + return "Right" + end + +end \ No newline at end of file diff --git a/media/lua/client/TOC_OverridenFunctions.lua b/media/lua/client/TOC_OverridenFunctions.lua index c16b34b..0e6bf6e 100644 --- a/media/lua/client/TOC_OverridenFunctions.lua +++ b/media/lua/client/TOC_OverridenFunctions.lua @@ -185,3 +185,30 @@ function ISInventoryPaneContextMenu.dropItem(item, player) end end + +-- Make the player unable to equip a tourniquet on an already fully amputated limb +local og_ISWearClothingIsValid = ISWearClothing.isValid +function ISWearClothing:isValid() + local base_check = og_ISWearClothingIsValid(self) + --return self.character:getInventory():contains(self.item); + + local item_full_type = self.item:getFullType() + + -- TODO Sides + local limbs_data = self.character:getModData().TOC.Limbs + + for _, side in pairs(TOC_sides) do + if string.find(item_full_type, "Test_Tourniquet_" .. side) then + if limbs_data[side .. "_UpperArm"].is_cut then + return false + end + + + end + + end + + return base_check + + +end diff --git a/media/models_X/test_left_tourniquet.fbx b/media/models_X/test_left_tourniquet.fbx new file mode 100644 index 0000000..d87eb83 Binary files /dev/null and b/media/models_X/test_left_tourniquet.fbx differ diff --git a/media/scripts/TOC_items.txt b/media/scripts/TOC_items.txt index f06ba7b..64f1117 100644 --- a/media/scripts/TOC_items.txt +++ b/media/scripts/TOC_items.txt @@ -440,4 +440,23 @@ item ProthesisMag3 ReplaceOnUse = ProthesisMag3, Tooltip = Tooltip_ProthesisMag2, } -} \ No newline at end of file + + + item Test_Tourniquet_Left + { + Weight = 1, + Type = Clothing, + DisplayCategory = Prosthesis, + DisplayName = Tourniquet Left, + ClothingItem = Test_Tourniquet_Left, + BodyLocation = Hands, + BloodLocation = Hands, + Icon = tourniquet, + Tooltip = Test, + CanHaveHoles = false, + + } +} + + +