I am trying to create a percentage probability for the game. For instance. if the item has a 45% chance of a critical hit, this should mean that 45 out of 100 hits will be critical.
At first I tried using a simple solution:
R = new Random(); int C = R.Next(1, 101); if (C <= ProbabilityPercent) DoSomething()
But in 100 iterations with a probability of, for example, 48%, it gives 40-52 out of 100. The same goes for 49, 50, 51. Thus, there is no difference between these “percentages”.
The question is how to set the percentage, for example. 50, and get strictly 50 out of 100 with random? This is a very important thing for the probability of finding rare items with the ability to increase the chance of finding an item. Thus, the 1% buff will be sensitive, because now it is not.
Sorry for my bad english.
source share