Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use new sound library functions #93

Merged
merged 6 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lua/acf/entities/guidance/wire_mclos.lua
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions lua/effects/acf_glatgmexplosion.lua
Original file line number Diff line number Diff line change
@@ -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()
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions lua/entities/acf_computer/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions lua/entities/acf_missile/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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()
Expand Down
15 changes: 8 additions & 7 deletions lua/entities/acf_rack/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions lua/entities/acf_radar/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion lua/entities/acf_receiver/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down