Apply state based on 0 MP at the end of the turn

Hello fine folks,

I want to be able to have each battle in my game apply a state at the end of each turn to any and every actor who has 0 MP, be they party member or enemy, in MV. It's a specific state.
This code will run at the end of every turn in every battle, so ideally we want it to be able to run quickly.
I'm not sure if this is something that can be done in engine by default or if a plugin would be required. Any help you can provide would be appreciated.

Cheers!
Without plugins method: This applys for only one actor. If you want for all members in battle then use this script:
Spoiler
JavaScript:
$gameParty.members().forEach(function(member){
    if (member.mp <= 0){
        member.addState(stateId);
    } else { member.removeState(stateId); }
});

3rd page of event editor, script button.

2021-08-08 13_08_30-Window.png
Without plugins method:

View attachment 198043
I don't really work with the "gameActors" function much. Does this also work for enemies? I'll be honest, I've already got a way to apply it to party members (it does the job but it could potentially be sped up) and now enemies is the crucial part.
Yes, with enemies also will work.
In conditional branch use call
$gameTroop.members()[number].mp < 0;

and applying state to enemy is on third page
2021-08-08 13_15_24-Window.png
Sorry I'm so inept with this stuff, but the third page lists only 9 options, either "entire troop" or 8 hard coded destination enemies. I'm not sure how to combine the non-specific "$gameTroop.members()[number].mp < 0" with the specific "Enemy 1", "Enemy 2", etc.

Edit wait do I replace number with the iD?
My SFG_AltDeathState plugin almost does this, but the state is applied the moment they reach 0 MP rather than at the end of the turn.

Original thread: https://forums.rpgmakerweb.com/threads/apply-state-based-on-0-mp-at-the-end-of-the-turn.139372/