How to make a percentage based table

So im trying to make make a “spin” crate type thing, and each item has a different percent chance to land on, how would I start going about it? like my first thought was making a table and selecting a random reward from the table, but then the percentages would all be equal so that wouldn’t work.

I was also wondering about items going into the crate, because i’ll have dozens of items in my game, and I would only like 25 in a crate, so how do people usually go about it? like is there a percent chance for the item to even be in the crate? if so wouldnt that increase the percentage by alot? I hope you understand what I mean

1 Like

The standard way of achieving this is to pick a number (normally 1 to 100) and assigning a percent to each item, for example:

• Legendary (5%) → `if randnum <= 5 then`
• Rare (15%) (15+5=20) → `elseif randnum <= 20 then`
• Uncommon (25%) (25+20=45) → `elseif randnum <= 45 then`
• Common (55%) → `else`
You can adjust these values accordingly. If you use decimal percentages, like a 0.1% chance you might want to to randint(1,1000) then divide by 10.
Hope this helps!
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.