Restore Dead Allies To 1 HP After Battle? (Persona 5 Feature)

In Persona 5, if an ally dies in battle, they will be automatically revived with 1 HP after the battle. Can this be done with common events, or is a script required? How would I go about making this?
Forgive me if this exists already. Maybe I'm bad at knowing what to look up, but I can't find this anywhere. Not on the master list, not on Google.
You can do this with a parallel process common event. Set aside a switch and call it "revive dead"; let's say it has ID 5. Your event should be activated by that switch.

Create a conditional branch for script condition "!$gameParty.inBattle()" and inside that do the following script command:

Code:
$gameParty.deadMembers().forEach(function(member) { member.removeState(1); });
Then turn switch 5 OFF.

Make a battle event (if you're not using shared battle events, you'll need this for all troops) which turns switch 5 ON on turn 0.
@Trihan that doesn't seem to be working. Am I doing this correctly?
Ah, it works now. Had to remove the extra lines. I just saw you edited your post, so that's my bad lol. Thanks!

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/restore-dead-allies-to-1-hp-after-battle-persona-5-feature.123472/