From 80e9391db5a846dc6fe786dad3e639040325f311 Mon Sep 17 00:00:00 2001 From: ZioPao Date: Thu, 17 Apr 2025 12:42:35 +0200 Subject: [PATCH] fix: fixed ignored actions that should ignore toc calculations --- common/media/lua/client/TOC/Admin.lua | 3 +- .../TOC/TimedActions/IgnoredActions.lua | 95 +++++++++---------- 2 files changed, 45 insertions(+), 53 deletions(-) diff --git a/common/media/lua/client/TOC/Admin.lua b/common/media/lua/client/TOC/Admin.lua index 6f40140..81dd1c4 100644 --- a/common/media/lua/client/TOC/Admin.lua +++ b/common/media/lua/client/TOC/Admin.lua @@ -31,6 +31,7 @@ local function AddAdminTocOptions(playerNum, context, worldobjects) end + -- ugly This whole section should be done better for _, pl in pairs(players) do ---@cast pl IsoPlayer @@ -45,7 +46,6 @@ local function AddAdminTocOptions(playerNum, context, worldobjects) sendClientCommand(CommandsData.modules.TOC_RELAY, CommandsData.server.Relay.RelayExecuteInitialization, { patientNum = clickedPlayerNum }) else - -- TODO ugly ClientRelayCommands.ReceiveExecuteInitialization() end end) @@ -65,7 +65,6 @@ local function AddAdminTocOptions(playerNum, context, worldobjects) { patientNum = clickedPlayerNum, limbName = limbName }) else ClientRelayCommands.ReceiveExecuteAmputationAction({surgeonNum=clickedPlayerNum, limbName=limbName, damagePlayer=false}) - -- todo ugly end end) diff --git a/common/media/lua/client/TOC/TimedActions/IgnoredActions.lua b/common/media/lua/client/TOC/TimedActions/IgnoredActions.lua index 5d5e88f..8a12c1e 100644 --- a/common/media/lua/client/TOC/TimedActions/IgnoredActions.lua +++ b/common/media/lua/client/TOC/TimedActions/IgnoredActions.lua @@ -1,6 +1,6 @@ -- TODO This section must be overhauled --- local DataController = require("TOC/Controllers/DataController") +local DataController = require("TOC/Controllers/DataController") local StaticData = require("TOC/StaticData") ---@diagnostic disable: duplicate-set-field @@ -13,70 +13,63 @@ local StaticData = require("TOC/StaticData") ---ISEquipWeaponAction ---ISUnequipAction --- --- We're forced to re-run this crap to fix it --- ---@param action ISBaseTimedAction --- local function HandleSpeedSpecificAction(action, time) --- action.skipTOC = true --- action.maxTime = time --- action.animSpeed = 1.0 --- end +--- We're forced to re-run this crap to fix it +---@param action ISBaseTimedAction +local function OverrideAction(action, time) + -- TODO Add forced debuff instead of just relying on the vanilla values? + action.skipTOC = true + action.maxTime = time + action.animSpeed = 1.0 +end --- local og_ISAttachItemHotbar_new = ISAttachItemHotbar.new --- function ISAttachItemHotbar:new(character, item, slot, slotIndex, slotDef) --- local action = og_ISAttachItemHotbar_new(self, character, item, slot, slotIndex, slotDef) --- HandleSpeedSpecificAction(action, -1) --- return action --- end +local og_ISAttachItemHotbar_new = ISAttachItemHotbar.new +function ISAttachItemHotbar:new(character, item, slot, slotIndex, slotDef) + local action = og_ISAttachItemHotbar_new(self, character, item, slot, slotIndex, slotDef) + OverrideAction(action, -1) + return action +end --- local og_ISDetachItemHotbar_new = ISDetachItemHotbar.new --- function ISDetachItemHotbar:new(character, item) --- local action = og_ISDetachItemHotbar_new(self, character, item) --- HandleSpeedSpecificAction(action, -1) --- return action --- end +local og_ISDetachItemHotbar_new = ISDetachItemHotbar.new +function ISDetachItemHotbar:new(character, item) + local action = og_ISDetachItemHotbar_new(self, character, item) + action = OverrideAction(action, -1) + return action +end --- local og_ISEquipWeaponAction_new = ISEquipWeaponAction.new --- function ISEquipWeaponAction:new(character, item, time, primary, twoHands) +local og_ISEquipWeaponAction_new = ISEquipWeaponAction.new +function ISEquipWeaponAction:new(character, item, time, primary, twoHands) --- local action = og_ISEquipWeaponAction_new(self, character, item, time, primary, twoHands) --- TOC_DEBUG.print("Override ISEquipWeaponAction New") + local action = og_ISEquipWeaponAction_new(self, character, item, time, primary, twoHands) + TOC_DEBUG.print("Override ISEquipWeaponAction New") --- -- check if right arm is cut off or not. if it is, penality shall apply --- -- if we got here, the action is valid, so we know that we have a prosthesis. + -- check if right arm is cut off or not. if it is, penality shall apply + -- if we got here, the action is valid, so we know that we have a prosthesis. + local dcInst = DataController.GetInstance() --- local dcInst = DataController.GetInstance() + -- Brutal Handwork should be considered. Use the twohands thing + if not (dcInst:getIsAnyLimbCut() and twoHands) then + OverrideAction(action, time) + end --- if not dcInst:getIsCut(StaticData.LIMBS_IND_STR.Hand_R) then --- action.skipTOC = true --- action.maxTime = time --- action.animSpeed = 1.0 --- TOC_DEBUG.print("Skipping TOC for ISEquipWeaponAction new") --- end + return action +end --- -- if not twoHands then --- -- TOC_DEBUG.print("Not a two handed action, re-adding skip TOC") --- -- HandleSpeedSpecificAction(action) --- -- end --- return action --- end +local og_ISUnequipAction_new = ISUnequipAction.new +function ISUnequipAction:new(character, item, time) + local action = og_ISUnequipAction_new(self, character, item, time) + ---@cast item InventoryItem --- local og_ISUnequipAction_new = ISUnequipAction.new --- function ISUnequipAction:new(character, item, time) --- local action = og_ISUnequipAction_new(self, character, item, time) --- ---@cast item InventoryItem + -- For some reason (I have no clue why), if we re-run the method it breaks basically every unequip clothing action. Not for weapons though. + if instanceof(item, 'HandWeapon') then + OverrideAction(action, time) + end --- -- For some reason (I have no clue why), if we re-run the method it breaks basically every unequip clothing action. Not for weapons though. --- if instanceof(item, 'HandWeapon') then --- --print("Running handlespeedspecificaction") --- HandleSpeedSpecificAction(action) --- end - --- return action --- end + return action +end ------------------------------------------------------ --- Normal cases