Lightning Shield

This week I’m going with another added effect state. Lightning shield is an active buff state that causes the affected battler to discharge lightning to all enemies when hit by a physical attack.

This state paste code will make use of our new plugin that I just released earlier today, which will make the copy + paste code for it much simpler to use and read. The plugin handles the calculations of the waiting and does the damage popups automatically based on the animation Id used.

So lets just jump into it.

What you need:

Our first state is the shield state. This is the state that is applied to the target when the lightning shield spell is cast on them. It has a turn duration, and some info in the note box.

lightningshieldstate

Here is the copy-paste code for this state:

<Custom React Effect>
if (this.isHpEffect() && this.isPhysical() && !target.isStateAffected(27)){
 user.addState(27)
 target.startAnimation(77, false, 0)
 for (i = 0; i < $gameTroop.members().length; i++){
  if (!$gameTroop.members()[i].isDead()){
   $gameTroop.members()[i].shddmg = origin.mat * 2
   target.addState(27)
   performStateAnimationDmg2(76, $gameTroop.members()[i], (Math.floor(($gameTroop.members()[i].shddmg) * ((Math.random()*40)+80)/100)), 4);
   $gameTroop.members()[i].shddmg = undefined
  }
 }
}
</Custom React Effect>
<Custom Deselect Effect>
target.removeState(27)
</Custom Deselect Effect>

StateId 27 is used as a fail safe to make sure that a lightning shield doesn’t trigger multiple times on the same action. Without it being applied and checked for, an attack that hit’s three times would trigger the shield three times as well.

The results?:

Have a look for yourself.

Leave a comment