how to sense when party member 1 is dead?

I would like it so in my game you have to have party member 1 alive- sorta like if they're the main character and the game can continue if anyone else but party member 1 dies, how would I go about this?

I would like it so the moment party member 1 is dead, it pops up with "-party member 1- is dead, thus you have failed your quest" and the game returns to title screen

I've also disabled formation options, so it that's not something else I have to add to my problems lol
JavaScript:
$gameParty.members().find(member => member.isDead()) != undefined
JavaScript:
$gameParty.members().find(member => member.isDead()) != undefined
Sorry, I've been trying this code for a while but it's not working- am i using it wrong or something?
Sorry, I've been trying this code for a while but it's not working- am i using it wrong or something?
The code @Gensun gave you doesn't do quite what you asked - it's checking whether any party member is dead.

It also doesn't do anything by itself.

Paste the below code into a text editor, save as a *.js file, and include in your project as a plugin. It will make it so party member 1 dying triggers game over.

Code:
Game_Party.prototype.isAllDead = function() {
    return $gameParty.leader().isDead();
};
The code @Gensun gave you doesn't do quite what you asked - it's checking whether any party member is dead.

It also doesn't do anything by itself.

Paste the below code into a text editor, save as a *.js file, and include in your project as a plugin. It will make it so party member 1 dying triggers game over.

Code:
Game_Unit.prototype.isAllDead = function() {
    return $gameParty.leader().isDead();
};
Thank you, that works great 😀
Sorry, I've been trying this code for a while but it's not working- am i using it wrong or something?
It returns true when any one member is dead, because I thought you were asking how to sense when any one member is dead, you're asking if party member 1 is dead. ATT Turan has the right code for what you're asking.
The code @Gensun gave you doesn't do quite what you asked - it's checking whether any party member is dead.

It also doesn't do anything by itself.

Paste the below code into a text editor, save as a *.js file, and include in your project as a plugin. It will make it so party member 1 dying triggers game over.

Code:
Game_Unit.prototype.isAllDead = function() {
    return $gameParty.leader().isDead();
};
So this worked- *However* for some reason, now the battle won't end, does anyone know why or how to solve that issue?
So this worked- *However* for some reason, now the battle won't end, does anyone know why or how to solve that issue?
Code:
Game_Party.prototype.isAllDead = function() {
    return $gameParty.leader().isDead();
};
Try this. I tried Turan's code and realized it breaks because modifying Game_Unit makes the change apply also to the enemy troop. This change I shared should make it apply only to the game party.
Code:
Game_Party.prototype.isAllDead = function() {
    return $gameParty.leader().isDead();
};
Try this. I tried Turan's code and realized it breaks because modifying Game_Unit makes the change apply also to the enemy troop. This change I shared should make it apply only to the game party.
I swear you coders are wizards, that works great thanks!

I have one more question regarding party members that I might just turn to a different post, but would you know how to make it so when a party member dies they are removed from the party? like a permadeath feature? ~again unless you know how I'll just make a different post lol~
I swear you coders are wizards, that works great thanks!

I have one more question regarding party members that I might just turn to a different post, but would you know how to make it so when a party member dies they are removed from the party? like a permadeath feature? ~again unless you know how I'll just make a different post lol~
I think the least buggiest way is to remove them only after battle. I tested this on a blank project and it seems to work. You want to save the code below as a .js file and install as a plugin.

Code:
_aliasPartyBattleEnd = Game_Party.prototype.onBattleEnd;
Game_Party.prototype.onBattleEnd = function() {
    this.removeDeadActors();
    _aliasPartyBattleEnd.call(this);
};

Game_Party.prototype.removeDeadActors = function() {
    this._actors = this._actors.filter( function(actorId) {
        return !$gameActors.actor(actorId).isDead();
        });
    $gamePlayer.refresh();
    $gameMap.requestRefresh();
};
Sorry about that, I just copied the method present in the codebase not thinking that it would apply differently to troops and parties. @Gensun's fix is good.

I have one more question regarding party members that I might just turn to a different post, but would you know how to make it so when a party member dies they are removed from the party? like a permadeath feature?
Did you try Googling it? There have been many threads about implementing permadeath that included evented and coded solutions.

Glad you got the game over working correctly.
Sorry about that, I just copied the method present in the codebase not thinking that it would apply differently to troops and parties. @Gensun's fix is good.


Did you try Googling it? There have been many threads about implementing permadeath that included evented and coded solutions.

Glad you got the game over working correctly.
Yes I did Google a few different threads but I figured that it wouldn't hurt getting a fresh opinion on the matter considering that I couldn't really find a super conscience answer ┐⁠(⁠ ⁠∵⁠ ⁠)⁠┌
Ok so just gonna say this because I feel a little silly, but I COMPLETELY misunderstood how a parallel common event worked and now have the characters disappeared from party without any plugins making it so it constantly senses each character having the "death" state and removes them if they have it

What I thought putting a common event on parallel did was it checks once per loading into a room, not constantly checking..... Whoops my bad
JavaScript:
$gameParty.members().find(member => member.isDead()) != undefined
This code is not wrong, but in this case, you usually want to type this:

JavaScript:
$gameParty.members().some(member => member.isDead())

Original thread: https://forums.rpgmakerweb.com/threads/how-to-sense-when-party-member-1-is-dead.181362/