Yanfly ATB change skill casting time via passive state

Hi all,

I am currently using Yanfly's ATB Battle System and Auto Passive States.
What I want to do is to make different casting time for different skills.

Specifically, in Yanfly's ATB system, one turn has stages of
1. wait for speed gauge to be filled,
2. commit an action
3. wait for charge gauge to be filled
4. do action
What I need is to increase the time cost for stage 3 depending on skills.

Since the gauge filling speed depends on the actor's agi,
so I made a passive state that reduces the user's agi by 50% with the custom condition:
<Custom Passive Condition>
if (user.isATBCharging()){
condition = true;}else{
condition = false;}
</Custom Passive Condition>
and added the <Passive State: 1> to the testing actor.

But during my test, the passive state does not show up in the stage 3 automatically,
the state only shows up in the stages 3 after a enemy hits the actor.
Similarly, the passive state does not go away in the stage 4 or the next stage 1, unless someone hit this actor.
Does any one know how to fix this problem? or is there any alternative way to make this features?

Note 1: I checked the .isATBCharging() function in the developer tool, the function's return is correct, so the problem should be
why the passive state doesn't not apply on time.
Note 2: I know the skill editor can set the invocation speed, and it can work. But, the allowed speed range is only -2000 to 2000, it is not enough for me to make a really long casting time.
Note 3: I know the Yanfly's ATB system is not supported anymore. Please let me know if this is a conflict that cannot be solved...
Just found a solution...

The problem is the battler does not update the state on time.
I just modified the Yanfly's ATB plugin, and inserted "battler.refresh();" in the isBattlerATBCharged function,
so that the battler is forced to refresh whenever the ATB stage is checked:

Code:
line 1246:
BattleManager.isBattlerATBCharged = function(battler) {
    battler.refresh();
    if (!battler.isATBCharging()) return false;
    if (battler.atbChargeRate() < 1) return false;
    if (battler.isConfused()) {
      battler.makeActions();
      if (battler.isActor()) battler.makeConfusionActions();
    }
    return battler.currentAction() && battler.currentAction().item();
};

Not sure if this is the best place to refresh the battler,
but at least it can work for now.

Original thread: https://forums.rpgmakerweb.com/threads/yanfly-atb-change-skill-casting-time-via-passive-state.109890/