Fixed picking up broken glass with item in off hand
This commit is contained in:
@@ -74,7 +74,7 @@ function ISBaseTimedAction:perform()
|
|||||||
if not dcInst:getIsAnyLimbCut() then return end
|
if not dcInst:getIsAnyLimbCut() then return end
|
||||||
|
|
||||||
local amputatedLimbs = CachedDataHandler.GetAmputatedLimbs(LocalPlayerController.username)
|
local amputatedLimbs = CachedDataHandler.GetAmputatedLimbs(LocalPlayerController.username)
|
||||||
local xp = self.maxTime/100
|
local xp = self.maxTime / 100
|
||||||
for k, _ in pairs(amputatedLimbs) do
|
for k, _ in pairs(amputatedLimbs) do
|
||||||
local limbName = k
|
local limbName = k
|
||||||
|
|
||||||
@@ -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,8 +300,7 @@ 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)
|
||||||
local dcInst = DataController.GetInstance()
|
local dcInst = DataController.GetInstance()
|
||||||
@@ -321,4 +338,4 @@ local og_ISClothingExtraAction_isValid = ISClothingExtraAction.isValid
|
|||||||
---@diagnostic disable-next-line: duplicate-set-field
|
---@diagnostic disable-next-line: duplicate-set-field
|
||||||
function ISClothingExtraAction:isValid()
|
function ISClothingExtraAction:isValid()
|
||||||
return WrapClothingAction(self, og_ISClothingExtraAction_isValid, InventoryItemFactory.CreateItem(self.extra))
|
return WrapClothingAction(self, og_ISClothingExtraAction_isValid, InventoryItemFactory.CreateItem(self.extra))
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user