stopsound @a record
execute if entity @a[tag=rest] run return fail
execute if entity @a[tag=!wave] run return fail
execute if entity @e[type=marker,tag=room_boss_trigger] run return fail
execute store result score .random music run random value 1..12
execute if score .previous music = .random music run return run function main:mechanics/music/wave_1
execute store result score .previous music run scoreboard players get .random music

execute if score .random music matches 1 run schedule function main:mechanics/music/name/background_1 5t
execute if score .random music matches 1 run scoreboard players set .length music 2600

execute if score .random music matches 2 run schedule function main:mechanics/music/name/background_2 5t
execute if score .random music matches 2 run scoreboard players set .length music 2640

execute if score .random music matches 3 run schedule function main:mechanics/music/name/background_3 5t
execute if score .random music matches 3 run scoreboard players set .length music 1900

execute if score .random music matches 4 run schedule function main:mechanics/music/name/background_4 5t
execute if score .random music matches 4 run scoreboard players set .length music 2440

execute if score .random music matches 5 run schedule function main:mechanics/music/name/background_5 5t
execute if score .random music matches 5 run scoreboard players set .length music 2780

execute if score .random music matches 6 run schedule function main:mechanics/music/name/background_6 5t
execute if score .random music matches 6 run scoreboard players set .length music 2960

execute if score .random music matches 7 run schedule function main:mechanics/music/name/background_7 5t
execute if score .random music matches 7 run scoreboard players set .length music 2540

execute if score .random music matches 8 run schedule function main:mechanics/music/name/background_8 5t
execute if score .random music matches 8 run scoreboard players set .length music 2200

execute if score .random music matches 9 run schedule function main:mechanics/music/name/background_9 5t
execute if score .random music matches 9 run scoreboard players set .length music 2120

execute if score .random music matches 10 run schedule function main:mechanics/music/name/background_10 5t
execute if score .random music matches 10 run scoreboard players set .length music 2320

execute if score .random music matches 11 run schedule function main:mechanics/music/name/background_11 5t
execute if score .random music matches 11 run scoreboard players set .length music 1860

execute if score .random music matches 12 run schedule function main:mechanics/music/name/background_12 5t
execute if score .random music matches 12 run scoreboard players set .length music 2520