Help With Escape Dialogue/Event

Hello again,

I was wondering if it was possible to have a battle skill or even a common event run after a failed escape. I want the event to run a small bit of dialogue like, "Trying to escape huh? I'll fix that" or something like that and the enemy will use a strong attack using the "force action" command.

What I can't seem to figure out is a way to make sure the player can SEE the escape button, USE escape and then it will FAIL and the dialogue/event will run. It is a boss battle so I want to make it seem like the player can run before hiding the escape command entirely if possible. I am using Yanfly's Battle Engine Core so if there are any plugin suggestions I might have to pass them through that first since Yanfly's plugin is a priority unfortunately.

It's another strange question that I'm starting to think I will need to request a plugin for, which I'm perfectly fine with doing. Any help would be appreciated, thanks in advance!
Copy the below and paste it into a text editor. Save it as a *.js file and include it as a plugin.

Code:
BattleManager.processEscape = function() {
    $gameParty.performEscape();
    SoundManager.playEscape();
    var success = this._preemptive ? true : (Math.random() < this._escapeRatio);
// Fill in your stuff on these lines
    if ($gameSwitches.value(X))
    {
        $gameTemp.reserveCommonEvent(Y);
        $gameParty.clearActions();
        this.startTurn();
        return false;
    }
    if (success) {
        this.displayEscapeSuccessMessage();
        this._escaped = true;
        this.processAbort();
    } else {
        this.displayEscapeFailureMessage();
        this._escapeRatio += 0.1;
        $gameParty.clearActions();
        this.startTurn();
    }
    return success;
};

where X is the ID of a switch in your game and Y is the ID of the common event to call. No leading zeros on the IDs.

You'll turn that switch ON for boss fights and it will circumvent the normal escape command functionality and go directly to the common event you specify. If you want to disable the escape command for the rest of that battle after they try to use it, include in your common event the script command: BattleManager._canEscape=false;
Copy the below and paste it into a text editor. Save it as a *.js file and include it as a plugin.

Code:
BattleManager.processEscape = function() {
    $gameParty.performEscape();
    SoundManager.playEscape();
    var success = this._preemptive ? true : (Math.random() < this._escapeRatio);
// Fill in your stuff on these lines
    if ($gameSwitches.value(X))
    {
        $gameTemp.reserveCommonEvent(Y);
        $gameParty.clearActions();
        this.startTurn();
        return false;
    }
    if (success) {
        this.displayEscapeSuccessMessage();
        this._escaped = true;
        this.processAbort();
    } else {
        this.displayEscapeFailureMessage();
        this._escapeRatio += 0.1;
        $gameParty.clearActions();
        this.startTurn();
    }
    return success;
};

where X is the ID of a switch in your game and Y is the ID of the common event to call. No leading zeros on the IDs.

You'll turn that switch ON for boss fights and it will circumvent the normal escape command functionality and go directly to the common event you specify. If you want to disable the escape command for the rest of that battle after they try to use it, include in your common event the script command: BattleManager._canEscape=false;

Thank you so much! Sorry it took so long to reply but this works fantastic. I'm assuming to allow escape again I just turn the value to true. Aside from that, this is exactly what I was looking for!

Original thread: https://forums.rpgmakerweb.com/threads/help-with-escape-dialogue-event.155891/