Adding a bunch of tiles would be imo the most elegant solution but not for that disparate of percentages. Otherwise, you could create a tuple of [tile_type, percent_chance]
and select one randomly. The only stipulations for this implementation is that the integer percent chances are in descending order as demonstrated AND that none of the chances are the same integer. This implementation assumes higher roll = better or more rare.
var tile_rarities = [[0, 80], [1, 10], [2, 5], [3,4]]
# list = [[tile_type, integer_percent_chance], [tile_type, integer_percent_chance],...]
func get_random_tile_type(list):
var total = 0
for pair in list:
total += pair[1]
randomize()
var roll = randi() % int(total) + 1
# default value just in case
var chosen_tile = list[0][0]
for pair in list:
if roll <= pair[1]:
chosen_tile = pair[0]
break
else:
roll -= pair[1]
return chosen_tile