Disabling Dashing, if MP in Party is 0

Hello there,

I'm trying to create a key feature in my current project, but I can't figure out, how I have to do it and it's starting to get frustrating.

I want to use the MP of the Heroes as Stamina, so that physical attack techniques and dashing on the overworld cost a small amount of MP(Stamina) and has to be recharged by, for example, re sting at campsites.

Therefore I need to check if the hero in Slot 0, 1, 2 or 3 has run out of Stamina to disable the dash until the stamina is at least 1.

I found a script, that allowes an event to call it, but for a global event I need to set a condition to check for the MP attribute. But that is not an option.
Another way I could think of, would be to asign a new status "exhausted" and check for that, but I don't have any Idea how to check the party for the lowest MP and asign that status.

Some help would be really appreciated.
Parallel process runs 60 times per second.
Thus an event set to trigger as Parallel Proccess, will do the trick.

You should name a variable MP.

Event Page 1:
Conditional Branch: TP MP = 0
Disable Dash.
Set Self Switch A ON
End.

Event Page 2 (has condition Self Switch A = ON):
Conditional Branch: TP MP <> 0
Enable Dash.
Self Switch A = OFF.
End.

And that is how it works.

P.S.
I haven't thought (yet) how to check if using dashing and reduce TP if so.

Edit: Corrected TP to MP
@Dreadshadow but that will only works for one map, right? why not use common event to run on a whole game?
@Dreadshadow that was my first idea, but there is no option in the conditional branch to check for any attribute.
And I already have a way, to reduce the MP while dashing via multiple conditional branches checking for button A and the Party Coordinates.
@Dreadshadow but that will only works for one map, right? why not use common event to run on a whole game?
You can always do a copy - paste of the event. Use Common Event for this? Involving self switches no, but yes, I guess you can make two common events, one for each page, it can be neat, but does not make much difference really, does it? We can use normal switches though and build it in Common Eventing. Not a bad idea really.

OH! MP! Not TP!!!
That would be easy mate!!!

Control Variables:
Operand: Game Data: Actor: MP

Then do Conditional Branch using the variable!!!
In this case, I'd be in favour of a small script snippet rather than a parallel process.

If you want to give it a go, just add this to the Materials section:

Code:
class Game_Player < Game_Character
  alias :shaz_dash? :dash?
  def dash?
      return false if $game_party.battle_members.any? {|actor| actor.mp < 1 }
      return shaz_dash?
  end
end
@Dreadshadow As I understand it right now, I have to do it like this:
Conditional Branch - Check for pressed Button A
Conditional Branch - Check for new player coordinates
Conditional Branch - Check for Variable "Hero 001 MP"
Conditional Branch - Check for Variable "Hero 002 MP"
and so on?
Since I'm not sure of how many Characters join the party, that seems impracticle.
You can target target party member. Speaking of impractical though, you might need a script.
I'm quite certain, that it's best handled in a script, but my knowledge of scripting is about solving math at preschoolers level.
That's why shaz wrote the script above. Have you tried it?
I have tried the script from shaz, but I get an error:
Script Stamina line 2: NameError occurred.
undifined method `dash´for class `Game_Player´
Replace :dash with :dash? in the snippet Shaz provided above. That should work.
Oh wow, Thank you so much guys. I don't know, how many yearly tries I had and people I asked, to get this little feature going.
The onlything left for me to do, is to set a conditional branch, so that the MP do not get reduced, if the party isn't dashing anymore.
I currently just check for the pressed dash button and not for "dash = true/false"
You can do $game_player.dash? which will return true if the party is dashing, and false if they're not.

Thanks @A-Moonless-Night for that fix! I'll add it to my post.

Original thread: https://forums.rpgmakerweb.com/threads/disabling-dashing-if-mp-in-party-is-0.93563/