# ------- Rand val gen -----------------
function rng:percentage

# Decrement % of being room
scoreboard players operation % dungeon = out rng

execute if score n_rooms dungeon >= min_rooms dungeon run scoreboard players operation %_less dungeon = %_less_per_room dungeon
execute if score n_rooms dungeon >= min_rooms dungeon run scoreboard players operation %_less dungeon *= n_rooms dungeon
execute if score n_rooms dungeon >= min_rooms dungeon run scoreboard players operation % dungeon -= %_less dungeon

execute if score n_rooms dungeon <= min_rooms dungeon if score p_rooms dungeon matches 1 run scoreboard players set % dungeon 100
execute if score n_rooms dungeon >= max_rooms dungeon run scoreboard players set % dungeon 0

execute if score % dungeon <= %_of_room dungeon run scoreboard players set is_door dungeon 0
execute if score % dungeon >= %_of_room dungeon run scoreboard players set is_door dungeon 1


# ----------- Door or wall -------------
tag @s remove door
tag @s add door_done

execute if score is_door dungeon matches 0 run tag @s add is_wall
execute if score is_door dungeon matches 1 run tag @s add is_door
