- 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?
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;
};
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.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).
NOTE: I did not test this, but it should work unless I made a stupid typo or some other dumb mistake.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; };
if ($gameParty.checkNumberOfDeadActors(false) > 0)
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.@alcreator440 Just call the function I created:
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.Code:if ($gameParty.checkNumberOfDeadActors(false) > 0)