It's a nice plugin, the effects are really fun and detailed.
In my OCD brain I was trying to think of a way to optimize that random loop for cases when very few options are enabled (worst-case scenario: only 1 option is enabled), since theoretically, landing on an enabled number
could never occur (if you ignore statistical certainty as n increases), or, at least, it could take a long time. So I came up with this:
Code:
DiceNow(client)
{
new number, count;
number = count = GetRandomInt(1, 25);
while(!EnabledNumbers[number])
{
if(number == 25)
number = 0;
else
number = number % 25 + 1;
if(number == count) // Looped through every number without finding a match
return;
}
...
That reduces the loop complexity to O(n) (at most 25 iterations), and solves the unusual bug that creates an infinite loop if the user has stupidly set their config to disable every option. It's slightly less random than what you have now, since a large group of closely-numbered disabled options will tend toward the same result, but it's just a suggestion. =P
__________________