Share Life (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.


Share Life is a skill from Summoners War that evens out the HP percentage of all allies and throws in an additional 15% heal, too! Here’s how you can make this skill!

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.

Get the copy/paste version of the code here:

Place this inside of your skill notebox. Replace the text with settings that fit your game.
<Before Eval>
// Check if the shared life rate has been defined.
if (this._sharedLifeRate === undefined) {
  // If it hasn't. Set it to 0.
  this._sharedLifeRate = 0;
  // Get the alive members of the party.
  var members = this.friendsUnit().aliveMembers();
  // Loop through each member.
  for (var i = 0; i < members.length; ++i) {
    // Get the current member.
    var member = members[i];
    // Add the member's current HP rate.
    this._sharedLifeRate += member.hpRate();
  }
  // Once the loop is done, divide the total by the number of members to get the average.
  this._sharedLifeRate /= members.length;
  // Add to it 15%.
  this._sharedLifeRate += 0.15;
}
</Before Eval>

<After Eval>
// Check if the target is alive.
if (target.isAlive()) {
  // If the target is, calculate the target HP to bring the target to.
  var targetHp = Math.floor(this._sharedLifeRate * target.mhp);
  // Calculate the difference between the target's current HP and target HP.
  var difference = targetHp - target.hp;
  // If the difference is larger than 0...
  if (difference > 0) {
    // Play a healing animation.
    target.startAnimation(41);
  // If the target is less than 0...
  } else if (difference < 0) {
    // Play a damage animation.
    target.startAnimation(54);
  }
  // Check if the difference is not 0...
  if (difference !== 0) {
    // Alter the target's HP.
    target.gainHp(difference);
    // Start the damage popup.
    target.startDamagePopup()
    // Clear the results.
    target.clearResult();
  }
}
</After Eval>

Happy sharing!