[RMMV] Changing Battle Screen Transition Animations

I am using KMS_SpiralEncount to create a spiral effect when transitioning from field map to battle screen. However I want to change the "Tint" of that transition based on whether or not the battle is a surprise attack (player surprises enemy), an ambush (enemy surprises player) or neutral battle (normal encounter). Does anyone know of a way to do this?

I am also using YEP_ForceAdvantage which allows for a common event to be set with each of these scenarios see attached screenshot. Is there a way to take advantage of these common event links to accomplish the screen tint on the transition?

[EDIT] Ok so I have figured out how to tint the screen using the Tint Screen Command. I have this set up on a common event with a parallel trigger but it keeps automatically triggering as soon as the map is loaded up and not only when there is a pre-emptive battle. Any help is greatly appreciated. New screenshot added to show the common event.
Parallel does that; just set it up as normal.

One could very easily set up the tint from code, but then how could it be changed back? and how could the previous tint be saved and restored?
Parallel does that; just set it up as normal.

One could very easily set up the tint from code, but then how could it be changed back? and how could the previous tint be saved and restored?
Thank you.
SpiralEncount calls the original updateEncounterEffect.

this should get you close.


JavaScript:
Yanfly.FAdv.BattleManager_setup = BattleManager.setup;
BattleManager.setup = function(troopId, canEscape, canLose) {
    Yanfly.FAdv.BattleManager_setup.call(this, troopId, canEscape, canLose);
    this.checkForceAdvantage(this._forceAdvantage);
};

Scene_Map.prototype.updateEncounterEffect = function() {
    if (this._encounterEffectDuration > 0) {
        this._encounterEffectDuration--;
        var speed = this.encounterEffectSpeed();
        var n = speed - this._encounterEffectDuration;
        var p = n / speed;
        var q = ((p - 1) * 20 * p + 5) * p + 1;
        var zoomX = $gamePlayer.screenX();
        var zoomY = $gamePlayer.screenY() - 24;
        if (n === 2) {
            $gameScreen.setZoom(zoomX, zoomY, 1);
            this.snapForBattleBackground();
            this.startFlashForEncounter(speed / 2);
        }
        $gameScreen.setZoom(zoomX, zoomY, q);
        if (n === Math.floor(speed / 6)) {
            this.startFlashForEncounter(speed / 2);
        }
        if (n === Math.floor(speed / 2)) {
            BattleManager.playBattleBgm();
            this.startFadeOut(this.fadeSpeed());
        }
        
        // screen tint stuff.
        if (this._encounterEffectDuration == 58) {
            var tintColor = [0,0,0,0];
            if (BattleManager._preemptive) { tintColor = [255, 0, 0, 0]; }
            else if (BattleManager._surprise) { tintColor = [0, 0, 255, 0]; }
            $gameScreen.startTint(tintColor, 50);
        } else if (this._encounterEffectDuration == 1) {
            var tintColor = [0, 0, 0, 0];
            $gameScreen.startTint(tintColor, 1);
        }
    }
};

Original thread: https://forums.rpgmakerweb.com/threads/rmmv-changing-battle-screen-transition-animations.133674/