Fixed blood on clothes after amputation

This commit is contained in:
Pao
2023-01-18 17:59:51 +01:00
parent dd54943175
commit b3ed7db01b
4 changed files with 43 additions and 10 deletions

View File

@@ -40,6 +40,7 @@
"BodyLocations", "BodyLocations",
"ISUnequipAction", "ISUnequipAction",
"ISInventoryPaneContextMenu", "ISInventoryPaneContextMenu",
"ISDropItemAction" "ISDropItemAction",
"BloodBodyPartType"
] ]
} }

View File

@@ -5,6 +5,10 @@ require "ISUI/ISInventoryPaneContextMenu"
local og_ISEquipTimedActionAdjustMaxTime = ISBaseTimedAction.adjustMaxTime local og_ISEquipTimedActionAdjustMaxTime = ISBaseTimedAction.adjustMaxTime
-- TODO On death hide the amputation so that other players cant pick it up
-- FIXME something is seriously broken here, it stacks up -- FIXME something is seriously broken here, it stacks up
function ISBaseTimedAction:adjustMaxTime(maxTime) function ISBaseTimedAction:adjustMaxTime(maxTime)

View File

@@ -6,4 +6,27 @@ function TocSetCorrectTextureForAmputation(item, player)
local matched_index = string.match(texture_string, "%d$") local matched_index = string.match(texture_string, "%d$")
print("TOC: Setting texture " .. 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 - 1)) -- TODO why is it correct with -1?
end
function TocSetBloodOnAmputation(player, body_part)
local body_part_type = body_part:getType()
local blood_body_part_type
if body_part_type == BodyPartType.Hand_R then
blood_body_part_type = BloodBodyPartType.ForeArm_R
elseif body_part_type == BodyPartType.Hand_L then
blood_body_part_type = BloodBodyPartType.ForeArm_L
elseif body_part_type == BodyPartType.Forearm_L or body_part_type == BodyPartType.UpperArm_L then
blood_body_part_type = BloodBodyPartType.UpperArm_L
elseif body_part_type == BodyPartType.Forearm_R or body_part_type == BodyPartType.UpperArm_R then
blood_body_part_type= BloodBodyPartType.UpperArm_R
end
print("TOC: Adding blood based on " .. tostring(body_part_type))
player:addBlood(blood_body_part_type, false, true, false)
player:addBlood(BloodBodyPartType.Torso_Lower, false, true, false)
end end

View File

@@ -217,21 +217,22 @@ function TheOnlyCure.CutLimb(part_name, surgeon_factor, bandage_table, painkille
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 = 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:AddDamage(100 - surgeon_factor)
body_part_type:setAdditionalPain(100 - surgeon_factor) body_part:setAdditionalPain(100 - surgeon_factor)
body_part_type:setBleeding(true) body_part:setBleeding(true)
body_part_type:setBleedingTime(100 - surgeon_factor) body_part:setBleedingTime(100 - surgeon_factor)
body_part_type:setDeepWounded(true) body_part:setDeepWounded(true)
body_part_type:setDeepWoundTime(100 - surgeon_factor) body_part:setDeepWoundTime(100 - surgeon_factor)
stats:setEndurance(surgeon_factor) stats:setEndurance(surgeon_factor)
stats:setStress(100 - surgeon_factor) stats:setStress(100 - surgeon_factor)
-- If bandages are available, use them -- If bandages are available, use them
body_part_type:setBandaged(bandage_table.use_bandage, 10, bandage_table.is_bandage_sterilized, bandage_table.bandage_type) body_part:setBandaged(bandage_table.use_bandage, 10, bandage_table.is_bandage_sterilized, bandage_table.bandage_type)
@@ -251,7 +252,7 @@ function TheOnlyCure.CutLimb(part_name, surgeon_factor, bandage_table, painkille
local body_damage = player:getBodyDamage() local body_damage = player:getBodyDamage()
if part_data[part_name].is_infected and body_damage.getInfectionLevel() < 20 then if part_data[part_name].is_infected and body_damage.getInfectionLevel() < 20 then
part_data[part_name].is_infected = false part_data[part_name].is_infected = false
body_part_type:SetBitten(false) body_part:SetBitten(false)
-- Second check, let's see if there is any other infected limb. -- Second check, let's see if there is any other infected limb.
if CheckIfStillInfected(part_data) == false then if CheckIfStillInfected(part_data) == false then
@@ -280,6 +281,10 @@ function TheOnlyCure.CutLimb(part_name, surgeon_factor, bandage_table, painkille
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)
-- Set blood on the amputated limb
TocSetBloodOnAmputation(getPlayer(), body_part)
player:transmitModData() player:transmitModData()
end end