Actors return to recruit location after defeat?

I've been replaying It's Our Revolution by Wood Penguin, and I really like the idea of having party members leave when defeated, and you having to go find the place you first recruited them to have them join you again.

Unfortunately, I have no experience with Javascript beyond the stuff I've found on the RMMV Script Calls sheet. What I was thinking of potentially doing was this:

1. When Actors get Knocked Out in a battle, have their IDs added to a variable as an Array.
2. After a battle is complete, put that array into $gameParty.removeActor().

I just don't know how to put that code together.

I also need to make Actors show up back at their original position for recruitment again. I was planning on using Common Events like so:

If: Script: $gameActors.actor(7).isDead()
Script: var key [5, 27, A]
$gameSelfSwitches.setValue(key, false)

And then repeating that for every possible Actor. Is there a more succinct way of writing this, or is this the best way to set this up without needing to make a Plugin Request?
um... did you had try it with normal event+script call?
you don't need self switch for this I think
switch for actor - who ever
enable when he dead(knockout) to show his page when recruiting again
it the basic that rpg maker already handle

and you can check knockout state by normal condition branch
then remove that actor from party
I don't think you need plugin at all
you just need to check basic of your editor knowledge more
you don't even need scripts.

the events pretending to be the actors to hire need three event pages.
First page without conditions is the page where the actor is not yet hired
Second page is conditioned with a switch "hired xy" for the case after they hired and left, waiting to be picked up again
Third page has no sprite and no content, is conditioned to "actor exits (= is in party)". This will make sure that the event vanishes while the actor is alive and in the party.

Then you make a parallel process common event triggered by a switch "after battle" to check all actors if they are dead. If yes, heal and remove from party. at the end of the event switch off the switch that triggered it.

last step: in every troop, make a troop event that turns on the after battle switch as soon as the battle is started. Because parallel processes can't work in battlescreen, the switch will trigger the common event directly after finishing battle.
Oh... whoops. I didn't put together that parallel processes would still work if they activate during a battle.

Sorry, I guess I got wrapped up in the idea that this was a really complicated thing to do that I just assumed it would need scripts.

Original thread: https://forums.rpgmakerweb.com/threads/actors-return-to-recruit-location-after-defeat.119536/