M'kay, I have a pretty good understand of how this works. The escape possibility is Scene_Battle 2 and goes from line 84 to line 129. Since you posted this in Script Support, I'm going to explain to you how it works. Here's the section, singled out:
#==============================================================================
# ** Scene_Battle (part 2)
#------------------------------------------------------------------------------
# This class performs battle screen processing.
#==============================================================================
class Scene_Battle
def update_phase2_escape
# Calculate enemy agility average
enemies_agi = 0
enemies_number = 0
for enemy in $game_troop.enemies
if enemy.exist?
enemies_agi += enemy.agi
enemies_number += 1
end
end
if enemies_number > 0
enemies_agi /= enemies_number
end
# Calculate actor agility average
actors_agi = 0
actors_number = 0
for actor in $game_party.actors
if actor.exist?
actors_agi += actor.agi
actors_number += 1
end
end
if actors_number > 0
actors_agi /= actors_number
end
# Determine if escape is successful
success = rand(100) < 50 * actors_agi / enemies_agi
# If escape is successful
if success
# Play escape SE
$game_system.se_play($data_system.escape_se)
# Return to BGM before battle started
$game_system.bgm_play($game_temp.map_bgm)
# Battle ends
battle_end(1)
# If escape is failure
else
# Clear all party member actions
$game_party.clear_actions
# Start main phase
start_phase4
end
end
end
It's a little confusing to look at when you first see it, so I'll break it down into pieces.
# Calculate enemy agility average
enemies_agi = 0
enemies_number = 0
for enemy in $game_troop.enemies
if enemy.exist?
enemies_agi += enemy.agi
enemies_number += 1
end
end
if enemies_number > 0
enemies_agi /= enemies_number
end
First, it sets the values for enemies_agi and enemies_number to 0 (basically resetting it). Then it finds all of the enemies and adds their agility to the enemies_agi value and then adds 1 to the enemies_number value. Then if there are more than one enemy, it divides enemies_agi by that number. Basically, it's finding the average. It does the same for actors in the next section.
This is the part we should really focus on:
# Determine if escape is successful
success = rand(100) < 50 * actors_agi / enemies_agi
# If escape is successful
if success
# Play escape SE
$game_system.se_play($data_system.escape_se)
# Return to BGM before battle started
$game_system.bgm_play($game_temp.map_bgm)
# Battle ends
battle_end(1)
# If escape is failure
else
# Clear all party member actions
$game_party.clear_actions
# Start main phase
start_phase4
end
success = rand(100) < 50 * actors_agi / enemies_agi
^ That line decides the success of an escape. It takes a random number between 1 and 100, then checks if it's less than 50 multiplied by the actors_agi divide by enemies_agi. Let's give values to these to make it easier.
actors_agi = 10
enemies_agi = 20
So that would be 50 * 10/20
-> 50 * .5
-> 25
Therefore, the random value has to be less than 25 to make the escape successful. Let's switch that around.
actors_agi = 20
enemies_agi = 10
50 * 20/10
-> 50 * 2
-> 100
So now it would have to be less than 100 for it to succeed. That's to help you see how this whole operation works.
First of all, with something like this, I suggest re-defining stuff as a new script instead of editing the defaults. It gives you more freedom and you can more easily play around with values and such. Something like what I singled out at the top is what you could paste above "Main" to work with it.
Here's a few things you can do:
1. If you want escape to always happen, take out all of the calculations and make it so only the success results is in that definition. EX:
#==============================================================================
# ** Scene_Battle (part 2)
#------------------------------------------------------------------------------
# This class performs battle screen processing.
#==============================================================================
class Scene_Battle
def update_phase2_escape
# Play escape SE
$game_system.se_play($data_system.escape_se)
# Return to BGM before battle started
$game_system.bgm_play($game_temp.map_bgm)
# Battle ends
battle_end(1)
end
end
This guarantees you'll be able to escape no matter what because it isn't making any of the calculations.
2. Edit the values of the operation. For example, you could decrease the chance of success by making rand(100) into rand(125), which would give you 25 more possibilities of it being too high to succeed.
3. Both of these will edit the rate throughout your game. If you want to have it happen only at certain times or if you want to be able to change it on-the-go, you should make a post in Script Requests (and you could probably link back to this for reference). Making a script like this is beyond my abilities, unfortunately.
I hope I was helpful. Let me know if I need to make something more clear. :thumb: