From d0a269a00641519ac930408d5b12cf6b7543284d Mon Sep 17 00:00:00 2001 From: Pao Date: Thu, 9 Feb 2023 21:32:59 +0100 Subject: [PATCH] fix to audio, gonna rewrite a lot of mp\client stuff --- .../player/turning/Bob_NoLegsTurning.xml | 14 ---- media/lua/client/TOC_ClientCommands.lua | 75 +++++++++++++------ media/lua/client/TOC_Compatibility.lua | 7 +- media/lua/client/TOC_Init.lua | 7 +- media/lua/client/TimedActions/ISCutLimb.lua | 6 ++ media/lua/server/TOC_MP_server.lua | 22 +++++- media/lua/shared/NPCs/ExtraBodyLocations.lua | 18 ++--- 7 files changed, 91 insertions(+), 58 deletions(-) delete mode 100644 media/AnimSets/player/turning/Bob_NoLegsTurning.xml diff --git a/media/AnimSets/player/turning/Bob_NoLegsTurning.xml b/media/AnimSets/player/turning/Bob_NoLegsTurning.xml deleted file mode 100644 index 0569b55..0000000 --- a/media/AnimSets/player/turning/Bob_NoLegsTurning.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - turn_idle_180L_craw; - Zombie_Crawl - - - - - - IsCrawling - BOOL - true - - \ No newline at end of file diff --git a/media/lua/client/TOC_ClientCommands.lua b/media/lua/client/TOC_ClientCommands.lua index 42b5c41..c7d30fa 100644 --- a/media/lua/client/TOC_ClientCommands.lua +++ b/media/lua/client/TOC_ClientCommands.lua @@ -1,21 +1,11 @@ --- Synchronization and MP related stuff +------------------------------------------ +-------- THE ONLY CURE BUT BETTER -------- +------------------------------------------ +------------ CLIENT COMMANDS ------------- + local Commands = {} -Commands["ResponseCanAct"] = function(arg) - - - print("TOC: ResponseCanAct") - local ui = GetConfirmUIMP() - ui.responseReceive = true - ui.responseAction = arg["toSend"][2] - ui.responsePartName = arg["toSend"][1] - ui.responseCan = arg["toSend"][3] - ui.responseUserName = getPlayerByOnlineID(arg["From"]):getUsername() - ui.responseActionIsBitten = getPlayerByOnlineID(arg["From"]):getBodyDamage():getBodyPart(TocGetBodyPartFromPartName(ui - .responsePartName)):bitten() -end - function SendCutLimb(player, part_name, surgeon_factor, bandage_table, painkiller_table) local arg = {} @@ -25,7 +15,7 @@ function SendCutLimb(player, part_name, surgeon_factor, bandage_table, painkille -- TODO Hotfix for sound, fix this later - arg["toSend"] = {part_name, surgeon_factor, bandage_table, painkiller_table, getPlayer():getOnlineID()} + arg["toSend"] = {part_name, surgeon_factor, bandage_table, painkiller_table} @@ -103,13 +93,30 @@ function AskCanUnequipProsthesis(player, part_name) end +-------------------------------------------------------------------------- + +Commands["ResponseCanAct"] = function(arg) + + + print("TOC: ResponseCanAct") + local ui = GetConfirmUIMP() + ui.responseReceive = true + ui.responseAction = arg["toSend"][2] + ui.responsePartName = arg["toSend"][1] + ui.responseCan = arg["toSend"][3] + ui.responseUserName = getPlayerByOnlineID(arg["From"]):getUsername() + ui.responseActionIsBitten = getPlayerByOnlineID(arg["From"]):getBodyDamage():getBodyPart(TocGetBodyPartFromPartName(ui + .responsePartName)):bitten() +end + + -- Patient (receive) Commands["CutLimb"] = function(arg) local arg = arg["toSend"] - local surgeon_id = arg[5] + --local surgeon_id = arg[5] -- Disable the sound coming from the surgeon - getPlayerByOnlineID(surgeon_id):getEmitter():stopSoundByName("Amputation_Sound") + --getPlayerByOnlineID(surgeon_id):getEmitter():stopSoundByName("Amputation_Sound") @@ -121,7 +128,6 @@ Commands["OperateLimb"] = function(arg) TocOperateLimb(arg[1], arg[2], arg[3]) end - Commands["EquipProsthesis"] = function(arg) -- part_name = arg[1] @@ -208,8 +214,6 @@ Commands["AcceptResetEverything"] = function(arg) end - - -- Cut Limb stuff Commands["AcceptDamageOtherPlayer"] = function(arg) @@ -219,8 +223,6 @@ Commands["AcceptDamageOtherPlayer"] = function(arg) TocDamagePlayerDuringAmputation(patient, part_name) end - - -- ANIMATIONS ----------------------- Commands["SetCrawlAnimation"] = function(args) @@ -241,6 +243,31 @@ end +------------------------------- +--- GENERIC COMMANDS --------- + +Commands["StopAmputationSound"] = function(args) + + local player = getPlayerByOnlineID(args.surgeon_id) + print("TOC: Running StopAmputationSound for " .. player:getUsername()) + + player:getEmitter():stopSoundByName("Amputation_Sound") + +end + + + + + + + + + + + + + + -- Base stuff local function OnTocServerCommand(module, command, args) @@ -263,7 +290,7 @@ Events.OnServerCommand.Add(OnTocServerCommand) ----------------------------------- TEST ----------------------------- +---------------------------------- Global Mod Data ----------------------------- function TOC_OnReceiveGlobalModData(key, modData) diff --git a/media/lua/client/TOC_Compatibility.lua b/media/lua/client/TOC_Compatibility.lua index 2cb754a..ab064ca 100644 --- a/media/lua/client/TOC_Compatibility.lua +++ b/media/lua/client/TOC_Compatibility.lua @@ -1,3 +1,8 @@ + + + + + local function TocReapplyAmputationClothingItem(mod_data) local player = getPlayer() local player_inv = player:getInventory() @@ -40,7 +45,7 @@ function TocCheckCompatibilityWithOlderVersions(mod_data) print("TOC: Something was wrongly initiliazed before. Resetting parameters") TocResetEverything() else - print("TOC: Found compatible data, correcting models in case of errors") + print("TOC: Found compatible data, correcting models in case of errors and adding limbs") TocReapplyAmputationClothingItem(mod_data) end diff --git a/media/lua/client/TOC_Init.lua b/media/lua/client/TOC_Init.lua index 6616442..9ca5989 100644 --- a/media/lua/client/TOC_Init.lua +++ b/media/lua/client/TOC_Init.lua @@ -78,11 +78,6 @@ local function TocUpdateBaseData(mod_data) end - - - - - if limb == "Hand" then mod_data.TOC.Limbs[part_name].cicatrization_base_time = 1700 mod_data.TOC.Limbs[part_name].depends_on = {} @@ -256,7 +251,7 @@ function TheOnlyCure.InitTheOnlyCure(_, player) TocSetInitData(mod_data, player) else TocCheckCompatibilityWithOlderVersions(mod_data) - TocUpdateBaseData(mod_data) -- Since it's gonna be common to update stuff + TocUpdateBaseData(mod_data) -- Since it's gonna be common to update stuff TocCheckLegsAmputations(mod_data) end diff --git a/media/lua/client/TimedActions/ISCutLimb.lua b/media/lua/client/TimedActions/ISCutLimb.lua index 16f1064..8ad4203 100644 --- a/media/lua/client/TimedActions/ISCutLimb.lua +++ b/media/lua/client/TimedActions/ISCutLimb.lua @@ -23,7 +23,12 @@ end function ISCutLimb:stop() + print("Stopping ISCutLimb") self.surgeon:getEmitter():stopSoundByName("Amputation_Sound") + sendClientCommand(self.surgeon, "TOC", "AskStopAmputationSound", {surgeon_id = self.surgeon:getOnlineID()}) + + -- TODO test this with more than 2 players + -- TODO this gets bugged when player dies while amputating end @@ -115,6 +120,7 @@ function ISCutLimb:perform() if self.patient ~= self.surgeon and isClient() then SendCutLimb(self.patient, self.part_name, surgeon_factor, bandage_table, painkiller_table) + sendClientCommand(self.surgeon, "TOC", "AskStopAmputationSound", {surgeon_id = self.surgeon:getOnlineID()}) else TocCutLimb(self.part_name, surgeon_factor, bandage_table, painkiller_table) end diff --git a/media/lua/server/TOC_MP_server.lua b/media/lua/server/TOC_MP_server.lua index d699978..d2d3269 100644 --- a/media/lua/server/TOC_MP_server.lua +++ b/media/lua/server/TOC_MP_server.lua @@ -47,6 +47,18 @@ TOC_Commands["AskToResetEverything"] = function(_, arg) end +TOC_Commands.AskStopAmputationSound = function(_, args) + + print("TOC: We're in AskStopAmputationSound") + sendServerCommand("TOC", "StopAmputationSound", {surgeon_id = args.surgeon_id}) + + +end + +TOC_Commands.ChangePlayerState = function(playerObj, args) + ModData.get("TOC_PLAYER_DATA")[playerObj:getUsername()] = args + ModData.transmit("TOC_PLAYER_DATA") +end ------ Global Mod Data ----------- @@ -57,8 +69,14 @@ end Events.OnInitGlobalModData.Add(TOC_OnInitGlobalModData) + +------------------------------------------------------ + + + TOC_Commands.OnClientCommand = function(module, command, playerObj, args) + print("TOC: Running ClientCommand " .. command) if module == 'TOC' and TOC_Commands[command] then TOC_Commands[command](playerObj, args) end @@ -68,7 +86,3 @@ end Events.OnClientCommand.Add(TOC_Commands.OnClientCommand) -TOC_Commands.ChangePlayerState = function(playerObj, args) - ModData.get("TOC_PLAYER_DATA")[playerObj:getUsername()] = args - ModData.transmit("TOC_PLAYER_DATA") -end \ No newline at end of file diff --git a/media/lua/shared/NPCs/ExtraBodyLocations.lua b/media/lua/shared/NPCs/ExtraBodyLocations.lua index b77bb41..78beefb 100644 --- a/media/lua/shared/NPCs/ExtraBodyLocations.lua +++ b/media/lua/shared/NPCs/ExtraBodyLocations.lua @@ -1,4 +1,4 @@ -local function addBodyLocationBefore(new_location, move_to_location) +local function AddBodyLocationBefore(new_location, move_to_location) local group = BodyLocations.getGroup("Human") local list = getClassFieldVal(group, getClassField(group, 1)) group:getOrCreateLocation(new_location) @@ -10,17 +10,17 @@ local function addBodyLocationBefore(new_location, move_to_location) end -addBodyLocationBefore("TOC_ArmRight", "Shoes") -addBodyLocationBefore("TOC_ArmLeft", "Shoes") +AddBodyLocationBefore("TOC_ArmRight", "Shoes") +AddBodyLocationBefore("TOC_ArmLeft", "Shoes") -addBodyLocationBefore("TOC_ArmRightProsthesis", "Shoes") -addBodyLocationBefore("TOC_ArmLeftProsthesis", "Shoes") +AddBodyLocationBefore("TOC_ArmRightProsthesis", "Shoes") +AddBodyLocationBefore("TOC_ArmLeftProsthesis", "Shoes") -addBodyLocationBefore("TOC_LegRight", "FannyPackFront") -addBodyLocationBefore("TOC_LegLeft", "FannyPackFront") +AddBodyLocationBefore("TOC_LegRight", "FannyPackFront") +AddBodyLocationBefore("TOC_LegLeft", "FannyPackFront") -addBodyLocationBefore("TOC_LegRightProsthesis", "FannyPackFront") -addBodyLocationBefore("TOC_LegLeftProsthesis", "FannyPackFront") +AddBodyLocationBefore("TOC_LegRightProsthesis", "FannyPackFront") +AddBodyLocationBefore("TOC_LegLeftProsthesis", "FannyPackFront")