Tips & Tricks – Erratic Deflector – 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.

The Erratic Deflector is an interesting effect. It deflects damage equal to 4x the user’s DEF/MDF, whichever is higher. The amount deflected will be split evenly across random allies. And the Deflector has a 20% chance of failure while active. It’s a rather random way of defense, but it can certainly keep things interesting! Here’s how we can make this effect in RPG Maker MV!

You can grab the copy/paste code here: 

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

<Custom React Effect>
// Check if this action deals HP damage
if (this.isHpEffect() && value > 0) {
  // The success rate of the deflector
  var successRate = 0.80;
  // Check if the success rate passed
  if (Math.random() < successRate) {
    // Get the target's alive allies
    var allies = target.friendsUnit().aliveMembers();
    // Check if the ally count is more than 1
    if (allies.length > 1) {
      // Remove the target from the allies
      allies.splice(allies.indexOf(target), 1);
      // Set the maximum amount of total targets
      var max = Math.min(allies.length, 4);
      // Set the minimum amount of total targets
      var min = 1;
      // Get a random number between them
      var totalTargets = Math.floor(Math.random() * (max - min + 1) + min);
      // Loop the amount
      while (allies.length > totalTargets) {
        // Remove random allies from the pool
        allies.splice(Math.floor(Math.random() * allies.length), 1);
      // Calculate the redirected damage
      var redirectedDamage = Math.min(value, Math.max(target.def * 4, target.mdf * 4));
      redirectedDamage = Math.ceil(redirectedDamage / totalTargets);
      // Reduce the value of the damage
      value = value - redirectedDamage;
      // Loop through the remaining allies
      while (allies.length > 0) {
        // Get the currently looped ally
        var member = allies.shift();
        // Check if the ally exists
        if (member) {
          // Make that member take damage
          // Display a popup
          // Show an animation
          // Check if the member is dead
          if (member.isDead()) {
            // Collapse the member
          // Clear the member's results
</Custom React Effect>


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, Plugins, and Lunatic Pack 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!