From 4fe64cb8e77099595b5cdddcba00f0cdce0062f5 Mon Sep 17 00:00:00 2001 From: thecraftianman <64441307+thecraftianman@users.noreply.github.com> Date: Thu, 2 Nov 2023 16:03:54 -0400 Subject: [PATCH] Use new sound library functions --- lua/acf/entities/guidance/wire_mclos.lua | 3 ++- lua/effects/acf_glatgmexplosion.lua | 6 +++--- lua/entities/acf_computer/init.lua | 5 +++-- lua/entities/acf_missile/init.lua | 5 +++-- lua/entities/acf_rack/init.lua | 15 ++++++++------- lua/entities/acf_radar/init.lua | 7 ++++--- lua/entities/acf_receiver/init.lua | 3 ++- 7 files changed, 25 insertions(+), 19 deletions(-) diff --git a/lua/acf/entities/guidance/wire_mclos.lua b/lua/acf/entities/guidance/wire_mclos.lua index ce95fb63..b4aa4013 100644 --- a/lua/acf/entities/guidance/wire_mclos.lua +++ b/lua/acf/entities/guidance/wire_mclos.lua @@ -1,5 +1,6 @@ local ACF = ACF local Guidances = ACF.Classes.Guidances +local Sounds = ACF.Utilities.Sounds local Guidance = Guidances.Register("Wire (MCLOS)", "Radio (MCLOS)") function Guidance:Configure(Missile) @@ -54,7 +55,7 @@ else self.Rope = nil if IsValid(self.Source) then - self.Source:EmitSound(SnapSound:format(math.random(3)), nil, nil, ACF.Volume) + Sounds.SendSound(self.Source, SnapSound:format(math.random(3)), nil, nil, 1) end end end diff --git a/lua/effects/acf_glatgmexplosion.lua b/lua/effects/acf_glatgmexplosion.lua index 994d2240..0eb364e7 100644 --- a/lua/effects/acf_glatgmexplosion.lua +++ b/lua/effects/acf_glatgmexplosion.lua @@ -1,6 +1,6 @@ local TraceData = { start = true, endpos = true, mask = true } local TraceLine = util.TraceLine - +local Sounds = ACF.Utilities.Sounds function EFFECT:Init(Data) self.DirVec = Data:GetNormal() @@ -31,8 +31,8 @@ function EFFECT:Airburst() local Mult = self.ParticleMul local sndrad = math.Clamp(Radius * 20, 75, 165) local sndradp = 300 - Radius - sound.Play("ambient/explosions/explode_4.wav", self.Origin, sndrad, math.Clamp(sndradp * 25, 15, 170), ACF.Volume) - sound.Play("ambient/explosions/explode_9.wav", self.Origin, sndrad, math.Clamp(sndradp * 22, 15, 120), ACF.Volume) + Sounds.PlaySound(self.Origin, "ambient/explosions/explode_4.wav", sndrad, math.Clamp(sndradp * 25, 15, 170), 1) + Sounds.PlaySound(self.Origin, "ambient/explosions/explode_9.wav", sndrad, math.Clamp(sndradp * 22, 15, 120), 1) local EF = self.Emitter:Add("effects/muzzleflash" .. math.random(1, 4), Origin ) if EF then EF:SetVelocity(self.DirVec * 100) diff --git a/lua/entities/acf_computer/init.lua b/lua/entities/acf_computer/init.lua index b8e892bf..f0eedcf6 100644 --- a/lua/entities/acf_computer/init.lua +++ b/lua/entities/acf_computer/init.lua @@ -8,6 +8,7 @@ local ACF = ACF local Damage = ACF.Damage local Utilities = ACF.Utilities local Clock = Utilities.Clock +local Sounds = Utilities.Sounds ACF.RegisterClassLink("acf_computer", "acf_rack", function(Computer, Target) if Computer.Weapons[Target] then return false, "This rack is already linked to this computer!" end @@ -79,8 +80,8 @@ local function CheckDistantLinks(Entity, Source) if Position:DistToSqr(Link:GetPos()) > MaxDistance then local Sound = UnlinkSound:format(math.random(1, 3)) - Entity:EmitSound(Sound, 70, 100, ACF.Volume) - Link:EmitSound(Sound, 70, 100, ACF.Volume) + Sounds.SendSound(Entity, Sound, 70, 100, 1) + Sounds.SendSound(Link, Sound, 70, 100, 1) Entity:Unlink(Link) end diff --git a/lua/entities/acf_missile/init.lua b/lua/entities/acf_missile/init.lua index 63c58632..87a97481 100644 --- a/lua/entities/acf_missile/init.lua +++ b/lua/entities/acf_missile/init.lua @@ -13,6 +13,7 @@ local ActiveMissiles = ACF.ActiveMissiles local Ballistics = ACF.Ballistics local Classes = ACF.Classes local Clock = ACF.Utilities.Clock +local Sounds = ACF.Utilities.Sounds local Damage = ACF.Damage local Missiles = Classes.Missiles local InputActions = ACF.GetInputActions("acf_missile") @@ -69,7 +70,7 @@ local function LaunchEffect(Missile) if ACF_SOUND_EXT then hook.Run("ACF_SOUND_MISSILE", Missile, Sound) else - Missile:EmitSound(Sound, 180, math.random(99, 101), ACF.Volume) + Sounds.SendSound(Missile, Sound, 180, math.random(99, 101), 1) end end @@ -512,7 +513,7 @@ function ENT:Launch(Delay, IsMisfire) self.Filter[#self.Filter + 1] = Missile end - self:EmitSound("phx/epicmetal_hard.wav", 70, math.random(99, 101), ACF.Volume) + Sounds.SendSound(self, "phx/epicmetal_hard.wav", 70, math.random(99, 101), 1) self:SetNotSolid(false) self:SetNoDraw(false) self:SetParent() diff --git a/lua/entities/acf_rack/init.lua b/lua/entities/acf_rack/init.lua index 63dbe355..425c2d49 100644 --- a/lua/entities/acf_rack/init.lua +++ b/lua/entities/acf_rack/init.lua @@ -11,6 +11,7 @@ local ACF = ACF local Classes = ACF.Classes local Utilities = ACF.Utilities local Clock = Utilities.Clock +local Sounds = Utilities.Sounds local function UpdateTotalAmmo(Entity) local Total = 0 @@ -164,8 +165,8 @@ do -- Spawning and Updating -------------------- if Position:DistToSqr(Link:GetPos()) > MaxDistance then local Sound = UnlinkSound:format(math.random(1, 3)) - Entity:EmitSound(Sound, 70, math.random(99, 109), ACF.Volume) - Link:EmitSound(Sound, 70, math.random(99, 109), ACF.Volume) + Sounds.SendSound(Entity, Sound, 70, math.random(99, 109), 1) + Sounds.SendSound(Link, Sound, 70, math.random(99, 109), 1) Entity:Unlink(Link) end @@ -312,7 +313,7 @@ do -- Custom ACF damage ------------------------ util.Effect("Sparks", Effect, true, true) - Rack:EmitSound(SparkSound:format(math.random(6)), math.random(55, 65), math.random(99, 101), ACF.Volume) + Sounds.SendSound(Rack, SparkSound:format(math.random(6)), math.random(55, 65), math.random(99, 101), 1) timer.Simple(math.Rand(0.5, 2), function() if not IsValid(Rack) then return end @@ -464,7 +465,7 @@ do -- Entity Inputs ---------------------------- Entity:UpdatePoint() if Entity.ForcedIndex then - Entity:EmitSound("buttons/blip2.wav", 70, math.random(99, 101), ACF.Volume) + Sounds.SendSound(Entity, "buttons/blip2.wav", 70, math.random(99, 101), 1) end end) @@ -545,7 +546,7 @@ do -- Firing ----------------------------------- self:UpdatePoint() else - self:EmitSound("weapons/pistol/pistol_empty.wav", 70, math.random(99, 101), ACF.Volume) + Sounds.SendSound(self, "weapons/pistol/pistol_empty.wav", 70, math.random(99, 101), 1) Delay = 1 end @@ -604,7 +605,7 @@ do -- Loading ---------------------------------- local Pos, Ang = GetMissileAngPos(Crate.BulletData, Point) local Missile = MakeACF_Missile(Rack.Owner, Pos, Ang, Rack, Point, Crate) - Rack:EmitSound("acf_missiles/fx/bomb_reload.mp3", 70, math.random(99, 101), ACF.Volume) + Sounds.SendSound(Rack, "acf_missiles/fx/bomb_reload.mp3", 70, math.random(99, 101), 1) return Missile end @@ -650,7 +651,7 @@ do -- Loading ---------------------------------- if not IsValid(Missile) then Missile = nil else - self:EmitSound("acf_missiles/fx/weapon_select.mp3", 70, math.random(99, 101), ACF.Volume) + Sounds.SendSound(self, "acf_missiles/fx/weapon_select.mp3", 70, math.random(99, 101), 1) Point.State = "Loaded" Point.NextFire = nil diff --git a/lua/entities/acf_radar/init.lua b/lua/entities/acf_radar/init.lua index 4be2b3c2..68ed209f 100644 --- a/lua/entities/acf_radar/init.lua +++ b/lua/entities/acf_radar/init.lua @@ -39,6 +39,7 @@ end) local Radars = ACF.ActiveRadars local Damage = ACF.Damage local CheckLegal = ACF.CheckLegal +local Sounds = ACF.Utilities.Sounds local UnlinkSound = "physics/metal/metal_box_impact_bullet%s.wav" local MaxDistance = ACF.LinkDistance * ACF.LinkDistance local TraceData = { start = true, endpos = true, mask = MASK_SOLID_BRUSHONLY } @@ -212,7 +213,7 @@ local function ScanForEntities(Entity) if Count ~= Entity.TargetCount then if Count > Entity.TargetCount then - Entity:EmitSound(Entity.SoundPath, 70, 100, ACF.Volume) + Sounds.SendSound(Entity, Entity.SoundPath, 70, 100, 1) end Entity.TargetCount = Count @@ -271,8 +272,8 @@ local function CheckDistantLinks(Entity, Source) if Position:DistToSqr(Link:GetPos()) > MaxDistance then local Sound = UnlinkSound:format(math.random(1, 3)) - Entity:EmitSound(Sound, 70, 100, ACF.Volume) - Link:EmitSound(Sound, 70, 100, ACF.Volume) + Sounds.SendSound(Entity, Sound, 70, 100, 1) + Sounds.SendSound(Link, Sound, 70, 100, 1) Entity:Unlink(Link) end diff --git a/lua/entities/acf_receiver/init.lua b/lua/entities/acf_receiver/init.lua index 53b89b12..1357be3c 100644 --- a/lua/entities/acf_receiver/init.lua +++ b/lua/entities/acf_receiver/init.lua @@ -12,6 +12,7 @@ local ACF = ACF local Damage = ACF.Damage local CheckLegal = ACF.CheckLegal +local Sounds = ACF.Utilities.Sounds local TimerExists = timer.Exists local TimerCreate = timer.Create local TimerRemove = timer.Remove @@ -60,7 +61,7 @@ local function CheckReceive(Entity) WireLib.TriggerOutput(Entity, "Detected", IsDetected and 1 or 0) if IsDetected then - Entity:EmitSound(Entity.SoundPath, 70, 100, ACF.Volume) + Sounds.SendSound(Entity, Entity.SoundPath, 70, 100, 1) end Entity:UpdateOverlay()