I'm building a rarity system, where I have a bunch of items, each with a rarity attached to them, spanning from 1 (common) to 5 (very rare).
To get a random item I create a table with lots of 1s, a bit less of 2s etc and one of each 5. Then table[math.random(#)] that table.
The problem is that this is terribly inefficient, since the table contains hundreds/thousands of items, because I want 1 to be very common and 5 to be very rare indeed.
Is there a better way of doing this?
Comments
Roll a dice with 100 sides;
1-40 ----->1 (common item)
40-70 ----->2 (less comon)
70-90 ------> 3 (magical item)
90 - 98 ------> 4 (rare item)
98 - 100 -----> 5 (legendary item)
Note: Change the interval how you want, and arrange the possibility. In addition you can change the rarity possibility easilly by events, like power ups, special magical items.
Sword of luck - Magical property increase chance of finding rare items %5
Likes: hgy29, totebo
1-Event dice - Talent dice (usually 100 sides)
2-Effect dice -Result dice (can change but let us assume 6 sides)
Player wish: I want climb to tree.
Note :Player agility points are so low.
So first we need to decide about the action: Roll a dice and let us assume it is 10 out of 100 .
Hence 10 is so much low it means that there will be a bad consequence of his action and not a successful event. Player can not climb a tree.
Roll a effect dice;
1-3 ---> 3 hp loss
4-5---> 5 hp loss, arm hurts.
6-----> broken leg, unconscious for 2 turns
Likes: totebo
Also, here is some help to design your own probability distribution from dice-rolls. Maybe you can create something that works well for your system.
Likes: totebo
https://github.com/piretro/lua-roulette-wheel/blob/master/rouletteWheel
Likes: totebo
Likes: totebo
Likes: antix