Added check to remove wrist watches when amputating
This commit is contained in:
@@ -114,17 +114,17 @@ function JCIO.DamagePlayerDuringAmputation(patient, partName)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function FindTourniquetInWornItems(patient, side)
|
local function FindTourniquetInWornItems(patient, side)
|
||||||
local worn_items = patient:getWornItems()
|
|
||||||
|
local checkString = "Surgery_" .. side .. "_Tourniquet"
|
||||||
|
local item = JCIO_Common.FindItemInWornItems(patient, checkString)
|
||||||
|
return item
|
||||||
|
|
||||||
for i = 1, worn_items:size() - 1 do -- Maybe wornItems:size()-1
|
end
|
||||||
local item = worn_items:get(i):getItem()
|
|
||||||
local item_full_type = item:getFullType()
|
|
||||||
if string.find(item_full_type, "Surgery_" .. side .. "_Tourniquet") then
|
|
||||||
return item
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return nil
|
local function FindWristWatchInWornItems(patient, side)
|
||||||
|
local checkString = "Watch_" .. side
|
||||||
|
local item = JCIO_Common.FindItemInWornItems(patient, checkString)
|
||||||
|
return item
|
||||||
|
|
||||||
end
|
end
|
||||||
----------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------
|
||||||
@@ -159,6 +159,7 @@ JCIO.CutLimb = function(partName, surgeonFactor, bandageTable, painkillerTable)
|
|||||||
local adjacentBodyPart = player:getBodyDamage():getBodyPart(JCIO_Common.GetAdjacentBodyPartFromPartName(partName))
|
local adjacentBodyPart = player:getBodyDamage():getBodyPart(JCIO_Common.GetAdjacentBodyPartFromPartName(partName))
|
||||||
|
|
||||||
local stats = player:getStats()
|
local stats = player:getStats()
|
||||||
|
local side = JCIO_Common.GetSideFromPartName(partName)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -167,7 +168,7 @@ JCIO.CutLimb = function(partName, surgeonFactor, bandageTable, painkillerTable)
|
|||||||
SetParametersForMissingLimb(bodyPart, false)
|
SetParametersForMissingLimb(bodyPart, false)
|
||||||
|
|
||||||
-- Use a tourniquet if available
|
-- Use a tourniquet if available
|
||||||
local tourniquetItem = FindTourniquetInWornItems(player, JCIO_Common.GetSideFromPartName(partName))
|
local tourniquetItem = FindTourniquetInWornItems(player, side)
|
||||||
|
|
||||||
local baseDamageValue = 100
|
local baseDamageValue = 100
|
||||||
|
|
||||||
@@ -177,9 +178,20 @@ JCIO.CutLimb = function(partName, surgeonFactor, bandageTable, painkillerTable)
|
|||||||
if partName == "Left_UpperArm" or partName == "Right_UpperArm" then
|
if partName == "Left_UpperArm" or partName == "Right_UpperArm" then
|
||||||
player:removeWornItem(tourniquetItem)
|
player:removeWornItem(tourniquetItem)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Removes wrist watches in case they're amputating the same side where they equipped it
|
||||||
|
local wristWatchItem = FindWristWatchInWornItems(player, side)
|
||||||
|
|
||||||
|
if wristWatchItem ~= nil then
|
||||||
|
player:removeWornItem(wristWatchItem)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- Set damage, stress, and low endurance after amputation
|
-- Set damage, stress, and low endurance after amputation
|
||||||
adjacentBodyPart:AddDamage(baseDamageValue - surgeonFactor)
|
adjacentBodyPart:AddDamage(baseDamageValue - surgeonFactor)
|
||||||
adjacentBodyPart:setAdditionalPain(baseDamageValue - surgeonFactor)
|
adjacentBodyPart:setAdditionalPain(baseDamageValue - surgeonFactor)
|
||||||
|
|||||||
@@ -273,4 +273,19 @@ JCIO_Common.GetCanBeHeldTable = function(limbs_data)
|
|||||||
return canBeHeld
|
return canBeHeld
|
||||||
|
|
||||||
end
|
end
|
||||||
-------------------------------
|
-------------------------------
|
||||||
|
|
||||||
|
JCIO_Common.FindItemInWornItems = function(player, checkString)
|
||||||
|
local wornItems = player:getWornItems()
|
||||||
|
|
||||||
|
for i = 1, wornItems:size() - 1 do -- Maybe wornItems:size()-1
|
||||||
|
local item = wornItems:get(i):getItem()
|
||||||
|
local itemFullType = item:getFullType()
|
||||||
|
if string.find(itemFullType, checkString) then
|
||||||
|
return item
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
|
||||||
|
end
|
||||||
@@ -4,6 +4,9 @@ require "TimedActions/ISUnequipAction"
|
|||||||
require "ISUI/ISInventoryPaneContextMenu"
|
require "ISUI/ISInventoryPaneContextMenu"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- TODO 1) Add exceptions for watches
|
||||||
|
|
||||||
local og_ISBaseTimedActionAdjustMaxTime = ISBaseTimedAction.adjustMaxTime
|
local og_ISBaseTimedActionAdjustMaxTime = ISBaseTimedAction.adjustMaxTime
|
||||||
function ISBaseTimedAction:adjustMaxTime(maxTime)
|
function ISBaseTimedAction:adjustMaxTime(maxTime)
|
||||||
|
|
||||||
@@ -184,29 +187,33 @@ function ISInventoryPaneContextMenu.dropItem(item, player)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Make the player unable to equip a tourniquet on an already fully amputated limb
|
-- Make the player unable to equip a tourniquet or watches on an already fully amputated limb
|
||||||
local og_ISWearClothingIsValid = ISWearClothing.isValid
|
local og_ISWearClothingIsValid = ISWearClothing.isValid
|
||||||
function ISWearClothing:isValid()
|
function ISWearClothing:isValid()
|
||||||
local base_check = og_ISWearClothingIsValid(self)
|
|
||||||
--return self.character:getInventory():contains(self.item);
|
local baseCheck = og_ISWearClothingIsValid(self)
|
||||||
|
local itemFullType = self.item:getFullType()
|
||||||
local item_full_type = self.item:getFullType()
|
local limbsData = self.character:getModData().JCIO.limbs
|
||||||
|
local itemsToBeChecked = {
|
||||||
-- TODO Sides
|
"Surgery_%1_Tourniquet", -- 1
|
||||||
local limbs_data = self.character:getModData().JCIO.limbs
|
"Watch_%1" -- 2
|
||||||
|
}
|
||||||
|
|
||||||
for _, side in pairs(JCIO.sideNames) do
|
for _, side in pairs(JCIO.sideNames) do
|
||||||
if string.find(item_full_type, "Test_Tourniquet_" .. side) then
|
for indexItem, itemName in pairs(itemsToBeChecked) do
|
||||||
if limbs_data[side .. "_UpperArm"].isCut then
|
local formattedItemName = string.format(itemName, side)
|
||||||
return false
|
|
||||||
|
if string.find(itemFullType, formattedItemName) then
|
||||||
|
if indexItem == 1 and limbsData[side .. "_UpperArm"].isCut then
|
||||||
|
return false
|
||||||
|
elseif indexItem == 2 and limbsData[side .. "_Hand"].isCut then
|
||||||
|
return false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return base_check
|
return baseCheck
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user