Check for number of dead party members

alcreator440

Veteran
Veteran
Joined
Mar 26, 2014
Messages
279
Reaction score
169
First Language
English
Primarily Uses
RMMV
Can anyone here tell me how to check to see if the number of dead in-battle party members exceeds 0 or not?
 

MushroomCake28

KAMO Studio
Global Mod
Joined
Nov 18, 2015
Messages
3,729
Reaction score
4,684
First Language
English
Primarily Uses
RMMZ
I suppose you already have some javascript basic. I've did a quick function in the $gameParty object that checks the number of dead actor. Set the allParty if you want it to check to whole party, false if only checking the first 4 party members (those in battle).

Code:
Game_Party.prototype.checkNumberOfDeadActors = function(allParty) {
    var totalDead = 0;
    if (allParty) {
        var totalCheck = this.members().length;
    } else {
        var totalCheck = 4;
    }
    for (var i = 0 ; i < totalCheck; i++) {
        if (this.members()[i].hp <= 0) {
            total += 1;
        }
    }
    return totalDead;
};
NOTE: I did not test this, but it should work unless I made a stupid typo or some other dumb mistake.
 

alcreator440

Veteran
Veteran
Joined
Mar 26, 2014
Messages
279
Reaction score
169
First Language
English
Primarily Uses
RMMV
I suppose you already have some javascript basic. I've did a quick function in the $gameParty object that checks the number of dead actor. Set the allParty if you want it to check to whole party, false if only checking the first 4 party members (those in battle).

Code:
Game_Party.prototype.checkNumberOfDeadActors = function(allParty) {
    var totalDead = 0;
    if (allParty) {
        var totalCheck = this.members().length;
    } else {
        var totalCheck = 4;
    }
    for (var i = 0 ; i < totalCheck; i++) {
        if (this.members()[i].hp <= 0) {
            total += 1;
        }
    }
    return totalDead;
};
NOTE: I did not test this, but it should work unless I made a stupid typo or some other dumb mistake.
Thanks for the quick reply. I was actually looking for something simpler like "if $gameParty.deadMembers() > 0" or something to that effect but I should have specified it. I had no idea it would take an elaborate piece of code to get what I'm after. However, I'm sure your response will come in handy for something else later on down the line.
 

MushroomCake28

KAMO Studio
Global Mod
Joined
Nov 18, 2015
Messages
3,729
Reaction score
4,684
First Language
English
Primarily Uses
RMMZ
@alcreator440 Just call the function I created:

Code:
if ($gameParty.checkNumberOfDeadActors(false) > 0)
EDIT: Not sure if I was clear enough. You have to copy/paste my code in a plugin (or directly in the game_object.js file, but not recommended). Then, you can simply call the function everywhere. I created the function cause I'm not sure if there is already a function to check the number of dead party members I didn't bother to search in depth in the default code.
 

alcreator440

Veteran
Veteran
Joined
Mar 26, 2014
Messages
279
Reaction score
169
First Language
English
Primarily Uses
RMMV
@alcreator440 Just call the function I created:

Code:
if ($gameParty.checkNumberOfDeadActors(false) > 0)
EDIT: Not sure if I was clear enough. You have to copy/paste my code in a plugin (or directly in the game_object.js file, but not recommended). Then, you can simply call the function everywhere. I created the function cause I'm not sure if there is already a function to check the number of dead party members I didn't bother to search in depth in the default code.
I appreciate the response but I actually found what I was looking for. It turns out that it was just "$gameParty.deadMembers().length > 0" lol. This thread can be closed now.
 

MushroomCake28

KAMO Studio
Global Mod
Joined
Nov 18, 2015
Messages
3,729
Reaction score
4,684
First Language
English
Primarily Uses
RMMZ
Lol that's what I get from rebuilding objects from scratch (so I don't know very well the default objects).
 

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

Latest Threads

Latest Posts

Latest Profile Posts

This is relevant so much I can't even!
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

Forum statistics

Threads
105,999
Messages
1,018,219
Members
137,777
Latest member
Bripah
Top