Managing Random Item Drops

I’ve recently seen an implementation of random item/unit drops that was

  • too complex
  • difficult to understand actual odds
  • annoying to change values in

The script checks for a new random number every time and uses a chain of if statements, which looks like this:


This logic is flawed because all other odds are only applied after the previous chance fails:

If you want to create correct odds, I recommend using type groups. They provide a much clearer overview of success odds. Here’s how they work:


Create type groups by going to the entities workspace, then selecting ‘Global Variables’. Create a new item type group, then put all the required loot items into that item type group. If you need there to be a way to pull nothing, add a ‘nothing’ item as well. Then give each item a probability. You can get an individual item’s chance of being pulled by adding all probabilities together (ex: 5+50+8+12+25 = 100, so dog has 8/100 = 8% chance).

Here is an example of a basic implementation of item type groups (left click for random loot):


I also added a feedback message that lets the user know what they pulled.

1 Like