## Runs from function dungeon_spawner/select_spawner
## @s = ldz:dungeon_spawner,family=scourge_spawner

scoreboard players add @e[type=ldz:dungeon_spawner,family=scourge_spawner] Spawner 0
scoreboard players add ..sc SpawnerXYZ 0
execute if score ..sc SpawnerXYZ matches 1 run scoreboard players set @e[type=ldz:dungeon_spawner,family=scourge_spawner,scores={SpawnerXYZ=1}] Spawner -1
execute if score ..sc SpawnerXYZ matches 2 run scoreboard players set @e[type=ldz:dungeon_spawner,family=scourge_spawner,scores={SpawnerXYZ=2}] Spawner -1
execute if score ..sc SpawnerXYZ matches 3 run scoreboard players set @e[type=ldz:dungeon_spawner,family=scourge_spawner,scores={SpawnerXYZ=3}] Spawner -1
execute if score ..sc SpawnerXYZ matches 4 run scoreboard players set @e[type=ldz:dungeon_spawner,family=scourge_spawner,scores={SpawnerXYZ=4}] Spawner -1
execute if score ..sc SpawnerXYZ matches 5 run scoreboard players set @e[type=ldz:dungeon_spawner,family=scourge_spawner,scores={SpawnerXYZ=5}] Spawner -1
execute if score ..sc SpawnerXYZ matches 6 run scoreboard players set @e[type=ldz:dungeon_spawner,family=scourge_spawner,scores={SpawnerXYZ=6}] Spawner -1
execute if score ..sc SpawnerXYZ matches 7 run scoreboard players set @e[type=ldz:dungeon_spawner,family=scourge_spawner,scores={SpawnerXYZ=7}] Spawner -1
execute if score ..sc SpawnerXYZ matches 8 run scoreboard players set @e[type=ldz:dungeon_spawner,family=scourge_spawner,scores={SpawnerXYZ=8}] Spawner -1
execute if score ..sc SpawnerXYZ matches 9 run scoreboard players set @e[type=ldz:dungeon_spawner,family=scourge_spawner,scores={SpawnerXYZ=9}] Spawner -1
execute if score ..sc SpawnerXYZ matches 10 run scoreboard players set @e[type=ldz:dungeon_spawner,family=scourge_spawner,scores={SpawnerXYZ=10}] Spawner -1

scoreboard players set @r[type=ldz:dungeon_spawner,family=scourge_spawner,scores={Spawner=0}] Spawner 1
execute as @e[type=ldz:dungeon_spawner,family=scourge_spawner,scores={Spawner=1}] at @s run function dungeon_spawner/spawn_scourge


## STORES CHOSEN COORDINATES FOR NEXT SELECTED SPAWNER
scoreboard players operation ..mc SpawnerXYZ = @e[type=ldz:dungeon_spawner,family=scourge_spawner,scores={Spawner=1}] SpawnerXYZ
scoreboard players set @e[type=ldz:dungeon_spawner,family=scourge_spawner] Spawner -1

scoreboard players reset @s SpawnerXYZ