Jump to content
  • Advertisement
Sign in to follow this  
DarkZoulz

Loot tables

This topic is 3906 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm sure this has been discussed before, but I'm working on a looting system for my game (which is a hack 'n slash type deal). I figure i'd go with the classic loot table system. Each enemy has a table of items that they can drop, and each item has a certain percentage of getting dropped. This seems like quite a good system to me, except for the fact that items at the top of the list are more likely to drop than those at the bottom. Let's say I roll successfully for item #2 in the loot table and generate that item for the player. What if item #5 also would have been a successful roll? How would I go about giving all the items in the loot table a "fair" chance of being selected? Are there any other smart ways of distributing loot?

Share this post


Link to post
Share on other sites
Advertisement
Rather than go down the list and trying each item individually, assign a range to each item. Since you want to use percentages make the roll from 1 to 100 then assign loot #1 1 to 5, #2 6 to 15 and so on. This will cause you to only ever drop one item at most.

If you want the chance to drop multiple items, do what you are doing now just don't stop after item #2 dropped keep going and see if other items drop. Or you could do the above then assign a range for dropping this and that. One thing to remember if you do that though is the percent chance of dropping #1 is equal to percent chance of #1 by itself + percent chance of the sum of all groups #1 is apart of.

Share this post


Link to post
Share on other sites
Loop trough the list and test each item for a propable drop, if droped add to a new list. At the end of the iteration randomly pick one.

Share this post


Link to post
Share on other sites
Quote:
Original post by Tjaalie
Loop trough the list and test each item for a propable drop, if droped add to a new list. At the end of the iteration randomly pick one.


That was actually a really good idea. And simple at that. Thanks to both of you!

Share this post


Link to post
Share on other sites
It's hard to see without an example how item 5 could have been an option for a roll of item 2.

That said, a good approach is thus:

Give each item in the loot table just a raw score (not a probability!)

Nothing 1000
Useless Dagger 100
Magical Fluff 10
Useful Belt 1

Loosely speaking, the idea is that Nothing is ten times as common as a useless dagger, which is ten times as common as magical fluff, which is... you get the idea.

Now we normalize the scores to give probabilities:

sum = (S1 + S2 + S3 + S4)
P1 = S1 / sum
P2 = S2 / sum
P3 = S3 / sum
P4 = S4 / sum

so the loot table looks something like this now:

P1 - Nothing
P2 - Useless Dagger
P3 - Magical Fluff
P4 - Useful Belt

such that the sum of the Pn's is equal to one. Then your creep dies, and you generate a random number R, and do something like this (python pseudocode):


r = Random()
choice = -1
for i in range(0,size_of_loot_table):
if r > P:
r -= P
else:
choice = i


In this way, the random number is depleted until it is less than one of the probabilities. This system is order independent (you can put the rare stuff earlier if you want) as well.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!