Unconnected
Maybe you could store your items into 'groups' of data.
Give each group a percentage:
001-042 = group: junk items
043-066 = group: common items
067-081 = group: uncommon items
082-092 = group: rare items.
093-098 = group: epic items.
099-100 = group: legendary items.
Roll a random number 1-100. Say the result = 72. This falls into the 'uncommon' item group. You can now choose a random item from the 'uncommon' group.
You might need to scale those numbers a little.
this is usually best if you don't need item scaling.
or you can set up like -> dual randoming - > 1st random selects group, 2nd random selects item in that group. for example
let's say you random legendary item, you want people mostly getting some legendary item more then some uber super duper legendary item. so you put chance on them, for example, the one with high chance ~50, and the uber one with ~5 , if 2nd roll gets <5 drop uber item, otherwise drop weaker item if roll <50, if roll even <100 even weaker and so on..
or you could do something like this (completely different, math):
- (roll a number from 1 to 10 * 100) /numberofdroppableitems / max number of levels * level *1.1 * number of items in the group
you can do much more math it all depends what you want