Let me try to go through all your questions in turn.
1. Checking whether or not a drop occurs given a certain drop chance
Just use a pseudo-random number generator and compare the result with the drop chance, just as you suggested in your question. For example, if you specify the drop chance in percentage points with up to two decimal places, you could ask
rand = generatePseudoRandomNumber(0, 10000) // between 0 and 10,000
if(rand <= dropChance * 100)
2. Checking which events happens given a set of possible events
Try to use a data structure that is more flexible than hard-coded switch expressions. I coded a basic version of a Lottery class here: https://gist.github.com/3368046. Lottery allows you to do stuff like this:
$Lottery = new Lottery();
$Lottery->addEntry($item1, $dropChanceOfItem1);
$Lottery->addEntry($item2, $dropChanceOfItem2);
$Lottery->addEntry($item3, $dropChanceOfItem3);
$drop = $Lottery->getWinner();
With my implementation, the drop chances do not even have to add up to 100%; the lottery determines the winner based on the number of lots that each participant has in relation to the other participants of the lottery.
3. When to check for drops and how to communicate the result to the player
I'd decide based on what the most critical bottleneck is: If bandwidth is expensive and if your service has a good latency (Amazon?), go for variant 1. If your service has latency issues, go for 2.
Answer from BerndBrot on Stack ExchangeHello,
I've played some games over the time and people always complain on their drop rate or RNG luck.
What is the real difference and how can i explaine someone the difference?
Videos
Let me try to go through all your questions in turn.
1. Checking whether or not a drop occurs given a certain drop chance
Just use a pseudo-random number generator and compare the result with the drop chance, just as you suggested in your question. For example, if you specify the drop chance in percentage points with up to two decimal places, you could ask
rand = generatePseudoRandomNumber(0, 10000) // between 0 and 10,000
if(rand <= dropChance * 100)
2. Checking which events happens given a set of possible events
Try to use a data structure that is more flexible than hard-coded switch expressions. I coded a basic version of a Lottery class here: https://gist.github.com/3368046. Lottery allows you to do stuff like this:
$Lottery = new Lottery();
$Lottery->addEntry($item1, $dropChanceOfItem1);
$Lottery->addEntry($item2, $dropChanceOfItem2);
$Lottery->addEntry($item3, $dropChanceOfItem3);
$drop = $Lottery->getWinner();
With my implementation, the drop chances do not even have to add up to 100%; the lottery determines the winner based on the number of lots that each participant has in relation to the other participants of the lottery.
3. When to check for drops and how to communicate the result to the player
I'd decide based on what the most critical bottleneck is: If bandwidth is expensive and if your service has a good latency (Amazon?), go for variant 1. If your service has latency issues, go for 2.
Yes, you take each percentage and map it to one or more numbers in that range. E.g. if there's 50% chance of getting a killer rabbit, and 20% chance of getting John Lennon glasses, and 30% of getting chainsaw fuel, then you would have 1...50 be the range for the rabbit, 51...70 for the glasses, and 71...100 for the fuel.
Now you generate a random number (e.g. using rand() or whatever your language offers, limiting it to 1...100 using 1 +(rand() % (100-1)), and depending on what range it falls in, you know what to drop.
Now this only gives you a single item. To get several items, you just draw several times*. So you'd be guaranteed to get one of the three above items from draw one, and one of four other smaller items from draw 2. You can even have draws where one of the items that can drop is "nothing". So to have a 2% chance of this dropping the Super Mega Ultra Grooveshark(tm), you'd have range 1-2 be the shark, and 3 to 100 "nothing" and just do an extra draw (generate another random number between 1 and 100) with that.
So your data structure would probably be a list of draws containing a list of items and their percentages, one of which could be a "nothing" item. Then your items (e.g. enemies) would simply reference one of those data structures as their "drop this when I die" structure.
*) Of course, if you want to always drop two items together, you may need to define some sort of "box" item that just contains those to items, then just draw once to get those two.
I've never really understood the drop rate system....
Currently I'm aiming for the 'Sandy' title and collecting the Insects of the desert.
There are particular one's which have a drop rate to them.
The one im currently aiming for says 1/200 drop rate. What does that even mean? a 1% chance of getting the drop per every 200 done?
If someone can explain it a bit more in depth, it would be great.
So my friends and I were doing a raid in Destiny 2 so we could maybe have a chance to get a gun that has a new 10% drop rate. We have 5 people who all have a 10% chance to get it. Someone said theres a 50% chance that at least 1 person gets the gun, which seemed to make sense but I'm not sure. Sorry if this is simple but I thought it was interesting and wanted to know the definite answer. Maybe I'm just overthinking It. Thank you in advance
As in, I understand it's a percentage, but how does the "game" decide when and if something drops?