Fixed items floating
This commit is contained in:
@@ -24,6 +24,19 @@ function CommonMethods.GetSide(name)
|
|||||||
if string.find(name, "_L") then return "L" else return "R" end
|
if string.find(name, "_L") then return "L" else return "R" end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---Returns full name for the side, to be used with BodyLocations
|
||||||
|
---@param side string
|
||||||
|
---@return string
|
||||||
|
function CommonMethods.GetSideFull(side)
|
||||||
|
if side == 'R' then
|
||||||
|
return "Right"
|
||||||
|
elseif side == 'L' then
|
||||||
|
return 'Left'
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
---Stops and start an event, making sure that we don't stack them up
|
---Stops and start an event, making sure that we don't stack them up
|
||||||
---@param event string
|
---@param event string
|
||||||
---@param method function
|
---@param method function
|
||||||
|
|||||||
@@ -263,3 +263,43 @@ function ISWorldObjectContextMenu.createMenu(player, worldobjects, x, y, test)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--* DISABLE WEARING CERTAIN ITEMS WHEN NO LIMB
|
||||||
|
|
||||||
|
local function CheckLimbFeasibility(limbName)
|
||||||
|
local dcInst = DataController.GetInstance()
|
||||||
|
local isFeasible = not dcInst:getIsCut(limbName) or dcInst:getIsProstEquipped(limbName)
|
||||||
|
TOC_DEBUG.print("isFeasible="..tostring(isFeasible))
|
||||||
|
return isFeasible
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
---@diagnostic disable-next-line: duplicate-set-field
|
||||||
|
local og_ISWearClothing_isValid = ISWearClothing.isValid
|
||||||
|
function ISWearClothing:isValid()
|
||||||
|
local isEquippable = og_ISWearClothing_isValid(self)
|
||||||
|
if not isEquippable then return isEquippable end
|
||||||
|
|
||||||
|
---@type Item
|
||||||
|
local item = self.item
|
||||||
|
local itemBodyLoc = item:getBodyLocation()
|
||||||
|
|
||||||
|
local limbToCheck = StaticData.AFFECTED_BODYLOCS_TO_LIMBS_IND_STR[itemBodyLoc]
|
||||||
|
if CheckLimbFeasibility(limbToCheck) then return isEquippable else return false end
|
||||||
|
end
|
||||||
|
|
||||||
|
local og_ISClothingExtraAction_isValid = ISClothingExtraAction.isValid
|
||||||
|
---@diagnostic disable-next-line: duplicate-set-field
|
||||||
|
function ISClothingExtraAction:isValid()
|
||||||
|
local isEquippable = og_ISClothingExtraAction_isValid(self)
|
||||||
|
if not isEquippable then return isEquippable end
|
||||||
|
|
||||||
|
|
||||||
|
TOC_DEBUG.print("Checking if we can equip item")
|
||||||
|
-- self.extra is a string, not the item
|
||||||
|
local testItem = InventoryItemFactory.CreateItem(self.extra)
|
||||||
|
local itemBodyLoc = testItem:getBodyLocation()
|
||||||
|
|
||||||
|
local limbToCheck = StaticData.AFFECTED_BODYLOCS_TO_LIMBS_IND_STR[itemBodyLoc]
|
||||||
|
TOC_DEBUG.print("Limb to check: " .. tostring(limbToCheck))
|
||||||
|
if CheckLimbFeasibility(limbToCheck) then return isEquippable else return false end
|
||||||
|
end
|
||||||
@@ -325,24 +325,35 @@ Events.OnPuttingTourniquet.Add(LocalPlayerController.HandleTourniquet)
|
|||||||
|
|
||||||
--* Object drop handling when amputation occurs
|
--* Object drop handling when amputation occurs
|
||||||
|
|
||||||
--- Drop all items from the affected limb
|
|
||||||
---@param limbName string
|
|
||||||
function LocalPlayerController.DropItemsAfterAmputation(limbName)
|
|
||||||
-- TODO Check for watches and stuff like that
|
|
||||||
|
|
||||||
TOC_DEBUG.print("Triggered DropItemsAfterAmputation")
|
function LocalPlayerController.CanItemBeEquipped(itemObj, limbName)
|
||||||
|
local bl = itemObj:getBodyLocation()
|
||||||
local side = CommonMethods.GetSide(limbName)
|
local side = CommonMethods.GetSide(limbName)
|
||||||
local sideStr
|
local sideStr = CommonMethods.GetSideFull(side)
|
||||||
|
|
||||||
if side == 'R' then
|
-- TODO Check from DataController
|
||||||
sideStr = "Right"
|
|
||||||
else
|
if string.contains(limbName, "Hand_") and (bl == sideStr .. "_MiddleFinger" or bl == sideStr .. "_RingFinger") then
|
||||||
sideStr = 'Left'
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local pl = getPlayer()
|
if string.contains(limbName, "ForeArm_") and (bl == sideStr .. "Wrist") then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Drop all items from the affected limb
|
||||||
|
---@param limbName string
|
||||||
|
function LocalPlayerController.DropItemsAfterAmputation(limbName)
|
||||||
|
TOC_DEBUG.print("Triggered DropItemsAfterAmputation")
|
||||||
|
local side = CommonMethods.GetSide(limbName)
|
||||||
|
local sideStr = CommonMethods.GetSideFull(side)
|
||||||
|
|
||||||
|
local pl = getPlayer()
|
||||||
local wornItems = pl:getWornItems()
|
local wornItems = pl:getWornItems()
|
||||||
|
|
||||||
for i = 1, wornItems:size() do
|
for i = 1, wornItems:size() do
|
||||||
|
|||||||
@@ -178,6 +178,40 @@ StaticData.TOURNIQUET_BODYLOCS_TO_GROUPS_IND_STR = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
StaticData.AFFECTED_BODYLOCS_TO_LIMBS_IND_STR = {}
|
||||||
|
|
||||||
|
local handsBodyLocs = {"Hands%s", "%s_MiddleFinger", "%s_RingFinger"}
|
||||||
|
local foreArmBodyLocs = {"%sWrist"}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
for side, _ in pairs(StaticData.SIDES_IND_STR) do
|
||||||
|
for part, _ in pairs(StaticData.PARTS_IND_STR) do
|
||||||
|
local limbName = part .. "_" .. side
|
||||||
|
|
||||||
|
local sideFull
|
||||||
|
if side == 'R' then sideFull = "Right" else sideFull = "Left" end
|
||||||
|
|
||||||
|
if part == "Hand" then
|
||||||
|
for i=1, #handsBodyLocs do
|
||||||
|
local bl = string.format(handsBodyLocs[i], sideFull)
|
||||||
|
StaticData.AFFECTED_BODYLOCS_TO_LIMBS_IND_STR[bl] = limbName
|
||||||
|
end
|
||||||
|
elseif part == "ForeArm" then
|
||||||
|
-- -- UGLY very ugly
|
||||||
|
-- for i=1, #handsBodyLocs do
|
||||||
|
-- local bl = string.format(handsBodyLocs[i], sideFull)
|
||||||
|
-- StaticData.AFFECTED_BODYLOCS_TO_LIMBS_IND_STR[bl] = limbName
|
||||||
|
-- end
|
||||||
|
for i=1, #foreArmBodyLocs do
|
||||||
|
local bl = string.format(foreArmBodyLocs[i], sideFull)
|
||||||
|
StaticData.AFFECTED_BODYLOCS_TO_LIMBS_IND_STR[bl] = limbName
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user