fix: override for both hands interaction for b42 and cheat prevention

This commit is contained in:
ZioPao
2025-09-30 00:58:37 +02:00
parent 4714bd7b82
commit 5f71cebdc0
3 changed files with 27 additions and 11 deletions

View File

@@ -36,6 +36,12 @@ end
-- We need to override when the player changes key binds manually to be sure that TOC changes are re-applied
local og_MainOptions_apply = MainOptions.apply
function MainOptions:apply()
og_MainOptions_apply(self)
CachedDataHandler.OverrideBothHandsFeasibility()
end

View File

@@ -23,7 +23,7 @@ end
function CachedDataHandler.CalculateCacheableValues(username) function CachedDataHandler.CalculateCacheableValues(username)
CachedDataHandler.CalculateHighestAmputatedLimbs(username) CachedDataHandler.CalculateHighestAmputatedLimbs(username)
if getPlayer():getUsername() == username then if getPlayer():getUsername() == username then
CachedDataHandler.CalculateBothHandsFeasibility() CachedDataHandler.OverrideBothHandsFeasibility()
end end
end end
@@ -130,14 +130,13 @@ function CachedDataHandler.GetHandFeasibility(side)
-- FIX horrendous workaround, but with a forced init we run the caching too early and it breaks this, setting it to nil. -- FIX horrendous workaround, but with a forced init we run the caching too early and it breaks this, setting it to nil.
if CachedDataHandler.handFeasibility[side] == nil then if CachedDataHandler.handFeasibility[side] == nil then
CachedDataHandler.CalculateBothHandsFeasibility() CachedDataHandler.OverrideBothHandsFeasibility()
end end
return CachedDataHandler.handFeasibility[side] return CachedDataHandler.handFeasibility[side]
end end
function CachedDataHandler.OverrideBothHandsFeasibility()
function CachedDataHandler.CalculateBothHandsFeasibility()
CachedDataHandler.CalculateHandFeasibility("Hand_L") CachedDataHandler.CalculateHandFeasibility("Hand_L")
CachedDataHandler.CalculateHandFeasibility("Hand_R") CachedDataHandler.CalculateHandFeasibility("Hand_R")
local interactStr = "Interact" local interactStr = "Interact"
@@ -151,17 +150,28 @@ function CachedDataHandler.CalculateBothHandsFeasibility()
if not CachedDataHandler.GetBothHandsFeasibility() then if not CachedDataHandler.GetBothHandsFeasibility() then
TOC_DEBUG.print("Disabling interact key") TOC_DEBUG.print("Disabling interact key")
TOC_DEBUG.print("Cached current key for interact: " .. tostring(CachedDataHandler.interactKey)) TOC_DEBUG.print("Cached current key for interact: " .. tostring(CachedDataHandler.interactKey))
getCore():addKeyBinding(interactStr, Keyboard.KEY_NONE)
else
TOC_DEBUG.print("Re-enabling interact key")
TOC_DEBUG.print("Cached current key for interact: " .. tostring(CachedDataHandler.interactKey))
if StaticData.COMPAT_42 then
getCore():addKeyBinding(interactStr, Keyboard.KEY_NONE, 0, false, false, false)
else
getCore():addKeyBinding(interactStr, Keyboard.KEY_NONE)
end
else
--TOC_DEBUG.print("Re-enabling interact key")
--TOC_DEBUG.print("Cached current key for interact: " .. tostring(CachedDataHandler.interactKey))
if StaticData.COMPAT_42 then
getCore():addKeyBinding(interactStr, CachedDataHandler.interactKey, 0, false, false, false)
else
getCore():addKeyBinding(interactStr, CachedDataHandler.interactKey) getCore():addKeyBinding(interactStr, CachedDataHandler.interactKey)
end end
end end
end
function CachedDataHandler.GetBothHandsFeasibility() function CachedDataHandler.GetBothHandsFeasibility()
return CachedDataHandler.handFeasibility["L"] or CachedDataHandler.handFeasibility["R"] return CachedDataHandler.handFeasibility["L"] or CachedDataHandler.handFeasibility["R"]
end end
return CachedDataHandler return CachedDataHandler

View File

@@ -86,7 +86,7 @@ function ProsthesisHandler.SearchAndSetupProsthesis(item, isEquipping)
dcInst:apply() dcInst:apply()
-- Calculates hands feasibility once again -- Calculates hands feasibility once again
CachedDataHandler.CalculateBothHandsFeasibility() CachedDataHandler.OverrideBothHandsFeasibility()
return true return true
end end