Fixes for picking up ampuatted limbs

This commit is contained in:
Pao
2023-01-19 23:42:36 +01:00
parent acca07a78d
commit 101c19dde7
6 changed files with 102 additions and 52 deletions

View File

@@ -41,6 +41,7 @@
"ISUnequipAction", "ISUnequipAction",
"ISInventoryPaneContextMenu", "ISInventoryPaneContextMenu",
"ISDropItemAction", "ISDropItemAction",
"BloodBodyPartType" "BloodBodyPartType",
"ISInventoryPane"
] ]
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 871 KiB

After

Width:  |  Height:  |  Size: 67 KiB

View File

@@ -90,36 +90,50 @@ end
-- Override helper -- Override helper
function CheckIfItemIsAmputatedLimb(item) function CheckIfItemIsAmputatedLimb(item)
-- TODO Benchmark if this is faster
local item_full_type = item:getFullType() local item_full_type = item:getFullType()
local sides = {"Left", "Right"}
local limbs_to_check = {"Hand", "LowerArm", "UpperArm"}
local is_amputated_limb = false if string.find(item_full_type, "TOC.Amputation_") then
return true
for _, part in ipairs(limbs_to_check) do else
for _, side in ipairs(sides) do return false
local part_name = side .. "_" .. part
local check_name = "TOC.Amputation_" .. part_name
print(check_name)
if item_full_type == check_name then
is_amputated_limb = true
break
end end
end
end
return is_amputated_limb
end end
-- function CheckIfItemIsAmputatedLimb(item)
-- local item_full_type = item:getFullType()
-- local sides = {"Left", "Right"}
-- local limbs_to_check = {"Hand", "LowerArm", "UpperArm"}
-- local is_amputated_limb = false
-- for _, part in ipairs(limbs_to_check) do
-- for _, side in ipairs(sides) do
-- local part_name = side .. "_" .. part
-- local check_name = "TOC.Amputation_" .. part_name
-- print(check_name)
-- if item_full_type == check_name then
-- is_amputated_limb = true
-- break
-- end
-- end
-- end
-- return is_amputated_limb
-- end
function CheckIfItemIsProsthesis(item) function CheckIfItemIsProsthesis(item)
local item_full_type = item:getFullType() local item_full_type = item:getFullType()
local prosthesis_list = GetProsthesisList() local prosthesis_list = GetProsthesisList()

View File

@@ -6,8 +6,6 @@ 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
function ISBaseTimedAction:adjustMaxTime(maxTime) function ISBaseTimedAction:adjustMaxTime(maxTime)
print("TOC: Input max time " .. tostring(maxTime)) print("TOC: Input max time " .. tostring(maxTime))
@@ -73,9 +71,61 @@ end
local og_ISEquipWeaponActionPerform = ISEquipWeaponAction.perform -------------------------------------------------
-- Block access to drag, picking, inspecting, etc to amputated limbs
local og_ISInventoryPaneOnMouseDoubleClick = ISInventoryPane.onMouseDoubleClick
function ISInventoryPane:onMouseDoubleClick(x, y)
local item_to_check = self.items[self.mouseOverOption]
local player_inventory = getPlayerInventory(self.player).inventory
if instanceof(item_to_check, "InventoryItem") then
og_ISInventoryPaneOnMouseDoubleClick(self, x,y)
elseif CheckIfItemIsAmputatedLimb(item_to_check.items[1]) or CheckIfItemIsProsthesis(item_to_check.items[1]) then
print("TOC: Can't double click this item")
else
og_ISInventoryPaneOnMouseDoubleClick(self, x,y)
end
end
local og_ISInventoryPaneGetActualItems = ISInventoryPane.getActualItems
function ISInventoryPane.getActualItems(items)
local ret = og_ISInventoryPaneGetActualItems(items)
-- This is gonna be slower than just overriding the function but hey it's more compatible
for i=1, #ret do
local item_full_type = ret[i]:getFullType()
if string.find(item_full_type, "Amputation_") or string.find(item_full_type, "Prost_") then
table.remove(ret, i)
end
end
return ret
end
local og_ISInventoryPaneContextMenuOnInspectClothing = ISInventoryPaneContextMenu.onInspectClothing
ISInventoryPaneContextMenu.onInspectClothing = function(playerObj, clothing)
-- Inspect menu bypasses getActualItems, so we need to add that workaround here too
local clothing_full_type = clothing:getFullType()
if not string.find(clothing_full_type, "Amputation_") then
og_ISInventoryPaneContextMenuOnInspectClothing(playerObj, clothing)
end
end
local og_ISEquipWeaponActionPerform = ISEquipWeaponAction.perform
function ISEquipWeaponAction:perform() function ISEquipWeaponAction:perform()
-- TODO in the inventory menu there is something broken, even though this works
og_ISEquipWeaponActionPerform(self) og_ISEquipWeaponActionPerform(self)
local part_data = self.character:getModData().TOC.Limbs local part_data = self.character:getModData().TOC.Limbs
local can_be_held = {} local can_be_held = {}
@@ -100,7 +150,7 @@ function ISEquipWeaponAction:perform()
self.character:setSecondaryHandItem(nil) self.character:setSecondaryHandItem(nil)
elseif not can_be_held["Right"] and can_be_held["Left"] then elseif not can_be_held["Right"] and can_be_held["Left"] then
self.character:setPrimaryHandItem(nil) self.character:setPrimaryHandItem(nil)
self.character:setSecondaryHandItem(nil) self.character:setSecondaryHandItem(self.item)
elseif not can_be_held["Left"] and not can_be_held["Right"] then elseif not can_be_held["Left"] and not can_be_held["Right"] then
self.character:dropHandItems() self.character:dropHandItems()
end end
@@ -118,18 +168,6 @@ function ISEquipWeaponAction:perform()
end end
-- local og_ISUnequipActionPerform = ISUnequipAction.perform
-- function ISUnequipAction:perform()
-- -- -- check if the "clothing" is actually an amputation or an equipped prosthesis
-- -- TODO Find a way to disable the green advancement UI thing
-- if CheckIfItemIsAmputatedLimb(self.item) == false and CheckIfItemIsInstalledProsthesis(self.item) == false then
-- og_ISUnequipActionPerform(self)
-- end
-- end
local og_ISInventoryPaneContextMenuUnequipItem = ISInventoryPaneContextMenu.unequipItem local og_ISInventoryPaneContextMenuUnequipItem = ISInventoryPaneContextMenu.unequipItem
function ISInventoryPaneContextMenu.unequipItem(item, player) function ISInventoryPaneContextMenu.unequipItem(item, player)
@@ -142,7 +180,6 @@ function ISInventoryPaneContextMenu.unequipItem(item, player)
end end
local og_ISInventoryPaneContextMenuDropItem = ISInventoryPaneContextMenu.dropItem local og_ISInventoryPaneContextMenuDropItem = ISInventoryPaneContextMenu.dropItem
function ISInventoryPaneContextMenu.dropItem(item, player) function ISInventoryPaneContextMenu.dropItem(item, player)
if CheckIfItemIsAmputatedLimb(item) == false and CheckIfItemIsInstalledProsthesis(item) == false then if CheckIfItemIsAmputatedLimb(item) == false and CheckIfItemIsInstalledProsthesis(item) == false then

View File

@@ -27,6 +27,15 @@ function ISCutLimb:start()
self:setActionAnim("SawLog") self:setActionAnim("SawLog")
local saw_item = GetSawInInventory(self.surgeon) local saw_item = GetSawInInventory(self.surgeon)
-- Return whatever object we've got in the inventory
if self.surgeon:getPrimaryHandItem() then
ISTimedActionQueue.add(ISUnequipAction:new(self.surgeon, self.surgeon:getPrimaryHandItem(), 2));
end
if self.surgeon:getSecondaryHandItem() and self.surgeon:getSecondaryHandItem() ~= self.surgeon:getPrimaryHandItem() then
ISTimedActionQueue.add(ISUnequipAction:new(self.surgeon, self.surgeon:getSecondaryHandItem(), 2));
end
if saw_item then if saw_item then
self:setOverrideHandModels(saw_item:getStaticModel(), nil) self:setOverrideHandModels(saw_item:getStaticModel(), nil)
@@ -45,7 +54,6 @@ function ISCutLimb:start()
body_damage_part:setBleedingTime(ZombRand(10,20)) body_damage_part:setBleedingTime(ZombRand(10,20))
-- TODO Make the object currently on the hand return to the inventory
end end

View File

@@ -1,17 +1,7 @@
IGUI_EN = { IGUI_EN = {
IGUI_ItemCat_Prosthesis = "Prosthesis", IGUI_ItemCat_Prosthesis = "Prosthesis",
IGUI_ItemCat_Amputation = "Amputation"
IGUI_ItemCat_Surgeon_kit = "Surgeon kit", IGUI_ItemCat_Surgeon_kit = "Surgeon kit",
IGUI_TOC_health_Cut = "Is cut",
IGUI_TOC_health_Cica = " and heal",
IGUI_TOC_health_Operate = " and operate",
IGUI_TOC_health_time1 = " - There is a long time left before heal",
IGUI_TOC_health_time2 = " - There is some time left before heal",
IGUI_TOC_health_time3 = " - There is a little time left before heal",
IGUI_TOC_health_time4 = " - No idea how long until it's healed.",
IGUI_char_Hand_multi = "Time multi due to amp/tot",
IGUI_perks_Right_Hand = "Right hand", IGUI_perks_Right_Hand = "Right hand",
IGUI_perks_Left_Hand = "Left hand", IGUI_perks_Left_Hand = "Left hand",
IGUI_perks_Prosthesis = "Prosthesis skills", IGUI_perks_Prosthesis = "Prosthesis skills",