Forcing to Ignore wait for action in battle

I added to Scene_Battle button that suposed to run common event showing choices for player whetter he want's to abort battle or not and everything is fine, except one detail, Common Event is executed AFTER selecting one of battle commands (Attack, Guards, skills etc).

How to force to run Common event regardless of action input, like on Scene_Map?
You could try saving this as a .js file and importing it as a plugin:
JavaScript:
BattleManager.updateEvent = function() {
  if (this.isActionForced()) {
    this.processForcedAction();
    return true;
  } else {
    return this.updateEventMain() || this.checkAbort();
  }
};
This is an override for the default BattleManager.updateEvent method without any battle phase checks (cf paragraph & spoiler below). Slight warning: this might cause undesired effects...I'm not entirely sure why events are restricted to run only in certain phases. 😅

Technical explanation: the flow of battle is directed by the BattleManager, which only considers event updates in specific phases of battle, namely "start", "turn", and "turnEnd". Player input is considered during the "input" phase: what you're seeing is the event getting queued until the phase changes from "input" to "turn".

Supporting core script excerpts (rpg_managers.js) plus some comments:
Spoiler: Annotated BattleManager event flow
JavaScript:
BattleManager.update = function() {
    if (!this.isBusy() && !this.updateEvent()) {  // update event
        switch (this._phase) {
        case 'start':
            this.startInput();
            break;
        case 'turn':
            this.updateTurn();
            break;
        case 'action':
            this.updateAction();
            break;
        case 'turnEnd':
            this.updateTurnEnd();
            break;
        case 'battleEnd':
            this.updateBattleEnd();
            break;
        }
    }
};

BattleManager.updateEvent = function() {
    switch (this._phase) {  // only start, turn, turnEnd phases
        case 'start':
        case 'turn':
        case 'turnEnd':
            if (this.isActionForced()) {
                this.processForcedAction();
                return true;
            } else {
                return this.updateEventMain();  // main event update stuff here
            }
    }
    return this.checkAbort();
};

BattleManager.updateEventMain = function() {
    $gameTroop.updateInterpreter();  // update event interpreter
    $gameParty.requestMotionRefresh();
    if ($gameTroop.isEventRunning() || this.checkBattleEnd()) {
        return true;
    }
    $gameTroop.setupBattleEvent();
    if ($gameTroop.isEventRunning() || SceneManager.isSceneChanging()) {
        return true;
    }
    return false;
};
@caethyril thank you for claryfing some things, but that update does not work. Even though I have installed HIME_CommonEventQueue plugin, but your code is placed at the bottom of plugin manager, so it's overriding default BM methods
I should've known the battle system wouldn't give up so easily. 😔

I did a bit of looking through the code and it seems the battle scene only updates the manager under specific conditions. It looks like events are limited to certain phases because of input window restrictions? Seeing the way it's set up, I feel like it may be less challenging to add a new window to the scene and code it like that. 😅

...it's late here right now, so I'm going to bed. 😴
@caethyril - I also did notice that... Let me rephrase question then, because of Scene_Battle design (HUD, game resolution etc) I had to remove Escape command from Window_Command and I need a button allowing a player to do with single click. I used for that @Aloe Guvner plugin VirtualButtons, wich allows to run common event or custom JS code. So for test run in my JS class I wrote this:
Code:
Soulrender.prototype.askForEscape = function(){

    var mainOptions = ["Abort Battle", "Continue"];
    $gameMessage.setChoicePositionType(1);
    $gameMessage.setChoiceBackground(0);
    $gameMessage.setChoices(mainOptions, 0);
    $gameMessage.setChoiceCallback(function(responseIndex)
    {
        switch (responseIndex){
        
            case 0:{
                BattleManager.processAbort();
            }
            
            case 1:{
                //BattleManager.startInput();
                /***********************/
            }                        
        }
    });
}
And that code is executed right away, but the other problem is at "case 1:" what to put there so the battle commands will apear again and battle won't be suspended in "limbo" :]
(Game_Interpreter.prototype.setWaitMode('message') don't work)
Oh, neat! I think you just need to reopen the command window. I tried this sort of thing and it seemed to work OK:
Spoiler: Edited code
JavaScript:
Soulrender.prototype.askForEscape = function() {
    var mainOptions = ["Abort Battle", "Continue"];
    var sc = SceneManager._scene, W;
    ['_partyCommandWindow', '_actorCommandWindow'].some(function(w) {
        if (sc[w] && !sc[w].isClosed()) return W = sc[w], true;
        return false;
    });
    $gameMessage.setChoicePositionType(1);
    $gameMessage.setChoiceBackground(0);
    $gameMessage.setChoices(mainOptions, 0);
    $gameMessage.setChoiceCallback(function(responseIndex) {
        switch (responseIndex) {
            case 0:
                BattleManager.processAbort();
                break;
            case 1:
                if (W) W.open();
                break;
        }
    });
};
I.e. get the current command window beforehand, then reopen it if "Continue" is chosen. The scene automatically reopens the status window (see spoiler below), but doesn't bother to track the command windows (I assume that's because choices normally can't display when those are open). 😮‍💨
Spoiler: Scene_Battle > updateStatusWindow
JavaScript:
Scene_Battle.prototype.updateStatusWindow = function() {
    if ($gameMessage.isBusy()) {
        this._statusWindow.close();
        this._partyCommandWindow.close();
        this._actorCommandWindow.close();
    } else if (this.isActive() && !this._messageWindow.isClosing()) {
        this._statusWindow.open();
    }
};
@caethyril Yes!! That works perfectly as I wanted. As a token of my graditute, please accept this girl with
beer 🙂
Spoiler
Screenshot_1.png

Original thread: https://forums.rpgmakerweb.com/threads/forcing-to-ignore-wait-for-action-in-battle.129236/