@escape_ratio = 1.5 - 1.0 * $game_troop.agi / $game_party.agi
So I am trying to figure this out. How does rpg maker handle this?
I came up with this example for a battle test that I did, but the math doesn't add up.
Example: 4 party members: agi: 20, 20, 24, 25
two enemies: Agi: 10 each (20 total)
So the math is this: 1.5-1.0 * 20/89
Total: 1.2752808988764044943820224719101
What would the escape chance be, because every time I hit escape against two of them it always acts like a 100% chance.
Also how would I go at adding the troops luck to their agility with the ratio?
Thanks for the help.
As you calculated, the chance of escape (before any bonuses for failed escapes are added in - I forget whether Ace uses those or not) is 1.27, or 127%. Anything above 1.00 will result in a 100% chance of escape (always Successful), and that will happen when the party's average AGI is at least one-and-a-half times the enemy troop's average AGI.
To add in other stats, you will need to first define the party's/troop's average LUK (for example), and to do so you will need to go to Game_Troop and Game_Party (or possibly just Game_Unit) in your script editor. There, you will find the definition method for the troop's average agility - probably called def agi . Copy and paste it and change the second version to be for luk instead of agi. Once you've done that (may need to do it for Troop and Party), you can introduce those things into the formula, so you'd have something like @escape_ratio = 2.5 - (1.0 * $game_troop.agi / $game_party.agi) - (1.0 * $game_troop.luk / $game_party.luk)
That would give the party a 50% chance to escape when their AGI and LUK are equal to the troop's (same as the original formula when AGI is equal), higher if AGI and LUK are higher than the troop's, lower if AGI and LUK are lower than the troop's.
The mistake you've made is taking .agi to be the cumulative total, but it isn't. If you look at the agi method in Game_Unit, it returns the *average* agi.
So for your party, that would be 89 / 4 = 22.25, and for your enemies it'd be 20 / 2 = 10.
The escape ratio would then be 1.5 - 1.0 * 10 / 22.25 = 1.5 - 0.44944 = 1.05056, or 1.05 to simplify. In other words, your initial escape ratio with those stats is 105%, which means an escape attempt will always succeed because the ratio is compared against a random number between 0 and 1 and the code checks if that value is less than the ratio, and there's no way for it not to be in this case.
What effect would you like the troop's luck to have on that?