Emergence escape when only 1 party member is left alive

Is it possible to give the player, an actor, or even an item, a passive that increases their chance of escaping the battle by, say, 100% if only that party member remains alive and the rest is dead/knocked out?
I was thinking about using this for dungeon mini-bosses and mobs. If you don't run you can get a game over screen just as usual, but you'll always have the option to escape (unless it's an important boss, in which case I'd turn escape off).
On the other hand, if all actors get killed by a powerful AoE skill, the player might not even get that chance too, and that's okay.

The reasoning behind this is that I want to incentive the player to explore the maps, but I don't them to have an unpleaseant surprise finding out that the cave they just entered is too difficult for them when they're 80% inside already.
not by default or eventing, as the default escape is handled completely in the scripts.
it would be possible to do something similar with troop events, but that would not be locked to the regular escape commands and would have different chances.

with a script that is of course possible, you would only have to rewrite the escape functions a bit.
not by default or eventing, as the default escape is handled completely in the scripts.
it would be possible to do something similar with troop events, but that would not be locked to the regular escape commands and would have different chances.
I think with troop events I would have to either increase their stats of agility and luck (which could get a bit messy) or provide a choice selection menu (which is kinda clumsy). I'm not really happy with either, but maybe I'm missing something.

with a script that is of course possible, you would only have to rewrite the escape functions a bit.
How could I start doing that?
How could I start doing that?

with knowledge of programming in RGSS3, you would search the function for calculating the escape chance and tweak it to be greater if the item is detected somewhere in the party.

without programming knowledge, you would have to request an Ace script in the script request forum and let someone else write it,
with knowledge of programming in RGSS3, you would search the function for calculating the escape chance and tweak it to be greater if the item is detected somewhere in the party.

without programming knowledge, you would have to request an Ace script in the script request forum and let someone else write it,
Oh, I see. I'll try to do it by troop events first and check other possibilities, such as keeping the player alive but decreasing EXP after a defeat, before I decide to make a script request (or start learning RGSS3, which could drag along for some time...). Anyway, thank you for the directions.

Original thread: https://forums.rpgmakerweb.com/threads/emergence-escape-when-only-1-party-member-is-left-alive.130504/