Initially some of the drops are specified using percentages. My advice is to never use percentages when selecting chances to pick an item from an arbitrary list of items. Instead, use numbers which loosely correlate to ratios. Here is an example list of items:
1, 1, 2, 2
the chance of picking the first item is 1/(1+1+2+2) or 1:6. The chance of picking the last item is 2:6. Using this method, you can add arbitrary odds to the list and it will automatically total up the odds for you. For example:
1, 1, 2, 2, 3
The first is a 1:9 chance, the last is a 3:9 chance. The numbers still maintain relative chance next to one another - i.e. you are 3 times more likely to get the last item than the first.
This is better than using percentages because you can add items without having to recalculate the percentages so that everything adds up to one hundred percent (yes you could normalize the percentage but this still makes it tougher to understand the chance of each item relative to one another. If you want to make a high chance of dropping nothing, simply add a null item to the list with a really high chance, i.e.:
(null) 99, (diamond) 1
This results in a 99/100 chance of dropping nothing, and a 1/100 chance of dropping a diamond.
Oh, great comment! I've gone back and forth on exactly this a number of times. I'm not a big fan of percents for exactly the reason you specify. The reason I'm still doing it instead of automatically totalling the odds is because it makes it easier to specify the chances of not dropping anything at all.
> If you want to make a high chance of dropping nothing, simply add a null item to the list with a really high chance, i.e.:
Brilliant. I'm going to change my code and do that. Thank you!
Check out http://diablo2.diablowiki.net/Item_Generation_Tutorial for a slightly more complex system that IMO is a lot more flexible and can give some truly astronomical drop rates on exceptionally rare items (i.e. Zod runes, Tyrael's Might sacred armor).
The trick D2 uses is using a table similar to this:
As you can see, some of the items are actually TreasureClasses, which have their own entries. Whenever the item picker lands on a TreasureClass, it drops to the corresponding table row and "rolls the dice" again, so to speak. This is repeated until the item picker lands on an actual item.
If you look at TreasureClassEx.txt from Diablo II, you'll see that they further use this system to calculate nodrop rates, item generation per act/per difficulty, etc. Pretty cool once you wrap your head around it!
That's a good idea and probably what I'd do if I were to take it one step further - in particular if you went with null item drops, it would be great to "subclass" that so that its ratio does not interfere with the rest of your calculations. I.e. - 1:20 chance of dropping an item, 1:6 chance that it is item type XYZ.
+1 for Diablo 2, the game that destroyed my grades in school. :)
Over the whole area, you should get 5/9 goblins, but any given room can be an interesting mix -- 3 hobgoblins and one soldier, 2 wolves and 2 goblins, one of each, etc.
Initially some of the drops are specified using percentages. My advice is to never use percentages when selecting chances to pick an item from an arbitrary list of items. Instead, use numbers which loosely correlate to ratios. Here is an example list of items:
1, 1, 2, 2
the chance of picking the first item is 1/(1+1+2+2) or 1:6. The chance of picking the last item is 2:6. Using this method, you can add arbitrary odds to the list and it will automatically total up the odds for you. For example:
1, 1, 2, 2, 3
The first is a 1:9 chance, the last is a 3:9 chance. The numbers still maintain relative chance next to one another - i.e. you are 3 times more likely to get the last item than the first.
This is better than using percentages because you can add items without having to recalculate the percentages so that everything adds up to one hundred percent (yes you could normalize the percentage but this still makes it tougher to understand the chance of each item relative to one another. If you want to make a high chance of dropping nothing, simply add a null item to the list with a really high chance, i.e.:
(null) 99, (diamond) 1
This results in a 99/100 chance of dropping nothing, and a 1/100 chance of dropping a diamond.