Spell Shield (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.


The Spell Shield from Baldur’s Gate 2 will give a one-time block to the first hit of a spell. No effects will proc and it will act as if it missed. Here’s how we can recreate this 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.

Instructions

Follow video instructions.

You can grab the copy/paste code here:

Place this code inside of your “Spell Shield” state’s notebox. Change the values to fit your game’s settings.

<Custom Select Effect>
// Check if this action is a skill and targets an opponent.
if (this.item() && DataManager.isSkill(this.item()) && this.isForOpponent()) {
  // Create a pool of blocked Skill TYPES.
  var blockedtypes = [];
  // Add the skill type ID's to that pool.
  blockedtypes.push(7, 8, 9);
  // Create a pool of blocked individual skills.
  var blockedskills = [];
  // Add the individual skill ID's to that pool.
  blockedskills.push(249, 250, 251, 252);
  blockedskills.push(253, 254, 255, 256);
  // Check if the skill type or skill ID matches.
  if (blockedtypes.contains(this.item().stypeId) || blockedskills.contains(this.item().id)) {
    // If it does, then store the skill's original success rate.
    this._formerItemSuccessRate = this.item().successRate;
    // Now drop the skill's success rate to 0.
    this.item().successRate = 0;
    // Start an animation to show the spell shield occurred.
    target.startAnimation(53);
  }
}
</Custom Select Effect>

<Custom Deselect Effect>
// Check if there is a success rate stored.
if (this._formerItemSuccessRate !== undefined) {
  // Restore the skill's success rate.
  this.item().successRate = this._formerItemSuccessRate;
  // Remove this spell shield state.
  target.removeState(stateId);
}
</Custom Deselect Effect>

Happy shielding!