# function rng:percentage
# execute if score out rng matches ..60 at @e[tag=boss] as @e[tag=center,tag=!boss,tag=!spawn,sort=furthest,limit=1,tag=one_door] run function rooms:1_layout/4.1_challenge
# tellraw @a [{"text":"TIC: "},{"score":{"name":"out","objective":"rng"}}]

# Armory (2 per floor)
tag @e[tag=center,tag=!boss,tag=!challenge,scores={rooms_from_spawn=2..},sort=random,limit=1] add armory
execute at @e[tag=center,tag=armory,limit=1] run tag @e[tag=center,tag=!boss,tag=!challenge,scores={rooms_from_spawn=2..},sort=random,limit=1,distance=47..] add armory

# Shop (1 per floor)
tag @e[tag=center,tag=!boss,tag=!armory,tag=!challenge,scores={rooms_from_spawn=2..},sort=random,limit=1] add shop

# Trapped ? (25% of rest)
execute as @e[tag=center,tag=!one_door,tag=!boss,tag=!shop,tag=!armory,tag=!spawn,tag=!challenge] at @s run function rooms:1_layout/is_trapped

# Enemy
tag @e[tag=center,tag=!boss,tag=!shop,tag=!armory,tag=!spawn,tag=!trapped,tag=!challenge] add enemy

scoreboard players set @e[tag=center,tag=!enemy,tag=!boss] room_state 6

scoreboard players set layout generation 0
