RPG Maker MV

RPG Maker MV

55 ratings
Creating a Random Loot Drop System
By XIIIthHarbinger
Want to have a random loot drop system in your game, without needing plugins, scripting, or anything else? In this guide I'll show you how to create step by step my system for it, that I use in my own projects.
   
Award
Favorite
Favorited
Unfavorite
Introduction:
Treasure chests are one of the staples of RPG style videogames across the decades, & RPG Maker games are no exceptions. In fact RPG Maker makes the creation of these very items one of the quick event creations hotkeys via ctrl + 3.

However, that hot key set up tends to very specific in what a given chest will provide, & once set up will always provide the same reward on that map every time the player explores that map. So let's add some replayability to our games by having some of our chests being trapped with mimics, & others having random loot. Thereby making our dungeons different every time our players take them on.

In this guide I am going to show you how to make chests in your game, drop random loot scaled to your player's character level, as well as integrate a random chance mimic battle for your dungeons, to make them interesting. Including walking you through creating a chest using that system, that at random will drop gold, items, armor, or weapons scaled to the player's level, or potentially trigger a mimic battle.
Requirements & Recommendations:
Requirements:

Plugins: None.
DLCs: None.
Scripts: None.
Additional Programs: None.

Nothing I am going to show you how to do here requires anything other than the default assets, & a bit of eventing.

Recommendations:

Plugins: Yanfly's Event Chase Player.
DLCs: None.
Scripts: Movement route inserts of plugin scripts.
Additional Programs: None.

I am going to recommend one DLC pack & one plugin here, because these two assets will allow you to fully replicate what I've done with the system in my own project. Which allows the mimics to pursue the player as a visual encounter, once activated.

This isn't necessary to the system, & you might not want to use visual encounters, or have your mimics actively pursue your player. In which case feel free to completely ignore what I did here.

However, if you want to fully emulate what I did in my own project, then you'll need the following:

First, you'll need Yanfly's Event Chase Player plugin to have the mimics pursue the player as a visual encounter, if they escape from the initial battle.

Yanfly's Event Chase Player Plugin[yanfly.moe]

Second, you'll need Katakura Hibiki's MV Monsters volume 1. You can find it here on Steam or on the Official Site. This will provide you with walking mimic sprites that closely resemble the default asset chest characters, as well as alternative battlers.

Feel free to use whichever art style of battler you prefer, I simply recommend the DLC here, because of the walking sprites are drawn to look very much like the default chest assets.

Katakura Hibiki's MV Monster DLC[www.rpgmakerweb.com]

Third, I recommend you create a "treasure room" map, where you can create all of the variants of chests you will have in your game. So that you may simply copy & paste these chests into whatever maps you wish to as you develop your game.
Getting Started:
Before we do anything else, you're going to need to have a working complete "Weapons", "Items", & "Armors" tabs in your database. Understand this doesn't mean you can't add to these tabs at a later date, but you are going to need to have a working set of items, weapons, armors to set up this system. Also you are going to need to create the mimic battles in the "Troops" tab of your database.

Also understand that for your items, weapons, armors, & troops, they don't have to be ready to use. They can simply be a placeholder with a name attached to them, that you will flesh out later in your development; but those place holders will be necessary to set up this system, & won't work without them.

Which is why we're going to set these events up in the database, & then use our events on maps to activate those common events; rather than setting them up as individual events on the maps. So, that we can modify the common event in the database, & it will be applied universally to all of our maps where those events are called up.

Additionally you'll need to determine your weapons, armors, & item types; As well as decide how many quality tiers you intend to have for items like health potions, as well as how many quality tiers for your weapons & armors. For example in the system I am going to show you, I use four tiers of item quality, & five tiers of weapon & armor quality.

Remember though, this guide, like all of my other guides, are not intended to tell you how you must set up these systems in your game; but rather to give you an example of how I've set them up in one of my own projects; & provide you with the necessary information for you to formulate a similar system for your own games.

Once you've set up your armors, weapons, & items you'll need to designate your common events in the database that will serve for the various chest events, based on the desired level of variety for your game, & whether or not you are intending to use mimics in these events.



For example in this project I use four different mimic troop variants; as well as five loot type events. Specifically gold, items, armors, weapons, & all four combined. Resulting in five loot version events where there aren't any potential mimic battle results; & five loot versions of each of the four mimic variants.

However, regardless of the variety of these events, all of them will have the same settings in our example, as far as triggers & switches. Namely, set the trigger to "None", because we'll be using individual events to call them up.

Now that you've designated your intended common events to serve for the various loot variants in your game, it's time set up our variables that these events will operate on. The terms I'll be using for these variables are based on my own project, & I'll be using them here to correspond to the screenshots; obviously you won't need to use those names for your variables, but you will need variables that serve the same purposes in your own project, so set them up now.

1) Treasure.
2) Gold.
3) Item.
4) Weapon.
5) Armor.
6) Level.
7) Enemy. (optional).
First RNG Sequence:
Now that we've established our required variables, & designated our intended common events; it's time to create the first branch in what I call a conditional branch tree. The design principle is rather akin to that of a Matryoshka doll, where the manipulation of one our variables is activated by an RNG sequence, & then assign various conditional branches based on those respective variable's values.

For our example, our first step will be to assign a value to the "Treasure" variable, via common event "Control Variables", & having the value randomly set between two numbers. In the case of our example one thru five.





The purpose of these values in our example will be as follow, "1" will activate our mimic battle sequence, "2" will activate our weapon loot sequence, "3" will activate our armor loot sequence, "4" will activate our item loot sequence, & finally "5" will activate our gold loot sequence.

However, it's important to reiterate here that this formula isn't one you are obligated to follow, both because you'll need to adapt it to reflect your own game; & because these numbers are how you effect the probability of the outcomes.

For example, if we wanted to increase the chances of getting gold, weapons, armors, & items being received; while reducing the chances of battling mimics; we could change the range from 1 thru 5 to 1 thru 10. Then assign our gold, armors, weapons & items sequences to numbers six thru ten, while keeping mimc battles exclusive to the "1" outcome.

Once the first RNG sequence is established, assign a conditional branch to each value within the specified range, in the case of our example one thru five. Giving us five total branches to work with.





You might be wondering at this point, why are we starting with the largest common event; after all, wouldn't it be easier to set the smaller versions first? The reason why we are going to set up the common event that will be the largest out of all of our examples is simple.

Once you've set up this largest variant, in which all of the sequences are involved; you'll be able to copy & past those sequences directly into the smaller common events. For example if you are making a chest that will only have gold, without the possibility of a mimic ambush, you'll be able to simply copy & paste what comes after the conditional branch of "Treasure = 5".

Then you'll be done, because you've already put in all the work to establish the sequence in first & largest event.
Mimics Lurking Everywhere:
Now that you've designated the required variables for our system, chosen the slots in your database for your common events to serve for your intended various chest variants, & set up our five conditional branches based on the "Treasure" variable value, we're ready to create our template treasure chest.

To do this go to your "Treasure Room" map if you created one, though any map will do; & while in event editing mode, either right click your mouse to a tile, then select quick event creation "treasure", or press hot key ctrl + 3. This should bring up the treasure chest creation menu.



Select whatever you like to be in the chest it doesn't matter, the important thing is what goes into the creation of the event formula.



Namely the format of the event. Which will be consistent throughout all of our treasure chest variants. The movement route & sound effects to illustrate the opening of the chest. The chest being directionally fixed so that it doesn't turn to "face" our player's character based on their relative position. The activation trigger being the action button. The priority being the same as the character. & a second event page activated by "Self Switch A" which our chest changes to once it's been emptied.

Now for any of your chest variants that won't have a mimic battle mechanic, you can simply use this preset template, & then replace the "Contents" portion with one of the common events you create in your database. The movement route & sound effect can be copy pasted into each outcome of the second RNG sequence of the common event, as we set them up. Because, all of the chest image files have the same layout, so the movement route will work regardless of which chest image file you select.

Alternatively, you can keep the movement route & sound effects that are generated by the preset; & then remove the self switch commands, dialogue boxes, & prescripted inventory addition, & replace them with the common event.

The only thing that will change from outcome to outcome, will be the contents of the dialogue box which describes what the player receives, which you can edit to reflect the different results; & the actual changes to the player's inventory.

Remember the idea is to set up our extensive common event once, then copy & paste the relevant portions, into their own more selective common event versions; then attach each one of these common events to a template "Treasure Chest Event" on a map. After which we can simply copy & paste those templates into as many maps as we need. Rather than eventing them all over again from the beginning.

Now go to your template common event you should have already created, find the conditional branch "Treasure = 1", & click on the space below it. On the third page of common events, find Battle Processing, & set up your mimic battle like so.





After you've set up the battle processing, copy the movement routes & sound effects that illustrate our chest opening, & paste them directly below the conditional branch "Treasure = 1" but above the battle processing. This way the aesthetics of opening the chest persist, before giving way to the mimic battle. Then in the battle processing open up the contents & find the control Self Switches on the first page.



For your win condition turn on Self Switch C, for escape turn on Self Switch B. Like so.



Normally, self switches are laid out in the event itself, but because we're having the activation of our treasure chest call up a common event; we can manipulate the self switches of the event itself, in a prescribed formula from the database. Without having to use normal switches, or programing the event each time. Just clear out the contents of the first event page of our treasure chest template, & replace it with calling up our template common event.

Now, since we are creating a treasure chest with a potential mimic battle we will need an additional two event pages, added to the template. One activated by self switch B, & one activated by self switch C, that we've already set up in our common event. The end result of which will look like this.









Now, as you might have guessed already, the initial page is obviously the activation page for our common event, just like with our chests that won't have mimics. The second page activated by self switch "A" is the followup page, to any actions derived from the treasure variable coming up as something other than "1", & thus not creating a mimic encounter. The third page page activated by self switch "B", will serve for when the player activates a mimic but then escapes from that battle. The forth & final page of the event is for when the player triggers a mimic encounter, but wins the subsequent battle.

Understand, if you don't intend for your player to be able to retreat from a mimic battle the third event page will be irrelevant; & thus you have no need to create it. Additionally if you are going to have the retreat option available, place a "wait" command after "escape", so that your player can actually create distance from the mimic character. Especially if you are using Yanfly's event chase player plugin as I recommended or something that serves an equivalent function. Otherwise your player will simply become caught in a perpetual loop, where as soon as they escape they will be placed back into battle with the mimic they escaped from.

Furthermore, the script codes in the movement route are intended to be used with Yanfly's Event Chase Player, which I won't be going into detail here. Feel free to use whatever system you like, or to have the mimics remain affixed in place, or even vanish if the player escapes from the battle. The important thing is the wait function for a sufficient number of frames, to allow the player to open distance if you want escape to work. & not to check "Wait for Completion", otherwise your player won't be able to move.

Finally, I strongly recommend you follow my example of an empty event page, for "Self Switch C on" victory condition; rather than something like an open chest that would normally replace the treasure chest event once opened. The reason being, that if the event pursues & engages your player, & is then subsequently defeated; it can block the player's movements, & potentially create an impassable barrier that will prevent their advance. Perhaps even effectively "dead end" their playthrough.
Scaling of Loot to Player Levels:
Now that we've established how our mimics function in our template common event. We need to establish a method for scaling to our player's level, & an RNG element to determine what the player receives. So let's scroll down our template common event to "Treasure = 2" & begin to set up our Weapons sections.

Well obviously we don't want our player getting end game weapons at level one, so we need a way to filter what they can potentially get, based on their current rate of game progress. So how do we do it?

At first you might be inclined to think, "I know I'll just create a conditional branch based on my player's level's."

Not a bad idea, let's try it out.





Well, that's disappointing. Now how are we going to scale our loot to our player's current level?

Simple, we're going to create a work around. How? Easy, we know that our conditional branches can be used to evaluate variables; so, we're going to take our "Level" variable, & tell our game to match the variable "Level", to our main character's Level, like so.





Once we've set our "Level" variable to correspond with our main characters level, we'll need to set tiers based on those variable values. For our template we're using five different tiers of weapons, so for convenience sake we're going to separate them by levels of five.

By using conditional branches like a set of Matryoshka dolls, each one with an else branch; with the condition to be met an amount higher than a particular value, with the else branch being a subsequent lower value conditional branch, like so. Until the criteria of one of those conditional branches is met.





The end result being:
If Level > 20 = Master Level Weapons.
Else
If Level > 15 = Adept Level Weapons.
Else
If Level > 10 = Journeyman Level Weapons.
Else
If Level > 5 = Apprentice Level Weapons.
Else
Level >/= 1 = Novice Level Weapons.

Now, you might be asking, but how do I know what to set my "level" criteria for my conditional branches at?

The answer is simply, you don't; nor can I tell you what you should set those "Level" criterias at either. Which is why we're using common events.

Balancing is one of the more difficult stages of late game development, & your project probably isn't at a stage where you can reliably gauge where these levels should be. Furthermore, there really isn't a magic formula that's going to let you predict at a glance, how to balance your game. As the number of factors that go into it, are numerous, & will likely change over time as you develop your project.

However, because you're using common events as your loot generator; when you're in late Alpha & early Beta stage testing, you can rather easily shift what you're player will find in dungeons, by simply altering the "Level" criteria of the conditional branches in the common event. Rather than individually fine tuning each chest in every location.

Because any change to the common event, will apply to all chests that call up the common event.
Multiple Main Characters
Now you may be asking, but what if I have more than one main character, how do I set up my level scaling method then?

Well that's going to depend on how many potential mains you have in your party.

For example in the project I am using for this example, I have two potential mains a male & a female, & the player chooses which one they desire to play as. Because I only have the two mains, I use a conditional branch based based on which one is in the party.





Which works if you are intending for an either or scenario in your game, based on multiple protagonists, or your heroes dividing into teams.

On the other hand, if you are intending to create a game with numerous potential characters in your party, who may or may not join you based on in game choices you're going to need to get a bit more creative.

First, I recommend you create a "Level" common event to be placed where our normal "Level" variable control event is. This is due to the potential inherent complexity, & to make our random loot drop common events take up less space.

Then, we're going to have to get a bit creative. Namely, instead of having the "Level" variable match the main character's current level; have each of the party's potential members check to see if they are in the party, & if they are, add their respective levels to the "Level" variable, like so.





Then we will need to divide the total accumulated "Level" of our party, by the number of party members like so.



Like always, determine the method best suited to your respective game.
Second RNG Sequence Weapons, Armor, & Items:
Now that we've created our level scaling tiers & attached them to our common event, it's time to apply the second RNG sequence. Items, Weapons, & Armors all function in essentially the same manner.

Namely, we'll create an RNG sequence just like before.



Then create various conditional branches based on those RNG outcomes, like so.





Then assign an individual item, weapon, or armor to be added to our inventory when that outcome is created like so.





Mechanically speaking there really isn't any difference between how you'll implement your armor, weapons, & item sequences; save for the total variance of the second RNG sequence, for example one thru fifteen for weapons but only one thru fourteen for armors. As well as potentially having different numbers of quality tiers that are scaled to the player character's current level.

However, the placement of our second RNG sequence can be situationally dependent.



As you can see from the screenshot above, I placed the second RNG sequence above the level conditionals, so it only has to be created once, rather than following each subsequent conditional branch of the "level" variable.

Simply put, this works for my project shown here, because in that game, the player starts out with access to all potential weapon types, & their advancement is due to acquiring more powerful variants as they advance, rather than new types of weapons.

If on the other hand, the player gains access to new weapons, armors, or item types in mid to late game, this might not be ideal. & in fact you might be better served by having the RNG range vary depending upon your Character's "Level" tier. Which will mean placing the second RNG sequence after the corresponding "Level" conditional branch.
Second RNG Sequence Gold:
Finally we come to creating our gold sequence.

Now this sequence varies a little from the the weapons, armors, & items sequences. However, many of the same things still apply.

We'll still use the "Level" variable to scale what our player receives, & we'll still attach conditional branches based on those level tiers, like so.



However, unlike our weapons, armor, items sequences, where the placement of the second RNG sequence is determined by necessity; in our gold sequence the second RNG should always come after the "Level" conditional branches. Because, we are going to use the range of the "Gold" variable to determine what the player receives, so each "Level" tier will by extension possess a different "Gold" variable range for its respective RNG.

Like so,



Which in turn, we will use to determine how much gold the player receives, like so.





Now you might be asking, well then how do I create a dialogue box to describe what the player received? The weapons, armors, & items were easy, I just described the item chosen by the RNG sequence. But here, we are talking about a range in the dozens maybe even the hundreds, or thousands.

It's rather simple actually, & one of the reasons why we have a gold variable, which in the case of our example project, "Gold" is Variable 62. We simply tell the dialogue box via text code to use the amount of the gold variable in our message, like so.



Which will replace the text code, with the "Gold" variable amount, that we just used to determine how much gold the player received.
Summation:
In conclusion, while this guide is written to demonstrate implementing a random loot generator mechanic when the player opens a treasure chest, it is by no means limited to just that purpose.

Enemy drops, quest rewards, etcetera can just as easily be used to implement those same sequences. Because the only thing that is inherent to a treasure chest, are the movement routers, sound effects, & self switches that alter the aesthetics of the chest & control the mimic battle mechanics.

Remove them, & the sequence can easily be used to provide weapons, armor, items, &/or gold similarly scaled to the player character's current level. & can be used to keep side quests & the like relevant, even for your late game players. Simply insert the random loot generator sequence or even sequences of choice into a quest completion dialogue, or as a consequence of winning a battle process.

The important thing in these guides, is not to replicate what I've shown you; but to understand how to create them yourself, & then alter them to best serve your own game.
< >
2 Comments
JadedGamerZ 19 Feb @ 3:01pm 
wow. this is making me rethink using Unity
terrypynn 16 Dec, 2019 @ 6:58am 
Cool walkthrough. Will probably try to implement something like this in a game sometime.:steamhappy: