State Removal after doing x amount of hit types.

Good Evening,

I've tried doing it myself through various other plugins to no avail.

To give an example:

Magic Boost State: Your next 3 Magic Spells will be boosted.

Battler with state casts 3 magic skills, and any number of physical/certain hit skills in between them but the state is not removed until the 3rd magic hitType skill is finished casting.

I am looking to have this extend to physical hitType as well.
You can do this using Yanfly's Buffs & States Core plugin. I tested this in the notebox of a "Magic Boost" state and it seemed to work as intended:
Code:
<Custom Apply Effect>
user.setStateCounter(999, 3);
</Custom Apply Effect>

<Custom Initiate Effect>
if (this.item().hitType === 2) {
  this._amplify = true;
}
</Custom Initiate Effect>

<Custom Confirm Effect>
if (this._amplify) {
  value *= 2;
}
</Custom Confirm Effect>

<Custom Conclude Effect>
var stateId = 999;
if (this._amplify) {
  this._amplify = null;
  user.addStateCounter(stateId, -1);
  if (user.getStateCounter(stateId) <= 0) {
    user.removeState(stateId);
  }
}
</Custom Conclude Effect>
Just replace the 999 values with the ID of your magic boost state. Here I've multiplied the skill output value by 2, you may want something different? The hit types are 0, 1, and 2 for certain, physical, and magical hits respectively (cf. HITTYPE constants in rpg_objects.js at ~line 1206). This Tips & Tricks example was used as a reference: http://yanfly.moe/2016/12/29/tips-tricks-linkens-ring-dota2-rpg-maker-mv/

Original thread: https://forums.rpgmakerweb.com/threads/state-removal-after-doing-x-amount-of-hit-types.92622/