Yanfly's ATB System Question (Ability Charging Phase)

Hi all!

I'm trying to set some things up for a project using Yanfly's ATB system. Namely, I'm trying to identify a way to execute certain actions when an enemy or actor begins charging up a skill.

The process for the ATB system works as follows:

1: The battler's "speed" gauge begins to fill up.
2: Once the speed gauge is full, the battler selects an action.
3: The "charge" gauge begins to fill up.
4: Once the charge gauge is full, the skill executes.

What I'm looking to do is to have various things occur immediately after #2, right as #3 begins - and last for the duration of #3 - but get removed after #3 is completed. (For example, while a skill is charging, the battler receives a passive state.)

Everything I've tried has only applied the effect AFTER #3 has completed, rather than just as it begins.

Here is the plugin in question: http://yanfly.moe/2015/11/06/yep-24-battle-system-active-turn-battle/

I would appreciate any help anyone is willing to offer! The main issue is I'm not really sure how to identify the start of the "charge up" phase.
I actually kind of found what I'm looking for in the plugin:

Code:
Game_Battler.prototype.updateATB = function() {
    if (this.isDead()) return this.resetAllATB();
    if (!this.canMove()) {
      this.updateATBStates();
      return;
    }
    if (this.isATBCharging()) {
      if (!this.currentAction()) this.resetAllATB();
      if (this.currentAction() && this.currentAction().item() === null) {
        this.resetAllATB();
      }
    }
    if (this.isATBCharging()) {
      var value = this.atbCharge() + this.atbSpeedTick();
      this.setATBCharge(value);
    } else if (this.atbRate() < 1) {
      var value = this.atbSpeed() + this.atbSpeedTick();
      this.setATBSpeed(value);
    }
};

"this.isATBCharging" basically means it's charging up a skill.

So here's my revised question: How can I use that little snippet in database items to do some pretty neat stuff?

General ideas I'd like to implement with this:

Always on passive state with the following conditions (for example):
  • if "this.isATBCharging" AND skill type = Magic -> Apply State "Casting"
  • if "this.isATBCharging" AND skill type = Weapon Skill -> Apply State "Charging"
Enemy AI could then prioritize casting Silence or Stun on PCs who are in the "Casting" state, or Blind or Sleep on PCs in the "Charging" state.

Or equipment could have something like "if state = Casting, speed up ATB by 50%", or add resistance to Silence, etc...

I think I just need some help getting started on the passive state, because I'm a bit lost on how to setup such a thing.

Original thread: https://forums.rpgmakerweb.com/threads/yanflys-atb-system-question-ability-charging-phase.94774/