diff --git a/media/lua/client/TOC/Controllers/LimitActionsController.lua b/media/lua/client/TOC/Controllers/LimitActionsController.lua index b65153d..282f61e 100644 --- a/media/lua/client/TOC/Controllers/LimitActionsController.lua +++ b/media/lua/client/TOC/Controllers/LimitActionsController.lua @@ -59,7 +59,17 @@ function ISBaseTimedAction:adjustMaxTime(maxTime) local perkLevelScaled if perkLevel ~= 0 then perkLevelScaled = perkLevel / 10 else perkLevelScaled = 0 end - time = time * (StaticData.LIMBS_TIME_MULTIPLIER_IND_NUM[limbName] - perkLevelScaled) + TOC_DEBUG.print("Perk Level: " .. tostring(perkLevel)) + TOC_DEBUG.print("OG time: " .. tostring(time)) + + -- Modified Time shouldn't EVER be lower compared to the og one. + local modifiedTime = time * (StaticData.LIMBS_TIME_MULTIPLIER_IND_NUM[limbName] - perkLevelScaled) + + if modifiedTime >= time then + time = modifiedTime + end + + --TOC_DEBUG.print("Modified time: " .. tostring(time)) end end diff --git a/media/lua/client/TOC/TimedActions/IgnoredActions.lua b/media/lua/client/TOC/TimedActions/IgnoredActions.lua index ace71a1..d40fd90 100644 --- a/media/lua/client/TOC/TimedActions/IgnoredActions.lua +++ b/media/lua/client/TOC/TimedActions/IgnoredActions.lua @@ -1,3 +1,8 @@ +-- TODO This section must be overhauled + +-- local DataController = require("TOC/Controllers/DataController") +-- local StaticData = require("TOC/StaticData") + ---@diagnostic disable: duplicate-set-field -- Bunch of actions shouldn't be modified by the adjusted time @@ -8,51 +13,70 @@ ---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 +-- --- 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 -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_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_ISDetachItemHotbar_new = ISDetachItemHotbar.new -function ISDetachItemHotbar:new(character, item) - local action = og_ISDetachItemHotbar_new(self, character, item) - 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, -1) +-- 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) - ---@cast item InventoryItem +-- local og_ISEquipWeaponAction_new = ISEquipWeaponAction.new +-- function ISEquipWeaponAction:new(character, item, time, primary, twoHands) - -- 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 +-- local action = og_ISEquipWeaponAction_new(self, character, item, time, primary, twoHands) +-- TOC_DEBUG.print("Override ISEquipWeaponAction New") - return action -end + +-- -- 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() + +-- 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 + + +-- -- 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 + +-- -- 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 ------------------------------------------------------ --- Normal cases diff --git a/media/lua/client/TOC/UI/ConfirmationPanel.lua b/media/lua/client/TOC/UI/ConfirmationPanel.lua new file mode 100644 index 0000000..6e00bea --- /dev/null +++ b/media/lua/client/TOC/UI/ConfirmationPanel.lua @@ -0,0 +1,116 @@ +---@class ConfirmationPanel : ISPanel +local ConfirmationPanel = ISPanel:derive("ConfirmationPanel") + +---Starts a new confirmation panel +---@param x number +---@param y number +---@param width number +---@param height number +---@param alertText string +---@param onConfirmFunc function +---@return ConfirmationPanel +function ConfirmationPanel:new(x, y, width, height, alertText, parentPanel, onConfirmFunc) + local o = ISPanel:new(x, y, width, height) + setmetatable(o, self) + self.__index = self + + o:initialise() + o.alertText = alertText + o.onConfirmFunc = onConfirmFunc + o.parentPanel = parentPanel + ConfirmationPanel.instance = o + + ---@cast o ConfirmationPanel + return o +end + +function ConfirmationPanel:createChildren() + ISPanel.createChildren(self) + self.borderColor = { r = 1, g = 0, b = 0, a = 1 } + + self.textPanel = ISRichTextPanel:new(0, 0, self.width, self.height) + self.textPanel:initialise() + self:addChild(self.textPanel) + self.textPanel.defaultFont = UIFont.Medium + self.textPanel.anchorTop = true + self.textPanel.anchorLeft = false + self.textPanel.anchorBottom = true + self.textPanel.anchorRight = false + self.textPanel.marginLeft = 0 + self.textPanel.marginTop = 10 + self.textPanel.marginRight = 0 + self.textPanel.marginBottom = 0 + self.textPanel.autosetheight = false + self.textPanel.background = false + self.textPanel:setText(self.alertText) + self.textPanel:paginate() + + local yPadding = 10 + local xPadding = self:getWidth() / 4 + local btnWidth = 100 + local btnHeight = 25 + + + local yButton = self:getHeight() - yPadding - btnHeight + + self.btnYes = ISButton:new(xPadding, yButton, btnWidth, btnHeight, "Yes", self, self.onClick) + self.btnYes.internal = "YES" + self.btnYes:initialise() + self.btnYes.borderColor = { r = 1, g = 0, b = 0, a = 1 } + self.btnYes:setEnable(true) + self:addChild(self.btnYes) + + self.btnNo = ISButton:new(self:getWidth() - xPadding - btnWidth, yButton, btnWidth, btnHeight, "No", self, + self.onClick) + self.btnNo.internal = "NO" + self.btnNo:initialise() + self.btnNo:setEnable(true) + self:addChild(self.btnNo) +end + +function ConfirmationPanel:onClick(btn) + if btn.internal == 'YES' then + self.onConfirmFunc(self.parentPanel) + self:close() + elseif btn.internal == 'NO' then + self:close() + end +end + +------------------------- + +---@param alertText string +---@param x any +---@param y any +---@param parentPanel any +---@param onConfirmFunc any +---@return ConfirmationPanel +function ConfirmationPanel.Open(alertText, x, y, parentPanel, onConfirmFunc) + local width = 500 + local height = 120 + + + local screenWidth = getCore():getScreenWidth() + local screenHeight = getCore():getScreenHeight() + + -- Check for oversize + if x+width > screenWidth then + x = screenWidth - width + end + + if y+height > screenHeight then + y = screenHeight - height + end + + local panel = ConfirmationPanel:new(x, y, width, height, alertText, parentPanel, onConfirmFunc) + panel:initialise() + panel:addToUIManager() + panel:bringToTop() + return panel +end + +function ConfirmationPanel.Close() + ConfirmationPanel.instance:close() +end + +return ConfirmationPanel \ No newline at end of file diff --git a/media/lua/client/TOC/UI/Interactions/CutLimbInteractionHandler.lua b/media/lua/client/TOC/UI/Interactions/CutLimbInteractionHandler.lua index f6ccbad..c6fa8d3 100644 --- a/media/lua/client/TOC/UI/Interactions/CutLimbInteractionHandler.lua +++ b/media/lua/client/TOC/UI/Interactions/CutLimbInteractionHandler.lua @@ -1,11 +1,12 @@ local BaseHandler = require("TOC/UI/Interactions/HealthPanelBaseHandler") local StaticData = require("TOC/StaticData") local DataController = require("TOC/Controllers/DataController") +local ConfirmationPanel = require("TOC/UI/ConfirmationPanel") local CutLimbAction = require("TOC/TimedActions/CutLimbAction") --------------------- --- TODO Add interaction to cut and bandage! + --* Various functions to help during these pesky checks @@ -61,6 +62,12 @@ local function GetStitchesConsumableItem(player) end +local textConfirmAmp = getText("IGUI_Confirmation_Amputate") +local textAmp = getText("ContextMenu_Amputate") +local textAmpBandage = getText("ContextMenu_Amputate_Bandage") +local textAmpStitch = getText("ContextMenu_Amputate_Stitch") +local textAmpStitchBandage = getText("ContextMenu_Amputate_Stitch_Bandage") + ---Add the action to the queue ---@param limbName string ---@param surgeon IsoPlayer @@ -69,24 +76,32 @@ end ---@param stitchesItem InventoryItem? ---@param bandageItem InventoryItem? local function PerformAction(surgeon, patient, limbName, sawItem, stitchesItem, bandageItem) - -- get saw in hand - -- todo primary or secondary depending on amputation status of surgeon - ISTimedActionQueue.add(ISEquipWeaponAction:new(surgeon, sawItem, 50, true, false)) - - local lHandItem = surgeon:getSecondaryHandItem() - if lHandItem then - ISTimedActionQueue.add(ISUnequipAction:new(surgeon, lHandItem, 50)) - end - ISTimedActionQueue.add(CutLimbAction:new(surgeon, patient, limbName, sawItem, stitchesItem, bandageItem)) + local x = (getCore():getScreenWidth() - 500) / 2 + local y = getCore():getScreenHeight() / 2 + + + ConfirmationPanel.Open(textConfirmAmp, x, y, nil, function() + + -- get saw in hand + -- todo primary or secondary depending on amputation status of surgeon + ISTimedActionQueue.add(ISEquipWeaponAction:new(surgeon, sawItem, 50, true, false)) + + local lHandItem = surgeon:getSecondaryHandItem() + if lHandItem then + ISTimedActionQueue.add(ISUnequipAction:new(surgeon, lHandItem, 50)) + end + + + ISTimedActionQueue.add(CutLimbAction:new(surgeon, patient, limbName, sawItem, stitchesItem, bandageItem)) + + end) + + end -local textAmp = getText("ContextMenu_Amputate") -local textAmpBandage = getText("ContextMenu_Amputate_Bandage") -local textAmpStitch = getText("ContextMenu_Amputate_Stitch") -local textAmpStitchBandage = getText("ContextMenu_Amputate_Stitch_Bandage") ---Adds the actions to the inventory context menu ---@param player IsoPlayer @@ -214,6 +229,18 @@ function CutLimbInteractionHandler:checkItem(item) end end + +---@param x number +---@param y number +---@param type any +function CutLimbInteractionHandler:openConfirmation(x, y, type) + ConfirmationPanel.Open(textConfirmAmp, x, y, nil, function() + self.onMenuOptionSelected(self, type) + end) +end + + + ---@param context ISContextMenu function CutLimbInteractionHandler:addToMenu(context) --TOC_DEBUG.print("CutLimbInteractionHandler addToMenu") @@ -221,8 +248,12 @@ function CutLimbInteractionHandler:addToMenu(context) local patientUsername = self:getPatient():getUsername() if #types > 0 and StaticData.LIMBS_TO_BODYLOCS_IND_BPT[self.limbName] and not DataController.GetInstance(patientUsername):getIsCut(self.limbName) then TOC_DEBUG.print("addToMenu, types > 0") + + local x = (getCore():getScreenWidth() - 500) / 2 + local y = getCore():getScreenHeight() / 2 + for i=1, #types do - context:addOption(getText("ContextMenu_Amputate"), self, self.onMenuOptionSelected, types[i]) + context:addOption(getText("ContextMenu_Amputate"), self, self.openConfirmation, x, y, types[i]) end end end diff --git a/media/lua/shared/Translate/EN/IG_UI_EN.txt b/media/lua/shared/Translate/EN/IG_UI_EN.txt index a634380..df9b692 100644 --- a/media/lua/shared/Translate/EN/IG_UI_EN.txt +++ b/media/lua/shared/Translate/EN/IG_UI_EN.txt @@ -15,4 +15,6 @@ IG_UI_EN = { IGUI_HealthPanel_WoundDirtyness = "Wound Dirtyness", IGUI_HealthPanel_ProstEquipped = "Prosthesis Equipped", + IGUI_Confirmation_Amputate = " Do you really want to amputate that limb?" + } \ No newline at end of file diff --git a/media/lua/shared/Translate/UA/Sandbox_UA.txt b/media/lua/shared/Translate/UA/Sandbox_UA.txt index ff5d557..f4ec574 100644 --- a/media/lua/shared/Translate/UA/Sandbox_UA.txt +++ b/media/lua/shared/Translate/UA/Sandbox_UA.txt @@ -3,5 +3,8 @@ Sandbox_UA = { Sandbox_TOC_CicatrizationSpeed = "Швидкість рубцювання", Sandbox_TOC_WoundDirtynessMultiplier = "Множник забруднення рани", Sandbox_TOC_SurgeonAbilityImportance = "Важливість медичних навичок лікаря", + Sandbox_TOC_EnableZombieAmputations = "Увімкнути ампутації зомбі", + Sandbox_TOC_ZombieAmputationDamageThreshold = "Поріг шкоди при ампутації зомбі", + Sandbox_TOC_ZombieAmputationDamageChance = "Шанс нанесення шкоди при ампутації зомбі", } \ No newline at end of file diff --git a/media/lua/shared/Translate/UA/UI_UA.txt b/media/lua/shared/Translate/UA/UI_UA.txt new file mode 100644 index 0000000..23087d4 --- /dev/null +++ b/media/lua/shared/Translate/UA/UI_UA.txt @@ -0,0 +1,16 @@ +UI_UA = { + UI_trait_Amputee_Hand = "Ампутована Ліва Рука", + UI_trait_Amputee_Hand_desc = "", + + UI_trait_Amputee_ForeArm = "Ампутоване Ліве Передпліччя", + UI_trait_Amputee_ForeArm_desc = "", + + UI_trait_Amputee_UpperArm = "Ампутоване Ліве Плече", + UI_trait_Amputee_UpperArm_desc = "", + + UI_trait_Insensitive = "Нечутливий", + UI_trait_Insensitive_desc = "", + + + UI_Say_CantEquip = "Я не можу встановити це таким чином..." +} \ No newline at end of file