Easiest way to check if entire party is at full HP and MP?

thepsyche

Veteran
Veteran
Joined
Nov 16, 2016
Messages
322
Reaction score
75
First Language
English
Hi there,

I'm trying to create a little conditional branch that checks if all the active party's members are at full HP and MP, before determining what the next action will be.

What's the quickest way of doing this?

Don't mind using a script, in fact that may be preferable.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,107
Reaction score
13,713
First Language
English
Primarily Uses
RMMV
Is this something you will do in battle, and are you only interested in battle members? Or do you want all members?

Using members in the command below will check ALL members when you're out of battle, but only battlers when you're in battle. Using allMembers will check ALL members, whether you're in battle or not, and using battleMembers will only check battlers, whether you're in battle or not.

$gameParty.members().every(function(actor) {return actor.hpRate() === 1 && actor.mpRate() === 1});

That will be true if all the actors have full hp and full mp. Put it in the Script line of your conditional branch.
 
Last edited:

CHKNRAVE

Surprisingly not sponsored by Yanfly.
Veteran
Joined
May 11, 2020
Messages
134
Reaction score
73
First Language
French
Primarily Uses
RMMV
JavaScript:
var condition = true;
for(i=1; i<=gameParty.members().length; i++) {
    var member = gameParty.members()[i];
    if((member.hp!==member.mhp)||(member.mp!==member.mmp)) {
        condition = false;
    }
}
if(condition==true) {
   //what happens if everybody is at full HP and MP
}
First we set up a condition variable to true.
Then, we check for every active party member if their HP isn't equal to their max HP, or if their MP isn't equal to their max MP. If that's the case, the condition variable is turned to false, otherwise it's untouched.
If, once every party member has been processed, the condition variable is still true, you input the commands for what you want to do.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,107
Reaction score
13,713
First Language
English
Primarily Uses
RMMV
@CHKNRAVE

It's $gameParty, not gameParty. $gameParty.members() returns an array that starts at 0, not 1, so your loop would need to be
Code:
for (i = 0; i < $gameParty.members().length; i++)
as if you had 5 party members and you called $gameParty.members()[5] you would get an out of bounds error.
 

Users Who Are Viewing This Thread (Users: 1, Guests: 2)

  • Latest Threads

    Latest Posts

    Latest Profile Posts

    Frostorm wrote on Featherbrain's profile.
    Hey, so what species are your raptors? Any of these?
    ... so here's my main characters running around inside "Headspace", a place people use as a safe place away from anxious/panic related thinking.
    Stream will be live shortly! I will be doing some music tonight! Feel free to drop by!
    Made transition effects for going inside or outside using zoom, pixi filter, and a shutter effect
    I have gathered enough feedback from a few selected people. But it is still available if you want to sign up https://forums.rpgmakerweb.com/index.php?threads/looking-for-testers-a-closed-tech-demo.130774/

    Forum statistics

    Threads
    105,992
    Messages
    1,018,193
    Members
    137,772
    Latest member
    Kirakirna
    Top