Yanfly's Lunatic State doesn't wait for choices on "React effect"?

Hello beutiful people of this marvelous forum! It's me! The annoying dev that doesn't know how to do any on ruby!
So, here's a problem I'm dealing with:

I'm using Yanfly's Lunatic State to make several effects on my game.

I'm right now scratching my head with this one (and I'm pretty sure I made a similar post a year ago or so...? any ways I couldn't find it, but I'm pretty sure the question was a little different. Still:

I'm trying to create a react state that before you take damage, a choice pop up to see how the actor want to react to that attack, so here's the effect I created:

1688986492358.png

Ignore the double "wait_for_message", I was trying stuff to see if I could handle the problem...

1688986699076.png

There's the react effect on the said state in case you were wondering.

And here's the common event:
1688986745890.png

Yes, I also used the double wait for message there just to try it out...
(If you see something weird in this script call besides the wait for message please make me note it.)

Now the problem as the tittle state is that the react effect doesn't wait for the damage, but it pop the choice at the moment I take the damage:
1688986864624.png

Is there a way to fix this? Or maybe, do you think there's an alternative to pop up a choice call BEFORE taking the damage? I tried to use the script call for the choices in the same react effect, but the script cannot handle the @game_actor something with the choices for some reason. Like is trying it to associate the choices with the current player or I don't know. So I tryed it using a common event instead, but yeah... this happen.

Anyways, as always, any help is welcome! And sorry in advance if my explanation wasn't very clear.

EDIT: Oh, another thing I just noticed... the common event can't know who the "self." for the "force action" is refering when is called. I think I can fix this with a variable. But in case you know a better alternative, that's also welcome.
First thing, "Reserve common event" (look at the name of the function!!!) is not the same as "start common event"
Reserve common event means "put this common event into queue for later execution once your interpreter is ready". So the problem isn't really with yanfly, the function works as intended.

Unfortunately for you there is absolutely no function to start a common event directly.

However I know that Yanfly made special action sequence code to cirmumvent that in MV, you might want to check if there is anything similar available for Ace.

An alternative to using variables for target identification is to place an invisible and functionless target state on the target and then have the common event check all targets to see which one got it.
Or use a script that creates special variables to automatically store this info, I think there was such a script from either Yanfly or Tsukihime
First thing, "Reserve common event" (look at the name of the function!!!) is not the same as "start common event"
Reserve common event means "put this common event into queue for later execution once your interpreter is ready". So the problem isn't really with yanfly, the function works as intended.
Omg really? I was using a script call collection from this forum, and the call for common events was only that "reserve common" etc. I'm gonna try the start common event to see if that fix it! Thanks as always 😀

EDIT:

Unfortunately for you there is absolutely no function to start a common event directly.

Oh, I'm so dumb sorry. I through you ment the "start_common_event" was actually a thing and now just realized it isnt. I got hyped to think that the problem could be solved that easily.
Hey,

If you don't mind, what exactly do you want to do with the common event call? Even if you delay the execution of the action in progress, at some point your character would probably get hit with the precalculated damage anyways (unless you also changed the result yourself), even if you made the target invulnerable or incapacitated the attacker.

The standard battle system is also not designed to support multiple actions at once, so you may experience some minor glitches if you interrupt one action to execute another (like if your forced action were to decide the battle then the original action would technically be executed after the battle ended, which means that any "battle only" states applied would not be removed).


I would probably not put this in a script, but if you just want a quick/dirty way to execute a common event at this time you could try doing this (not yet tested):
Code:
last_result = @result.clone  # Forcing another action may destroy the current result
$game_temp.reserve_common_event(123)
SceneManager.scene.process_event  # The react effect already checks if still on the battle screen
@result = last_result


If the above mentioned points sound like problems there may be better places to put the common event call, depending on which steps you need to happen before or after.

--

Generally on running your own events:

"Call Common Event" would normally just instruct the event interpreter that is already running to switch to a different list of event commands for the time being. There is not really an exact equivalent when you don't have an active event.
Running your own event would normally consist of multiple steps:
Code:
# Set up your event command list:

interpreter = Game_Interpreter.new
interpreter.setup($game_common_events[123].list)

# Call this each time you want to advance your event execution by one frame:

interpreter.update

# Use this to check if the event is still running and has not finished:

interpreter.running?

Normally nothing in the game does happen truly in parallel. Normally the active scene will generate a new frame, then initialize a chain of update calls that include everything that needs to be updated for the next frame. If you want something to happen over a period of time instead of instantly, you would normally chop up your process into pieces, and place those pieces in the update chain through a script so that they get executed one at a time.
(You can ignore this process and create frames yourself without letting everything finish updating if really needed, but you'd have to decide which parts of the game you want to update, by using SceneManager.scene.update_basic or Graphics.update)


(May need to look over this post again later^^)
OK, here you're trying to do it the hardest way possible, IMHO.
I don't know what Yanfly's script expects you to do with that common event or if that was an idea you came up with for some specific reason. What I can see here is that you could replace the parts concerning the dialog and choice windows with their respective event commands... unless that Yanfly script is asking you to just use a script call.

If the common event is reserved and detected by the battle interpreter in a timely fashion, the common event should be executed like it'd do it on the map. Since every battle and even the game troop have an interpreter by default, it should activate it at some point.
I would probably not put this in a script, but if you just want a quick/dirty way to execute a common event at this time you could try doing this (not yet tested):
Code:
last_result = @result.clone  # Forcing another action may destroy the current result
$game_temp.reserve_common_event(123)
SceneManager.scene.process_event  # The react effect already checks if still on the battle screen
@result = last_result

Omg! I tried it and it worked like flying colors! (At least for now). I don't know what kind of problems this could generate in the future, but at least for now is doing it work.

For anyone interested in what I'm trying to attemp:
As some of you may know, I was working on a yugioh fangame. I try to recreate some cards the most similar they work in the real card game but also adapted to an RPG enviroment. The problem is that cards usually can be activated on your opponent's turn under some conditions. That's where my first problem started. I was working on a famous card known as "Kuriboh", if you had seen the anime, you know what this card does, if not, basically: it turn to 0 a damage you will take from a monster. The problem is that I could had make it to turn the first damage you would have taken to 0, but usually, you want to save it for the strongest attack, that adds a little more of strategy at the game. But I wasn't able to generate a "choice" in middle of an attack declaration cuz the attack was going though the whole game message and choice, ignoring it completely. Now with this is seem to have fixed that part 😀

Anyways, thanks a lot bro!

Original thread: https://forums.rpgmakerweb.com/threads/yanflys-lunatic-state-doesnt-wait-for-choices-on-react-effect.159175/