Tips & Tricks – Moody (Pokémon) – RPG Maker MV

Yanfly Engine Plugins is a plugin library made for RPG Maker MV, a wonderful piece of software to help you make that role playing game of your dreams. You can find out more about RPG Maker MV here.

In Pokémon, the Moody passive is a fun passive trait which causes its user to randomly gain buffs and debuffs. In the latest version of the game, the buffed stat goes up quite a bit while the debuffed stat goes down once. The randomly buffed stat and debuff stat will always be different from one another. Here’s how we can recreate this effect in RPG Maker MV!

You can grab the copy/paste code here: 


Insert the following Lunatic Mode code into your Moody passive state’s notebox. Change the values in red to reflect your game’s settings.

<Custom Regenerate Effect>
// This is the number of turns the buffs and debuffs will last
var turns = 5;
// Create a pool for the parameters that can be changed
var allowedParams = [];
// Insert Param ID's you want to randomly add here:
allowedParams.push(2, 3, 4, 5, 6, 7);
// Make a copy of the pool
var result = allowedParams.slice();
// Initialize the parameter ID
var paramId;
// Loop through each of the copied pool's parameters
while (result.length > 0) {
  // Get a randomly looped parameter
  paramId = result[Math.floor(Math.random() * result.length)];
  // Remove it from the copied pool
  result.splice(result.indexOf(paramId), 1);
  // Check if the user isn't at max buffs for that stat
  if (!user.isMaxBuffAffected(paramId)) {
    // Buff the user twice for that stat
    user.addBuff(paramId, turns);
    user.addBuff(paramId, turns);
    // Break the loop
    break;
  }
}
// Make a copy of the pool again
var result = allowedParams.slice();
// Check if the previously initialized parameter has a value
if (paramId !== undefined) {
  // Get the index of the parameter
  var index = result.indexOf(paramId);
  // If it is 0 or greater
  if (index > -1) {
    // Then remove it from the pool
    result.splice(index, 1);
  }
}
// Loop through the copied pool once more
while (result.length > 0) {
  // Get a randomly looped parameter
  paramId = result[Math.floor(Math.random() * result.length)];
  // Remove the looped parameter from the pool
  result = result.splice(result.indexOf(paramId), 1);
  // Check if the user isn't at max debuffs for that parameter
  if (!user.isMaxDebuffAffected(paramId)) {
    // Then add a debuff to that parameter
    user.addDebuff(paramId, turns);
    // Break the loop
    break;
  }
}
</Custom Regenerate Effect>

Enjoy!

Happy RPG Making!


These plugins and Tips & Tricks ideas are made possible thanks to our creative patrons on Patreon! The majority of our Tips & Tricks ideas are placed within the Patreon-exclusive Sample Project for quick and easy access! If you'd like to make a Plugin Suggestion, Yanfly's Patreon-based Suggestion Box a visit here:


If you have any bugs to report, visit the following link:


If you have any questions about Action Sequences, visit the following link:



Thank you!