How does order-of-execution work in MV?

We've had a report of an issue with Valkyrie: Sacred Feathers S which is tricky to reproduce, because on-paper it shouldn't be happening.

To give a really brief overview of the problem, at the end of each wave of enemies I call a Common Event called WaveEndCelebration; this does a bunch of stuff in order
  1. make the player invulnerable
  2. move the camera
  3. play an ME sound
  4. show a "wave complete!" HUD image (i.e. set its opacity to 255)
  5. Wait a bit
  6. Hide the wave complete HUD image
  7. Move the camera back to default position
  8. Make the player vulnerable
There are also some wait steps in-between these, to make it look neat. This happens at the end of every wave.

However, we've had a problem where a player sees the celebration, but the Common Event doesn't complete. It's like the CE gets to step 5 but doesn't continue on to do the rest. There are no "jump to labels" or anything; the Common Event itself is quite simple, so there's no clear reason why this is happening.

The player ends up stuck in a situation where the game continues, while the camera's in the wrong place and the HUD image remains onscreen.

So, enough with the specific example. What I wanted to ask is about order-of-execution.

I know that in MV, if you have 2 parallel events, they execute like-a-zipper, i.e. event A runs a line, B runs a line, A runs a line, B runs a line... They don't run whole pages at once. This is why you should be cautious about their use of variables/switches because two parallel events can execute on top of each other.

But how does it work when you execute a common event from a parallel page?

Does the resulting common event run like-a-zipper too? Or will it complete the entire common event?

I ask this because I know there's some weirdness in MV to do with running multiple common events on one frame, like I think it discards some? I can't remember the specific issue but I remember there was something said about this a while back.

I've been totally unable to reproduce the issue, so right now I'm tracking down theoretical causes. I guess I'm looking for any reason why a CE might "crash out" like this and simply stop.

Can anyone clarify how this is supposed to work?
But how does it work when you execute a common event from a parallel page?
So, without digging into the code, my understanding is that when you're calling one event from another, that's considered to be An Event Command - thus, the entirety of the called event should resolve before the interpreter looks at the next line of the original event.

That said, is that an accurate description of your situation? It sounds like you're in battle, so you wouldn't have parallel events running there, right? Or do you mean a troop event...or you're not using the default battle system, and this is all happening on a map?

Anyhow...my next question would be is this reported by multiple players, but you can't reproduce it? Or is it just one person (indicating the possibility of something funky on their end)?
I ask this because I know there's some weirdness in MV to do with running multiple common events on one frame, like I think it discards some?
I'm not saying you're wrong, but I haven't read anything about this.
There is nothing random in any computer at all - even the so-called "random generators" use reproducable mathematical functions to create their output.
It's just that in a lot of cases the human mind can't follow directly what the computer does and that seems to be random as a result.

so we need more of the skipped details to see what is really going on. Can you show a screenshot of how the common event is called?
So, without digging into the code, my understanding is that when you're calling one event from another, that's considered to be An Event Command - thus, the entirety of the called event should resolve before the interpreter looks at the next line of the original event.

That said, is that an accurate description of your situation? It sounds like you're in battle, so you wouldn't have parallel events running there, right? Or do you mean a troop event...or you're not using the default battle system, and this is all happening on a map?

Anyhow...my next question would be is this reported by multiple players, but you can't reproduce it? Or is it just one person (indicating the possibility of something funky on their end)?

I'm not saying you're wrong, but I haven't read anything about this.

The discarding thing might be out-of-date information, but it was what the HIME_CommonEventQueue.js plugin was written for (I would link to a thread but can't seem to see one). I actually use that in NALE, but I can't use it in this project as it breaks the CEs that run when projectiles hit enemies.

It's not in a battle (though I can understand why you asked this, as I wasn't clear) the battle system is on the actual map.

And yeah, it might be something unusual due to another person's hardware, I can't rule that out at present. It's a very awkward bug to repro as the process nearly always works correctly (seemingly > 999 times out of 1000).

My present theory is that it has to do with a bunch of things executing in near-parallel. I have various common events, such as when projectiles strike enemies, when the player is hit by enemies, etc., and they're executed from various places (e.g. the projectile-hits execute common events to deal out damage), and there's a certain magic combination of "happening at nearly the same time" things that breaks it which almost never happens.
There is nothing random in any computer at all - even the so-called "random generators" use reproducable mathematical functions to create their output.
It's just that in a lot of cases the human mind can't follow directly what the computer does and that seems to be random as a result.

so we need more of the skipped details to see what is really going on. Can you show a screenshot of how the common event is called?

Here you go, here's where I call it:

1636479676018.png


Basically, if the wave is over (simple conditional) then we reset some values and call the celebration, and afterwards, the event jumps to a label; this is at the end of the page.

1636479795838.png


This is the event itself; there's nothing particularly unusual about it. It essentially does a bunch of stuff, then undoes that stuff.

From observation with the person who brought this up, it appears to crash out at around the blue line.
The discarding thing might be out-of-date information, but it was what the HIME_CommonEventQueue.js plugin was written for
I gotcha. It looks like that is specific to reserving multiple common events at the same time - having more than one attached to a skill/item. If they're on different lines of another event, or being called from separate events, it shouldn't be an issue (just from looking at threads about it).
it appears to crash out at around the blue line.
with or without an error message?
if it is without an error message then there is a very high chance that the error has nothing to do with your events at all. Crash without error message is either a third-party program (like an antivirus) force-closing the browser running the game, or a memory overflow (that means insufficient hardware)

if it is with an error message it would help getting a screenshot.

that said, can you make a copy of the parallel event and reduce it to the conditional branches only before posting a screenshot? Your conditions are not exactly wrong, but their order in that screenshot is a bit unconventional. It might be that wrong orders there have caused a logic gap between some conditions if you used the same priority switching in other places of the conditional.
with or without an error message?
Sorry, by "crash out" it doesn't crash, it's just as if the event stops and doesn't complete, the game continues.
For reference, by default (i.e. no plugins):
  1. All events get processed in series. Parallel map event interpreters are simply updated, one by one, after the main interpreter.

  2. Troop events can only run during certain battle phases: start (Turn 0), turn, and turnEnd. Parallel/Autorun events are completely inactive in battle.

  3. Roughly speaking, RMMV's battle mechanics flow like this:
    • Update forced action
    • Update currently-running troop event
    • Update battle phase
    • Check for troop event start
    • Update current battle phase
    So, for example:
    • Forced actions pause troop events and phase updates.
    • Phase changes do not happen while a troop event is running.
    • Phase change happens before checking troop event trigger conditions.
Andar's suggestion to double-check your event logic sounds good. Otherwise I suspect this is a plugin issue.

Original thread: https://forums.rpgmakerweb.com/threads/how-does-order-of-execution-work-in-mv.141975/