Thank you for reading this post, you are amazing! Below I will discuss the technique that we are using to create infinite randomized items for the alpha release of our game.
The execution is done in unreal engine using blueprints only but the same principles can be applied in any engine or language.
This system works very well or us and I hope that someone somewhere can find it helpful in some way. If you have any questions or would like to know more please feel free to leave a comment below and we will be in touch!
This system works very well or us and I hope that someone somewhere can find it helpful in some way.
Items in Void Arena are stored as STRUCTS. Here is a quick peek at what that looks like with the engine:
If you are familiar with structs in unreal engine you can jump right to the next bit but if you are unsure about what this means I will briefly explain.
A STRUCT in unreal is a variable that can hold other variables. It is very useful when you need to pass quite a bit of data about an object such as an item with many affixes and stats attached to it. Creating a new STRUCT is easy.. right click in the file explorer in the editor and navigate to “blueprints” then select the last option labeled “Structure”
When you open that structure you will be able to add new variables and assign their corresponding classes.
Now let’s get to the good part. We have a bit of ground to cover but thankfully most of it is more repetitive than complicated.
The first thing that we do is determine the name of the item. We will do this by randomly pulling two words together from a long list of potential names and combining them using the append string node. First we roll a couple of random numbers then we create the name using the value at the index of the random chosen number.
Next we determine the item’s rarity. We are again doing this by rolling a random number, this time between 0 and the length of our array (which will hold values for our rarities). In order to keep this bit simple, we created an array with 15 entries. 7 common, 5 uncommon, 3 legendary and 2 artifact. This will control how often a specific rarity drops and drop rates can be easily balanced by adding or removing entries of a particular rarity.
Then you guessed it! We will roll another random number, this time between 1 & 12. This will now determine what kind of item it is, a weapon or a wearable piece of armor. We will now check if the item is a weapon or armor. If it is a weapon we assign it’s damage based on a random roll. If it is a piece of armor it will do something similar but for the armor value.
The following step is to check the rarity of the item and set up affixes and secondary affixes based on the rarity.
If the item is common it gets 1 random affix:
This will happen up to 4 times based on rarity and will happen again for secondary affixes.
Now that we have determined the item’s affixes, we set all the values using the set member in node and link that up to our struct reference:
Here are some examples of what the randomly generated items look like:
The coolest part of this whole system is that now that we have a reference to the randomly rolled numbers written into new items, we can use these to reference some logic on our player that will fire off when equipping or unequipping items, as well as at the start of the game.
This logic will grant gameplay effects to the character’s ability system component which grants the characters the affixes from the items.
Thank you so much for sticking around with me this far!!!
I hope that this glimpse into our random loot generator will give you ideas on how you can implement this in your own project. If you are just here use you are a fan of Void Arena, I hope this helps to better understand how items are rolled. If you have any questions or would like to participate in the conversation, feel free to leave a comment below!
If you would like to help support us the best things you can do are:
Did I mention that you’re amazing?!?!