How to Check if Enemy No Longer Has State Buff in Combat

I am developing a Boss combat sequence, which has an enemy which transforms, receives a state, and then at the end of that state, transforms back.

I am trying to figure out how I can detect if the enemy unit no longer has the buff. I setup a common event.
The common event looks like this:
If - ENEMY#1 is affected by STATE
*nothing*
Else
ENEMY#1 Transform

What confuses me is how this is supposed to be called up in the Troops tab under "Battle Event." I have the Common Event in an event page on the Troops tab under Battle Event, and I have the settings as follows:

"Conditions" -> "Don't Run" ||| "Span" -> "Turn,"

I assumed that it would run the common event each turn, since the Span description says:
"[Turn] Run only once per turn."
(And I can't use "moment" because it hard locks the game and I have to shut it down.)

To me, it makes sense that if the player does not run from battle (which they won't be able to anyway during this boss fight), then the common event should be checked for at the end of every turn. However, it's not doing anything. The state on ENEMY#1 runs out, and nothing happens.

Does anyone have any idea what I'm doing wrong here? I would greatly appreciate any advice. 😳
One thing I'd do is this:

Code:
IF enemy is affected by state
    Turn some switch ON
ELSE
    IF switch is ON
        Transform
    END
    Turn switch OFF
END

The problem with your code is that the enemy would always transform when not affected by the state. What you want is for the enemy to only transform after the state has ended.

As for why your event is not running, the manual can help. You can open it by either pressing F1 in the editor, or clicking on "Help" > "Contents". From there, expand the "Database" group and click on "Troop Settings" to get more info on what "Conditions" and "Span" do.

For example, "Don't Run" refers to the event, not the player. This means that the event will not run. Ever. I think what you want is either "Turn End" or "Turn 1 + 1 * X".
here's the quick, dirty and easy way.

set up a page to run on each x turn. on that turn, change him. set another page to run on each x turn after that, and transform him back.

eg, first page: run on turn 3+6
second page: run on turn 6 + 6

that should transform on turn 3, 9, 15, 18 and transform back on 6, 12, 18, 24, meaning he'll transform for 3 turns for three turns and alternate.
You can't do exactly this in the base engine. If you want the transformation to expire exactly when the state is removed, you'll need to use a plugin like Visustella's Skills and States which allows you to run code when states are applied or removed.

Here's a tutorial video about it:


This is using Yanfly's plugins for MV, so some of the notetags will be different, but the concept is the same. And you can see if Trihan has already translated this Tip & Trick into Visustella notetags in his thread about it.
One thing I'd do is this:

Code:
IF enemy is affected by state
    Turn some switch ON
ELSE
    IF switch is ON
        Transform
    END
    Turn switch OFF
END

The problem with your code is that the enemy would always transform when not affected by the state. What you want is for the enemy to only transform after the state has ended.

As for why your event is not running, the manual can help. You can open it by either pressing F1 in the editor, or clicking on "Help" > "Contents". From there, expand the "Database" group and click on "Troop Settings" to get more info on what "Conditions" and "Span" do.

For example, "Don't Run" refers to the event, not the player. This means that the event will not run. Ever. I think what you want is either "Turn End" or "Turn 1 + 1 * X".
I already have a switch like that; I just didn't include that information because it wasn't relevant to what I was asking about, but thanks for the extra info anyway.

I checked out the Database section, and it did not provide any other helpful information beyond what I already knew.

I had decided to ask my question around "Don't Run," even though I have already tried this with "Turn End" and "Turn 0 +1*X" -- this is what did not make sense to me. If a condition is set in a battle event, like ENEMY HP < 50%, it will trigger when an enemy's HP is less than 50%. Duh. This all makes sense. What doesn't make sense is if a common event won't run on normal turn end... hmm... hang on...
...
Okay, so I just took a few minutes, and added in a simple text box to see if the common event is running. Turns out, it DOES trigger the common event. So that's not the problem. Let me get to the other comments before I say anymore.

here's the quick, dirty and easy way.

set up a page to run on each x turn. on that turn, change him. set another page to run on each x turn after that, and transform him back.

eg, first page: run on turn 3+6
second page: run on turn 6 + 6

that should transform on turn 3, 9, 15, 18 and transform back on 6, 12, 18, 24, meaning he'll transform for 3 turns for three turns and alternate.
I appreciate the suggestion but it won't work for what I'm doing for a number of reasons.

You can't do exactly this in the base engine. If you want the transformation to expire exactly when the state is removed, you'll need to use a plugin like Visustella's Skills and States which allows you to run code when states are applied or removed.

Here's a tutorial video about it:


This is using Yanfly's plugins for MV, so some of the notetags will be different, but the concept is the same. And you can see if Trihan has already translated this Tip & Trick into Visustella notetags in his thread about it.

Wait a second. I have already succeeded in doing this with the Player Characters in combat (i.e. transforming then transforming again after a state buff fades). Are you telling me that, for some really weird reason, that this cannot be done with the enemies too?
-------------
Wait wait wait... you know what? I just decided to do some more testing, adding in a lot of text boxes to see where things come up. (This is a good idea, I need to do this more often.) Turns out, I had my transform command in the wrong slot. Not only does it work, I have successfully embarrassed myself once again in front of the entire community because that's what I do. :oops:

Well, all your help has been greatly appreciated, and I have taken a few notes from some of things you guys have told me, so at least it wasn't in vain, and as always I appreciate all of you very much! 🙂
well don't leave us hanging, what's the answer? xD
well don't leave us hanging, what's the answer? xD
Oh! I'm sorry. The answer is to use "Turn End" and Span -> "Turn," despite the fact that would be logically redundant. I used the transform command in the common event, and then called the common event in the Troops Battle Event page.
Wait a second. I have already succeeded in doing this with the Player Characters in combat (i.e. transforming then transforming again after a state buff fades). Are you telling me that, for some really weird reason, that this cannot be done with the enemies too?
Not at all. Transforming can absolutely be done without plugins. Doing what you described in your original post, basing the transformation on exactly when the state is removed, can't be done without plugins.

If the state is only a timer, and there's no way for it to be removed aside from it timing out at the end of a turn, then that works just fine for you.

The answer is to use "Turn End" and Span -> "Turn," despite the fact that would be logically redundant.
Right - and at that point, it doesn't matter what you set for the Span, so long as it's one that will only run once. For your purposes, it doesn't matter whether you use Turn or Battle, unless your boss can re-transform a second time, in which case Turn is the best choice.
I used the transform command in the common event, and then called the common event in the Troops Battle Event page.
Why? You can just use the transform command directly in the troop event.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-check-if-enemy-no-longer-has-state-buff-in-combat.146374/