Selecting enemies or actors

Hello!

I am kinda new to RPG Maker MV and trying to understand how everything works. I would like to know how does the game understand during a battle that you're selecting an enemy or an actor when you hover over your mouse. I have tried reverse engineering it but I couldn't find what I was looking for. I thought it detects your cursor position from TouchInput.x and TouchInput.y and changes the enemy index accordingly, but apparently not. Which class method should I look for?
I'm a bit unsure as to exactly what you're asking for.

By default, MV doesn't allow a skill to flexibly target an actor or enemy. It can target either enemies or allies strictly. This can be altered by plugins however.

If you're asking for a check to see if target is an actor or enemy, the Game_BattlerBase class (it's found in the rpg_objects.js file) has an isActor() function that returns true if the target is an actor, and an isEnemy() function that returns true if the target is an enemy.

If you think I failed to understand your question, I would ask you to rephrase it a bit.
Sorry, I think I couldn't write clearly. Let's forget the actor for now.

After selecting regular attack command during the side-view battle, when you hover your mouse over a specific enemy, you can see that the enemy is highlighted and the enemy index changes.

How does the game detect that the cursor is touching the enemy sprite?
It does detect it using TouchInput.x and TouchInput.y

If the cursor is touching the enemy's 'hitbox', then the game detects it as the cursor touching the enemy sprite.

The enemy 'hitbox' is the size of the battler graphic.

The function can be found in line 1066 of the rpg_windows.js file.

Code:
Window_Selectable.prototype.isTouchedInsideFrame = function() {
    var x = this.canvasToLocalX(TouchInput.x);
    var y = this.canvasToLocalY(TouchInput.y);
    return x >= 0 && y >= 0 && x < this.width && y < this.height;
};
Oh, I thought that was only for selecting the commands within the windows.
I will have another look at it then. Thank you very much!

Original thread: https://forums.rpgmakerweb.com/threads/selecting-enemies-or-actors.79894/