Added working tourniquet for left side

This commit is contained in:
Pao
2023-02-06 14:13:44 +01:00
parent 1545c88a19
commit 9633be4fc5
7 changed files with 111 additions and 12 deletions

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<clothingItem>
<m_MaleModel>test_left_tourniquet</m_MaleModel>
<m_FemaleModel>test_left_tourniquet</m_FemaleModel>
<m_GUID>afbab35d-8bd4-4d61-87c7-054651ead1bd</m_GUID>
<m_Static>false</m_Static>
<m_AllowRandomHue>false</m_AllowRandomHue>
<m_AllowRandomTint>false</m_AllowRandomTint>
<textureChoices>Prosthesis\wood_base</textureChoices>
</clothingItem>

View File

@@ -76,4 +76,11 @@
<path>media/clothing/clothingItems/Prost_Left_LowerArm_MetalHand.xml</path> <path>media/clothing/clothingItems/Prost_Left_LowerArm_MetalHand.xml</path>
<guid>0405a4c0-f71b-45a8-9edc-489fc81dca39</guid> <guid>0405a4c0-f71b-45a8-9edc-489fc81dca39</guid>
</files> </files>
<files>
<path>media/clothing/clothingItems/Test_Tourniquet_Left.xml</path>
<guid>afbab35d-8bd4-4d61-87c7-054651ead1bd</guid>
</files>
</fileGuidTable> </fileGuidTable>

View File

@@ -98,6 +98,20 @@ function TocDamagePlayerDuringAmputation(patient, part_name)
body_damage_part:setBleedingTime(ZombRand(10, 20)) body_damage_part:setBleedingTime(ZombRand(10, 20))
end 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 --- 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 local limbs_data = toc_data.Limbs
-- TODO Stop for a bit,
-- Cut Hand -> Damage in forearm -- Cut Hand -> Damage in forearm
-- Cut Forearm -> Damage in Upperarm -- Cut Forearm -> Damage in Upperarm
-- Cut UpperArm -> Damage to torso -- Cut UpperArm -> Damage to torso
local body_damage = player:getBodyDamage() local body_damage = player:getBodyDamage()
local body_part = body_damage:getBodyPart(TocGetBodyPartFromPartName(part_name)) local body_part = body_damage:getBodyPart(TocGetBodyPartFromPartName(part_name))
local adiacent_body_part = player:getBodyDamage():getBodyPart(TocGetAdiacentBodyPartFromPartName(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 -- The bit will be checked later since we're not sure if the player is not infected from another wound
TocSetParametersForMissingLimb(body_part, false) 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 -- Set damage, stress, and low endurance after amputation
adiacent_body_part:AddDamage(100 - surgeon_factor) adiacent_body_part:AddDamage(base_damage_value - surgeon_factor)
adiacent_body_part:setAdditionalPain(100 - surgeon_factor) adiacent_body_part:setAdditionalPain(base_damage_value - surgeon_factor)
adiacent_body_part:setBleeding(true) 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:setDeepWounded(true)
adiacent_body_part:setDeepWoundTime(100 - surgeon_factor) adiacent_body_part:setDeepWoundTime(base_damage_value - surgeon_factor)
stats:setEndurance(surgeon_factor) stats:setEndurance(surgeon_factor)
stats:setStress(100 - surgeon_factor) stats:setStress(base_damage_value - surgeon_factor)
-- Set malus for strength and fitness -- 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.Fitness)
player:LoseLevel(Perks.Strength) player:LoseLevel(Perks.Strength)
@@ -161,8 +186,9 @@ function TocCutLimb(part_name, surgeon_factor, bandage_table, painkiller_table)
-- If painkillers are available, use them -- If painkillers are available, use them
-- TODO add painkiller support -- 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 if limbs_data[part_name].is_cut == false then
limbs_data[part_name].is_cut = true limbs_data[part_name].is_cut = true

View File

@@ -109,3 +109,13 @@ function TocGetSawInInventory(surgeon)
player_inv:getItemFromType("Chainsaw") player_inv:getItemFromType("Chainsaw")
return item return item
end end
function TocGetSideFromPartName(part_name)
if string.find(part_name, "Left") then
return "Left"
else
return "Right"
end
end

View File

@@ -185,3 +185,30 @@ function ISInventoryPaneContextMenu.dropItem(item, player)
end end
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

Binary file not shown.

View File

@@ -440,4 +440,23 @@ item ProthesisMag3
ReplaceOnUse = ProthesisMag3, ReplaceOnUse = ProthesisMag3,
Tooltip = Tooltip_ProthesisMag2, Tooltip = Tooltip_ProthesisMag2,
} }
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,
}
} }