From db42feed35435c24bdfc694f7f36107dce57d8fd Mon Sep 17 00:00:00 2001 From: ZioPao Date: Wed, 21 Aug 2024 17:23:12 +0200 Subject: [PATCH] Added exceptions for various equipping actions --- .../Controllers/LimitActionsController.lua | 12 +++- .../TOC/TimedActions/IgnoredActions.lua | 64 +++++++++++++++++-- 2 files changed, 67 insertions(+), 9 deletions(-) diff --git a/media/lua/client/TOC/Controllers/LimitActionsController.lua b/media/lua/client/TOC/Controllers/LimitActionsController.lua index fb1db65..a5fb74b 100644 --- a/media/lua/client/TOC/Controllers/LimitActionsController.lua +++ b/media/lua/client/TOC/Controllers/LimitActionsController.lua @@ -32,8 +32,12 @@ function ISBaseTimedAction:adjustMaxTime(maxTime) local time = og_ISBaseTimedAction_adjustMaxTime(self, maxTime) -- Exceptions handling, if we find that parameter then we just use the original time - local queue = ISTimedActionQueue.getTimedActionQueue(getPlayer()) - if queue and queue.current and queue.current.skipTOC then return time end + local actionsQueue = ISTimedActionQueue.getTimedActionQueue(getPlayer()) + + if actionsQueue and actionsQueue.current and actionsQueue.skipTOC then + --TOC_DEBUG.print("Should skip TOC stuff") + return time + end -- Action is valid, check if we have any cut limb and then modify maxTime local dcInst = DataController.GetInstance() @@ -57,6 +61,10 @@ function ISBaseTimedAction:adjustMaxTime(maxTime) time = time * (StaticData.LIMBS_TIME_MULTIPLIER_IND_NUM[limbName] - perkLevelScaled) end end + if actionsQueue and actionsQueue.current then + TOC_DEBUG.print("OG Action: " .. tostring(actionsQueue.current.Type)) + end + TOC_DEBUG.print("New time with amputations: " .. tostring(time)) return time end diff --git a/media/lua/client/TOC/TimedActions/IgnoredActions.lua b/media/lua/client/TOC/TimedActions/IgnoredActions.lua index e668e74..6fb660c 100644 --- a/media/lua/client/TOC/TimedActions/IgnoredActions.lua +++ b/media/lua/client/TOC/TimedActions/IgnoredActions.lua @@ -1,10 +1,60 @@ ---@diagnostic disable: duplicate-set-field -- Bunch of actions shouldn't be modified by the adjusted time +----------------------------------------------- +---* Some actions have specific maxTime calculations and we must account for that +---ISAttachItemHotbar +---ISDetachItemHotbar +---ISEquipWeaponAction +---ISUnequipAction + +--- We're forced to re-run this crap to fix it +---@param action ISBaseTimedAction +local function HandleSpeedSpecificAction(action) + action.skipTOC = true + action.animSpeed = action.maxTime / action:adjustMaxTime(action.maxTime) + action.maxTime = -1 +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) + return action +end + +local og_ISDetachItemHotbar_new = ISDetachItemHotbar.new +function ISDetachItemHotbar:new(character, item) + local action = og_ISDetachItemHotbar_new(self, character, item) + HandleSpeedSpecificAction(action) + return action +end + +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") + if not twoHands then + 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) + HandleSpeedSpecificAction(action) + return action +end + +------------------------------------------------------ +--- Normal cases + + local og_ISEatFoodAction_new = ISEatFoodAction.new function ISEatFoodAction:new(character, item, percentage) local action = og_ISEatFoodAction_new(self, character, item, percentage) - TOC_DEBUG.print("Override ISEatFoodAction") + --TOC_DEBUG.print("Override ISEatFoodAction") action.skipTOC = true return action end @@ -12,7 +62,7 @@ end local og_ISReadABook_new = ISReadABook.new function ISReadABook:new(character, item, time) local action = og_ISReadABook_new(self, character, item, time) - TOC_DEBUG.print("Override ISReadABook") + --TOC_DEBUG.print("Override ISReadABook") action.skipTOC = true return action end @@ -20,7 +70,7 @@ end local og_ISTakePillAction_new = ISTakePillAction.new function ISTakePillAction:new(character, item, time) local action = og_ISTakePillAction_new(self, character, item, time) - TOC_DEBUG.print("Override ISTakePillAction") + --TOC_DEBUG.print("Override ISTakePillAction") action.skipTOC = true return action end @@ -28,7 +78,7 @@ end local og_ISTakeWaterAction_new = ISTakeWaterAction.new function ISTakeWaterAction:new(character, item, waterUnit, waterObject, time, oldItem) local action = og_ISTakeWaterAction_new(self, character, item, waterUnit, waterObject, time, oldItem) - TOC_DEBUG.print("Override ISTakeWaterAction") + --TOC_DEBUG.print("Override ISTakeWaterAction") action.skipTOC = true return action end @@ -36,7 +86,7 @@ end local og_ISDrinkFromBottle_new = ISDrinkFromBottle.new function ISDrinkFromBottle:new(character, item, uses) local action = og_ISDrinkFromBottle_new(self, character, item, uses) - TOC_DEBUG.print("Override ISDrinkFromBottle") + --TOC_DEBUG.print("Override ISDrinkFromBottle") action.skipTOC = true return action end @@ -44,7 +94,7 @@ end local og_ISFinalizeDealAction_new = ISFinalizeDealAction.new function ISFinalizeDealAction:new(player, otherPlayer, itemsToGive, itemsToReceive, time) local action = og_ISFinalizeDealAction_new(self, player, otherPlayer, itemsToGive, itemsToReceive, time) - TOC_DEBUG.print("Override ISFinalizeDealAction") + --TOC_DEBUG.print("Override ISFinalizeDealAction") action.skipTOC = true return action end @@ -52,7 +102,7 @@ end local og_ISCampingInfoAction_new = ISCampingInfoAction.new function ISCampingInfoAction:new(character, campfireObject, campfire) local action = og_ISCampingInfoAction_new(self, character, campfireObject, campfire) - TOC_DEBUG.print("Override ISCampingInfoAction") + --TOC_DEBUG.print("Override ISCampingInfoAction") action.skipTOC = true return action end \ No newline at end of file