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,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<animNode x_extends="turn_idle_180.xml">
<m_Name>turn_idle_180L_craw;</m_Name>
<m_AnimName>Zombie_Crawl</m_AnimName>
<m_Conditions />
<m_Conditions />
<m_Conditions />
<m_Conditions />
<m_Conditions>
<m_Name>IsCrawling</m_Name>
<m_Type>BOOL</m_Type>
<m_BoolValue>true</m_BoolValue>
</m_Conditions>
</animNode>

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

View File

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

View File

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