Roaming Mend (MV Plugin Tips & Tricks)

From Yanfly.moe Wiki
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.


Thievery is a skill used by Zidane, the protagonist of Final Fantasy 9. Thievery deals damage based on Zidane’s agility and the number of times Zidane has successfully stolen something from his enemies. Now, you can recreate an effect like this for RPG Maker MV, too!

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.

Instructions

Follow video instructions.

Insert this into the Roaming Mend state’s notebox. Change the values to fit your game.

<Custom Apply Effect>
// Set the default charges to 4.
this._roamingMendCharges = 4;
// Calculate the amount of the heal.
this._roamingMendHeal = origin.mat * 4;
// Sets the counter to display the charges.
this.setStateCounter(stateId, 'x' + 4);
</Custom Apply Effect>

<Custom Remove Effect>
// Removes the stored charge information.
this._roamingMendCharges = undefined;
// Removes the stored heal information.
this._roamingMendHeal = undefined;
</Custom Remove Effect>

<Custom Deselect Effect>
// Check if the target took HP damage and has more than 1 HP.
if (this.isHpEffect() && this.isDamage() && target.hp > 0) {
  // Get the stored healing value. If none, it will default to 1.
  var heal = target._roamingMendHeal || 1;
  // Plays an animation on the target.
  target.startAnimation(45);
  // Heals the target's HP.
  target.gainHp(heal);
  // Starts the healing popup on the target.
  target.startDamagePopup();
  // Clears the target's results.
  target.clearResult();
  // Calculates the next charge amount.
  var charges = target._roamingMendCharges - 1;
  // Removes the state from the target.
  target.removeState(stateId);
  // Check if there are more than 0 charges.
  if (charges > 0) {
    // Create an empty array.
    var members = [];
    // Loop through each of the target's alive allies.
    for (var i = 0; i < target.friendsUnit().aliveMembers().length; ++i) {
      // Set the potential variable to the current looped ally.
      var potential = target.friendsUnit().aliveMembers()[i];
      // If the ally doesn't exist, move onto the next.
      if (!potential) continue;
      // If the ally is the same as the target, move onto the next.
      if (potential === target) continue;
      // If the ally is already affected by a different Roaming Mend effect, move onto the next.
      if (potential.isStateAffected(stateId)) continue;
      // If the ally's HP is at zero (hence dead), move onto the next.
      if (potential.hp <= 0) continue;
      // Now that all checks have been cleared, put the potential ally into the members array.
      members.push(potential);
    }
    // Get a random member of the members array.
    var member = members[Math.floor(Math.random() * members.length)];
    // Check if the random member exists.
    if (member) {
      // Play an animation on that random member.
      member.startAnimation(97);
      // Move the Roaming Mend state onto that random member.
      member.addState(stateId);
      // The random member's charges get updated.
      member._roamingMendCharges = charges;
      // The healing amount gets transfered over to the random member.
      member._roamingMendHeal = heal;
      // Sets the charge counter for the random member.
      member.setStateCounter(stateId, 'x' + charges);
    }
  }
}
</Custom Deselect Effect>

Happy mending!