Game over when MP runs out.

Hello! I'm fairly new to RPG Maker Ace and especially new to the forum (so I hope this is the right place to ask!)

I'm trying to set it up in the game I'm working on that when the MP reaches zero for a character it'll trigger game over. The idea is it's a moral meter.

I figured out that you can go under control variables > game data > actor > MP. So I've already worked special dialogues that represent, 'hey, your MP is looking kinda low, better check that!' Problem is, no idea now how to actually setup the game over when it hits zero after that. I was guessing it might be something to do with common events? But I don't know, that's why I've come here. So again hopefully you guys might be able to help!
Out of combat you'd be able to do this. You can make a common event that runs parallel. Then just have a check If X actor mp < X then "you are low on mp" etc. Then at the bottom have a wait time of a second or two so it doesn't bog you down.
If you wanted to do this in battle, you'd want to use some scripts that can trigger something like a counter attack or a passive state that instantly kills everyone and causes the game over.

You'd create a skill that causes the death of all allies (either by causing KO status or something like b.mhp as the damage formula), set it as a counter with the condition being that it happens when the character's MP falls to 0. Give that to every character.

If you wanted to do it over a short period of time, you could have a passive state triggered by the character's MP being 0, and give them a hefty HP Degeneration, like 20-30% per turn or so. So they'd end up dying within a few turns.
If you wanted to do this in battle, you'd want to use some scripts that can trigger something like a counter attack or a passive state that instantly kills everyone and causes the game over.
Frankly speaking, if the OP decides to go for a script, I would recommend using one that calls for the MP check directly as part of the standard battle loop and triggers the game over screen. It would be much shorter and easier to handle.

If not going for a script, performing such check on the whole party at the end of each turn might be enough, as the standard VX Ace system checks anything that is at the end of turn after each character has already attacked. This solution, though, might not fit perfectly the overall UX flow, as characters would be able to perform their actions even after somebody reaches 0 HP.

Even so, it still depends on how the battle system is used. The OP might be using the battle system in a different way and have different expectations. @Babylon if that were the case, we would need more information.
Out of combat you'd be able to do this. You can make a common event that runs parallel. Then just have a check If X actor mp < X then "you are low on mp" etc. Then at the bottom have a wait time of a second or two so it doesn't bog you down.
Common events are kind of bullying me right now. I did figure it might be a parrel process but I notice it requires a conditional switch. Should I just activate a switch at the very start of the game that makes it eligible for this to happen? When I look at the screen shot here I figure it should work but it doesn't.

For reference, I'd rather this be able to happen outside of combat.

screen shot.png
Should I just activate a switch at the very start of the game that makes it eligible for this to happen?
Yes, you are correct. If you want it to always check whether either actor MP reached 0, you need to trigger it from the very beginning.

The common event you showed in your screenshot, however, only displays a message and a game over screen, but it is not checking the actor MP at all. Keep in mind that even if the variable you are using in your condition is where you store your actor's MP, not updating it before checking its value makes the whole idea of using Parallel Process common events pointless.

The steps you need to follow are the following:
  1. Store your actor/actors MP in a variable.
  2. Check whether that variable is 0.
  3. Do your stuff when it is 0.
  4. [OPTIONAL] Wait at the end of the event.
Points 1 and 2 might even be collapsed in a single point, as it is possible to check whether any actor has 0 MP using just the conditional branch script box.
If you want more information on this, you can check the documentation here (this one is from a newer version of Ruby, but that part has not changed from the one used in RGSS3): https://ruby-doc.org/core-2.7.0/Array.html#method-i-any-3F

The result would be something like this (please, double check the syntax because I am going by heart here and it has been quite a long time since I last used it)
Ruby:
$game_actors.any? |actor| actor.mp < 1
# Checking if less than one makes it robust when doubles are involved

Step 4 is actually optional in this case. Honestly, having such a simple check run each frame does not require any graphical update and should have no impact on performance at all, conversely, adding a wait command might make such detection a bit sloppy and players might perceive it as a whole second is quite long.

You might want to give it a try without adding the wait command and then, if you really experience performance issues, add the wait command.
Yes, you are correct. If you want it to always check whether either actor MP reached 0, you need to trigger it from the very beginning.

The common event you showed in your screenshot, however, only displays a message and a game over screen, but it is not checking the actor MP at all. Keep in mind that even if the variable you are using in your condition is where you store your actor's MP, not updating it before checking its value makes the whole idea of using Parallel Process common events pointless.

The steps you need to follow are the following:
  1. Store your actor/actors MP in a variable.
  2. Check whether that variable is 0.
  3. Do your stuff when it is 0.
  4. [OPTIONAL] Wait at the end of the event.
Points 1 and 2 might even be collapsed in a single point, as it is possible to check whether any actor has 0 MP using just the conditional branch script box.
If you want more information on this, you can check the documentation here (this one is from a newer version of Ruby, but that part has not changed from the one used in RGSS3): https://ruby-doc.org/core-2.7.0/Array.html#method-i-any-3F

The result would be something like this (please, double check the syntax because I am going by heart here and it has been quite a long time since I last used it)
Ruby:
$game_actors.any? |actor| actor.mp < 1
# Checking if less than one makes it robust when doubles are involved

Step 4 is actually optional in this case. Honestly, having such a simple check run each frame does not require any graphical update and should have no impact on performance at all, conversely, adding a wait command might make such detection a bit sloppy and players might perceive it as a whole second is quite long.

You might want to give it a try without adding the wait command and then, if you really experience performance issues, add the wait command.
To clarify this should be done in script editor? If so, I'm pretty much script illiterate, been keeping everything vanilla up until now. I was hoping I could pull this off with a common event. Otherwise I really don't know what I'm doing here yet, I'm that fresh.

If I do use script editor for this, it'd be that line of code you provided:
>$game_actors.any? |actor| actor.mp < 1
And then I would input a line for game over? I was actually hoping to trigger a few different game over events through a random variable. Just to depict different kinds of mental breakdowns lol. That might be trickier for me with scripts.
You don't need any scripting. This is in MV but should be the same in VX Ace I believe
MpDeath.png


And you are probably going to be ending up running many parallel processes like this during the game, so I always suggest have 1 switch at the beginning of the game that auto runs on an event and then is erased so you can have all your parallel processes running at the same time. Always have a wait at the end, you really don't need to be more exact than checking once a second in this or most situations.

Also, not part of your question but if you were to make this in MV you'd have access to Frog Health plugin which makes you have as many different resources as you'd want. So you could make a custom resource called Sanity, then use SRD Hudmaker to show the bar on your screen linked to the resource you made. I know this because I was making a game with sanity as well, but scrapped the idea after seeing how overdone it was lol.
Haha! Success! Amazing, amazing, amazing! Thank you everyone in this thread. For posterity, my issue was I wasn't assigning the actor to the game data's MP correctly. As in, the very fist line in the common event, had to be a control variable > game data > actor > MP. Was missing that before.

Anyways, thank you again for the direction. I'm going to have so much fun with this. Cheers!
(Also no way sanity meters are overdone! They're common for a reason!)

Original thread: https://forums.rpgmakerweb.com/threads/game-over-when-mp-runs-out.168548/