Make actors leave party and battle as soon as they die fighting

Hello, everyone. I basically need help with what's in the title. I want actors to be removed from the battle and party as soon as the enemy, with their skills, reduce their hp to 0. This should also work with poison or any state that deals dot. I have access to yanfly's plugins in case they're needed. Thanks for reading!
The non-plugin way to this would be a troop event with actor x health = 0 as a consition, which removes the actor as soon as it's triggered.
If you have a lot of troops / actors I'd recommend to have a blank troop with only these events ready to copy, whenever you need a new troop.
I renamed "Knockout" to dying, and leave the actor in my party during the battle, so that they can be revived by a relatively cheap stimulant. I use a common event called from a parallel event to check the party and remove casualties. (Parallel events don't seem to run during battles.) If someone dies outside battle you don't get a chance to use a stimulant.

If you are considering revival of dead and removed party members, there are several options. You could use a series of switches in the same order as those of your actors, and use plugins such Himeworks' Hidden Choices and Large Choices to choose the dead actor to revive. You could make the casualty removal event give the party a Hidden A (or Hidden 😎 item with the same name as the dead actor, then use the "Select Item" editor command. What I do currently is to use Himeworks' Party Manager to put them in another party based at the map the local necromancer is to be found.
1744267591372.png

Original thread: https://forums.rpgmakerweb.com/threads/make-actors-leave-party-and-battle-as-soon-as-they-die-fighting.176851/