MV Checking enemyIndex of user

Hi all,

I'm trying to use an Eval in a YEP Battle A.I. Core condition so I can determine if the user is of a certain enemy index. Important to note here that I do mean index of the current troop and not the enemyId.

For instance, here would be how I check for the enemyId of the user in an eval:

Code:
user.enemyId() == 13

So, I literally just need the enemyIndex version of that. I really hope it's literally just not "enemyIndex" cause I will look like a right fool 🤣 - but I did look that up and it didn't seem to be a thing.
I'm trying to use an Eval in a YEP Battle A.I. Core condition so I can determine if the user is of a certain enemy index...I really hope it's literally just not "enemyIndex" cause I will look like a right fool 🤣 - but I did look that up and it didn't seem to be a thing.
No, the data structure for an enemy has no way to know what its index is in an array you put it into.

You can do
Code:
$gameTroop.members().indexOf(user)

Or, if you ever need it to be usable regardless of whether it's an actor or an enemy,
Code:
user.friendsUnit().indexOf(user)
Oh yeeeeeeah! That's it, worked a charm. Thanks @ATT_Turan !
Actually, one further question @ATT_Turan - it seems that trying to reverse this and use it for the target is not valid. I've tried:

Code:
$gameTroop.members().indexOf(target)

But it isn't valid. Do you know how I would go about doing this?
It looks like YEP AI Core doesn't define a target variable for the eval field. You might end up having to use a different approach there, e.g. with YEP Target Core or Selection Control? 😅

Incidentally, a shorthand for ATT_Turan's solution would be user.index(). It does much the same, checking $gameParty (actors) or $gameTroop (enemies) for the position of user, it's just shorter to write.
Ah! Thanks @caethyril . Also, you know what - a while back, Astfgl66 made this extension plugin which adds "Targeteval" as a valid condition, so you can then follow up with bit of code and it will apply to the target, which is really handy. I've been testing it out, and it seems to work well so far!

EDIT: Of course, "target" in the circumstance of a Targeteval condition will end up being "user". So just apply the condition as you would to a user, but make sure you're using "Targeteval" and not "Eval".

For anyone interested, the plugin extension is here.

Thanks!

Original thread: https://forums.rpgmakerweb.com/threads/checking-enemyindex-of-user.149814/