MV Hide dead party members from being shown walking behind the party leader

Is there a way to selectively disable the "show party followers" only on those party characters which are dead or knocked out ?
Since it's just weird to see supposedly dead characters still walk behind you.

Ok with plugin or script solutions.
I've already tried to look for older threads about this, but no luck so far.

Some commercial games use a variant of this, like replacing dead characters with a placeholder, sometimes a little grave, or the sprite of the character fallen down on the ground.
A way to dodge the problem would be to just disable all party followers, but if it's possible to have both (followers + hidden deads) that would be better.
You'll need a plugin for that. The code is not trivial, but here's one way to do it:
JavaScript:
(() => {
    const Game_Follower_update = Game_Follower.prototype.update;
    Game_Follower.prototype.update = function () {
        Game_Follower_update.call(this);
        this.setTransparent($gamePlayer.isTransparent() || (this.actor() && this.actor()._hp <= 0));
    };

    Game_Followers.prototype.updateMove = function () {
        const partyLine = [$gamePlayer];
        const remainder = [];
        this._data.forEach(follower => {
            const actor = follower.actor();
            const list = (actor && actor._hp > 0) ? partyLine : remainder;
            list.push(follower);
        });

        for (let i = partyLine.length - 1; i > 0; i--) {
            partyLine[i].chaseCharacter(partyLine[i - 1]);
        }
        remainder.forEach(follower => follower.chaseCharacter($gamePlayer));
    };
})();

It consists of 2 steps:
  1. Set the follower's transparency according to whether they are dead (hp <= 0) or not.

  2. Make followers follow the next live character.
    • Make sure they follow each other in reverse order, otherwise they'll all end up in the same place.

    • Make sure the dead followers keep following the party, otherwise they might have to run across the map once they revive, and using the Gather Followers event command will freeze the game, as it'll wait for all followers to have gathered (but the dead ones don't move).
I've noticed that actors have a property named isDead(), but this appears to only be valid during combat, where "Dead" is a special state. Outside of combat, the only way I've found to determine whether a character is dead, is to check if their HP is non-zero.

Note that followers only move when the player character moves. If some follower dies, the rest won't try to fill the gap until the player moves. And since they move at the same speed as the player character, they won't be able to fill the gap until the player chooses to change direction (the followers can fill the gap by moving diagonally). So I recommend using the Gather Followers event command whenever one dies, so that there is never a gap.

Also note that this plugin does not cover the case where the player character died. But feel free to modify the plugin as you see fit.

Finally, you can use this plugin however you see fit with no strings attached. Have fun with it.

I've moved this thread to Plugin Requests (from MV Support). Thank you.

@Nolonar Amazing, it works nicely. Thanks a lot.
Bar the limitations you already mentioned,
it not working in the case of first character being dead, being the most noticeable shortcoming,
while the gaps in the line (after a formation swap of the dead body, or after someone dying from poison in the overmap) get sorted out randomly quickly enough while moving, so it's not as much of a burden.

I've sorted out the code into a plugin file, for anyone else interested.

For fixing the dead leader case, that may require a separate plugin (even if the overworld party leader + followers are complementary), as it may require to automatically swap the dead first party member with the first alive character in the party, whenever after battle or after a generic knockout event, or also after a manual formation command, which pushed the dead character in the first position.

Original thread: https://forums.rpgmakerweb.com/threads/hide-dead-party-members-from-being-shown-walking-behind-the-party-leader.152172/