Polish arena effects, audio and diagnostics

This commit is contained in:
Leshyi committed 2026-11-30 01:26:42 +05:00
1 parent 2774e625c1
commit 16a359d4af
28 files changed
+512 -257

No files matched your search

+29 -13
View File
@@ -18,6 +18,8 @@ local RunService = game:GetService("RunService")
local SoundService = game:GetService("SoundService")
local SniperEffects = {}
local AudioConfig = require(game:GetService("ReplicatedStorage"):WaitForChild("Hunter"):WaitForChild("EffectsConfig") :: ModuleScript)
local activeCues: {Sound} = {}
-- Free Creator Store sounds. volume, plus how far the sound carries when it is in the world.
-- group: which volume setting scales it (attribute Vol<group> of the SniperViewmodel config
@@ -40,25 +42,20 @@ local SOUNDS: { [string]: SoundDef } = {
Elimination = { id = "rbxassetid://15675043410", volume = 0.78, speed = 1.18, near = 0, far = 0, group = "Kill", cut = 0.52 },
StreakAccent = { id = "rbxassetid://3120909354", volume = 0.5, speed = 1, near = 0, far = 0, group = "Kill" }, -- Level_up
ReloadReady = { id = "rbxassetid://15675085146", volume = 0.24, speed = 1.15, near = 0, far = 0, group = "Reload", cut = 0.19 },
SiegeEnter = { id = "rbxassetid://113416294133952", volume = .23, speed = 1.30, near = 0, far = 0, group = "HUD" },
SiegeCharge = { id = "rbxassetid://2789428506", volume = .22, speed = 1, near = 0, far = 0, group = "HUD" },
SiegeTick = { id = "rbxassetid://113416294133952", volume = .22, speed = 1.48, near = 0, far = 0, group = "HUD" },
SiegeBlocked = { id = "rbxassetid://2789428506", volume = .25, speed = .70, near = 0, far = 0, group = "HUD" },
SiegeDecay = { id = "rbxassetid://2789428506", volume = .20, speed = .58, near = 0, far = 0, group = "HUD" },
RoundStart = { id = "rbxassetid://4612374036", volume = .27, speed = 1.15, near = 0, far = 0, group = "HUD" },
Tick = { id = "rbxassetid://113416294133952", volume = .22, speed = 1.12, near = 0, far = 0, group = "HUD" },
RoundCountdown = { id = "rbxassetid://113416294133952", volume = 0.25, speed = 1, near = 0, far = 0, group = "HUD" }, -- timer tick
ButtonHover = { id = "rbxassetid://84648433095796", volume = 0.22, speed = 1, near = 0, far = 0, group = "HUD" },
ButtonPress = { id = "rbxassetid://121882355123711", volume = 0.27, speed = 1, near = 0, far = 0, group = "HUD" },
FlagDropped = { id = "rbxassetid://2789428506", volume = 0.23, speed = .72, near = 0, far = 0, group = "HUD" },
HotPointMove = { id = "rbxassetid://113416294133952", volume = 0.23, speed = 1.18, near = 0, far = 0, group = "HUD" },
HotPointStart = { id = "rbxassetid://2789428506", volume = 0.25, speed = 1, near = 0, far = 0, group = "HUD" }, -- Unlock_phoenix
HotPointCaptured = { id = "rbxassetid://4612374036", volume = 0.28, speed = 1, near = 0, far = 0, group = "HUD" }, -- bling_big_diamond_pickup
MoneyCollect1 = { id = "rbxassetid://84894146013271", volume = 0.15, speed = 1, near = 0, far = 0, group = "Pickup", cut = 0.16 },
CupidKnife = { id = "rbxassetid://120151468640015", volume = 0.32, speed = 1, near = 0, far = 0, group = "Pickup" },
-- a player / bot destroyed: the body breaks apart like blocks (heard by everyone, from the body)
Break = { id = "rbxassetid://130215756597524", volume = 1, speed = 1, near = 25, far = 300, group = "Kill" }, -- blockbreak sfx
}
local arenaCues: {[string]: boolean} = {}
local function addCue(name: string, cue: AudioConfig.Cue)
SOUNDS[name] = {id = cue.id, volume = cue.volume, speed = cue.speed, near = 0, far = 0, group = "HUD"}
arenaCues[name] = true
end
for name, cue in AudioConfig.Cues do addCue(name, cue) end
for name, target in AudioConfig.Aliases do addCue(name, AudioConfig.Cues[target]) end
SniperEffects.SOUNDS = SOUNDS
-- the settings live as attributes on the local player's SniperViewmodel script
@@ -92,7 +89,10 @@ SniperEffects.BOLT_CUES = {
task.spawn(function()
-- Sound instances, not bare ids: a bare id string is preloaded as an image and fails
local preload = {}
local seen: {[string]: boolean} = {}
for _, def in SOUNDS do
if def.id == "" or seen[def.id] then continue end
seen[def.id] = true
local s = Instance.new("Sound")
s.SoundId = def.id
table.insert(preload, s)
@@ -105,13 +105,28 @@ end)
function SniperEffects.sound(name: string, at: Instance?, pitch: number?): Sound?
local def = SOUNDS[name]
if not def then
if not def or def.id == "" then
return nil
end
local volume = def.volume * math.max(setting("VolMaster", 1), 0) * math.max(setting("Vol" .. def.group, 1), 0)
if volume <= 0 then
return nil
end
local limited = arenaCues[name]
if limited then
for i = #activeCues, 1, -1 do
if not activeCues[i].Parent then table.remove(activeCues, i) end
end
if #activeCues >= AudioConfig.SoundLimit then
-- Убираем самый тихий сигнал. Если новый ещё тише, оставляем текущий микс.
local quietest = 1
for i = 2, #activeCues do
if activeCues[i].Volume < activeCues[quietest].Volume then quietest = i end
end
if activeCues[quietest].Volume > volume then return nil end
table.remove(activeCues, quietest):Destroy()
end
end
local s = Instance.new("Sound")
s.Name = "Sniper" .. name
s.SoundId = def.id
@@ -123,6 +138,7 @@ function SniperEffects.sound(name: string, at: Instance?, pitch: number?): Sound
s.RollOffMaxDistance = def.far
end
s.Parent = at or SoundService
if limited then table.insert(activeCues, s) end
s:Play()
if def.cut then
local fade = def.cut