MV State that changes escape ratio

Heyho!

I am trying to create a state that makes all attempts to escape successful. I am using Yanflys Buffs and States Core and several other plugins from the Yanfly library, so that might come in handy.

My first idea was to use a battle event to check if the state is apllied and then change the ratio with a script call, like

BattleManager._escapeRatio = 100

However this would mean to implement this in every troop event, which is quite tedious. If there are any other ways to accomplish this I am happy to learn 🙂

Another note: I am adding this state to a piece of armor with Yanflys Attachable Augments, so it does not necessarily have to be state. The important thing is, when you attach the augment and equip the armor, than you can escape every time.
if you dont allow players to change equipment mid battle, you could change the escapeRatio through a <Custom Battle Effect> on the state. that way, any time an actor wearing the armor is present in the battle, the escape rate is automatically made to be guaranteed
BattleManager._escapeRatio = 100
It's a ratio, it only needs to be 1 😛

Alternately, you can just put it into the formula. Paste the below into a text editor, save as a *.js file, include as a plugin.

Code:
BattleManager.makeEscapeRatio = function() 
{
    if ($gameParty.aliveMembers().some(actor => actor.isEquipped($dataArmor[42])))
        this._escapeRatio = 1;
    else
        this._escapeRatio = 0.5 * $gameParty.agility() / $gameTroop.agility();
};

Replace 42 with the ID of the armor.
Thanks to both of you 🙂

@ATT_Turan that should also be possible with a state instead of an armor, right? As I said I'd like to have an augment that creates this behaviour when attached to an armor.

@Robro33 unfortunately I allow changing armor mid Battle. Then again I'm not sure players will even notice^^ it's quiet unlikely that they unequip the always-escape-armor and then try to escape. And even then, escaping is quite likely in the first place, so I don't think they will track it down to the former equipped armor.
Just change the bit for actor.isEquipped() to actor.isStateAffected()
that should also be possible with a state instead of an armor, right? As I said I'd like to have an augment that creates this behaviour when attached to an armor.
You would need to use the script call to check for an actor's state instead of their equipment then.

i wasnt going to bring it up unless you mentioned the midbattle equipment changing, but the plugin might have the same problem.
I remember a while back someone was asking for a change for how escape rates were calculated and part of the issue was that the function to make the escape rate is only ran as the fight starts, not when an escape attempt is made.

youd need to either run it before every escape attempt or take the same check @ATT_Turan provided and bake it into BattleManager.processEscape() or whatever its called. Im not home to check at the moment

Try it to be sure though incase im misremembering
the function to make the escape rate is only ran as the fight starts, not when an escape attempt is made.
Oh gawrsh that's a good point.

So you'd add this to your plugin:
Code:
var oldProcessEscape = BattleManager.processEscape;
BattleManager.processEscape = function() {
    BattleManager.makeEscapeRatio();
   oldProcessEscape.call(this);
};

That will recalculate the escape ratio each time you do the command.

Original thread: https://forums.rpgmakerweb.com/threads/state-that-changes-escape-ratio.173643/