MV Yanfly Instant Cast and Actor Auto Battle AI not working.

In my battle system you get an instant cast "movement" turn which is limited by a state, then a normal turn. I have it working for actors and enemy AI but not Actor AI for some reason. The Actor AI will only use one skill no matter what.

Enemy even get an extra "thinking" turn before moving that is offloaded to my plugin. I had problems with STB, row movement and instant cast before so I also have my plugin handling movement for actors and enemies. I tried making this auto battle scene work with forced actions in troop events but they get buggy.

Using a Yanfly plugin list, except a few for few not related.
I'll try to list the relevant plugins.
Battle_A.I._Core_(YEP)
Actor_Auto_Battle_A.I._(YEP)
Battle_System_-_STB_(YEP)
Instant_Cast_(YEP)
Row_Formation_(YEP)

Here is my plugin list if you really want to see it.

Spoiler: Plugin list
1699229991789.png
1699230501653.png
1699230523476.png
1699230545137.png
1699230564503.png
1699230586439.png
1699230606602.png
1699230695215.png

Here are the AI lists I have. Note the enemy lists (Wolves) work fine.
Spoiler: AI Lists
JavaScript:
//Mae Auto
<AI Level: 100>
<AI Priority>
Eval 2 > user._row: Move Backwards, User
Eval $gameParty.members()[0]._row > user._row: Move Backwards, User
Eval $gameParty.members()[0]._row < user._row: Move Forwards, User
Always: Heal I, Lowest HP%
Eval $gameParty.rowAliveSize(1) >= 1: Attack
Always: Wait
</AI Priority>

//Cory Auto
<AI Level: 100>
<AI Priority>
Eval user._row < 2: Move Backwards, User
Eval user._row > 2: Move Forwards, User
Always: Point Shot
Always: Stun Shot
Always: Attack, Lowest HP%
Always: Wait
</AI Priority>

Caravan Master Auto
<AI Level: 100>
<AI Priority>
Battle Cry
Eval user._row === 1: Horse Run Back, User
Eval user._row === 4: Horse Run Up, User
Always: Horse Charge
Always: Attack
Always: Battle Cry
Always: Wait
</AI Priority>

//Wolves
<Sideview Weapon: 0, swing, 16>
<Default Row: 4>
<Sideview Battler: SV_Wolf>
<AI Level: 100>
<AI Priority>
Always: SKILL 46
Switch 201 On: Enemy Charge
Switch 162 On: Enemy Move Up Line
Switch 163 On: Enemy Move Forward, User
Eval $gameParty.rowAliveSize(1) >= 1: Attack
Always: Wait, User
</AI Priority>

//Werewolf
<Default Row: 3, 2>
<Sideview Battler: WerewolfScratchAttack>
<Sideview Weapon: 10>
<Sideview No Collapse>
<Sideview Attack Motion: Swing>
<Scale Sprite: 150%>
<Sideview Idle Motion: victory>
<AI Level: 100>
<AI Priority>
Always: Enemy Move Forward
Switch 162 On: Enemy Move Up Line
User._row === 1 +++ $gameParty.rowAliveSize(1) >= 1: Death Claw, Highest MaxHP
Eval $gameParty.rowAliveSize(1) >= 1: Attack, Highest MaxHP
Always: Death Growl, User
Always: Wait, User
</AI Priority>

Looking at the actor AI plugin, it seems it just uses most of the code from the BattleAI plugin so not sure why this doesn't work. This is the only real technical challenge left to solve to have the working demo out for this game.
Not having looked at any of it in-depth, my presumption would be that the Actor Auto plugin makes decisions at the beginning of the turn, like the standard AI does (just with programmable options).

Setting a skill to Instant Cast sets the actor's turn back to their input phase (which is skipped by actors with the Auto Battle trait), but that's still after any AI decisions are made.
Not having looked at any of it in-depth, my presumption would be that the Actor Auto plugin makes decisions at the beginning of the turn, like the standard AI does (just with programmable options).

Setting a skill to Instant Cast sets the actor's turn back to their input phase (which is skipped by actors with the Auto Battle trait), but that's still after any AI decisions are made.
Thank you, I am having so much trouble understanding the how turns work with all these plugins. Imagine not knowing how to code or use rpg maker or even design a game and then starting with my plugin list. :LZYdizzy: I am finally getting there though!

This helps but with STB and instant cast I'm just now starting to figure it out. I saw this other post too.
Can I just modify Game_Actor.prototype.makeAutoBattleActions? If I could just copy and past what ever the enemy does in the makeActions function or something? If I take out the check for autobattle in canInput() that would give me back the input phase and then what? lol
I'm thinking of avoiding autobattle flag entirely and just making the enemy AI always run on the classes I choose since you have to use different classes anyway.
Just not really sure where to start here.

Edit: Instacast and STB have really been the source of all my problems this entire project... The autobattleAI won't work since like you say it decides its actions before it's STB turn comes up.

edit2: I still don't really understand what a turn even is with STB. You say turn and it sometimes means the whole turn for everyone, like with state decay. Other times a turn means the battlers turn. The enemy AI sees it's individual turns but actors on auto battle do not.
Maybe the explanation on this page will help? 👋
Have you tried using a supported battle system instead? Is there some reason you're sticking with STB rather than, say, CTB or ATB?

Imagine not knowing how to code or use rpg maker or even design a game and then starting with my plugin list.
You dug that pit for yourself, though. That's why the suggestion is generally to start with something simple, walk before you run, that kind of thing. Feature creep, especially if you haven't clearly designed the scope of your game beforehand, is very real! (Doubly so if you're prone to window-shopping.)
Maybe the explanation on this page will help? 👋
Have you tried using a supported battle system instead? Is there some reason you're sticking with STB rather than, say, CTB or ATB?
I just started thinking about this haha. I choose STB because I don't like the other systems and I thought it would be easier that the rest. And it is as far as balance goes. I didn't realize STB is not supported.

You dug that pit for yourself, though. That's why the suggestion is generally to start with something simple, walk before you run, that kind of thing. Feature creep, especially if you haven't clearly designed the scope of your game beforehand, is very real! (Doubly so if you're prone to window-shopping.)

I tired so hard to make the scope manageable. 😅 Then I made just about every mistake you could. I thought the battle system would be easy! Too late though. When you start out you don't even know what the engine can do so it's hard to define a realistic set of features. I know I've changed them a few times just to work with the plugins I already have.

Anyway I have make some progress. I got the AI to work but you still have to wait at the input screen

EDIT: ok now auto battle fully works but not with instant skills. Here is my code:
Spoiler: Code
Code:
      Fugs.ActorAI.Game_Actor_makeActions = Game_Actor.prototype.makeActions;
      Game_Actor.prototype.makeActions = function () {
        Fugs.ActorAI.Game_Actor_makeActions.call(this);
        if (BattleManager._subject == null) {
          console.log("BattleManager._subject", BattleManager._subject);
          return;
        }
        if (BattleManager._subject.currentClass().aiPattern.length > 0) {
          console.log(
            "currentClass().aiPattern.length > 0"
          );
          this.setAIPattern();
          this.setActionState("waiting");
        } else {
          return console.log("1");
        }
      };
   
      Fugs.ActorAI.Game_Actor_startSTBInput = BattleManager.startSTBInput;
      BattleManager.startSTBInput = function () {
        Fugs.ActorAI.Game_Actor_startSTBInput.call(this);
        const battler = this._subject;
        if (BattleManager._subject == null) {
          console.log("if (BattleManager._subject == null)");
          return
        }
        if (BattleManager.actor().currentClass().aiPattern.length > 0) {
          battler.makeActions();
          this.startAction();
        }
      };
I had instant skills working before I figured out the input function. Too bad I deleted the code and never pushed it before. Pretty sure is was in the isInputting() function that got instants to work. I was doing a bunch of dumb stuff at the time...
I have no idea why the instant casts still don't work for actors with AI. It works for everyone else as intended. I also have no idea where to start. Staring at the code isn't working this time. This is so close to working!

Original thread: https://forums.rpgmakerweb.com/threads/yanfly-instant-cast-and-actor-auto-battle-ai-not-working.162700/