diff --git a/.vscode/settings.json b/.vscode/settings.json index b9abe73..847574b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -41,6 +41,7 @@ "ISUnequipAction", "ISInventoryPaneContextMenu", "ISDropItemAction", - "BloodBodyPartType" + "BloodBodyPartType", + "ISInventoryPane" ] } \ No newline at end of file diff --git a/generic.png b/generic.png index 7e82008..fde941b 100644 Binary files a/generic.png and b/generic.png differ diff --git a/media/lua/client/TOC_HelperFunctions.lua b/media/lua/client/TOC_HelperFunctions.lua index de19ac3..25d42cb 100644 --- a/media/lua/client/TOC_HelperFunctions.lua +++ b/media/lua/client/TOC_HelperFunctions.lua @@ -90,36 +90,50 @@ end -- Override helper function CheckIfItemIsAmputatedLimb(item) - - + -- TODO Benchmark if this is faster 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 + if string.find(item_full_type, "TOC.Amputation_") then + return true + else + return false end - return is_amputated_limb - 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) local item_full_type = item:getFullType() local prosthesis_list = GetProsthesisList() diff --git a/media/lua/client/TOC_OverridenFunctions.lua b/media/lua/client/TOC_OverridenFunctions.lua index 8aad3f5..10636c5 100644 --- a/media/lua/client/TOC_OverridenFunctions.lua +++ b/media/lua/client/TOC_OverridenFunctions.lua @@ -6,8 +6,6 @@ require "ISUI/ISInventoryPaneContextMenu" local og_ISEquipTimedActionAdjustMaxTime = ISBaseTimedAction.adjustMaxTime --- TODO On death hide the amputation so that other players cant pick it up - function ISBaseTimedAction:adjustMaxTime(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() + + -- TODO in the inventory menu there is something broken, even though this works og_ISEquipWeaponActionPerform(self) local part_data = self.character:getModData().TOC.Limbs local can_be_held = {} @@ -100,7 +150,7 @@ function ISEquipWeaponAction:perform() self.character:setSecondaryHandItem(nil) elseif not can_be_held["Right"] and can_be_held["Left"] then 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 self.character:dropHandItems() end @@ -118,18 +168,6 @@ function ISEquipWeaponAction:perform() 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 function ISInventoryPaneContextMenu.unequipItem(item, player) @@ -142,7 +180,6 @@ function ISInventoryPaneContextMenu.unequipItem(item, player) end local og_ISInventoryPaneContextMenuDropItem = ISInventoryPaneContextMenu.dropItem - function ISInventoryPaneContextMenu.dropItem(item, player) if CheckIfItemIsAmputatedLimb(item) == false and CheckIfItemIsInstalledProsthesis(item) == false then diff --git a/media/lua/client/TimedActions/ISCutLimb.lua b/media/lua/client/TimedActions/ISCutLimb.lua index 51e8e63..6d64d46 100644 --- a/media/lua/client/TimedActions/ISCutLimb.lua +++ b/media/lua/client/TimedActions/ISCutLimb.lua @@ -27,6 +27,15 @@ function ISCutLimb:start() self:setActionAnim("SawLog") 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 self:setOverrideHandModels(saw_item:getStaticModel(), nil) @@ -45,7 +54,6 @@ function ISCutLimb:start() body_damage_part:setBleedingTime(ZombRand(10,20)) - -- TODO Make the object currently on the hand return to the inventory end diff --git a/media/lua/shared/translate/EN/IG_UI_EN.txt b/media/lua/shared/translate/EN/IG_UI_EN.txt index e7950f8..df73531 100644 --- a/media/lua/shared/translate/EN/IG_UI_EN.txt +++ b/media/lua/shared/translate/EN/IG_UI_EN.txt @@ -1,17 +1,7 @@ IGUI_EN = { IGUI_ItemCat_Prosthesis = "Prosthesis", + IGUI_ItemCat_Amputation = "Amputation" 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_Left_Hand = "Left hand", IGUI_perks_Prosthesis = "Prosthesis skills",