MV Check what enemy is in a specific troop slot

Hi all, I have a skill idea that would make a second enemy attack only if that second enemy is a specific enemy id. Basically what I would need to know is how to write an if statement that would go something like:

If (enemy troop member "x" is equal to enemy_id "x")
{
do stuff
};

For the most part i know how to get this to work but the only thing i need is the Enemy troop member and enemy_id scripts. If anyone can help it would be greatly appreciated.

Additionally, If anyone know how to check the casters enemy_id, that would also be helpful.
Example based on above:

If (enemy troop member "x"'s enemy_id is equal to casters enemy_id )
{
do stuff
};

I was thinking that if I could do it that way, the same skill could be used by other enemies without having to make a second skill.
To get a specific enemy troop member you can simply access the array $gameTroop.members().
Note that arrays begin their numbering at 0 and that there is no guarantee that a given array element even exists when you just directly access it via its index. To access the second troop member's enemy id and compare it to x and ensure that it exists you will need to do the following:
$gameTroop.members()[1] && $gameTroop.members()[1].enemyId() == x

The second question could be a bit more involved, depending on where exactly you put that code. Yanfly notetags often are able to access caster and target as a and b like in the damage formula. However if this code goes into a common event that will be executed by the skill you will need to save the caster id first (for example in the damage formula or a yanfly notetag) to a variable and then access this variable in the common event.
Thank you so much. That gave me what I needed to get the skill completed.

Original thread: https://forums.rpgmakerweb.com/threads/check-what-enemy-is-in-a-specific-troop-slot.150263/