Created
July 3, 2012 10:19
-
-
Save Riateche/3038910 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Item drop_random_item() { | |
int r = rand(0, total_chance_sum); | |
int current_sum = 0; | |
for(int i = 0; i < items.count(); i++) { | |
if (current_sum <= r && r < current_sum + items[i].chance) return items[i]; | |
current_sum += items[i].chance; | |
} | |
} |
Дружище, можешь объяснить как это работает?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you!