From a1336c8d2efcf73643e9c1eb07c71ebbf2aab300 Mon Sep 17 00:00:00 2001 From: ZioPao Date: Wed, 15 May 2024 11:38:08 +0200 Subject: [PATCH 1/4] Destroying the instance will break stuff --- media/lua/client/TOC/Controllers/ItemsController.lua | 1 + media/lua/client/TOC/Main.lua | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/media/lua/client/TOC/Controllers/ItemsController.lua b/media/lua/client/TOC/Controllers/ItemsController.lua index 60f2ff1..7b81d88 100644 --- a/media/lua/client/TOC/Controllers/ItemsController.lua +++ b/media/lua/client/TOC/Controllers/ItemsController.lua @@ -17,6 +17,7 @@ ItemsController.Player = {} ---@return number ---@private function ItemsController.Player.GetAmputationTexturesIndex(playerObj, isCicatrized) + -- FIX Broken local textureString = playerObj:getHumanVisual():getSkinTexture() local isHairy = textureString:sub(-1) == "a" diff --git a/media/lua/client/TOC/Main.lua b/media/lua/client/TOC/Main.lua index 55ac0ef..03f53dd 100644 --- a/media/lua/client/TOC/Main.lua +++ b/media/lua/client/TOC/Main.lua @@ -58,8 +58,9 @@ function Main.WipeData(player) -- Let's wipe the instance too just to be sure - local DataController = require("TOC/Controllers/DataController") - DataController.DestroyInstance(username) + -- TODO This can break things I guess + --local DataController = require("TOC/Controllers/DataController") + --DataController.DestroyInstance(username) end From 696edc1f1dac56fd92e24664ee05b064d61df602 Mon Sep 17 00:00:00 2001 From: ZioPao Date: Wed, 15 May 2024 11:47:28 +0200 Subject: [PATCH 2/4] Fixed wrong skin color for amputations --- media/lua/client/TOC/Controllers/ItemsController.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/media/lua/client/TOC/Controllers/ItemsController.lua b/media/lua/client/TOC/Controllers/ItemsController.lua index 7b81d88..f539e6c 100644 --- a/media/lua/client/TOC/Controllers/ItemsController.lua +++ b/media/lua/client/TOC/Controllers/ItemsController.lua @@ -21,7 +21,8 @@ function ItemsController.Player.GetAmputationTexturesIndex(playerObj, isCicatriz local textureString = playerObj:getHumanVisual():getSkinTexture() local isHairy = textureString:sub(-1) == "a" - local matchedIndex = tonumber(textureString:match("%d$")) or 0 + local matchedIndex = tonumber(textureString:match("%d%d")) -- it must always be at least 1 + TOC_DEBUG.print("Texture string: " .. tostring(textureString)) if isHairy then matchedIndex = matchedIndex + 5 @@ -31,7 +32,7 @@ function ItemsController.Player.GetAmputationTexturesIndex(playerObj, isCicatriz matchedIndex = matchedIndex + (isHairy and 5 or 10) -- We add 5 is it's the texture, else 10 end - TOC_DEBUG.print("isCicatrized= " .. tostring(isCicatrized)) + TOC_DEBUG.print("isCicatrized = " .. tostring(isCicatrized)) TOC_DEBUG.print("Amputation Texture Index: " .. tostring(matchedIndex)) return matchedIndex - 1 end From 80c8b22faa67b722cb1d3876b43e3595be0bff32 Mon Sep 17 00:00:00 2001 From: ZioPao Date: Wed, 15 May 2024 11:52:45 +0200 Subject: [PATCH 3/4] lock for HandleDamage not disengaging in some cases --- media/lua/client/TOC/Controllers/LocalPlayerController.lua | 6 +++++- media/lua/client/TOC/Main.lua | 2 +- mod.info | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/media/lua/client/TOC/Controllers/LocalPlayerController.lua b/media/lua/client/TOC/Controllers/LocalPlayerController.lua index 225651a..18b7986 100644 --- a/media/lua/client/TOC/Controllers/LocalPlayerController.lua +++ b/media/lua/client/TOC/Controllers/LocalPlayerController.lua @@ -149,7 +149,11 @@ LocalPlayerController.hasBeenDamaged = false function LocalPlayerController.HandleDamage(character) --TOC_DEBUG.print("Player got hit!") -- TOC_DEBUG.print(damageType) - if character ~= getPlayer() then return end + if character ~= getPlayer() then + -- Disable lock before doing anything else + LocalPlayerController.hasBeenDamaged = false + return + end local bd = character:getBodyDamage() local dcInst = DataController.GetInstance() local modDataNeedsUpdate = false diff --git a/media/lua/client/TOC/Main.lua b/media/lua/client/TOC/Main.lua index 03f53dd..a62a028 100644 --- a/media/lua/client/TOC/Main.lua +++ b/media/lua/client/TOC/Main.lua @@ -6,7 +6,7 @@ require("TOC/Events") ---@class Main local Main = { - _version = "2.0.10" + _version = "2.0.11" } function Main.Start() diff --git a/mod.info b/mod.info index 42be3ff..f1f701f 100644 --- a/mod.info +++ b/mod.info @@ -4,5 +4,5 @@ description=You've been bitten. You have only two choices. id=TheOnlyCure icon=icon.png url=https://github.com/ZioPao/The-Only-Cure -modversion=2.0.10 +modversion=2.0.11 pzversion=41.65 From 5f64ead3547692f0b4f576f43ef75c7c7e87bd03 Mon Sep 17 00:00:00 2001 From: ZioPao Date: Wed, 15 May 2024 13:13:27 +0200 Subject: [PATCH 4/4] Fixed disabling of Interact Key --- .../TOC/Controllers/LocalPlayerController.lua | 6 +----- media/lua/client/TOC/Handlers/CachedDataHandler.lua | 13 +++++++++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/media/lua/client/TOC/Controllers/LocalPlayerController.lua b/media/lua/client/TOC/Controllers/LocalPlayerController.lua index 18b7986..5f66489 100644 --- a/media/lua/client/TOC/Controllers/LocalPlayerController.lua +++ b/media/lua/client/TOC/Controllers/LocalPlayerController.lua @@ -202,17 +202,13 @@ function LocalPlayerController.HandleDamage(character) LocalPlayerController.hasBeenDamaged = false end ----Setup HandleDamage, triggered by OnPlayerGetDamage +---Setup HandleDamage, triggered by OnPlayerGetDamage. To prevent a spam caused by this awful event, we use a bool lock ---@param character IsoPlayer|IsoGameCharacter ---@param damageType string ---@param damageAmount number function LocalPlayerController.OnGetDamage(character, damageType, damageAmount) - -- TODO Check if other players in the online triggers this - if LocalPlayerController.hasBeenDamaged == false then -- Start checks - - -- TODO Add a timer before we can re-enable this bool? LocalPlayerController.hasBeenDamaged = true LocalPlayerController.HandleDamage(character) end diff --git a/media/lua/client/TOC/Handlers/CachedDataHandler.lua b/media/lua/client/TOC/Handlers/CachedDataHandler.lua index 2d6330d..38f5cdb 100644 --- a/media/lua/client/TOC/Handlers/CachedDataHandler.lua +++ b/media/lua/client/TOC/Handlers/CachedDataHandler.lua @@ -133,16 +133,21 @@ function CachedDataHandler.CalculateBothHandsFeasibility() CachedDataHandler.CalculateHandFeasibility("Hand_L") CachedDataHandler.CalculateHandFeasibility("Hand_R") local interactStr = "Interact" + + if CachedDataHandler.interactKey == nil or CachedDataHandler.interactKey == 0 then + CachedDataHandler.interactKey = getCore():getKey(interactStr) + end + + + if not CachedDataHandler.GetBothHandsFeasibility() then TOC_DEBUG.print("Disabling interact key") - - -- Cache the current key - CachedDataHandler.interactKey = getCore():getKey(interactStr) + 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 not CachedDataHandler.interactKey then CachedDataHandler.interactKey = getCore():getKey(interactStr) end getCore():addKeyBinding(interactStr, CachedDataHandler.interactKey) end end