MZ Plugin so you can lose Random Encounters

Hi! I´ve found a few posts that say to do this adding
Code:
BattleManager._canLose = true
to every single troop event manually, but I was wondering if it´d be possible to make a plugin so you can lose all random encounters directly in a more straight forward way. Thanks a mil!!
BattleManager.setup = function(troopId, canEscape, canLose) {
this.initMembers();
this._canEscape = canEscape;
this._canLose = true;
$gameTroop.setup(troopId);
$gameScreen.onBattleStart();
this.makeEscapeRatio();
};
BattleManager.setup = function(troopId, canEscape, canLose) {
this.initMembers();
this._canEscape = canEscape;
this._canLose = true;
$gameTroop.setup(troopId);
$gameScreen.onBattleStart();
this.makeEscapeRatio();
};
Works like a charm! thanks a million!! ☺️
But that means all battles can be lost, doesn't it? It seems to me that that's probably not what you want. I'd suggest this instead (untested):

Code:
BattleManager.onEncounter = function() {
    this._preemptive = (Math.random() < this.ratePreemptive());
    this._surprise = (Math.random() < this.rateSurprise() && !this._preemptive);
    this._canLose = true;
};
Oh yeah I forgot they might have bosses and stuff, good point 😀
But that means all battles can be lost, doesn't it? It seems to me that that's probably not what you want. I'd suggest this instead (untested):

Code:
BattleManager.onEncounter = function() {
    this._preemptive = (Math.random() < this.ratePreemptive());
    this._surprise = (Math.random() < this.rateSurprise() && !this._preemptive);
    this._canLose = true;
};
Oooh that´s great! thanks a mil!!
This thread is closed due to being reported as solved. If you need it reopened, report it to let us know. Thank you!

Original thread: https://forums.rpgmakerweb.com/threads/plugin-so-you-can-lose-random-encounters.178046/