Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (577)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  How do you handle loot tables and drop chances?  (Read 969 times)
0 Members and 2 Guests are viewing this topic.
Offline tyeeeee1
« Posted 2013-08-09 01:56:04 »

Hey,

The question is in the title; How do you handle loot tables and drop chances?

The way I'm currently handling them can be seen in the link below within the getNextDrop method. It seems like a pretty bad way to do loot tables/drop chances but it works for the moment.
https://github.com/Valkryst/Project_02/blob/master/src/main/java/valkryst/systems/Drops.java
Offline wessles

JGO Wizard


Medals: 67
Projects: 4
Exp: 3 years


Profile picture isn't relevant.


« Reply #1 - Posted 2013-08-09 02:39:43 »

I dont get what you are asking. I usually just make there a 0.1/100 chance. Not much else to it. Do you mean making an organized table of chances? In that case, just have an int array (not float array! less memory used, so just use multiplication knowledge), and reference them with constants corresponding to each drop.

1  
2  
3  
4  
5  
6  
public static final int APPLE=0, IRON=1, GOLD=2, DIAMOND=3
public static final int[] chances = new int[10, 6, 4, 1]

public static float getDropChance(int type) {
    return chances[type]*.01f;
}

Offline tyeeeee1
« Reply #2 - Posted 2013-08-09 03:02:49 »

What I mean is how do you, whoever is reading, go about creating a bunch of drop tables, fill them with items and drop chances and then figure out which items to draw in your games.

The way I do it is above in the github link but I basically fill an int array with the itemIDs and a double array with the drop chances. Then send those into a method to set everything up. Then to figure out what items to drop I create a random float between 0.0 and 1.0 then multiply the float by 100 and any items with drop chances higher than the float will be dropped.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline wessles

JGO Wizard


Medals: 67
Projects: 4
Exp: 3 years


Profile picture isn't relevant.


« Reply #3 - Posted 2013-08-09 03:05:04 »

That really depends on your object framework. There are so many, Ill just let you find them yourself. I don't mean the broad term kinds, but the high level frameworks that differ with each programmer, unless you are copying someone else. Really, there are a ton of ways. Just experiment!

Offline drabla

Junior Duke


Medals: 5



« Reply #4 - Posted 2013-08-09 04:19:10 »

Here is how we did it some years ago - This was for a game with lots of items

We had a Webinterface on which we could add items to a Boss / Mob. The Lootable could be exported and looked kind of like this:

[bossID].table
tdIDlnItemIDtdDropChance
012620.01
113370.50

Every time a boss was loaded (start of level) , a random number between 1 and 100 was drawn for each item on the list.
DropChance was multiplied by the random number. If it was >= 1 we added it to a Collection.

Every Boss/Mobb had a chance to drop say 3 -6 items.
We would than randomly pick (random.nextInt(3) + 3) items from that Collection and wait for the boss to go down.

In the loottable were always enough dropChance = 1.0  items to guarantee something would drop.

Crazy times... Smiley
Offline Cero
« Reply #5 - Posted 2013-08-13 12:46:30 »

Yeah basically like that

every enemy has a droplist: a list of items and the chance in percent.
In my case thise has to be a per enemy list because in my game enemy A could drop a potion with 10% while enemy b could drop it at 30%
if in our game you would say: well no matter who drops it, they always have fixed chances, then you could simplify.
then I would do this per text file - you CAN use xml or json, and you would like to write a small tool for it...

Offline RobinB

JGO Ninja


Medals: 44
Projects: 1
Exp: 3 years


Spacegame in progress


« Reply #6 - Posted 2013-08-13 13:35:30 »

i guess you should loop trough all droppable items.
Each item gets checked against its own random value.
This way not all items with > 30% drop when the number is 30;

Like this:
Chance / CurrentRandom / Item
.01    .0324    1
.10    .1243    2
.22    .3679    3

So this pass only item 1 drops, while the other items had a bigger chance.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (49 views)
2014-10-17 03:59:02

Norakomi (38 views)
2014-10-16 15:22:06

Norakomi (31 views)
2014-10-16 15:20:20

lcass (34 views)
2014-10-15 16:18:58

TehJavaDev (65 views)
2014-10-14 00:39:48

TehJavaDev (65 views)
2014-10-14 00:35:47

TehJavaDev (54 views)
2014-10-14 00:32:37

BurntPizza (72 views)
2014-10-11 23:24:42

BurntPizza (43 views)
2014-10-11 23:10:45

BurntPizza (84 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!