I'm having trouble thinking of making a loot spawn system based on the rarity of an item. So say, for instance, that there was a can of beans, a pistol, and a rare military pack. I would want it so that the military pack would spawn less than any other type of item. I thought about making it so that there would be a function that gets a random number and if the item's chance value hits the random number it would spawn. Only problem with this is I don't think that would be based on rarity and it would be just random instead. Plus if it didn't hit that number nothing would spawn. So whats the best way to do this? I think I've got the right idea I just would like some help leading me in the right direction.
Even though I've had trouble with random numbers myself(When a 1/1000 chance ability activates 9 times in a row you know something is wrong.), it is the simplest method and it would be the right idea.
You could make it out of a large number like 1000 - and make one specific item go between 1-12 whenever it lands on that number it spawns, while common items 13-100, et cetera.
So yeah, I suggest you go with your current idea.