MV Rouge-like Randomly Generated Loot table with Yanfly PictureCommonEvents

Preface, I'm very much a novice and if something seems out of place it's probably because it is and I didn't know better.

For my game, I wanted to make finding loot more interesting, so I came up with a system that generates loot randomly from a predetermined loot-table. Here's what it looks like.


The way it works is that the chest turns on a switch that then activates this common event.
1747957062962.png


The way this works is for each of the eight "slots" in the chest there is a variable that is randomly set from 1 to 12, and then there is a lot of if-else statements after that, checking to see what number each variable is and then based on that running a script that chooses an image from a pool of images and displays that at the specified co-ordinates.

1747957374833.png

This goes on for awhile.
->Sidenote the variable for each slot is set from 1 to 12, but there is no if statement for if the variable is 12, meaning no image is displayed, and there is (roughly) a 1 in 12 chance for each slot to be empty.

I'm using Yanfly's PictureCommonEvents to make it so each picture links to a common event that either acts as a loot table, randomly giving the player an item from that table, or as a trap.

For example here is the loot table for Daggers, and then the one for the poison trap.
1747957764588.png

1747957783866.png


Ignore the MimicGreed variable for now, the important thing is that the loot tables randomly choose a number and then if the number is chosen, gives the player the corresponding item. The traps meanwhile play a sound, flash the screen a color, and then give some party members the status effects/deal them damage.

->Sidenote: For my game you can have up to 5 active party members. The intention with the traps is that they are supposed to randomly affect up to three of these active party members, but the way I have it evented right now isn't right. If anyone can tell me how to get that working as intended, or if it is impossible/requires a plugin, I would much appreciate it.

When the player has gotten all the loot from the chest, they can hit ESC or the cancel button to activate an event that erases all the pictures onscreen, turns off the switch that started the original common event, and re-enables player input (the script at the start of TreasureChestLootMinigame disables player input so that you aren't able to move your character around while looting the chest).
1747958309099.png


1747958509797.png



Finally the last aspect of this randomly generated loot idea is the idea of what I'm tentatively calling "MimicRerolls".
As you saw at the end of the video, one of the traps the player can activate is the Mimic Trap, which immediately puts you in a fight against a Mimic (right now I'm using the default art as placeholder, I plan to create something scarier in the future).

Here is the battle processing for the Mimic, and this is also where the MimicGreedVariable comes in.
1747959304474.png

If you escape from the Mimic, you lose any chance to get the treasure, the same as if you had left by hitting ESC. If you die to the Mimic, it's game over. But if you win, then all the pictures are erased and then redrawn by turning the original event switch off and then on again, meaning that by killing the Mimic, you just earned yourself another treasure chest!

And since this is the same event, this chest also has the chance to have a Mimic inside it. Mimic-Ception, if you will, meaning you can kill that Mimic to earn even more loot, and potentially roll a third Mimic, and a fourth, fifth, etc., etc.

To balance this, once you leave a chest by hitting ESC, you won't be able to reopen it, meaning you would need to keep fighting Mimics without taking a rest break or healing your party members if you wanted to reroll your loot. And this is where MimicGreed comes in.
Every time you loot a worthwhile item from a chest, it increases the MimicGreed by 1, and every time you trigger a trap, it decreases by 1. My plan is that the MimicTrap event will check what the MimicGreed variable is, and the higher it is, the more dangerous the Mimic you face will be. This way it becomes a risk/reward type system.

Do you purposely activate the Mimic for the upside of more loot? If you do, will you activate it again? How much are you willing to bet you can win? Or will you be swallowed by your own greed?

Anyhow, that's how far I've come with this idea so far. I felt like sharing it because it took a while to figure out how to make it and have it look kind of nice. I'm open to any feedback or questions/concerns about why I did things the way I did. If there's a simpler way to do any part of this, and I've wasted time by overcomplicating anything I especially want to know. Thanks to anyone who reads this, have a nice day.
Jumpscare warning around the 1:20 mark,


Here's another use of this method of making images appear that link to common event lootables with Yanfly's PictureCommonEvents. This time with a spooky skeleton!

1748572193451.png

It pretty much works the same as the chest version outlined above. When you activate the bone piles, it turns on a switch that activates a common event that draws all the pictures, and then each of those pictures is linked to a common event that randomly gives you an item of that type. When it turns on the looting minigame switch, it also sets a self-switch to the empty bones event that makes it so you can't loot the same event twice.


1748572330511.png

1748572411312.png

1748572445393.png


The entire minigame event is just a bunch of variables being set randomly, and then conditionals that draw the pictures based on those variables. The variable "LootAmount" is used to determine which "tier" of loot you can find, and then there are various conditionals in each tier that change the likelihood of getting certain loot types. There are separate variables for Armor, Headwear, Jewelry, and Boots. I did this to diversify the chances of any specific thing spawning.

Also of note, there are two common events for the ring loot tables, that's because a skeleton can spawn with up to two rings, meaning two pictures for the rings have to be drawn that each link to a separate common event that are actually both the same.

1748572847563.png

1748572969564.png


Lastly, as for the how and why of the Defiled Dead jumpscare enemy.

How it works is that each frame you are in the skeleton loot minigame, the variable "AngerOfDefiledDead" is set to go up by 1. (Also, whenever you loot an item off the skeleton, it increases that variable by an amount from 150 to 300.) Once the variable hits 5400 or higher, it triggers a fight with the Defiled Dead enemy, which is supposed to represent the spirit you've angered by robbing the dead.

The numbers might seem a bit arbitrary, but the way I mathed it out was that since RPGMaker MV runs at 60 frames/second, and the Anger value goes up by 1 point per frame, you would need to be in the minigame for a minute and a half for the encounter to happen. And each item you loot would take roughly 2.5 to 5 seconds off this timer, causing the fight to happen sooner.

Right now, the Defiled Dead isn't meant to be a particularly hard enemy, more so just a "speedbump" to test if the player can survive a fight, and a way to break up the monotony of looting. I might make an item/event that you can find in the late-game that will reset the Anger value so that once you can reliably beat them, you are no longer forced to fight them.

That's all I've got for now, thank you to anyone who reads this, have a nice day.

Original thread: https://forums.rpgmakerweb.com/threads/rouge-like-randomly-generated-loot-table-with-yanfly-picturecommonevents.177849/