Can Troops leave Battle?

Hi there!

As a humorous boss battle, I plan to have my enemy boss troop get bored and decide to RANDOMLY quit the battle with the player's party all by themselves.

I can't put my mind around how a boss troop or any troop can escape the battle at all. Nor do I want to do it cheaply with some kind of hidden death state. That would be a static solution anyway.

How would it be possible to let enemy troops escape the battle at random?

I believe that the following script may be of some help: https://forums.rpgmakerweb.com/index.php?threads/enhancing-troop-functionality.18372/#post-177062

Specifically:
By default, the engine uses a single escape formula to determine whether the party escapes from battle or not. This script allows you to specify a custom escape ratio for each troop.

This script uses formulas to determine the escape ratio in battle as follows:

In the first page of a troop event, create a comment of the form

<escape ratio: formula>

Where `formula` is a valid ruby statement that returns a number.
Four variables are available in your formula

p - current game party
t - current troop
v - game variables
s - game switches

A few example uses:

<escape ratio: 0>
Zero chance of escape
<escape ratio: p.agi / t.agi>
ratio of party's agi to troop's agi
<escape ratio: 1.5 - 1.0 * t.agi / p.agi>
This is the default escape ratio

However this is meant for the Escape Ratio of the PLAYER's Party. Not for how Enemy Troops can exit battle.

Is there some kind of tweak or special formula that can change this script into being a control of the Escape Ratio of the ENEMY TROOP can escape from battle?

Please Help. Games can't be funny without this feature.
no need for anything complex.

the escape skill and escape effect are intended to be used on enemies, just have it randomly in the boss action pattern.
I tried that but it gets really predictable really quickly whether by Turn Number or Enemy HP in the database.
I'd really like it to be truely random and unpredictable, for example, if the Player's Party Agility is lower than the Enemy Troop, the Troop will escape battle at once without any damage inflicted. etc etc.
then you have to work on your predictability, not on the effect itself. Because the skill is exactly what you want and need, and it is only a question on when the skill is used.

so the question is when and under which conditions and whith which chance do you want the skill to be used?
define that and we can tell you how to do it. Because the skill can only look unpredictable to the player, the developer should always know all possible causes and chances.

Original thread: https://forums.rpgmakerweb.com/threads/can-troops-leave-battle.148532/