fix to audio, gonna rewrite a lot of mp\client stuff

This commit is contained in:
Pao
2023-02-09 21:32:59 +01:00
parent e4dc172094
commit d0a269a006
7 changed files with 91 additions and 58 deletions

View File

@@ -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)

View File

@@ -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

View File

@@ -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

View File

@@ -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