Check which actor was selected after using a skill

Hello! Is it possible to check which actor was selected in a skill?
Example: "If the skill Heal was used in Actor 2 - event", How can i make it? Is there a script call for it?
You can store the target (b) in damage formula to a variable.

Or if you copy something like MZ does to set the last action datas, you can put a plugin like this:

const _myEdit1_GameAction_apply = Game_Action.prototype.apply;

Game_Action.prototype.apply = function(target) {
_myEdit1_GameAction_apply.call(this, target);
if (target.isActor()) {
$gameVariables.setValue(X, target.actorId());
} else {
$gameVariables.setValue(Y, target.index() + 1);
}
}

Original thread: https://forums.rpgmakerweb.com/threads/check-which-actor-was-selected-after-using-a-skill.182576/