Skip to content

Commit

Permalink
Merge pull request #144 from thegrb93/volume-scale
Browse files Browse the repository at this point in the history
Lower decible of some sounds and add volume scale option
  • Loading branch information
TwistedTail committed Nov 24, 2020
2 parents 3d87d70 + 80a9170 commit 2515552
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 26 deletions.
1 change: 1 addition & 0 deletions lua/acf/base/acf_globals.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ do -- ACF global vars
ACF.GunfireEnabled = true
ACF.SmokeWind = 5 + math.random() * 35 --affects the ability of smoke to be used for screening effect
ACF.EnableKillicons = true -- Enable killicons overwriting.
ACF.SoundVolume = 1 --Scales sound volume
-- Fuzes
ACF.MinFuzeCaliber = 2 -- Minimum caliber that can be fuzed (centimeters)
-- Reload Mechanics
Expand Down
4 changes: 2 additions & 2 deletions lua/effects/acf_explosion.lua
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ function EFFECT:Core(Direction)
end
end

sound.Play("ambient/explosions/explode_5.wav", self.Origin, math.Clamp(Radius * 10, 75, 165), math.Clamp(300 - Radius * 12, 15, 255))
sound.Play("ambient/explosions/explode_4.wav", self.Origin, math.Clamp(Radius * 10, 75, 165), math.Clamp(300 - Radius * 25, 15, 255))
sound.Play("ambient/explosions/explode_5.wav", self.Origin, math.Clamp(Radius * 10, 75, 165), math.Clamp(300 - Radius * 12, 15, 255), ACF.SoundVolume)
sound.Play("ambient/explosions/explode_4.wav", self.Origin, math.Clamp(Radius * 10, 75, 165), math.Clamp(300 - Radius * 25, 15, 255), ACF.SoundVolume)
end

function EFFECT:GroundImpact()
Expand Down
6 changes: 3 additions & 3 deletions lua/effects/acf_muzzle_flash.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ function EFFECT:Init(Data)
if Sound ~= "" then
local SoundPressure = (Propellant * 1000) ^ 0.5

sound.Play(Sound, GunPos, math.Clamp(SoundPressure, 75, 127), 100) --wiki documents level tops out at 180, but seems to fall off past 127
sound.Play(Sound, GunPos, math.Clamp(SoundPressure, 75, 127), 100, ACF.SoundVolume) --wiki documents level tops out at 180, but seems to fall off past 127

if not (Class == "MG" or Class == "RAC") then
sound.Play(Sound, GunPos, math.Clamp(SoundPressure, 75, 127), 100)
sound.Play(Sound, GunPos, math.Clamp(SoundPressure, 75, 127), 100, ACF.SoundVolume)

if SoundPressure > 127 then
sound.Play(Sound, GunPos, math.Clamp(SoundPressure - 127, 1, 127), 100)
sound.Play(Sound, GunPos, math.Clamp(SoundPressure - 127, 1, 127), 100, ACF.SoundVolume)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lua/effects/acf_penetration.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function EFFECT:Init(Data)
util.DecalEx(GetDecal(Type), Trace.Entity, Trace.HitPos, self.Normal, Color(255, 255, 255), Scale, Scale)
end

sound.Play("acf_base/fx/penetration" .. math.random(1, 6) .. ".mp3", Trace.HitPos, math.Clamp(self.Mass * 200, 65, 500), math.Clamp(self.Velocity * 0.01, 25, 255), 1)
sound.Play("acf_base/fx/penetration" .. math.random(1, 6) .. ".mp3", Trace.HitPos, math.Clamp(self.Mass * 200, 65, 500), math.Clamp(self.Velocity * 0.01, 25, 255), ACF.SoundVolume)
end

function EFFECT:Metal()
Expand Down
2 changes: 1 addition & 1 deletion lua/effects/acf_ricochet.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function EFFECT:Init(Data)
util.DecalEx(GetDecal(DecalType), Trace.Entity, Trace.HitPos, Trace.HitNormal, Color(255, 255, 255), Scale, Scale)
end

sound.Play("acf_base/fx/penetration" .. math.random(1, 4) .. ".mp3", Origin, math.Clamp(Mass * 200, 65, 500), math.Clamp(Velocity * 0.01, 25, 255), 1)
sound.Play("acf_base/fx/penetration" .. math.random(1, 4) .. ".mp3", Origin, math.Clamp(Mass * 200, 65, 500), math.Clamp(Velocity * 0.01, 25, 255), ACF.SoundVolume)
end

function EFFECT:Think()
Expand Down
6 changes: 3 additions & 3 deletions lua/entities/acf_ammo/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ local function RefillCrates(Refill)
Crate:Consume(-Transfer)
Refill:Consume(Transfer)

Crate:EmitSound("items/ammo_pickup.wav", 350, 100, 0.5)
Refill:EmitSound("items/ammo_pickup.wav", 350, 100, 0.5)
Crate:EmitSound("items/ammo_pickup.wav", 70, 100, 0.5 * ACF.SoundVolume)
Refill:EmitSound("items/ammo_pickup.wav", 70, 100, 0.5 * ACF.SoundVolume)

elseif Refill.SupplyingTo[Crate] then
Refill.SupplyingTo[Crate] = nil
Expand Down Expand Up @@ -755,7 +755,7 @@ do -- Metamethods -------------------------------
if VolumeRoll and AmmoRoll then
local Speed = ACF_MuzzleVelocity(Entity.BulletData.PropMass, Entity.BulletData.ProjMass / 2, Entity.Caliber)

Entity:EmitSound("ambient/explosions/explode_4.wav", 350, math.max(255 - Entity.BulletData.PropMass * 100,60))
Entity:EmitSound("ambient/explosions/explode_4.wav", 140, math.max(255 - Entity.BulletData.PropMass * 100,60), ACF.SoundVolume)

Entity.BulletData.Pos = Entity:LocalToWorld(Entity:OBBCenter() + VectorRand() * (Entity:OBBMaxs() - Entity:OBBMins()) / 2)
Entity.BulletData.Flight = VectorRand():GetNormalized() * Speed * 39.37 + ACF_GetAncestor(Entity):GetVelocity()
Expand Down
4 changes: 2 additions & 2 deletions lua/entities/acf_engine/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ end
local function GetPitchVolume(Engine)
local RPM = Engine.FlyRPM
local Pitch = math.Clamp(20 + (RPM * Engine.SoundPitch) * 0.02, 1, 255)
local Volume = 0.25 + (0.1 + 0.9 * ((RPM / Engine.LimitRPM) ^ 1.5)) * Engine.Throttle * 0.666
local Volume = 0.25 + (0.1 + 0.9 * ((RPM / Engine.LimitRPM) ^ 1.5)) * Engine.Throttle * 0.666 * ACF.SoundVolume

return Pitch, Volume
end
Expand All @@ -202,7 +202,7 @@ local function CheckDistantFuelTanks(Engine)

for Tank in pairs(Engine.FuelTanks) do
if EnginePos:DistToSqr(Tank:GetPos()) > 262144 then
Engine:EmitSound(UnlinkSound:format(math.random(1, 3)), 500, 100)
Engine:EmitSound(UnlinkSound:format(math.random(1, 3)), 70, 100, ACF.SoundVolume)

Engine:Unlink(Tank)
end
Expand Down
8 changes: 4 additions & 4 deletions lua/entities/acf_fueltank/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -427,11 +427,11 @@ function ENT:Think()
Tank:Consume(-Exchange)

if self.FuelType == "Electric" then
self:EmitSound("ambient/energy/newspark04.wav", 75, 100, 0.5)
Tank:EmitSound("ambient/energy/newspark04.wav", 75, 100, 0.5)
self:EmitSound("ambient/energy/newspark04.wav", 70, 100, 0.5 * ACF.SoundVolume)
Tank:EmitSound("ambient/energy/newspark04.wav", 70, 100, 0.5 * ACF.SoundVolume)
else
self:EmitSound("vehicles/jetski/jetski_no_gas_start.wav", 75, 120, 0.5)
Tank:EmitSound("vehicles/jetski/jetski_no_gas_start.wav", 75, 120, 0.5)
self:EmitSound("vehicles/jetski/jetski_no_gas_start.wav", 70, 120, 0.5 * ACF.SoundVolume)
Tank:EmitSound("vehicles/jetski/jetski_no_gas_start.wav", 70, 120, 0.5 * ACF.SoundVolume)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lua/entities/acf_gearbox/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ local function ChangeGear(Entity, Value)
Entity.ChangeFinished = ACF.CurTime + Entity.SwitchTime
Entity.InGear = false

Entity:EmitSound("buttons/lever7.wav", 250, 100)
Entity:EmitSound("buttons/lever7.wav", 70, 100, ACF.SoundVolume)
Entity:UpdateOverlay()

WireLib.TriggerOutput(Entity, "Current Gear", Value)
Expand Down
8 changes: 4 additions & 4 deletions lua/entities/acf_gun/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ do -- Metamethods --------------------------------
if self.State ~= "Loaded" then -- Weapon is not loaded
if self.State == "Empty" and not self.Retry then
if not self:Load() then
self:EmitSound("weapons/pistol/pistol_empty.wav", 500, 100) -- Click!
self:EmitSound("weapons/pistol/pistol_empty.wav", 70, 100, ACF.SoundVolume) -- Click!
end

self.Retry = true
Expand Down Expand Up @@ -501,7 +501,7 @@ do -- Metamethods --------------------------------

self:ReloadEffect(Reload and Time * 2 or Time)
self:SetState("Unloading")
self:EmitSound("weapons/357/357_reload4.wav", 500, 100)
self:EmitSound("weapons/357/357_reload4.wav", 70, 100, ACF.SoundVolume)
self.CurrentShot = 0
self.BulletData = EMPTY

Expand Down Expand Up @@ -709,8 +709,8 @@ do -- Metamethods --------------------------------
if Crate:GetPos():DistToSqr(Pos) > 62500 then -- 250 unit radius
self:Unlink(Crate)

self:EmitSound(UnlinkSound:format(math.random(1, 3)), 500, 100)
Crate:EmitSound(UnlinkSound:format(math.random(1, 3)), 500, 100)
self:EmitSound(UnlinkSound:format(math.random(1, 3)), 70, 100, ACF.SoundVolume)
Crate:EmitSound(UnlinkSound:format(math.random(1, 3)), 70, 100, ACF.SoundVolume)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lua/weapons/acf_base/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ end

function SWEP:Reload()
if (self:Clip1() < self.Primary.ClipSize and self.Owner:GetAmmoCount(self.Primary.Ammo) > 0) then
self:EmitSound("weapons/AMR/sniper_reload.wav", 350, 110)
self:EmitSound("weapons/AMR/sniper_reload.wav", 70, 110, ACF.SoundVolume)
self:DefaultReload(ACT_VM_RELOAD)
end
end
Expand All @@ -36,7 +36,7 @@ end

--Server side effect, for external stuff
function SWEP:MuzzleEffect()
self:EmitSound("weapons/AMR/sniper_fire.wav")
self:EmitSound("weapons/AMR/sniper_fire.wav", nil, nil, ACF.SoundVolume)
self.Owner:MuzzleFlash()
self.Owner:SetAnimation(PLAYER_ATTACK1)
end
Expand Down
6 changes: 3 additions & 3 deletions lua/weapons/torch/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ function SWEP:PrimaryAttack()
Effect:SetEntity(self)
util.Effect("thruster_ring", Effect, true, true)

Entity:EmitSound("items/medshot4.wav", true, true)
Entity:EmitSound("items/medshot4.wav", nil, nil, ACF.SoundVolume)
else
if CPPI and not Entity:CPPICanTool(Owner, "torch") then return end

Expand All @@ -157,7 +157,7 @@ function SWEP:PrimaryAttack()
Entity.ACF.Health = Health
Entity.ACF.Armour = Armor

Entity:EmitSound("ambient/energy/NewSpark0" .. math.random(3, 5) .. ".wav", true, true)
Entity:EmitSound("ambient/energy/NewSpark0" .. math.random(3, 5) .. ".wav", nil, nil, ACF.SoundVolume)
TeslaSpark(Trace.HitPos, 1)
end
end
Expand Down Expand Up @@ -200,7 +200,7 @@ function SWEP:SecondaryAttack()
Effect:SetOrigin(Trace.HitPos)
util.Effect("Sparks", Effect, true, true)

Entity:EmitSound("weapons/physcannon/superphys_small_zap" .. math.random(1, 4) .. ".wav")
Entity:EmitSound("weapons/physcannon/superphys_small_zap" .. math.random(1, 4) .. ".wav", nil, nil, ACF.SoundVolume)
end
end
end
Expand Down

0 comments on commit 2515552

Please sign in to comment.