# What is formula to get rare items diablo 2 style?

Get help using Construct 2

### » Wed May 08, 2013 5:33 am

I'm looking for a formula to get rare items each enemy destroyed and leaves a rare item by 20% chance. Not be in frequency.

Could you help me?
B
99
S
35
G
29
Posts: 3,139
Reputation: 28,426

### » Wed May 08, 2013 5:42 am

I'm not really sure what you mean but I believe a Diablo style loot system involves a sizable array with different prefix and suffix values that get attached to each object based on chance, and each of those values do something different to the loot.

But if you simply want an enemy to drop a weapon on death based on chance, do the event "compare two values" and use something like "round(random(0,100))" and for percentage, make the second value "is less than or equal to 20" and that will commit the action in a 20% chance.
B
10
S
3
G
3
Posts: 234
Reputation: 3,467

### » Wed May 08, 2013 7:02 am

@Sushin I will try it this method, maybe it seems 50% chance for some reason because it's using random.

If you played some RPG game, when you face against, the hit chance is 20% is likely you get "miss" if you attack him. Otherwise if hit chance is 90% is almost impossible to get "miss".

Isn't another serious method like Fire Emblem game? Joannesalfa2013-05-08 07:03:33
B
99
S
35
G
29
Posts: 3,139
Reputation: 28,426

### » Wed May 08, 2013 7:22 am

If you choose a random value between numbers 0 and 100, and then choose any value lower than 50, that is effectively a 50% chance that the number is anywhere between 0 and 50 (almost, depending on how rounding works). If you go higher or lower than 50 than it should be a higher or lower chance. It's not a coin flip.

What you can do is create a variable called "hit chance" and it can change to any number you want. If it is accuracy, and you put it at 70 accuracy, you can use this accuracy variable to check against the random variable, so the code would look like this: "If round(random(0,100)) is less than accuracy" and that will give you a 70% chance to hit, and you can change accuracy whenever you want for a player or whatever.
B
10
S
3
G
3
Posts: 234
Reputation: 3,467

### » Wed May 08, 2013 8:06 am

@Sushin thanks for clearing! I believe it would work.
B
99
S
35
G
29
Posts: 3,139
Reputation: 28,426

### » Wed May 08, 2013 8:34 am

Well I can't say the exact random values. The behaviour seems to indicate a result mechanism similar too this layout. Also keep in mind that diablo2 uses a layered percentage. So rolling could actually result in 2 drops. on the base kill rolling 10% would drop gold AND an item.

50% to drop gold
10% to drop item

on item
90% for potion(random 50/50)
10% for gear

on gear
90% vender stuff
10% magical

on magical(sorry, i don't recall the colour scheme)
60% green(common)
30% blue(rare)
10% super(very rare)

this results in an increase decelinitino of odds. Also in Diablo 2, items were unknown. The reason was that then they can spawn the stats when a "Identify" was used. The item had a base level(based on creature) ans the stats were pulled on the level scale.

obviously set pieces were a little different :)
B
94
S
18
G
9
Posts: 2,457
Reputation: 15,177