• Hey! Register here to create your account, engage with the community, and talk about what is new!

How to make a drop system based on percentages ?

Frizou

New member
Joined
Aug 16, 2022
Messages
12
Reaction score
2
How do you make a drop system based on a loot table that uses percentages ?
example : 20% of stone, 20% of dirt, 50% of wood, 10% of iron
 
Solution
You can use " Set Variable: Set to Random Number " and set a variable to 1 - 100 or something higher if you want larger selection range.
1660841071739.png
Then, place an " If Variable: Value Is Within Range " and put the variable you made with the random number along with two numbers.
1660841166826.png
If you want to have a 50% chance of something, put the variable specified above, the number 1, and the number 50.
You can place multiple of the If Variables on a single code line, just make sure none of the Within Ranges intersect with others.
For example, have 1-50 in one " If Variable: Is Within Range " and have 51-100 in another.

I hope this helps!

ARMcPro

Forum adept
Overlord
Joined
Oct 20, 2020
Messages
1,260
Reaction score
356
in the Set Variable block, there is a Set To Random Value. Place the block, put a variable of your choice in the 1st slot (preferably LOCAL)
and then put 2 stones in separate slots, 2 dirt items in separate slots, 5 wood items in separate slots and 1 iron item.

Now you can use the variable you put in the 1st slot as your item.
 

Frizou

New member
Joined
Aug 16, 2022
Messages
12
Reaction score
2
Thank you !
(are there any more advanced techniques for very low percentages like 3.56% ? or is that just too much code ?)
 

ARMcPro

Forum adept
Overlord
Joined
Oct 20, 2020
Messages
1,260
Reaction score
356
Thank you !
(are there any more advanced techniques for very low percentages like 3.56% ? or is that just too much code ?)
there is but it's kinda too much code
but if you want it, place a Set Variable: Random Number and then place a lot of if's to check the range
so if the range is between 0 and 3.56%, spawn that item, if the range is between 3.561 and 12% spawn another item
1660680501642.png
 

JustSticky

Well-known member
Overlord
Joined
Mar 4, 2021
Messages
77
Reaction score
43
You can use " Set Variable: Set to Random Number " and set a variable to 1 - 100 or something higher if you want larger selection range.
1660841071739.png
Then, place an " If Variable: Value Is Within Range " and put the variable you made with the random number along with two numbers.
1660841166826.png
If you want to have a 50% chance of something, put the variable specified above, the number 1, and the number 50.
You can place multiple of the If Variables on a single code line, just make sure none of the Within Ranges intersect with others.
For example, have 1-50 in one " If Variable: Is Within Range " and have 51-100 in another.

I hope this helps!
 
Solution

Frizou

New member
Joined
Aug 16, 2022
Messages
12
Reaction score
2
You can use " Set Variable: Set to Random Number " and set a variable to 1 - 100 or something higher if you want larger selection range.
View attachment 1598
Then, place an " If Variable: Value Is Within Range " and put the variable you made with the random number along with two numbers.
View attachment 1600
If you want to have a 50% chance of something, put the variable specified above, the number 1, and the number 50.
You can place multiple of the If Variables on a single code line, just make sure none of the Within Ranges intersect with others.
For example, have 1-50 in one " If Variable: Is Within Range " and have 51-100 in another.

I hope this helps!
Oh wow thats really useful, thanks a lot !
im guessing i can go further than 1-100 for rarer occurences ?
 
Top Bottom