I'm looking for a way to make chances of getting better loot increase the more you've looted. I do not want it to be possible to get a rare item the first 5 times and not being able to get an epic item the first 10 times.

However, the more the player loots, the better chance he should have of getting better items/less chance of getting nothing, normal, ...

This is my current code, but it is, as you can see, completely static. I know this might not be of much help, but at least it shows an overview of the items and the %-chance I have in mind.

var rand = random(100); // Random number 0-100
if(rand < 40){
    return LOOT_NOTHING;
}else if(rand < 70){
    return LOOT_NORMAL;
}else if(rand < 90){
    return LOOT_UNCOMMON;
}else if(rand < 99){
    return LOOT_RARE;
    return LOOT_EPIC;

The project is written in GML, but pretty much any language will suffice as an answer as it's not very language-specific.


3 Answers 3


It might be easier to choose items like ten by ten, then 'shuffle' the bag of items so they appear in random order.

expl :

10 first items : 4 null, 6 normal.
10 next : 4 null, 5 normal, 1 uncommon.
10 next : 4 null, 4 normal, 1 uncommon, 1 rare.
10 next : 4 null, 3 normal, 2 uncommon, 1 rare.
10 next : 3 null, 2 normal, 2 uncommon, 2 rare, 1 epic.
then you keep this last balance.

Store those coef in a convenient array so you can fine-tune the balance at any time.

Rq : If when testing it doesn't feel random enough, you can easily make it more random by storing item probability, not item count :

10 first items : 40% null, 60% normal.
10 next : 40% null, 50% normal, 10% uncommon.

you roll the dice when building the bag, then shuffle it afterwise. Only issue here is that, for instance after 40 items in the previous example, you might get several epic items or none...

Edit : Despite the increased complexity, i would add, for the second solution, a cap/max, so that, for instance, you don't get several epic item in a row.
The description becomes :

10 first items : 40% null, 60% normal. max 6 normal.
10 next : 40% null, 50% normal, 10% uncommon. max 1 uncommon.
10 next : 4 null, 4 normal, 1 uncommon, 1 rare. max 1 uncommon, 1 rare.

You might represent the data as (Javascript notation) (where -1 means no max) :

var lootCoeff = [
                  [ [ /* prob */ 0.4, 0.5, 0.1], [ /* max */ -1, 5, 1 ] ],
                  [ [ /* prob */ 0.4, 0.4, 0.1, 0.1], [ /* max */ -1, 5, 1, 1 ] ],  
  • \$\begingroup\$ This is a great idea! I will most likely go for the second solution, as the game suits the randomness better than a shuffled order of items you will get within 50 times. \$\endgroup\$
    – PWL
    Commented Mar 11, 2016 at 11:29
  • \$\begingroup\$ I can't say I agree with your edit. It sound like a good idea, but this would just ensure that you get at least 40% null. By limiting the items to the same as the chance (ex. max 1 for 10%) we end up with the same output as the first solution. \$\endgroup\$
    – PWL
    Commented Mar 11, 2016 at 12:05
  • \$\begingroup\$ The intent of this 'max' is mainly, for instance, to avoid several 'epic' items to be looted in a row, a thing i'd expect to be very undesirable. With the max, you can have only 1 epic or none, which i would prefer. Obviously this makes coding and balancing coefs harder.. \$\endgroup\$ Commented Mar 11, 2016 at 14:27

Assume you have a list named "Rewards", which holds the "rare", "epic" etc. values. Also assume you have an integer that holds how many times user rolled.

On each roll you pick a random item from the list, and give it to player.

At certain tresholds -say, each 10 rolls- you add more "epic" items to the list.

So as user rolls, the chances he gets an "epic" item increases.


You could go for a rolling scale, give each item a minimum roll of X and each time you roll for an item roll = (random) + Y, where Y is your bonus (increasing a certain amount with each roll. Then pick the highest threshold made by your roll.

say your rng (in range 1-20) produces 12 and you have had 5 rolls so far your roll-result is 17. your threshold for normal items is 15 and your threshold for rare items is 25. so you get a normal item. next roll y increases to 6 so you'll hit a rare item on a roll of 19 or higher.

The scale and ranges can be adjusted to your preference


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .