MV Help State

When hitting 3 or more enemies in a single attack, Mana +20%.

How to recreate this in rpg maker mv, using yanfly plugins


I tried this way but without success.


Code:
<Custom Conclude Effect>
var hits = 0;
for (var i = 0; i < targets.length; i++) {
  if (targets[i] && targets[i].result().isHit()) {
    hits++;
  }
}
if (hits >= 3) {
  var gain = Math.floor(user.mmp * 0.20);
  user.gainMp(gain);
}
</Custom Conclude Effect>
Don't you need to add there a line to tell what the 'targets' is?
Like below 'vat hits' add: var targets = BattleManager._targets;
Don't you need to add there a line to tell what the 'targets' is?
Like below 'vat hits' add: var targets = BattleManager._targets;


Now the game doesn't crash, but it doesn't restore mana, any idea what it could be? Maybe the hit counters aren't working? I'm using the action sequence "Action Effect: all enemies".
What do you mean? Like you target 1 enemy but then have the action effect hit all? Try looping through the members of $gameTroop.aliveMembers() in your notetag.

Original thread: https://forums.rpgmakerweb.com/threads/help-state.180282/