Auto-Potion (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.


In Final Fantasy Tactics, Auto-Potion is a reactive effect that makes characters utilize the lowest level health Potion they have available whenever they have taken direct damage. This way, they can consistently mitigate damage. Here’s how to recreate that effect in RPG Maker MV!

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 find the copy/paste version of the code here:

Place these notetags into your Auto-Potion skill’s notebox. Change the values to fit your game’s settings!
// Make this skill react as a counter to anything.
<Counter Condition>
</Counter Condition>

<Custom Requirement>
// Set the original condition to false.
value = false;
// If the user is an actor...
if (user.isActor()) {
  // Create an array of valid potions the counter can use.
  var potions = [];
  // Add the ID's of the potions that can be used for Auto-Potion.
  potions.push(1, 2, 3, 4);
  potions.push(5, 6, 7, 8);
  // Loop through each of the potion ID's.
  for (var i = 0; i < potions.length; ++i) {
    // Get the current ID.
    var id = potions[i];
    // If the party has this potion in its item bag...
    if ($gameParty.numItems($dataItems[id]) > 0) {
      // ...then set the value to true.
      value = true;
      // ...and break the loop.
      break;
    }
  }
// If the user isn't an actor...
} else {
  // ...then the condition is automatically fulfilled.
 value = true;
}
</Custom Requirement>

<After Eval>
var potions = [];
potions.push(1, 2, 3, 4);
potions.push(5, 6, 7, 8);
for (var i = 0; i < potions.length; ++i) {
  var id = potions[i];
  if ($gameParty.numItems($dataItems[id]) > 0) {
    var item = $dataItems[id];
    if (user.isActor()) {
      $gameParty.loseItem(item, 1);
    }
    this.setItem(id);
    var text = '<CENTER>' + user.name() + ' uses \\i[' + item.iconIndex + ']' + item.name + '!';
    BattleManager.addText(text);
    break;
  }
}
</After Eval>

<setup action>
display action
action effect
</setup action>
Inside of the Auto-Potion state’s notebox, place these notetags. Change the values to fit your game’s settings
// This is the ID of the Auto-Potion counter skill.
<Counter Skills: 24>
// This is the number of times the user can use Auto-Potion per turn.
<Counter Total: +20>

Happy potions!