# how to set random value to %5 drop rate??

0 favourites
• 10 posts
From the Asset Store
Easily generate many levels from a set of pre-built scenes (Construct 3 template)
• Hi,

if i click a chest, I want it to choose a random item,

for example the sword is a rare item

and costume is very rare

how to set percentage? like it has a 5% to get the item.

I know you can put it like if click on chest "set random value to choose(1, 2, 3, 4, etc)

and if it value = 1 it should give a sword.

but i dont want that, i want to know how you give it a %5 drop rate.

• ## Try Construct 3

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• Instead of the choose you mentioned, you use random(x,y) to get a number between 1-100 and then if its 5 or less it will spawn the 5% rare item.

• Oh wow, thank you so much :)

• it works perfect, only problem is that if i have like 3 very rare items

i put random(1,100)

if random is less or equal to 5 it should spawn one rarer object#1

if random is less or equal to 4 it should spawn one rare object#2

and so on.

if i click my chest, it spawns both those objects

• I think this is correct, it is doing what I want it to do :)

• I think this is correct, it is doing what I want it to do :)

Instead of double random, if you have a random between 1-100, it means that each number has 1% of drop chance, so for multiple itens you could use like:

If random result is >=1 and < 5 = Drop item 1 (This means that you have 5% drop rate)

and a second condition

If random result is >=5 and < 8 = Drop item 2 (This means that you have 4% drop rate)

..

If random result is = 100.. Drop item 80 (This means that you have 1% drop rate)

Using just 1 random and multiple comparations

• Like this?

• Like this?

Yes,

first condition has 5% drop rate, second one has 10%

• Thank you so much Klabundee and lions_ :)

• If you're planning on picking between weighted multiple items you might want to check out probability tables using the Advanced Random plugin:

It makes it a lot easier to change the weightings on the go, especially if you have a large number of items to choose between.

• 10 posts
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)