# Best Drop Rate Practice?

Discussion and feedback on Construct 2

### » Wed Nov 23, 2016 7:49 am

I am aware that I can do a Random Generated Number (RGN) in order to get a random number.
I can take that Random Number and mathematically set the drop rate of an item using conditions.

If the RGN is between 0 and 999
Then I know 0-499 will be 50% and so will 500-999.

When I have a low amount of items an enemy may drop, then it can easily be managed with a Random Generated Number. What do you do when you will constantly be adding to the list of dropped items. Every time you add a single item or change a single condition it changes everything. I should add that I am only giving one item out at a time. Is there an easier way to do this so I don't have to change every number in the conditions each time I add or change an item? I understand that every time you add in another item you change the percent of the other items. So if there isn't a way around this then I suppose I am looking for another tactic.

I guess I am asking how to keep a fixed drop rate on some items.

Does Random Number Generation tend to favor certain numbers over others?

The only other thing I can think of is using an Array.
Placing X amount of items into the Array to give each item weight.
I would then select a random item.
Similar to a sweepstakes or giveaway.

ItemA will be put into an Array 10 times.
ItemB will be put into an Array 20 times.
ItemC will be put into an Array 1 time.
ItemD will be put into an Array 15 times.

Every time I put in a new item or adjust a number of entries the percent of every item changes. I was trying to avoid that but at least I won't have to adjust nearly every number. Using an Array seems to be going off of weight instead.

Is this an accurate way of having a random item given?

Would using an Array be more beneficial than RGN?

I could do this without an Array, by using Cumulative.

By adding 10, 20, 1 and 15 I get the max amount of entries.
46 entries total.
The random generated number is generated. Lets say 32.

ItemA is 10.
32 isn't equal or below 10.

ItemA+ItemB = 30
32 is not equal or below 30

ItemA+ItemB+ItemC = 31
32 is not equal or below 31

ItemA+ItemB+ItemC+ItemD = 46
32 is equal or below 46

So the item generated is ItemD.

It is a bit tedious, but it would prevent me from having to change a lot by making a simple change or adding an item. It would also prevent the need for an extra Array.
I could probably set up a variable and just have it loop the correct amount of times automatically.

I just need a small bit of guidance on how to do drop rates if the items that can be dropped will be increasing over time. Right now I have about 14 planned and I will still have more to add.
Last edited by Unconnected on Sat Nov 26, 2016 1:11 am, edited 1 time in total.
B
80
S
41
G
13
Posts: 257
Reputation: 13,511

### » Wed Nov 23, 2016 8:09 pm

The only other thing I can think of is using an Array.
Placing X amount of items into the Array to give each item weight.
I would then select a random item.
Similar to a sweepstakes or giveaway.

ItemA will be put into an Array 10 times.
ItemB will be put into an Array 20 times.
ItemC will be put into an Array 1 time.
ItemD will be put into an Array 15 times.

Have you tried using "choose(ItemA, ItemA, [...etc], ItemD)" ?
B
32
S
9
G
7
Posts: 274
Reputation: 5,725

### » Wed Nov 23, 2016 11:31 pm

@Unconnected

Maybe you could store your items into 'groups' of data.

Give each group a percentage:

001-042 = group: junk items
043-066 = group: common items
067-081 = group: uncommon items
082-092 = group: rare items.
093-098 = group: epic items.
099-100 = group: legendary items.

Roll a random number 1-100. Say the result = 72. This falls into the 'uncommon' item group. You can now choose a random item from the 'uncommon' group.

You might need to scale those numbers a little.
B
34
S
11
G
3
Posts: 191
Reputation: 3,678

### » Wed Nov 23, 2016 11:48 pm

@TRMG That is basically the same thing as generating a random number, but it would take longer to change the odds. I think this is okay to do if you only have a few items, but I have quite a bunch.

@gameglaux Yes, I am glad you brought that up. I was gonna go for weight. Where each one would get a variable for weight and then I could manipulate the pool of items easily, but this seems better.

I was actually reading on loot drop practices. I probably wouldn't have made the connection of groups if you haven't mentioned it.

I believe what you brought up would coincide with a dice role. The first dice roll (RGN) picks a group and the second dice (RGN) picks an item in that group.

http://www.gamasutra.com/blogs/DanielCook/20141215/232300/Loot_drop_best_practices.php

I also should point out that sometimes people cheat when they have a chance to get loot. They can save the game and keep reloading until they get what item they want..

It is a good idea to store a random generated number or a few ahead of time to prevent people from reloading the game until they get the random number they want.

Thanks guys. Input appreciated.
B
80
S
41
G
13
Posts: 257
Reputation: 13,511

### » Thu Nov 24, 2016 8:38 am

gameglaux wrote:@Unconnected

Maybe you could store your items into 'groups' of data.

Give each group a percentage:

001-042 = group: junk items
043-066 = group: common items
067-081 = group: uncommon items
082-092 = group: rare items.
093-098 = group: epic items.
099-100 = group: legendary items.

Roll a random number 1-100. Say the result = 72. This falls into the 'uncommon' item group. You can now choose a random item from the 'uncommon' group.

You might need to scale those numbers a little.

this is usually best if you don't need item scaling.
or you can set up like -> dual randoming - > 1st random selects group, 2nd random selects item in that group. for example
let's say you random legendary item, you want people mostly getting some legendary item more then some uber super duper legendary item. so you put chance on them, for example, the one with high chance ~50, and the uber one with ~5 , if 2nd roll gets <5 drop uber item, otherwise drop weaker item if roll <50, if roll even <100 even weaker and so on..

or you could do something like this (completely different, math):
- (roll a number from 1 to 10 * 100) /numberofdroppableitems / max number of levels * level *1.1 * number of items in the group

you can do much more math it all depends what you want
Sea Monsters template - Isometric
Also includes 40 pages PDF of optimizations and "how-to" for your games, and how the "sea monsters" template was built. Follow link for details :)

sea-monsters-templates-and-assets_t162705
B
43
S
14
G
12
Posts: 630
Reputation: 9,465

### » Thu Nov 24, 2016 9:39 am

Unconnected wrote:I also should point out that sometimes people cheat when they have a chance to get loot. They can save the game and keep reloading until they get what item they want..

You could kind of get around this by using a seeded random number. When the player starts a character, new game or area, seed a random number generator. Then use this random number generator for your loot generator every time you need a loot reward. The player can load the save game as much as they like, the same 'random' number comes out of the generator each time. The only way they can change the outcome is by going back to where the seed was randomised for the generator in the first place.

Of course, as you are saving a characters progress they could open the save file and change things there. You could implement a simple checksum to prevent casual tampering. The bottom line is, unless you do calculations and store data server side, people can cheat. I wouldnt worry about it. Have fun developing your game and worry about that stuff afterwards if its a major concern.
B
34
S
11
G
3
Posts: 191
Reputation: 3,678

### » Thu Nov 24, 2016 10:32 am

You can check my tutorial on how to code monster loot drop and having different rates of drops depending on rarity of items/type of monsters.
New to Construct ? Where to start

Please attach a capx to any help request or bug report !
Moderator
B
311
S
128
G
101
Posts: 7,413
Reputation: 75,222

### » Fri Nov 25, 2016 1:59 pm

@gameglaux

That does sound like a better idea.
A seed is easier on the memory as well as more secure.

I tried looking up how to use seeds, and couldn't figure it out completely, until I found this

Https://cdsmith.wordpress.com/2011/10/10/build-your-own-simple-random-numbers/

It is basically a formula that can be changed with a few variables.
This allows the game to calculate repeatable randomness.
The only issue is a pattern becomes noticeable if you limit the highest seed number to a lower number.
11 would give you 10 numbers before a pattern is repeated.

***EDIT***

The formula in the link reverses the Dividend and Divisor when it figures remainder.
X*7 % 11

1*7 % 11 is supposed to equal 4.
This is proven by 7+4 = 11

In link it does
1*7%11= 7

I believe this is done in order to keep the generator and it's calculation simple.
In a spreadsheet I found out if you correct the Dividend and Divisor then the generator stops working.
You end up getting stuck in a 0 or 1 loop.
Also X can not be equal or a multiple of 11 (11, 22, 33, 44, 55)
11%11 is 0 and will cause a 0 loop.
22%11 is 0 and will cause a 0 loop.
Last edited by Unconnected on Sat Nov 26, 2016 3:44 pm, edited 1 time in total.
B
80
S
41
G
13
Posts: 257
Reputation: 13,511

### » Fri Nov 25, 2016 3:42 pm

I have a semi related question. I don't know what it's called so I'm not sure how to look it up.

If I have a random number.
275268

How do I select a number from it to set it to a variable?

How do I select 8?
How do I select 268?
Wildcard?
B
80
S
41
G
13
Posts: 257
Reputation: 13,511

### » Fri Nov 25, 2016 8:24 pm

Unconnected wrote:I have a semi related question. I don't know what it's called so I'm not sure how to look it up.

If I have a random number.
275268

How do I select a number from it to set it to a variable?

How do I select 8?
How do I select 268?
Wildcard?

I dont quite understand because if you know the values you want, you wont need a random number.
edit: do you mean get the 8th or 268th number from the generator? Not tried. You could always keep a counter and run a loop on the generator.

As usual, @rexrainbow comes to the rescue: http://c2rexplugins.weebly.com/rex_randomgen.html
B
34
S
11
G
3
Posts: 191
Reputation: 3,678

Next

Return to Construct 2 General

### Who is online

Users browsing this forum: No registered users and 1 guest