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 a511ac777a
commit a9a7063287
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)
CachedDataHandler.CalculateHighestAmputatedLimbs(username)
if getPlayer():getUsername() == username then
CachedDataHandler.CalculateBothHandsFeasibility()
CachedDataHandler.OverrideBothHandsFeasibility()
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.
if CachedDataHandler.handFeasibility[side] == nil then
CachedDataHandler.CalculateBothHandsFeasibility()
CachedDataHandler.OverrideBothHandsFeasibility()
end
return CachedDataHandler.handFeasibility[side]
end
function CachedDataHandler.CalculateBothHandsFeasibility()
function CachedDataHandler.OverrideBothHandsFeasibility()
CachedDataHandler.CalculateHandFeasibility("Hand_L")
CachedDataHandler.CalculateHandFeasibility("Hand_R")
local interactStr = "Interact"
@@ -151,12 +150,22 @@ function CachedDataHandler.CalculateBothHandsFeasibility()
if not CachedDataHandler.GetBothHandsFeasibility() then
TOC_DEBUG.print("Disabling interact key")
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))
getCore():addKeyBinding(interactStr, 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)
end
end
end
@@ -165,3 +174,4 @@ function CachedDataHandler.GetBothHandsFeasibility()
end
return CachedDataHandler

View File

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