Skip to content

Commit 273055b

Browse files
Merge pull request #93 from thecraftianman/sound-lib
Use new sound library functions
2 parents ac16764 + f123eeb commit 273055b

File tree

7 files changed

+25
-19
lines changed

7 files changed

+25
-19
lines changed

lua/acf/entities/guidance/wire_mclos.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
local ACF = ACF
22
local Guidances = ACF.Classes.Guidances
3+
local Sounds = ACF.Utilities.Sounds
34
local Guidance = Guidances.Register("Wire (MCLOS)", "Radio (MCLOS)")
45

56
function Guidance:Configure(Missile)
@@ -54,7 +55,7 @@ else
5455
self.Rope = nil
5556

5657
if IsValid(self.Source) then
57-
self.Source:EmitSound(SnapSound:format(math.random(3)), nil, nil, ACF.Volume)
58+
Sounds.SendSound(self.Source, SnapSound:format(math.random(3)), nil, nil, 1)
5859
end
5960
end
6061
end

lua/effects/acf_glatgmexplosion.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
local TraceData = { start = true, endpos = true, mask = true }
22
local TraceLine = util.TraceLine
3-
3+
local Sounds = ACF.Utilities.Sounds
44

55
function EFFECT:Init(Data)
66
self.DirVec = Data:GetNormal()
@@ -31,8 +31,8 @@ function EFFECT:Airburst()
3131
local Mult = self.ParticleMul
3232
local sndrad = math.Clamp(Radius * 20, 75, 165)
3333
local sndradp = 300 - Radius
34-
sound.Play("ambient/explosions/explode_4.wav", self.Origin, sndrad, math.Clamp(sndradp * 25, 15, 170), ACF.Volume)
35-
sound.Play("ambient/explosions/explode_9.wav", self.Origin, sndrad, math.Clamp(sndradp * 22, 15, 120), ACF.Volume)
34+
Sounds.PlaySound(self.Origin, "ambient/explosions/explode_4.wav", sndrad, math.Clamp(sndradp * 25, 15, 170), 1)
35+
Sounds.PlaySound(self.Origin, "ambient/explosions/explode_9.wav", sndrad, math.Clamp(sndradp * 22, 15, 120), 1)
3636
local EF = self.Emitter:Add("effects/muzzleflash" .. math.random(1, 4), Origin )
3737
if EF then
3838
EF:SetVelocity(self.DirVec * 100)

lua/entities/acf_computer/init.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ local ACF = ACF
88
local Damage = ACF.Damage
99
local Utilities = ACF.Utilities
1010
local Clock = Utilities.Clock
11+
local Sounds = Utilities.Sounds
1112

1213
ACF.RegisterClassLink("acf_computer", "acf_rack", function(Computer, Target)
1314
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)
7980
if Position:DistToSqr(Link:GetPos()) > MaxDistance then
8081
local Sound = UnlinkSound:format(math.random(1, 3))
8182

82-
Entity:EmitSound(Sound, 70, 100, ACF.Volume)
83-
Link:EmitSound(Sound, 70, 100, ACF.Volume)
83+
Sounds.SendSound(Entity, Sound, 70, 100, 1)
84+
Sounds.SendSound(Link, Sound, 70, 100, 1)
8485

8586
Entity:Unlink(Link)
8687
end

lua/entities/acf_missile/init.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ local ActiveMissiles = ACF.ActiveMissiles
1313
local Ballistics = ACF.Ballistics
1414
local Classes = ACF.Classes
1515
local Clock = ACF.Utilities.Clock
16+
local Sounds = ACF.Utilities.Sounds
1617
local Damage = ACF.Damage
1718
local Missiles = Classes.Missiles
1819
local InputActions = ACF.GetInputActions("acf_missile")
@@ -69,7 +70,7 @@ local function LaunchEffect(Missile)
6970
if ACF_SOUND_EXT then
7071
hook.Run("ACF_SOUND_MISSILE", Missile, Sound)
7172
else
72-
Missile:EmitSound(Sound, 180, math.random(99, 101), ACF.Volume)
73+
Sounds.SendSound(Missile, Sound, 180, math.random(99, 101), 1)
7374
end
7475
end
7576

@@ -512,7 +513,7 @@ function ENT:Launch(Delay, IsMisfire)
512513
self.Filter[#self.Filter + 1] = Missile
513514
end
514515

515-
self:EmitSound("phx/epicmetal_hard.wav", 70, math.random(99, 101), ACF.Volume)
516+
Sounds.SendSound(self, "phx/epicmetal_hard.wav", 70, math.random(99, 101), 1)
516517
self:SetNotSolid(false)
517518
self:SetNoDraw(false)
518519
self:SetParent()

lua/entities/acf_rack/init.lua

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ local ACF = ACF
1111
local Classes = ACF.Classes
1212
local Utilities = ACF.Utilities
1313
local Clock = Utilities.Clock
14+
local Sounds = Utilities.Sounds
1415

1516
local function UpdateTotalAmmo(Entity)
1617
local Total = 0
@@ -164,8 +165,8 @@ do -- Spawning and Updating --------------------
164165
if Position:DistToSqr(Link:GetPos()) > MaxDistance then
165166
local Sound = UnlinkSound:format(math.random(1, 3))
166167

167-
Entity:EmitSound(Sound, 70, math.random(99, 109), ACF.Volume)
168-
Link:EmitSound(Sound, 70, math.random(99, 109), ACF.Volume)
168+
Sounds.SendSound(Entity, Sound, 70, math.random(99, 109), 1)
169+
Sounds.SendSound(Link, Sound, 70, math.random(99, 109), 1)
169170

170171
Entity:Unlink(Link)
171172
end
@@ -312,7 +313,7 @@ do -- Custom ACF damage ------------------------
312313

313314
util.Effect("Sparks", Effect, true, true)
314315

315-
Rack:EmitSound(SparkSound:format(math.random(6)), math.random(55, 65), math.random(99, 101), ACF.Volume)
316+
Sounds.SendSound(Rack, SparkSound:format(math.random(6)), math.random(55, 65), math.random(99, 101), 1)
316317

317318
timer.Simple(math.Rand(0.5, 2), function()
318319
if not IsValid(Rack) then return end
@@ -464,7 +465,7 @@ do -- Entity Inputs ----------------------------
464465
Entity:UpdatePoint()
465466

466467
if Entity.ForcedIndex then
467-
Entity:EmitSound("buttons/blip2.wav", 70, math.random(99, 101), ACF.Volume)
468+
Sounds.SendSound(Entity, "buttons/blip2.wav", 70, math.random(99, 101), 1)
468469
end
469470
end)
470471

@@ -545,7 +546,7 @@ do -- Firing -----------------------------------
545546

546547
self:UpdatePoint()
547548
else
548-
self:EmitSound("weapons/pistol/pistol_empty.wav", 70, math.random(99, 101), ACF.Volume)
549+
Sounds.SendSound(self, "weapons/pistol/pistol_empty.wav", 70, math.random(99, 101), 1)
549550

550551
Delay = 1
551552
end
@@ -604,7 +605,7 @@ do -- Loading ----------------------------------
604605
local Pos, Ang = GetMissileAngPos(Crate.BulletData, Point)
605606
local Missile = MakeACF_Missile(Rack.Owner, Pos, Ang, Rack, Point, Crate)
606607

607-
Rack:EmitSound("acf_missiles/fx/bomb_reload.mp3", 70, math.random(99, 101), ACF.Volume)
608+
Sounds.SendSound(Rack, "acf_missiles/fx/bomb_reload.mp3", 70, math.random(99, 101), 1)
608609

609610
return Missile
610611
end
@@ -650,7 +651,7 @@ do -- Loading ----------------------------------
650651
if not IsValid(Missile) then
651652
Missile = nil
652653
else
653-
self:EmitSound("acf_missiles/fx/weapon_select.mp3", 70, math.random(99, 101), ACF.Volume)
654+
Sounds.SendSound(self, "acf_missiles/fx/weapon_select.mp3", 70, math.random(99, 101), 1)
654655

655656
Point.State = "Loaded"
656657
Point.NextFire = nil

lua/entities/acf_radar/init.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ end)
3939
local Radars = ACF.ActiveRadars
4040
local Damage = ACF.Damage
4141
local CheckLegal = ACF.CheckLegal
42+
local Sounds = ACF.Utilities.Sounds
4243
local UnlinkSound = "physics/metal/metal_box_impact_bullet%s.wav"
4344
local MaxDistance = ACF.LinkDistance * ACF.LinkDistance
4445
local TraceData = { start = true, endpos = true, mask = MASK_SOLID_BRUSHONLY }
@@ -212,7 +213,7 @@ local function ScanForEntities(Entity)
212213

213214
if Count ~= Entity.TargetCount then
214215
if Count > Entity.TargetCount then
215-
Entity:EmitSound(Entity.SoundPath, 70, 100, ACF.Volume)
216+
Sounds.SendSound(Entity, Entity.SoundPath, 70, 100, 1)
216217
end
217218

218219
Entity.TargetCount = Count
@@ -271,8 +272,8 @@ local function CheckDistantLinks(Entity, Source)
271272
if Position:DistToSqr(Link:GetPos()) > MaxDistance then
272273
local Sound = UnlinkSound:format(math.random(1, 3))
273274

274-
Entity:EmitSound(Sound, 70, 100, ACF.Volume)
275-
Link:EmitSound(Sound, 70, 100, ACF.Volume)
275+
Sounds.SendSound(Entity, Sound, 70, 100, 1)
276+
Sounds.SendSound(Link, Sound, 70, 100, 1)
276277

277278
Entity:Unlink(Link)
278279
end

lua/entities/acf_receiver/init.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ local ACF = ACF
1212

1313
local Damage = ACF.Damage
1414
local CheckLegal = ACF.CheckLegal
15+
local Sounds = ACF.Utilities.Sounds
1516
local TimerExists = timer.Exists
1617
local TimerCreate = timer.Create
1718
local TimerRemove = timer.Remove
@@ -60,7 +61,7 @@ local function CheckReceive(Entity)
6061
WireLib.TriggerOutput(Entity, "Detected", IsDetected and 1 or 0)
6162

6263
if IsDetected then
63-
Entity:EmitSound(Entity.SoundPath, 70, 100, ACF.Volume)
64+
Sounds.SendSound(Entity, Entity.SoundPath, 70, 100, 1)
6465
end
6566

6667
Entity:UpdateOverlay()

0 commit comments

Comments
 (0)