Damage Formula that forcesescape on enemies

I'm trying to create a skill that has a 44% chance to force an enemy to leave battle.

But you can only force a removal during a skill without a given percentage.

Is there a damage formula that would allow for a change in the rate?
Some ideas:
  1. If the skill only forces escape, then you can set its Success rate to 44% and just add an Escape effect.

  2. You can have the skill add a state (no icon = invisible to player), then run a common event. In that event, roll a random number (Control Variables -> Random) and compare it to a threshold to decide whether to make the enemy escape. Unfortunately this is awkward because there's no "Enemy Escape" command: you'd either have to use Force Action or a script call for that part...

    You could make the entire common event with a script call, e.g.

    for (const enemy of $gameTroop.members()) { if (enemy.isStateAffected(123) && Math.random() < 0.44) { enemy.removeState(123); enemy.escape(); } }
    Replace 123 with the ID of the marker state you're using.

  3. You could try something like this in the damage formula:

    if (Math.random() < 0.44) b.escape(); 0
    Replace the 0 with your skill's damage formula. Note that the damage formula is only designed for calculating values, not for applying effects. Strange things might happen if you apply changes in the damage formula, e.g. force escape or add/remove a buff/state. For example, actors with an Auto Battle trait will evaluate the formulae of all available skills on all available targets to decide which skill to use. Plugins may also do stuff like that.

  4. To avoid the damage formula problems, you could find a plugin that lets you run script before/after a skill hits, e.g. the <JS Post-Damage> skill notetag from VisuStella MZ Battle Core:

    <JS Post-Damage> if (Math.random() < 0.44) { target.escape(); } </JS Post-Damage>
Some ideas:
  1. If the skill only forces escape, then you can set its Success rate to 44% and just add an Escape effect.

  2. You can have the skill add a state (no icon = invisible to player), then run a common event. In that event, roll a random number (Control Variables -> Random) and compare it to a threshold to decide whether to make the enemy escape. Unfortunately this is awkward because there's no "Enemy Escape" command: you'd either have to use Force Action or a script call for that part...

    You could make the entire common event with a script call, e.g.

    for (const enemy of $gameTroop.members()) { if (enemy.isStateAffected(123) && Math.random() < 0.44) { enemy.removeState(123); enemy.escape(); } }

    Replace 123 with the ID of the marker state you're using.

  3. You could try something like this in the damage formula:

    if (Math.random() < 0.44) b.escape(); 0

    Replace the 0 with your skill's damage formula. Note that the damage formula is only designed for calculating values, not for applying effects. Strange things might happen if you apply changes in the damage formula, e.g. force escape or add/remove a buff/state. For example, actors with an Auto Battle trait will evaluate the formulae of all available skills on all available targets to decide which skill to use. Plugins may also do stuff like that.

  4. To avoid the damage formula problems, you could find a plugin that lets you run script before/after a skill hits, e.g. the <JS Post-Damage> skill notetag from VisuStella MZ Battle Core:

    <JS Post-Damage> if (Math.random() < 0.44) { target.escape(); } </JS Post-Damage>

Thanks! I actually used the success 44% (I forgot about that for ‘some reason’. ha)

but now it seems the skill is always ‘greyed out’ in battle and I’m unable to use it.

It’s set up correctly as all my other skills
Without plugins, that implies that no-one in the party currently meets the skill's requirements. Check the skill's:
  • Occasion (i.e. Menu/Battle/Always/Never);
  • Required Weapons;
  • MP/TP costs.
Also check to see if the user has that skill/type sealed via a Seal Skill or Seal Skill Type trait.

Otherwise check your plugins.
Without plugins, that implies that no-one in the party currently meets the skill's requirements. Check the skill's:
  • Occasion (i.e. Menu/Battle/Always/Never);
  • Required Weapons;
  • MP/TP costs.
Also check to see if the user has that skill/type sealed via a Seal Skill or Seal Skill Type trait.

Otherwise check your plugins.
1662664428952.png


This is the skill in question, I've poured over my plugins and can't seem to find anything.
  1. That skill has a TP Cost of 40. Does the user have at least 40 TP when you're trying to use it?

  2. Did you check to see if the user has a Seal Skill (or Seal Skill Type) trait? It might be on the Actor, Class, a State, or any of their equipped Weapons/Armors. Remember that the state/equipment might not be visible in-game if you've left the icon/name blank.

  3. You can uncheck all plugins in the Plugin Manager, save your project, and test. If that makes the skill usable, then the problem is plugin-related. In that case you could post screenshot(s) of your Plugin Manager showing all plugins you are using and their load order...maybe that'll help someone figure out what's going on. 👋

Original thread: https://forums.rpgmakerweb.com/threads/damage-formula-that-forcesescape-on-enemies.151124/