I grouped up duplicates and removed the repetitive stuff ("sounds\\", ".ogg"):
Lua Code:
local sounds
if UnitExists("boss1") then
local bossHP = UnitHealth("boss1") / UnitHealthMax("boss1")
if bossHP > 0.8 then
sounds = {
"01-Rising-Dragon",
"02-Cometh",
"03-Gothams-Reckoning",
"06-the-battle-is-to-the-strong",
"06-the-battle-is-to-the-strong-2",
"07-Kakuzu",
"07-The-Fire-Rises",
"08-Prominence",
"10-Fear-Will-Find-You",
"10-Silver-for-Monsters",
"10-Silver-for-Monsters",
"13-Imagine-The-Fire",
"15-Divinity",
"16-tatakau",
"17-No-Stone-Unturned",
"17-No-Stone-Unturned-2",
"19-a-chaser",
"19-Steel-for-Humans.ogg",
"35-Hunt-Or-Be-Hunted",
"35-Hunt-Or-Be-Hunted",
"35-Hunt-Or-Be-Hunted.ogg",
"129-truth-behind-the-project",
"bloodborne-ludwig-1",
"bloodborne-ludwig-2",
"FFXV-1",
"FFXV-4",
"Twilight-of-the-Gods",
"ubw-06-souls",
"ubw-06-souls-2",
"ubw-18-fist",
"ubw-23-each",
"ubw2-05-overcome",
"ubw2-06-bluered",
"ubw2-18-excalibur",
"ubw2-23-music",
"10-Silver-for-Monsters",
"80percentplus-06-the-battle-is-to-the-strong",
"pull-Edge-of-Green.ogg",
}
elseif bossHP > 0.4 then
sounds = {
"01-Rising-Dragon",
"02-Cometh",
"03-Gothams-Reckoning",
"06-the-battle-is-to-the-strong",
"06-the-battle-is-to-the-strong-2",
"07-Kakuzu",
"07-The-Fire-Rises",
"08-Prominence",
"10-Fear-Will-Find-You",
"10-Silver-for-Monsters",
"10-Silver-for-Monsters",
"13-Imagine-The-Fire",
"15-Divinity",
"16-tatakau",
"17-No-Stone-Unturned",
"17-No-Stone-Unturned-2",
"19-a-chaser",
"19-Steel-for-Humans.ogg",
"35-Hunt-Or-Be-Hunted",
"35-Hunt-Or-Be-Hunted",
"35-Hunt-Or-Be-Hunted.ogg",
"129-truth-behind-the-project",
"bloodborne-ludwig-1",
"bloodborne-ludwig-2",
"FFXV-1",
"FFXV-4",
"Twilight-of-the-Gods",
"ubw-06-souls",
"ubw-06-souls-2",
"ubw-18-fist",
"ubw-23-each",
"ubw2-05-overcome",
"ubw2-06-bluered",
"ubw2-18-excalibur",
"ubw2-23-music",
"01-Rising-Dragon",
-- "06-Raido-2",
"18-Dark-Spot",
}
else
sounds = {
"bloodborne-ludwig-1",
"bloodborne-ludwig-1",
"execute06-Raido",
"execute-09-Incantation",
"execute-17-sara-ni-tatakau-2",
"FFXV-3",
"Twilight-of-the-Gods",
"ubw2-05-overcome-execute",
}
end
elseif IsInInstance() then
sounds = {
"19-a-chaser",
"FFXV-4",
"old-18-Risen-From-Darkness",
}
else
sounds = {
"world-Edge-of-Green",
"world-Edge-of-Green",
"world-Edge-of-Green",
}
end
local originalCVar = GetCVar("Sound_EnableMusic")
SetCVar("Sound_EnableMusic", 0)
PlaySoundFile(("sound\\%s.ogg"):format(sounds[math.random(#sounds)]), "Master")
C_Timer.After(40, function()
SetCVar("Sound_EnableMusic", originalCVar)
end)
Anything with an ".ogg" still had two to begin with (not sure if intended or not). The commented out "06-Raido-2" is because it wasn't reachable with your original code.