# Escape ratio questions

Status
Not open for further replies.

#### slickdeath97

##### Veteran
@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.

#### Wavelength

##### MSD Strong
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.

#### Trihan

##### Speedy Scripter
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?

#### slickdeath97

##### Veteran
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.
Ok. I am a bit confused. I found the agi in unit thing you were talking about, but what do i do?
If possible please do pictures, I do better with a picture setup.

#### Wavelength

##### MSD Strong
Ok. I am a bit confused. I found the agi in unit thing you were talking about, but what do i do?
If possible please do pictures, I do better with a picture setup.
I don't have the time to make, crop, and upload the pictures, but I'll try to explain it more firmly:
Duplicate it but change all instances of agi to luk in the second, duplicated method, like such:
Ruby:
``````  #--------------------------------------------------------------------------
# * Calculate Average Value of Luck
#--------------------------------------------------------------------------
def luk
return 1 if members.size == 0
members.inject(0) {|r, member| r += member.luk } / members.size
end``````
Leave the original method alone.

That will allow you to use a unit's (troop or party) LUK in the formula, so instead of the original
`@escape_ratio = 1.5 - 1.0 * \$game_troop.agi / \$game_party.agi`
you could do something like
`@escape_ratio = 2.5 - (1.0 * \$game_troop.agi / \$game_party.agi) - (1.0 * \$game_troop.luk / \$game_party.luk)`

#### slickdeath97

##### Veteran
I don't have the time to make, crop, and upload the pictures, but I'll try to explain it more firmly:
Duplicate it but change all instances of agi to luk in the second, duplicated method, like such:
Ruby:
``````  #--------------------------------------------------------------------------
# * Calculate Average Value of Luck
#--------------------------------------------------------------------------
def luk
return 1 if members.size == 0
members.inject(0) {|r, member| r += member.luk } / members.size
end``````
Leave the original method alone.

That will allow you to use a unit's (troop or party) LUK in the formula, so instead of the original
`@escape_ratio = 1.5 - 1.0 * \$game_troop.agi / \$game_party.agi`
you could do something like
`@escape_ratio = 2.5 - (1.0 * \$game_troop.agi / \$game_party.agi) - (1.0 * \$game_troop.luk / \$game_party.luk)`
That worked! Thanks for the help.

#### MushroomCake28

##### KAMO Studio

Status
Not open for further replies.

### Latest Profile Posts

Worked on a cutscene skip domino effect using Maker Systems' script as the basis. Basically if I have a batch of cutscenes in a row on different maps, now when you skip one cutscene it will skip the entire set. No more spamming X to skip a scene every new map.

Oh and it will work regardless of where you do it from in the set. Convenient!
seems absolutely WILD to me now all the hundreds of hours of work I used to do in 2k(3) over a decade ago with a resolution of 320x240. that seems so insanely TINY now, seemed so normal at the time!
Playing Aroma Indosiar theme song.
Aroma is an Indonesian TV show about cooking.
Working on a characteeer! (Why is it so hard to color hair?) ;-;
Just finished eventing a couple simple puzzles in RMMV, for my very first game "Sample Quest." Just messing around, throwing things together, and calling it a story XD On a non-RM note, got my hair cut today!