Lightning Rod (MV Plugin Tips & Tricks)

From Yanfly.moe Wiki
Revision as of 14:12, 9 July 2019 by Yanfly (talk | contribs) (Created page with "{{Yanfly Tips & Tricks MV |preview = <youtube>https://www.youtube.com/watch?v=z-XI8dasvbc</youtube> |desc = Lightning Rod is an ability in Pokémon that will draw thunder at...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Welcome to the wiki! This is where you can find resources from Yanfly.moe, Ækashics.moe,
VisuStella, Caz Wolf, Fallen Angel Olivia, Atelier Irina, and other affiliated content creators.


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!

Required Plugins

The following plugin(s) is required to create this Tips & Tricks effect:

For help on how to install plugins, click here.

For help on how to update plugins, click here.

About

This is a Tips & Tricks effect created for RPG Maker MV. Tips & Tricks are not to be confused with plugins. Instead, they are usually customized code created for the sake of producing unique features/effects that do not require an entire plugin to do.

Yanfly Engine Plugins

This Tips & Tricks effect is made possible due to the Yanfly Engine Plugins library.

Click here if you want to help support Team Yanfly on Patreon.

Warning for RPG Maker MZ Users

Warning.jpg

If you are using RPG Maker MZ and VisuStella MZ, the following code may or MAY NOT work as this Tips & Tricks is made for RPG Maker MV. VisuStella MZ is NOT responsible if this Tips & Trick does not work because the code base for RPG Maker MV and RPG Maker MZ are different and the code base between Yanfly Engine Plugins and VisuStella MZ is even more drastically different.

Instructions

Follow video instructions.

You can grab the copy/paste code here:

Insert the following code into the origin state’s notebox. Change the values 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 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!