I need help making (sort of) specific IF statements for Battle (RMMV)

Hello! I was told to ask my questions here, and not completely rely on the steam forums.

So I'm making a game with a complicated mechanic. If a character is hurt, a bulkier character will jump in front of them and take damage for them. Sort of like the whipping boy skill in Dragon Quest 9.

The thing is, this skill is automatic. The character's passive is to body-block damage for her allies, and I think I'm going to have to code this in Javascript (if possible). I'm more used to C#, but I think I can use simple IF statements to accomplish this goal.

I think I need to know the Actor ID for the person using the body blocking skills, and I need to know the id for individual party members. I would also need to disable this passive when the character's health is too low.

Where can I find the character IDs for all of my characters, and how EXACTLY would I code this mechanic into my game?
Just so you know, this function is already available in the editor by default (states > traits > other > special flag > substitute).

However, I don't really know how to edit its default behaviour (by default it only takes attacks for allies below 25% of their HP). I'm sure someone with actual knowledge on Javascript can help you with that.
Just so you know, this function is already available in the editor by default (states > traits > other > special flag > substitute).

However, I don't really know how to edit its default behaviour (by default it only takes attacks for allies below 25% of their HP). I'm sure someone with actual knowledge on Javascript can help you with that.

I didn't know that a function like this exists, but as i said I'd need it to be automatic and start earlier than 25%.

Do you know how I can find the actors IDs?

Original thread: https://forums.rpgmakerweb.com/threads/i-need-help-making-sort-of-specific-if-statements-for-battle-rmmv.93774/