Fixed picking up broken glass with item in off hand

This commit is contained in:
ZioPao
2024-08-21 13:21:09 +02:00
parent 22e6621300
commit 10f97cffa1
2 changed files with 27 additions and 9 deletions

View File

@@ -92,7 +92,6 @@ function ISBaseTimedAction:perform()
if dcInst:getIsProstEquipped(limbName) then if dcInst:getIsProstEquipped(limbName) then
LocalPlayerController.playerObj:getXp():AddXP(Perks["ProstFamiliarity"], xp) LocalPlayerController.playerObj:getXp():AddXP(Perks["ProstFamiliarity"], xp)
end end
end end
end end
end end
@@ -124,7 +123,6 @@ end
---A recreation of the original method, but with amputations in mind ---A recreation of the original method, but with amputations in mind
function ISEquipWeaponAction:performWithAmputation() function ISEquipWeaponAction:performWithAmputation()
TOC_DEBUG.print("running ISEquipWeaponAction performWithAmputation") TOC_DEBUG.print("running ISEquipWeaponAction performWithAmputation")
local hand = nil local hand = nil
local otherHand = nil local otherHand = nil
@@ -203,12 +201,15 @@ local og_ISEquipWeaponAction_perform = ISEquipWeaponAction.perform
function ISEquipWeaponAction:perform() function ISEquipWeaponAction:perform()
og_ISEquipWeaponAction_perform(self) og_ISEquipWeaponAction_perform(self)
-- TODO Can we do it earlier?
--if self.character == getPlayer() then
local dcInst = DataController.GetInstance(self.character:getUsername()) local dcInst = DataController.GetInstance(self.character:getUsername())
-- Just check it any limb has been cut. If not, we can just return from here -- Just check it any limb has been cut. If not, we can just return from here
if dcInst:getIsAnyLimbCut() == true then if dcInst:getIsAnyLimbCut() then
self:performWithAmputation() self:performWithAmputation()
end end
--end
end end
function ISInventoryPaneContextMenu.doEquipOption(context, playerObj, isWeapon, items, player) function ISInventoryPaneContextMenu.doEquipOption(context, playerObj, isWeapon, items, player)
@@ -268,6 +269,23 @@ function ISWorldObjectContextMenu.createMenu(player, worldobjects, x, y, test)
---@type ISContextMenu ---@type ISContextMenu
local ogContext = og_ISWorldObjectContextMenu_createMenu(player, worldobjects, x, y, test) local ogContext = og_ISWorldObjectContextMenu_createMenu(player, worldobjects, x, y, test)
-- The vanilla game doesn't count an item in the off hand as "equipped" for picking up glass. Let's fix that here
local brokenGlassOption = ogContext:getOptionFromName(getText("ContextMenu_RemoveBrokenGlass"))
if brokenGlassOption then
local playerObj = getSpecificPlayer(player)
if (CachedDataHandler.GetHandFeasibility(StaticData.SIDES_IND_STR.R) and playerObj:getPrimaryHandItem()) or
(CachedDataHandler.GetHandFeasibility(StaticData.SIDES_IND_STR.L) and playerObj:getSecondaryHandItem())
then
brokenGlassOption.notAvailable = false
brokenGlassOption.toolTip = nil -- This is active only when you can't do the action.
end
end
-- check if no hands, disable various interactions -- check if no hands, disable various interactions
if not CachedDataHandler.GetBothHandsFeasibility() then if not CachedDataHandler.GetBothHandsFeasibility() then
TOC_DEBUG.print("NO hands :((") TOC_DEBUG.print("NO hands :((")
@@ -282,7 +300,6 @@ function ISWorldObjectContextMenu.createMenu(player, worldobjects, x, y, test)
return ogContext return ogContext
end end
--* DISABLE WEARING CERTAIN ITEMS WHEN NO LIMB --* DISABLE WEARING CERTAIN ITEMS WHEN NO LIMB
local function CheckLimbFeasibility(limbName) local function CheckLimbFeasibility(limbName)

View File

@@ -123,7 +123,8 @@ function CachedDataHandler.CalculateHandFeasibility(limbName)
CachedDataHandler.handFeasibility[side] = not dcInst:getIsCut(limbName) or dcInst:getIsProstEquipped(limbName) CachedDataHandler.handFeasibility[side] = not dcInst:getIsCut(limbName) or dcInst:getIsProstEquipped(limbName)
end end
---@param side string Either "L" or "R"
---@return boolean
function CachedDataHandler.GetHandFeasibility(side) function CachedDataHandler.GetHandFeasibility(side)
return CachedDataHandler.handFeasibility[side] return CachedDataHandler.handFeasibility[side]
end end