I looked at multiple stack overflow articles and couldn't find a reasonable response. If there is a duplicate please indicate.
I have a list of items. Something like:
String giantRat []={"Bandage", "Healing Potion", "Minor Healing Potion", "Rat Teeth", "Fur", "Rat Tail", ""};
This indicates the possible items this giantRat
can drop.
There is a correlated array with matching index that holds what I would hope is the weighted probability of the occurence. Something like:
int giantRatDropRate[]={1,1,1,6,8,3,5};
These would be scaled up to say, 50 (multiplied each by 2) and then I would theoretically role a 50 sided dice (Random
). This seems like it's been the wrong approach and I can't figure out a way to do this.
Again, the idea is to roll a die and choose 1 item from the list based on weighting. Maybe the dice roll is the wrong way. Any help appreciated.
Aucun commentaire:
Enregistrer un commentaire