Understanding Battle Animations and Interrupting Them After Execution

I want to check to see if a specific skill is used in battle and after the first part of the attack animation plays (for a magic spell when the magic circle forms under the actor), transfer the game to a custom scene in which I plan to have a mini game of some sort and when that mini game is completed, return to the map and execute a cut scene. I have been looking through the code for a few hours and I am a unsure what function to overwrite to catch the game right after the actor does the first part of the animation but before the next part executes. I have been looking through BattleManager specifically at these functions:
Code:
BattleManager.startAction = function() {
    var subject = this._subject;
    var action = subject.currentAction();
    var targets = action.makeTargets();
    this._phase = 'action';
    this._action = action;
    this._targets = targets;
    subject.useItem(action.item());
    this._action.applyGlobal();
    this.refreshStatus();
    this._logWindow.startAction(subject, action, targets);
};

BattleManager.updateAction = function() {
    var target = this._targets.shift();
    if (target) {
        this.invokeAction(this._subject, target);
    } else {
        this.endAction();
    }
};

BattleManager.endAction = function() {
    this._logWindow.endAction(this._subject);
    this._phase = 'turn';
};

BattleManager.invokeAction = function(subject, target) {
    this._logWindow.push('pushBaseLine');
    if (Math.random() < this._action.itemCnt(target)) {
        this.invokeCounterAttack(subject, target);
    } else if (Math.random() < this._action.itemMrf(target)) {
        this.invokeMagicReflection(subject, target);
    } else {
        this.invokeNormalAction(subject, target);
    }
    subject.setLastTarget(target);
    this._logWindow.push('popBaseLine');
    this.refreshStatus();
};

BattleManager.invokeNormalAction = function(subject, target) {
    var realTarget = this.applySubstitute(target);
    this._action.apply(realTarget);
    this._logWindow.displayActionResults(subject, realTarget);
};

and it just looks like a lot of math calculations for determining if an attack is countered or not. I was hoping the invokeAction functions would call the animation functions in Spriteset_Battle but I dont see anything in the battle manager pertaining to animation (Though I'm not seeing a lot of update functions in the Spriteset_Battle class either). So my question is where is the code that executes the first part of the magic animation so after that completes, I can redirect the game to my custom scene before any more actors or enemies do anything else?
Unfortunately (and much to the annoyance of a lot of devs), a lot of battle logic happens on the Window_BattleLog. Instead of only using the BattleLog as a combat log, it also controls many animations. Take a look at Window_BattleLog.prototype.startAction:

Code:
Window_BattleLog.prototype.startAction = function(subject, action, targets) {
    var item = action.item();
    this.push('performActionStart', subject, action);
    this.push('waitForMovement');
    this.push('performAction', subject, action);
    this.push('showAnimation', subject, targets.clone(), item.animationId);
    this.displayAction(subject, item);
};

Additionally, they've also decided to have a function named "push" that is not the normal JavaScript "push" function, so that can be a little confusing, too. Window_BattleLog has a stack of functions it stores in its _methods property. It adds to that stack via its push method, then, unless it's waiting (checked via the updateWait method), it calls the next function.

You'll see in the BattleManager.startAction function that the last bit of logic calls _logWindow.startAction, which is the BattleLog's startAction method. performActionStart and performAction are methods that animate the battler Sprite, while showAnimation is probably what you're looking for. Specifically, I'd probably start investigating in this block:

Code:
Window_BattleLog.prototype.showAnimation = function(subject, targets, animationId) {
    if (animationId < 0) {
        this.showAttackAnimation(subject, targets);
    } else {
        this.showNormalAnimation(targets, animationId);
    }
};

Window_BattleLog.prototype.showAttackAnimation = function(subject, targets) {
    if (subject.isActor()) {
        this.showActorAttackAnimation(subject, targets);
    } else {
        this.showEnemyAttackAnimation(subject, targets);
    }
};

Window_BattleLog.prototype.showActorAttackAnimation = function(subject, targets) {
    this.showNormalAnimation(targets, subject.attackAnimationId1(), false);
    this.showNormalAnimation(targets, subject.attackAnimationId2(), true);
};

Window_BattleLog.prototype.showEnemyAttackAnimation = function(subject, targets) {
    SoundManager.playEnemyAttack();
};

Window_BattleLog.prototype.showNormalAnimation = function(targets, animationId, mirror) {
    var animation = $dataAnimations[animationId];
    if (animation) {
        var delay = this.animationBaseDelay();
        var nextDelay = this.animationNextDelay();
        targets.forEach(function(target) {
            target.startAnimation(animationId, mirror, delay);
            delay += nextDelay;
        });
    }
};

If you're using Yanfly Plugins, it's going to be completely different, though. You get the sense that he hated the approach of putting non-log logic on the log window because in his BattleEngineCore Plugin, he completely removes all logic from those methods:

Code:
Window_BattleLog.prototype.startAction = function(subject, action, targets) {
};

Window_BattleLog.prototype.endAction = function(subject) {
};

So if you are using Yanfly's BattleEngineCore, you'll have to go digging through his logic to figure out how he's rebuilt where animations happen.
If thats a specific skill, I suggest just doing

- Make the skill only have the magic animation
- Make it run a common event that transfer you to the mini-game map or whatever it is

No need to tap into the code
The thing is when I say mini game I mean a custom coded non rpgmaker map scene. So basically think something like space invaders. As far as I know, it is impossible or at the very least, extremely difficult to modify the map scene so that it functions as a separate type of game. I want to add custom movement and objects falling from the sky onto the object that the player gains control of which in this case wont be an actor anymore but another sprite. I would be open to using a common event if its possible but I dont think common events allow you to transfer to custom created scenes. If I'm wrong please correct me. I'm very new to this software. And thank you Zevia, I'll be sure to take a look at that code block and at the moment, I'm not using any YEP plugins. I want to see what I can do myself before I tap into his and other people's stuff.
You could still make the common event transfer you to your custom scene though via script calls, it doesnt necessarily mean it has to be a map. I just said map on my other post because I thought it was on a map
oh yeah that does sound a lot easier but I may still attempt this just to see if I can do it.

Original thread: https://forums.rpgmakerweb.com/threads/understanding-battle-animations-and-interrupting-them-after-execution.106219/