From 8b51a13c715cb763ab4c3c98ccdd8d6eaf776b5d Mon Sep 17 00:00:00 2001 From: Pao Date: Sun, 26 Feb 2023 23:06:10 +0100 Subject: [PATCH] Finished renaming files --- .../ActionsMethods/JCIO_ProsthesisMethods.lua | 2 +- media/lua/client/JCIO_CommonFunctions.lua | 24 +++++++ ...Functions.lua => JCIO_HelperFunctions.lua} | 26 -------- ...tibility.lua => JCIO_ModCompatibility.lua} | 66 +++++++++---------- ...ctions.lua => JCIO_OverridenFunctions.lua} | 2 +- ...Handler.lua => JCIO_ProsthesisHandler.lua} | 0 media/lua/client/JCIO_ServerCommands.lua | 30 +++++---- .../{TOC_Update.lua => JCIO_Update.lua} | 10 ++- .../JCIO_UninstallProsthesisAction.lua | 2 +- media/lua/server/JCIO_ClientCommands.lua | 17 +++-- 10 files changed, 94 insertions(+), 85 deletions(-) rename media/lua/client/{TOC_HelperFunctions.lua => JCIO_HelperFunctions.lua} (79%) rename media/lua/client/{TOC_ModCompatibility.lua => JCIO_ModCompatibility.lua} (78%) rename media/lua/client/{TOC_OverridenFunctions.lua => JCIO_OverridenFunctions.lua} (99%) rename media/lua/client/{TOC_ProsthesisHandler.lua => JCIO_ProsthesisHandler.lua} (100%) rename media/lua/client/{TOC_Update.lua => JCIO_Update.lua} (96%) diff --git a/media/lua/client/ActionsMethods/JCIO_ProsthesisMethods.lua b/media/lua/client/ActionsMethods/JCIO_ProsthesisMethods.lua index b35c64f..26dffe7 100644 --- a/media/lua/client/ActionsMethods/JCIO_ProsthesisMethods.lua +++ b/media/lua/client/ActionsMethods/JCIO_ProsthesisMethods.lua @@ -7,7 +7,7 @@ ---Equip a prosthesis transforming a normal item into a clothing item ---@param partName string ---@param prosthesisItem any the prosthesis item ----@param prosthesisBaseName string +---@param prosthesisBaseName string I don't really remember function JCIO.EquipProsthesis(partName, prosthesisItem, prosthesisBaseName) -- TODO probably will have to move this from the TOC menu to classic equip to have dynamic durability diff --git a/media/lua/client/JCIO_CommonFunctions.lua b/media/lua/client/JCIO_CommonFunctions.lua index e088416..20d6e07 100644 --- a/media/lua/client/JCIO_CommonFunctions.lua +++ b/media/lua/client/JCIO_CommonFunctions.lua @@ -251,3 +251,27 @@ function JCIO_Common.CheckIfProsthesisAlreadyInstalled(limbsData, partName) end end + + +function JCIO_Common.GetCanBeHeldTable(limbs_data) + + local canBeHeld = {} + + for _, side in pairs(JCIO.sideNames) do + canBeHeld[side] = true + + if limbs_data[side .. "_Hand"].isCut then + if limbs_data[side .. "_LowerArm"].isCut then + if not limbs_data[side .. "_LowerArm"].isProsthesisEquipped then + canBeHeld[side] = false + end + elseif not limbs_data[side .. "_Hand"].isProsthesisEquipped then + canBeHeld[side] = false + end + end + end + + return canBeHeld + +end +------------------------------- \ No newline at end of file diff --git a/media/lua/client/TOC_HelperFunctions.lua b/media/lua/client/JCIO_HelperFunctions.lua similarity index 79% rename from media/lua/client/TOC_HelperFunctions.lua rename to media/lua/client/JCIO_HelperFunctions.lua index ec73f54..99d7eac 100644 --- a/media/lua/client/TOC_HelperFunctions.lua +++ b/media/lua/client/JCIO_HelperFunctions.lua @@ -67,29 +67,3 @@ function TocFindAmputationOrProsthesisName(part_name, player, choice) end - - - -------------------------------------- --- Override and mod compat helper -function TocPopulateCanBeHeldTable(can_be_held, limbs_data) - - for _, side in pairs(JCIO.sideNames) do - can_be_held[side] = true - - if limbs_data[side .. "_Hand"].isCut then - if limbs_data[side .. "_LowerArm"].isCut then - if not limbs_data[side .. "_LowerArm"].isProsthesisEquipped then - can_be_held[side] = false - end - elseif not limbs_data[side .. "_Hand"].isProsthesisEquipped then - can_be_held[side] = false - end - end - end - -end - - - - diff --git a/media/lua/client/TOC_ModCompatibility.lua b/media/lua/client/JCIO_ModCompatibility.lua similarity index 78% rename from media/lua/client/TOC_ModCompatibility.lua rename to media/lua/client/JCIO_ModCompatibility.lua index 7f3946d..f13286c 100644 --- a/media/lua/client/TOC_ModCompatibility.lua +++ b/media/lua/client/JCIO_ModCompatibility.lua @@ -1,6 +1,10 @@ ---------------------------------- --- Compatibility for various mods ---------------------------------- +------------------------------------------ +------------- JUST CUT IT OFF ------------ +------------------------------------------ + +------------------------------------------ +-- Compatibility for various mods +------------------------------------------ local function SetCompatibilityFancyHandwork() @@ -12,13 +16,10 @@ local function SetCompatibilityFancyHandwork() local secondary = self.chr:getSecondaryHandItem() local equip = true - local limbs_data = getPlayer():getModData().TOC.Limbs - local can_be_held = {} - - -- TODO not totally realiable - TocPopulateCanBeHeldTable(can_be_held, limbs_data) - + local limbsData = getPlayer():getModData().JCIO.limbs + local canBeHeld = JCIO_Common.GetCanBeHeldTable(limbsData) + -- If we already have the item equipped if (primary and primary == item) or (secondary and secondary == item) then ISTimedActionQueue.add(ISUnequipAction:new(self.chr, item, 20)) @@ -36,25 +37,25 @@ local function SetCompatibilityFancyHandwork() if mod then --print("JCIO: Fancy Handwork modifier") -- If we still have something equipped in secondary, unequip - if secondary and equip and can_be_held["Left"] then + if secondary and equip and canBeHeld["Left"] then ISTimedActionQueue.add(ISUnequipAction:new(self.chr, secondary, 20)) end - if can_be_held["Left"] then + if canBeHeld["Left"] then ISTimedActionQueue.add(ISEquipWeaponAction:new(self.chr, item, 20, false, item:isTwoHandWeapon())) - elseif can_be_held["Right"] then + elseif canBeHeld["Right"] then ISTimedActionQueue.add(ISEquipWeaponAction:new(self.chr, item, 20, true, item:isTwoHandWeapon())) end else -- If we still have something equipped in primary, unequip - if primary and equip and can_be_held["Right"] then + if primary and equip and canBeHeld["Right"] then ISTimedActionQueue.add(ISUnequipAction:new(self.chr, primary, 20)) end -- Equip Primary - if can_be_held["Right"] then + if canBeHeld["Right"] then ISTimedActionQueue.add(ISEquipWeaponAction:new(self.chr, item, 20, true, item:isTwoHandWeapon())) - elseif can_be_held["Left"] then + elseif canBeHeld["Left"] then ISTimedActionQueue.add(ISEquipWeaponAction:new(self.chr, item, 20, false, item:isTwoHandWeapon())) end @@ -69,10 +70,10 @@ local function SetCompatibilityFancyHandwork() function FHSwapHandsAction:isValid() - local limbs_data = getPlayer():getModData().TOC.Limbs - local can_be_held = {} - TocPopulateCanBeHeldTable(can_be_held, limbs_data) - return (can_be_held["Right"] and can_be_held["Left"]) and(((self.character:getPrimaryHandItem() or self.character:getSecondaryHandItem()) ~= nil)) + local limbsData = getPlayer():getModData().JCIO.limbs + local canBeHeld = JCIO_Common.GetCanBeHeldTable(limbsData) + + return (canBeHeld["Right"] and canBeHeld["Left"]) and(((self.character:getPrimaryHandItem() or self.character:getSecondaryHandItem()) ~= nil)) end end @@ -88,12 +89,8 @@ local function SetCompatibilityFancyHandWorkAndSwapIt() local secondary = self.chr:getSecondaryHandItem() local equip = true - local limbs_data = getPlayer():getModData().TOC.Limbs - local can_be_held = {} - - -- TODO not totally realiable - TocPopulateCanBeHeldTable(can_be_held, limbs_data) - + local limbsData = getPlayer():getModData().JCIO.limbs + local canBeHeld = JCIO_Common.GetCanBeHeldTable(limbsData) -- If we already have the item equipped if (primary and primary == item) or (secondary and secondary == item) then @@ -112,25 +109,25 @@ local function SetCompatibilityFancyHandWorkAndSwapIt() if mod then --print("JCIO: Fancy Handwork modifier") -- If we still have something equipped in secondary, unequip - if secondary and equip and can_be_held["Left"] then + if secondary and equip and canBeHeld["Left"] then ISTimedActionQueue.add(ISUnequipAction:new(self.chr, secondary, 20)) end - if can_be_held["Left"] then + if canBeHeld["Left"] then ISTimedActionQueue.add(ISEquipWeaponAction:new(self.chr, item, 20, false, item:isTwoHandWeapon())) - elseif can_be_held["Right"] then + elseif canBeHeld["Right"] then ISTimedActionQueue.add(ISEquipWeaponAction:new(self.chr, item, 20, true, item:isTwoHandWeapon())) end else -- If we still have something equipped in primary, unequip - if primary and equip and can_be_held["Right"] then + if primary and equip and canBeHeld["Right"] then ISTimedActionQueue.add(ISUnequipAction:new(self.chr, primary, 20)) end -- Equip Primary - if can_be_held["Right"] then + if canBeHeld["Right"] then ISTimedActionQueue.add(ISEquipWeaponAction:new(self.chr, item, 20, true, item:isTwoHandWeapon())) - elseif can_be_held["Left"] then + elseif canBeHeld["Left"] then ISTimedActionQueue.add(ISEquipWeaponAction:new(self.chr, item, 20, false, item:isTwoHandWeapon())) end @@ -159,13 +156,12 @@ end -------------------------------------------------------- local function CheckModCompatibility() - local activated_mods = getActivatedMods() + local activatedMods = getActivatedMods() print("JCIO: Checking mods") + if activatedMods:contains("FancyHandwork") then - if activated_mods:contains("FancyHandwork") then - - if activated_mods:contains("SwapIt") then + if activatedMods:contains("SwapIt") then require "SwapIt Main" print("JCIO: Overriding FancyHandwork and SwapIt methods") SetCompatibilityFancyHandWorkAndSwapIt() diff --git a/media/lua/client/TOC_OverridenFunctions.lua b/media/lua/client/JCIO_OverridenFunctions.lua similarity index 99% rename from media/lua/client/TOC_OverridenFunctions.lua rename to media/lua/client/JCIO_OverridenFunctions.lua index 06a4aeb..1daacfa 100644 --- a/media/lua/client/TOC_OverridenFunctions.lua +++ b/media/lua/client/JCIO_OverridenFunctions.lua @@ -125,7 +125,7 @@ function ISEquipWeaponAction:perform() og_ISEquipWeaponActionPerform(self) local limbs_data = self.character:getModData().TOC.Limbs local can_be_held = {} - TocPopulateCanBeHeldTable(can_be_held, limbs_data) + JCIO_Common.GetCanBeHeldTable(can_be_held, limbs_data) if not self.item:isRequiresEquippedBothHands() then if can_be_held["Right"] and not can_be_held["Left"] then diff --git a/media/lua/client/TOC_ProsthesisHandler.lua b/media/lua/client/JCIO_ProsthesisHandler.lua similarity index 100% rename from media/lua/client/TOC_ProsthesisHandler.lua rename to media/lua/client/JCIO_ProsthesisHandler.lua diff --git a/media/lua/client/JCIO_ServerCommands.lua b/media/lua/client/JCIO_ServerCommands.lua index 2867e16..258cdd0 100644 --- a/media/lua/client/JCIO_ServerCommands.lua +++ b/media/lua/client/JCIO_ServerCommands.lua @@ -1,7 +1,7 @@ ------------------------------------------ --------- JUST CUT IT OFF -------- +------------- JUST CUT IT OFF ------------ ------------------------------------------ ------------- CLIENT COMMANDS ------------- +------------- SERVER COMMANDS ------------ local ServerCommands = {} @@ -30,7 +30,6 @@ ServerCommands.CanCutLimb = function(arg) arg["toSend"] = { part_name, "Cut", JCIO_Common.CheckIfCanBeCut(part_name) } sendClientCommand("JCIO", "SendServer", arg) end - ServerCommands.CutLimb = function(arg) local data = arg["toSend"] @@ -44,7 +43,6 @@ ServerCommands.CutLimb = function(arg) end - ServerCommands.CanOperateLimb = function(arg) local part_name = arg["toSend"] @@ -57,7 +55,12 @@ end ServerCommands.OperateLimb = function(arg) local data = arg["toSend"] - JCIO.OperateLimb(data[1], data[2], data[3]) + + local partName = data[1] + local surgeonFactor = data[2] + local useOven = data[3] + + JCIO.OperateLimb(partName, surgeonFactor, useOven) end @@ -79,7 +82,11 @@ ServerCommands.EquipProsthesis = function(arg) -- prosthesis_name = arg[3] local data = arg["toSend"] - JCIO.EquipProsthesis(data[1], data[2], data[3]) + + local partName = data[1] + local prosthesisItem = data[2] + + JCIO.EquipProsthesis(partName, prosthesisItem, _) -- TODO Add the third param end @@ -93,16 +100,17 @@ ServerCommands.CanUnequipProsthesis = function(arg) sendClientCommand("JCIO", "SendServer", arg) end ServerCommands.UnequipProsthesis = function(arg) - - -- part_name = arg[1] - local data = arg["toSend"] - TheOnlyCure.TocUnequipProsthesis(data[1], data[2]) + + local patient = data[1] + local partName = data[2] + local equippedProsthesis = data[3] + + JCIO.UnequipProsthesis(patient, partName, equippedProsthesis) end - ServerCommands.CanResetEverything = function(arg) local part_name = "RightHand" --useless diff --git a/media/lua/client/TOC_Update.lua b/media/lua/client/JCIO_Update.lua similarity index 96% rename from media/lua/client/TOC_Update.lua rename to media/lua/client/JCIO_Update.lua index cd2b619..0442cc7 100644 --- a/media/lua/client/TOC_Update.lua +++ b/media/lua/client/JCIO_Update.lua @@ -1,3 +1,9 @@ +------------------------------------------ +------------- JUST CUT IT OFF ------------ +------------------------------------------ +------------- UPDATE EVENTS -------------- + + require "TOC_Init" local function CheckIfPlayerIsInfected(player, limbsData) @@ -48,7 +54,6 @@ local function ManagePhantomPain(player, limbsData) end end - local function SetHealthStatusForBodyPart(partData, partName, player) @@ -137,7 +142,6 @@ local function SetHealthStatusForBodyPart(partData, partName, player) end end end - local function UpdatePlayerHealth(player, partData) local bodyDamage = player:getBodyDamage() @@ -235,7 +239,7 @@ JCIO.UpdateEveryOneMinute = function() if jcioModData ~= nil then -- FIXME Send little packets instead of the whole thing? -- TODO we shouldn't run this if we're in SP I guess? - sendClientCommand(player, 'TOC', 'ChangePlayerState', { jcioModData.limbs } ) + sendClientCommand(player, 'JCIO', 'ChangePlayerState', { jcioModData.limbs } ) end diff --git a/media/lua/client/TimedActions/JCIO_UninstallProsthesisAction.lua b/media/lua/client/TimedActions/JCIO_UninstallProsthesisAction.lua index c0fff50..0a53d2c 100644 --- a/media/lua/client/TimedActions/JCIO_UninstallProsthesisAction.lua +++ b/media/lua/client/TimedActions/JCIO_UninstallProsthesisAction.lua @@ -54,7 +54,7 @@ function JCIO_UninstallProsthesisAction:perform() SendUnequipProsthesis(self.patient, self.partName, self.item) else - TheOnlyCure.TocUnequipProsthesis(self.patient, self.partName, self.item) + JCIO.OperateLimb(self.patient, self.partName, self.item) end ISBaseTimedAction.perform(self) diff --git a/media/lua/server/JCIO_ClientCommands.lua b/media/lua/server/JCIO_ClientCommands.lua index 04e1123..ce15fad 100644 --- a/media/lua/server/JCIO_ClientCommands.lua +++ b/media/lua/server/JCIO_ClientCommands.lua @@ -1,4 +1,7 @@ - +------------------------------------------ +------------- JUST CUT IT OFF ------------ +------------------------------------------ +------------- CLIENT COMMANDS ------------ local ClientCommands = {} @@ -31,7 +34,7 @@ ClientCommands.AskStopAmputationSound = function(_, args) end -- Animations -ClientCommands.NotifyNewCrawlAnimation = function(player, args) +ClientCommands.NotifyNewCrawlAnimation = function(_, args) sendServerCommand("JCIO", "SetCrawlAnimation", {id = args.id, check = args.check}) @@ -42,8 +45,8 @@ end -- Cheats ClientCommands.AskToResetEverything = function(_, arg) - local clicked_player = getPlayerByOnlineID(arg[1]) - sendServerCommand(clicked_player, "JCIO", "ResetEverything", {}) + local clickedPlayer = getPlayerByOnlineID(arg[1]) + sendServerCommand(clickedPlayer, "JCIO", "ResetEverything", {}) end @@ -56,17 +59,17 @@ end ------ Global Mod Data ----------- -function TOC_OnInitGlobalModData() +local function OnInitGlobalModData() ModData.getOrCreate("JCIO_PLAYER_DATA") end -Events.OnInitGlobalModData.Add(TOC_OnInitGlobalModData) +Events.OnInitGlobalModData.Add(OnInitGlobalModData) ------------------------------------------------------ local function OnClientCommand(module, command, playerObj, args) - if module == 'TOC' and ClientCommands[command] then + if module == 'JCIO' and ClientCommands[command] then ClientCommands[command](playerObj, args) end end