I’m in need of a drop/reward system by percentage, so i created (as i always do) a weighted loot system that kinda acts like having a chance in percentages.
But the problem with this system is it’s not using percentages in the way that i can set 5% and the chance will be 5 percent, it’s pulling a random number 1-100 then just divide that to get the chances.
Is there a way to do this with real percentages?
this is what i created (test file):
random_number = randint(1,100) if random_number <= 50: #white 50% name = 'Common' color = [1,1,1,1] loot = 100 elif random_number > 50 and random_number <= 75: #green 25% name = 'Uncommon' color = [0,1,0,1] loot = 500 elif random_number > 75 and random_number <= 85: #blue 10% name = 'Rare' color = [0,0,1,1] loot = 1000 elif random_number > 85 and random_number <= 92: #purple 7% name = 'Epic' color = [1,0,1,1] loot = 2500 elif random_number > 92 and random_number <= 97: #yellow 5% name = 'Legendary' color = [1,1,0,1] loot = 5000 elif random_number > 97 and random_number <= 100: #red 3% name = 'Wealthy' color = [1,0,0,1] loot = 10000
So i wonder how do you tackle this (if you do)?