This commit is contained in:
ZioPao
2024-03-21 03:37:50 +01:00
parent 3fb22a9b1e
commit 7a7e90dd7d
4 changed files with 43 additions and 48 deletions

View File

@@ -35,14 +35,14 @@ end
---Main function to delete a clothing item
---@param playerObj IsoPlayer
---@param clothingItem InventoryItem?
---@param clothingItem InventoryItem
---@return boolean
---@private
function ItemsController.Player.RemoveClothingItem(playerObj, clothingItem)
if clothingItem and instanceof(clothingItem, "InventoryItem") then
playerObj:removeWornItem(clothingItem)
playerObj:getInventory():Remove(clothingItem) -- Can be a InventoryItem too.. I guess? todo check it
playerObj:getInventory():Remove(clothingItem) -- Umbrella is wrong, can be an InventoryItem too
TOC_DEBUG.print("found and deleted" .. tostring(clothingItem))
-- Reset model
@@ -76,6 +76,12 @@ end
---@param playerObj IsoPlayer
function ItemsController.Player.DeleteAllOldAmputationItems(playerObj)
-- This part is a workaround for a pretty shitty implementation on the java side. Check ProsthesisHandler for more infos
-- FIX This doesn't really help in this case.
local group = BodyLocations.getGroup("Human")
group:setMultiItem("TOC_Arm", false)
group:setMultiItem("TOC_ArmProst", false)
for i=1, #StaticData.LIMBS_STR do
local limbName = StaticData.LIMBS_STR[i]
local clothItemName = StaticData.AMPUTATION_CLOTHING_ITEM_BASE .. limbName
@@ -84,6 +90,8 @@ function ItemsController.Player.DeleteAllOldAmputationItems(playerObj)
ItemsController.Player.RemoveClothingItem(playerObj, clothItem)
end
group:setMultiItem("TOC_Arm", true)
group:setMultiItem("TOC_ArmProst", true)
-- Reset model just in case
playerObj:resetModelNextFrame()
end

View File

@@ -225,37 +225,4 @@ function ISInventoryPaneContextMenu.doEquipOption(context, playerObj, isWeapon,
end
end
end
-- local og_ISInventoryPaneContextMenu_doClothingItemExtraMenu = ISInventoryPaneContextMenu.doClothingItemExtraMenu
-- ---@param context ISContextMenu
-- ---@param clothingItemExtra any
-- ---@param playerObj IsoPlayer
-- function ISInventoryPaneContextMenu.doClothingItemExtraMenu(context, clothingItemExtra, playerObj)
-- og_ISInventoryPaneContextMenu_doClothingItemExtraMenu(context, clothingItemExtra, playerObj)
-- -- local dc = DataController.GetInstance(playerObj:getUsername())
-- -- local text = getText("ContextMenu_InstallProstRight")
-- -- local rightOpt = context:getOptionFromName(text)
-- -- if rightOpt then
-- -- -- check if can be equipped
-- -- rightOpt.notAvailable = dc:getIsAnyLimbCut() and not dc:getIsCut("UpperArm_R")
-- -- end
-- -- text = getText("ContextMenu_InstallProstLeft")
-- -- local leftOpt = context:getOptionFromName(text)
-- -- if leftOpt then
-- -- leftOpt.notAvailable = dc:getIsAnyLimbCut() and not dc:getIsCut("UpperArm_L")
-- -- end
-- -- Check if in context there are the options for the prosts
-- end
-- -- TODO IMPORTANT!!!! ADD LIMIT FOR UPPER ARM AND WHEN YOU DON'T HAVE AMPUTATIONS FOR PROSTHETITCSmhh
end

View File

@@ -35,18 +35,18 @@ function ProsthesisHandler.GetGroup(item)
end
---Check if a prosthesis is equippable. It depends whether the player has a cut limb or not on that specific side. There's an exception for Upper arm, obviously
---@param name string
---@param fullType string
---@return boolean
function ProsthesisHandler.CheckIfEquippable(name)
function ProsthesisHandler.CheckIfEquippable(fullType)
TOC_DEBUG.print("Current item is a prosthesis")
local side = CommonMethods.GetSide(name)
local side = CommonMethods.GetSide(fullType)
TOC_DEBUG.print("Checking side: " .. tostring(side))
local highestAmputatedLimbs = CachedDataHandler.GetHighestAmputatedLimbs(getPlayer():getUsername())
if highestAmputatedLimbs then
local hal = highestAmputatedLimbs[side]
if not string.contains(hal, "UpperArm") then
if hal and not string.contains(hal, "UpperArm") then
TOC_DEBUG.print("Found acceptable limb to use prosthesis => " .. tostring(hal))
return true
end
@@ -81,9 +81,9 @@ local function HandleProsthesisValidation(item, isEquippable)
local isProst = ProsthesisHandler.CheckIfProst(item)
if not isProst then return isEquippable end
local itemName = item:getName() -- use name for side
local fullType = item:getFullType() -- use fulltype for side
if isEquippable then
isEquippable = ProsthesisHandler.CheckIfEquippable(itemName)
isEquippable = ProsthesisHandler.CheckIfEquippable(fullType)
end
@@ -112,9 +112,24 @@ local og_ISClothingExtraAction_isValid = ISClothingExtraAction.isValid
---@diagnostic disable-next-line: duplicate-set-field
function ISClothingExtraAction:isValid()
local isEquippable = og_ISClothingExtraAction_isValid(self)
return HandleProsthesisValidation(self.item, isEquippable)
-- self.extra is a string, not the item
local testItem = InventoryItemFactory.CreateItem(self.extra)
return HandleProsthesisValidation(testItem, isEquippable)
end
--[[
Horrendous workaround
To unequp items, the java side uses WornItems.setItem, which has
a check for multiItem. Basically, if it's active, it won't actually remove the item,
fucking things up. So, to be 100% sure that we're removing the items, we're gonna
disable and re-enable the multi-item bool for the Unequip Action.
]]
local og_ISClothingExtraAction_perform = ISClothingExtraAction.perform
function ISClothingExtraAction:perform()
og_ISClothingExtraAction_perform(self)
@@ -123,8 +138,12 @@ end
local og_ISUnequipAction_perform = ISUnequipAction.perform
function ISUnequipAction:perform()
og_ISUnequipAction_perform(self)
ProsthesisHandler.SearchAndSetupProsthesis(self.item, false)
local group = BodyLocations.getGroup("Human")
group:setMultiItem("TOC_ArmProst", false)
og_ISUnequipAction_perform(self)
group:setMultiItem("TOC_ArmProst", true)
end