(MV) Bizarre, game-breaking bug with a variable in battle

Hi there,

This issue directly relates to Yanfly's Battle AI Core. I have an actor who uses auto-battle with Yanfly's Battle AI Core + Actor Auto-battle plugin extension. I've used this many times, including in this very project, am well-versed in the syntax, and have not encountered a problem like this before. Essentially, I have a skill that calls a simple common event. This common event sets Variable 2 to equal 1. Simple, right? I can confirm that the skill does indeed change the variable, as I've added conditions in the troop event to test that the variable has been changed to equal 1. It has.

HOWEVER...this variable is not registered as changed in the actor's AI Priority list. The very first line under <AI Priority> is:
Code:
Variable 2 === 1: Charge up,
The actor should use the skill "Charge up" if variable 2 equals 1, but the actor does not. Even more strangely, if I change it to:
Code:
Variable 2 === 0: Charge up,
...then the actor does use the skill "Charge up". This indicates that the syntax is correct, otherwise the actor would not use the skill "Charge Up" at all. So essentially, the variable is being successfully changed globally, but NOT for the actor AI. I find this very, very strange.

Some info on the skill that calls the common event: Scope: None. Effects: Common Event X.
That's it. I changed the scope of the skill to target the user or even an enemy, in case "Scope: None" was causing the issue, but that did not change anything. I've also changed the variable to be a different one in case there was an issue specifically with Variable 2, but it did not change the outcome.

How is this possible? Does anyone have an idea of what could be causing this bug? Because my game revolves around certain skills giving "orders" to my actors, which they then execute using Battle AI, it is game-breaking for me and has completely paused my project. Any ideas would be very much appreciated. Thank you in advance!
Update:

After more experimenting, It seems that there is an issue with <Instant> (Yanfly's instant cast plugin) on a skill actually activating before AI actors make their battle decisions. I have come to this conclusion because the following turn, the actor AI performs the correct skill based on the conditions ("Charge up").

Enemies/actors with AI are supposed to make their decisions right before they make their turn, so I'm still not sure why an instant cast skill changing a variable is not immediately changing the actor's AI decisions. If the variable is already changed instantly, why doesn't the AI follow its own rules? Does anyone know of a way to have the AI actors make a decision on the spot, like how it is supposed to occur?

Thank you again for any help!

I've moved this thread to Javascript/Plugin Support. Thank you.


@jglag , please avoid double posting, as it is against the forum rules. You can use the "Edit" function on your posts to add additional information you've forgotten or respond to multiple people. You can review our forum rules here. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/mv-bizarre-game-breaking-bug-with-a-variable-in-battle.128221/