Need a script call to grab an enemy stat and compare against the players

So I'm making a skill that needs to compare the enemy agility against the actors agility. I'm looking for a script call that can call upon the currently selected enemy agility and store it into a variable to compare against the actors agility.
thank you.
var enemyAgi = $gameTroop.members()[id].agi
- takes agility of enemy in current troop wich you are fighting
var actorAgi = $gameParty.members()[id].agi
- takes agility of party member (0 is leader, >0 are rest of crew

Edit: I didn't catch "currently selected" that I don't know, but that what I gave you can use on targeted enemy. I had somewhere an entire function that allows to create a skill that reads all enemy stats. Gimme a minute...

Here it is:
JavaScript:
Game_System.prototype.eyeOfTruth = function(caster, target){
    
    //setub basic variables wich we will use later
    
    /* Current HP wich will be shown in format x / y" */
    var currentHp = 0;
    /* Current MP wich will be shown in format x / y" */
    var currentMp = 0;
    /* Current ATK value (states included) */
    var currentAtk= 0;
    /* Current DEF value (states included) */
    var currentDef= 0;
    /* Current Magic Attack value (states included) */
    var currentMat= 0;
    /* Current Magic Defence value (states included) */
    var currentMdf= 0;
    /* Current ATK value (states included) */
    var currentAgi= 0;
    /* Current ATK value (states included) */
    var currentLuk= 0;
    /* Enemy description if there is any (use notetag for enemy <enemy_desc:your desc>*/
    var description = null;
    /*    *****    Start obtaining data    ***** */
    if (target.isEnemy() && target.isAlive()){
        if (!target.isStateAffected(48)){
            currentHp = target.hp + " / " + target.mhp;
            currentMp = target.mp + " / " + target.mmp;
            currentAtk = target.atk;
            currentDef = target.def;
            currentMat = target.mat;
            currentMdf = target.mdf;
            currentAgi = target.agi;
            currentLuk = target.luk;
            description = target.name() + ": " + $dataEnemies[target.enemyId()].meta['enemy_desc'] || "???";
            /*    *****    reading data completed    *****    */
        } else {
            
            description = "???";           
        }
        //    /////    Render Data and display it    /////    //
        //target.customPopup("Mirror Force!", 0);
        $gameMessage.add("<WordWrap>\\msgrows[5]\\c[6]" + description + "\\c[24]<br>" + TextManager.hp +": " + currentHp +
            "<br>\\c[23]" + TextManager.mp + ": " + currentMp + "<br>\\c[0]" + TextManager.param(2) + ": " + currentAtk + " / " +
            TextManager.param(4) + ": " + currentMat + "<br>" + TextManager.param(3) + ": " + currentDef + " / " +
            TextManager.param(5) + ": " + currentMdf + "<br>" + TextManager.param(6) + ": " + currentAgi + " / " + TextManager.param(7) + ": " + currentLuk);       
    }
    return 0;
}

Save this as JS file (any name), place it in plugins folder and add this to plugin manager.
In your skill in field "formula" add following code:
Code:
$gameSystem.eyeOfTruth(a,b)

Basicly this will just display info about targeted enemy, but if you wish to change it, feel free.
Also I will help you if you need to adjust this code to your needs, because right now it's using lot of Yanfly's message plugins.
var enemyAgi = $gameTroop.members()[id].agi
- takes agility of enemy in current troop wich you are fighting
var actorAgi = $gameParty.members()[id].agi
- takes agility of party member (0 is leader, >0 are rest of crew

Edit: I didn't catch "currently selected" that I don't know, but that what I gave you can use on targeted enemy. I had somewhere an entire function that allows to create a skill that reads all enemy stats. Gimme a minute...
I thought about doing something like that, but I want to avoid needing the troop id number. It has to do with that I'm going to have waves of enemies showing up in the game using some plugins, so I'm going to go beyond the whole 8 enemy troop limit.
I was looking at this skill by Yanfly http://www.yanfly.moe/wiki/Libra_(MV_Plugin_Tips_&_Tricks) that kind of does some of the things I'm looking for in terms of being able to just grab the stats of the selected enemy, but I just haven't figured out how to properly apply it to what I want to do.
Thank you.
I'm not sure if this makes any sense, I know little about coding, but just by what you and Yanfly have this is what I came up with:

if (target.isEnemy()) {$gameVariables.setValue(8) = target.agi};

It doesn't work, but maybe it will make more clear what I want to do.
if you can do the effect inside the damage formula, then the target agi is simply b.agi (similar to b.def for the target defense)
Figured out how to do what I wanted to do using yanflys skill core

<Before Eval>

$gameVariables.setValue(19, a.agi);

</Before Eval>

Original thread: https://forums.rpgmakerweb.com/threads/need-a-script-call-to-grab-an-enemy-stat-and-compare-against-the-players.138460/