execute store result score world Spawning_Rolled run random value 1..8

# Triple check for same waves back to back.
# If it passes all three (1/n^4) probability, the same wave will spawn
execute if score world PreviousWaveRoll = world Spawning_Rolled run execute store result score world Spawning_Rolled run random value 1..8
execute if score world PreviousWaveRoll = world Spawning_Rolled run execute store result score world Spawning_Rolled run random value 1..8
execute if score world PreviousWaveRoll = world Spawning_Rolled run execute store result score world Spawning_Rolled run random value 1..8

execute store result score world PreviousWaveRoll run scoreboard players get world Spawning_Rolled

execute if score world Spawning_Rolled matches 1 run function kiwi2:waves/starter_waves/8_zombies
execute if score world Spawning_Rolled matches 2 run function kiwi2:waves/starter_waves/5_skeletons
execute if score world Spawning_Rolled matches 3 run function kiwi2:waves/starter_waves/3_creepers
execute if score world Spawning_Rolled matches 4 run function kiwi2:waves/starter_waves/6_spiders
execute if score world Spawning_Rolled matches 5 run function kiwi2:waves/starter_waves/6_husks
execute if score world Spawning_Rolled matches 6 run function kiwi2:waves/starter_waves/1_phantom
execute if score world Spawning_Rolled matches 7 run function kiwi2:waves/starter_waves/3_bogged
execute if score world Spawning_Rolled matches 8 run function kiwi2:waves/starter_waves/4_piglins