How to Randomly Generate Loot: Part 2

UPDATE: I accidentally published a draft.  Here’s the complete post.

Part 1: What Makes a Gun?

Part 2: Money & Pie

Gun Pie

Proportions are what random generation is all about.  Whether you’re generating a gun, a sword, or a hero costume, everything you put into it is just one part of a bigger whole.  So when you add more of one ingredient, you have to take away from somewhere else.  This fundamental limitation is what keeps any one item from being ridiculously, stupidly awesome and overpowered.

Money & Pie

A pie chart is an easy way to visualize proportions.  Consider the chart above.  It represents a simple gun that does a lot of damage, but isn’t such a great choice if fire rate, clip size, or reload speed is what you’re after.

You can vary the characteristics of the gun a lot by changing the proportions. Not so good at aiming? Try this:

Reload speed + fire rate =

Don’t care so much about tactics and just want to asplode things?

Damage + fire rate =

If this seems a bit abstract, then think of it like a budget. Imagine Jakobs was designing the Bleedinator and had a fixed budget of $2,000,000. They’d have to decide how much of that money goes to improving the gun’s damage, and how much of it goes to building a heat sink that supports that massive fire rate. Take the same chart as above, but this time with dollar figures representing the salaries paid to the people in charge of those departments:

Bleedinator's budget. Employees were all Claptraps.

In Part 1, I said that an item’s worth is far from unimportant: thinking of a randomly generated loot in terms of total worth can be handy when you want to develop a random generation algorithm that scales items’ power along with the player.  A gun’s pricetag can act as a multiplier for its many characteristics.

For a simple example, let’s imagine making random guns for a new player starting at level 1.  We make a rule: level 1 players get guns worth $100,000, level 2 players get guns worth $200,000, and so on.  Just like in real life, you get what you pay for, and in a given level, the attributes the player sees on his guns will float in a range appropriate for level 1 players.  Then, as the player levels up, he’ll see those attributes improve as more “money” is spent on them.

But this makes for a pretty boring economy, right?  Any player will quickly realize that all their guns sell for the same amount.  We need to randomize not just the guns’ attributes, but their worth, too.  Refining our rule for budgets, let’s say that level 1 players get guns worth anywhere between $100,000 and $200,000, level 2 players get guns worth $150,000-$250,000, etc.

If you wanted to get even more elaborate, you can randomize a gun’s worths based on a curve.  This adds a simple “rarity” mechanic, whereby every now and then the player will get an exceptionally good gun.  Start by rolling a random number between 0.0 and 1.0.  Then find the worth corresponding to that number on a “rarity curve”:

Rarity Curve (x^4)

With this (simple and exaggerated) curve, about 10% of your guns–those created when you rolled between 0.9 and 1.0–are likely to yield worths between about $215,000 and $200,000.  A majority of your guns, though, will end up on the $150,000 side of the scale.

This is just one approach to randomly generating loot.  It’s a model that’s based on carving pieces of quality out of a chunk of predetermined worth.  Another model might use rarity as a starting point.  It’s nowhere near as sophisticated as what you’d find in Borderlands or Diablo, but it illustrates some of the important relationships and constraints among all the factors in play.  As we move closer to writing code around this idea, there remain lots of gotchas to consider, like making sure that none of your slices are so small as to be worthless.  I’ll explore some ways to work in some of the more abstract characteristics, like ammo type and elemental (optional) attributes.

    • jovko
    • July 11th, 2011

    Part 3?

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.