From 7d379aeea63c900bba29b339c4ec70aa1113c711 Mon Sep 17 00:00:00 2001 From: Pao Date: Thu, 12 Jan 2023 22:40:41 +0100 Subject: [PATCH] Moved some functions that didn't belong --- media/lua/client/TOC_Client.lua | 47 ------ media/lua/client/TOC_GlobalFunctions.lua | 185 ----------------------- media/lua/client/TOC_UI.lua | 9 -- media/lua/server/TOC_MP_server.lua | 74 +++++---- 4 files changed, 48 insertions(+), 267 deletions(-) diff --git a/media/lua/client/TOC_Client.lua b/media/lua/client/TOC_Client.lua index 84ddfff..04aaab9 100644 --- a/media/lua/client/TOC_Client.lua +++ b/media/lua/client/TOC_Client.lua @@ -2,44 +2,6 @@ local Commands = {} -function SendCutLimb(player, part_name, surgeon_factor, bandage_table, painkiller_table) - local arg = {} - arg["From"] = getPlayer():getOnlineID() - arg["To"] = player:getOnlineID() - arg["command"] = "CutLimb" - arg["toSend"] = {part_name, surgeon_factor, bandage_table, painkiller_table} - sendClientCommand("TOC", "SendServer", arg) -end - -function SendOperateLimb(player, part_name, surgeon_factor, use_oven) - local arg = {} - arg["From"] = getPlayer():getOnlineID() - arg["To"] = player:getOnlineID() - arg["command"] = "OperateLimb" - arg["toSend"] = {part_name, surgeon_factor, use_oven} - sendClientCommand("TOC", "SendServer", arg) -end - -function AskCanCutLimb(player, part_name) - GetConfirmUIMP().responseReceive = false; - local arg = {}; - arg["From"] = getPlayer():getOnlineID(); - arg["To"] = player:getOnlineID(); - arg["command"] = "CanCutLimb"; - arg["toSend"] = part_name; - sendClientCommand("TOC", "SendServer", arg); -end - -function AskCanOperateLimb(player, part_name) - GetConfirmUIMP().responseReceive = false; - local arg = {}; - arg["From"] = getPlayer():getOnlineID(); - arg["To"] = player:getOnlineID(); - arg["command"] = "CanOperateArm"; - arg["toSend"] = part_name; - sendClientCommand("TOC", "SendServer", arg); -end - Commands["ResponseCanAct"] = function(arg) local ui = GetConfirmUIMP() ui.responseReceive = true @@ -71,8 +33,6 @@ Commands["CanCutLimb"] = function(arg) sendClientCommand("TOC", "SendServer", arg) end - - Commands["CanOperateLimb"] = function(arg) local part_name = arg["toSend"] @@ -84,15 +44,8 @@ Commands["CanOperateLimb"] = function(arg) end - - local function OnTocServerCommand(module, command, args) --- TODO Change name of the func - - if module == 'TOC' then - print(command) - if command == 'GivePlayerData' then --local surgeon = getPlayerByOnlineID(args[1]) diff --git a/media/lua/client/TOC_GlobalFunctions.lua b/media/lua/client/TOC_GlobalFunctions.lua index 5b215ea..133bbb6 100644 --- a/media/lua/client/TOC_GlobalFunctions.lua +++ b/media/lua/client/TOC_GlobalFunctions.lua @@ -1,188 +1,3 @@ --- TODO OLD TO DELETE -local function CheckIfStillInfected(toc_data) - for k,v in pairs(GetBodyParts()) do - if toc_data[v].is_infected == true then - getPlayer().Say("I'm still infected...") - return true - end - - end - - return false - -end - --- TODO OLD TO DELETE -local function CureInfection(bodyDamage) - bodyDamage:setInfected(false); - bodyDamage:setInfectionMortalityDuration(-1); - bodyDamage:setInfectionTime(-1); - bodyDamage:setInfectionLevel(0); - local bodyParts = bodyDamage:getBodyParts(); - for i=bodyParts:size()-1, 0, -1 do - local bodyPart = bodyParts:get(i); - bodyPart:SetInfected(false); - end -end - --- -- TODO change it to CutLimb or CutBodyPart --- function CutArm(partName, surgeonFact, useBandage, bandageAlcool, usePainkiller, painkillerCount) - - - --- local player = getPlayer(); --- local toc_data = player:getModData().TOC; --- local bodyPart = player:getBodyDamage():getBodyPart(TOC_getBodyPart(partName)); -- why the fuck do we we need this - --- --Set damage of body part & stress & endurance --- local stats = player:getStats(); --- bodyPart:AddDamage(100 - surgeonFact); --- bodyPart:setAdditionalPain(100 - surgeonFact); --- bodyPart:setBleeding(true); --- bodyPart:setBleedingTime(100 - surgeonFact); --- bodyPart:setDeepWounded(true) --- bodyPart:setDeepWoundTime(100 - surgeonFact); --- stats:setEndurance(0 + surgeonFact); --- stats:setStress(100 - surgeonFact); - --- -- Bandage --- --if useBandage and bandageAlcool then --- -- bodyPart:setBandaged(true, 10, true, bandage:getType()); --- --elseif useBandage and not bandageAlcool then --- -- bodyPart:setBandaged(true, 10, false, bandage:getType()); --- --end - --- -- Painkiller --- --if usePainkiller then --- -- for _ = 1,painkillerCount+1 do --- -- player:getBodyDamage():JustTookPill(painkiller); --- -- end --- -- if painkillerCount < 10 then addSound(player, player:getX(), player:getY(), player:getZ(), 50-painkillerCount*5, 50-painkillerCount*5) end --- --else --- -- addSound(player, player:getX(), player:getY(), player:getZ(), 50, 50) --- --end - --- -- Change modData - --- local current_bodypart = bodyPart:getType() --- local body_damage = player:getBodyDamage() - --- for k,v in pairs(GetBodyParts()) do - --- if v == partName then --- toc_data[v].is_cut = true --- toc_data[v].is_amputation_shown = true --- toc_data[v].cicatrization_time = toc_data[v].cicatrization_base_time - surgeonFact * 50 - - --- -- Heal the infection here --- if toc_data[v].is_infected and body_damage.getInfectionLevel() < 20 then --- toc_data[v].is_infected = false --- current_bodypart:SetBitten(false) - --- -- Second check, let's see if there is any other infected limb. --- if CheckIfStillInfected(toc_data) == false then --- CureInfection(body_damage) --- end - --- end - --- for depended_k, depended_v in pairs(toc_data[v].depends_on) do --- toc_data[depended_v].is_cut = true --- toc_data[depended_v].is_amputation_shown = true --- toc_data[depended_v].cicatrization_time = toc_data[v].cicatrization_base_time - surgeonFact * 50 --- end --- end --- end - - - --- --Equip cloth --- local cloth = player:getInventory():AddItem(find_clothName2_TOC(partName)); --- player:setWornItem(cloth:getBodyLocation(), cloth); --- player:transmitModData(); --- end - -function OperateArm(partName, surgeonFact, useOven) - local player = getPlayer(); - local toc_data = player:getModData().TOC; - - if useOven then - local stats = player:getStats(); - stats:setEndurance(0); - stats:setStress(100); - end - - if toc_data[partName].is_operated == false then - toc_data[partName].is_operated = true - toc_data[partName].cicatrization_time = toc_data[partName].cicatrization_time - (surgeonFact * 200) - if useOven then toc_data[partName].is_cauterized = true end - for depended_k, depended_v in pairs(toc_data[partName].depends_on) do - toc_data[depended_v].is_operated = true - toc_data[depended_v].cicatrization_time = toc_data[depended_v].cicatrization_time - (surgeonFact * 200) - if useOven then toc_data[depended_v].is_cauterized = true end - - end - - end - - SetBodyPartsStatus(player, partName, useOven) - player:transmitModData(); -end - -function SetBodyPartsStatus(player, partName, useOven) - -- TODO use GetBodyParts with depends_on - - local a_rightArm = {"RightArm", "RightForearm", "RightHand"} - local a_rightForearm = {"RightForearm", "RightHand"} - local a_rightHand = {"RightHand"} - - local a_leftArm = {"LeftArm", "LeftForearm", "LeftHand"} - local a_leftForearm = {"LeftForearm", "LeftHand"} - local a_leftHand = {"LeftHand"} - - local chosen_array = {} - if partName == "RightArm" then - chosen_array = a_rightArm - - elseif partName == "RightForearm" then - chosen_array = a_rightForearm - - elseif partName == "RightHand" then - chosen_array = a_rightHand - - elseif partName == "LeftArm" then - chosen_array = a_leftArm - - elseif partName == "LeftForearm" then - chosen_array = a_leftForearm - - elseif partName == "LeftHand" then - chosen_array = a_leftHand - end - - - - - - for k,v in pairs(chosen_array) do - local tmpBodyPart = player:getBodyDamage():getBodyPart(TheOnlyCure.GetBodyPartTypeFromBodyPart(v)) - - tmpBodyPart:setDeepWounded(false); -- Basically like stictching - tmpBodyPart:setDeepWoundTime(0); - if useOven then - tmpBodyPart:AddDamage(100) - tmpBodyPart:setAdditionalPain(100); - tmpBodyPart:setBleeding(false) - tmpBodyPart:setBleedingTime(0) -- no bleeding since it's been cauterized - else - tmpBodyPart:setBleeding(true); - tmpBodyPart:setBleedingTime(ZombRand(1, 5)); -- Reset the bleeding, maybe make it random - end - - end - -end function GetKitInInventory(surgeon) diff --git a/media/lua/client/TOC_UI.lua b/media/lua/client/TOC_UI.lua index 1f5b1da..e575c1c 100644 --- a/media/lua/client/TOC_UI.lua +++ b/media/lua/client/TOC_UI.lua @@ -434,23 +434,14 @@ end -- Make the UIS - local function SetCorrectArgsMainUI(toc_data) - - -- TODO Make it less shitty mainUI["b11"]:addArg("toc_data", toc_data) - mainUI["b12"]:addArg("toc_data", toc_data) - mainUI["b21"]:addArg("toc_data", toc_data) - mainUI["b22"]:addArg("toc_data", toc_data) - mainUI["b31"]:addArg("toc_data", toc_data) - mainUI["b32"]:addArg("toc_data", toc_data) - end diff --git a/media/lua/server/TOC_MP_server.lua b/media/lua/server/TOC_MP_server.lua index 84d26ef..b139546 100644 --- a/media/lua/server/TOC_MP_server.lua +++ b/media/lua/server/TOC_MP_server.lua @@ -1,52 +1,74 @@ --- A rly big thx to Fenris_Wolf and Chuck to help me with that. Love you guy if isClient() then return end - - - - ---Server side local Commands = {} - --- TODO what is this? Commands["SendServer"] = function(player, arg) local otherPlayer = getPlayerByOnlineID(arg["To"]) print("The Only Cure Command: ", arg['command']) sendServerCommand(otherPlayer, "TOC", arg["command"], arg) end -local function OnTocClientCommand(module, command, player, args) +function SendCutLimb(player, part_name, surgeon_factor, bandage_table, painkiller_table) + local arg = {} + arg["From"] = getPlayer():getOnlineID() + arg["To"] = player:getOnlineID() + arg["command"] = "CutLimb" + arg["toSend"] = {part_name, surgeon_factor, bandage_table, painkiller_table} + sendClientCommand("TOC", "SendServer", arg) +end +function SendOperateLimb(player, part_name, surgeon_factor, use_oven) + local arg = {} + arg["From"] = getPlayer():getOnlineID() + arg["To"] = player:getOnlineID() + arg["command"] = "OperateLimb" + arg["toSend"] = {part_name, surgeon_factor, use_oven} + sendClientCommand("TOC", "SendServer", arg) +end + +function AskCanCutLimb(player, part_name) + GetConfirmUIMP().responseReceive = false; + local arg = {}; + arg["From"] = getPlayer():getOnlineID(); + arg["To"] = player:getOnlineID(); + arg["command"] = "CanCutLimb"; + arg["toSend"] = part_name; + sendClientCommand("TOC", "SendServer", arg); +end + +function AskCanOperateLimb(player, part_name) + GetConfirmUIMP().responseReceive = false; + local arg = {}; + arg["From"] = getPlayer():getOnlineID(); + arg["To"] = player:getOnlineID(); + arg["command"] = "CanOperateArm"; + arg["toSend"] = part_name; + sendClientCommand("TOC", "SendServer", arg); +end + +local function OnTocClientCommand(module, command, player, args) if module == 'TOC' then - print(command) if command == 'GetPlayerData' then - local surgeon_id = args[1] local patient_id = args[2] - - - - local playerOne = getPlayerByOnlineID(args[1]) - local playerTwo = getPlayerByOnlineID(args[2]) - local playerOneID = args[1] - sendServerCommand(playerTwo, "TOC", "GivePlayerData", {surgeon_id, patient_id}) + --local playerOne = getPlayerByOnlineID(args[1]) + local patient = getPlayerByOnlineID(args[2]) + --local playerOneID = args[1] + sendServerCommand(patient, "TOC", "GivePlayerData", {surgeon_id, patient_id}) elseif command == 'SendPlayerData' then - local playerOne = getPlayerByOnlineID(args[1]) - local playerOneID = args[1] + local surgeon = getPlayerByOnlineID(args[1]) + local surgeon_id = args[1] local toc_data = args[2] - sendServerCommand(playerOne, "TOC", "SendTocData", {playerOneID, toc_data}) + sendServerCommand(surgeon, "TOC", "SendTocData", {surgeon_id, toc_data}) + elseif command == Commands[command] then + args = args or {} + Commands[command](_, args) end end end -local onClientCommand = function(module, command, player, args) - if module == 'TOC' and Commands[command] then - args = args or {} - Commands[command](_, args) - end -end Events.OnClientCommand.Add(OnTocClientCommand) ---Client 1 -> Server -> Client 1 \ No newline at end of file