Tips & Tricks – Lightning Rod (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.

Lightning Rod is an ability in Pokémon that will draw thunder attacks towards a unit. This time, we’ll make it draw those attacks and nullify it, too, using the power of auras!

You can grab the copy/paste code here: 

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

<Custom React Effect>
// Check if HP damage is dealt
if (this.isHpEffect() && value > 0) {
  // Get the lightning element's ID
  var lightningId = 9;
  // Get the action's current elements
  var elements = this.getItemElements();
  // Check if the elements contains lightning
  if (elements.contains(lightningId)) {
    // Set damage dealt to 0
    value = 0;
    // Get the parameter to alter
    var paramId = 4;
    // Set how long the buff will last
    var turns = 5;
    // Apply the buff to the target
    target.addBuff(paramId, turns);
    // Play an animation on the target
    target.startAnimation(51);
  }
}
</Custom React Effect>

Insert the following code in the aura effect that alters foes. Change the values in red to reflect the game’s settings.

<Custom Action Start Effect>
// Get the current action.
var action = user.currentAction();
// Check if the action exists and targets an opponent.
if (action && action.isForOpponent()) {
  // Get the lightning element ID.
  var lightningId = 9;
  // Get the Lightning Rod origin state ID.
  var lightningRod = 229;
  // Get the action's elements.
  var elements = action.getItemElements();
  // Check if the elements contain Lightning.
  if (elements.contains(lightningId)) {
    // If the do, create a new pool.
    var pool = [];
    // Get the opponent's unit's alive members.
    var group = user.opponentsUnit().aliveMembers();
    // Loop through each one.
    for (var i = 0; i < group.length; ++i) {
      // Get the currently looped member.
      var member = group[i];
      // Check if the member exists and is a Lightning Rod origin.
      if (member && member.isStateAffected(lightningRod)) {
        // Add that member to the pool.
        pool.push(member);
      }
    }
    // Check if the pool's size is larger than 0.
    if (pool.length > 0) {
      // Get a random Lightning Rod origin from the pool.
      var rod = pool[Math.floor(Math.random()* pool.length)]
      // Set the action's target to the Lightning Rod origin.
      action.setTarget(rod.index());
    }
  }
}
</Custom Action Start Effect>

Insert the following notetags in the aura effect that alter allies.

<Null Physical Taunt>
<Null Magical Taunt>
<Null Certain Taunt>

Enjoy!

Please wait while you are redirected...or Click Here if you do not want to wait.