I am trying to create an accessory that, when equipped, increases the chance to escape battles.
I can't figure out how to create the armor using events, or find a script that will help me.
If you can help in any way that would be much appreciated, thank you!
By default, AGI affects Escape Ratio. It's found in BattleManager.
#--------------------------------------------------------------------------
# * Create Escape Success Probability
#--------------------------------------------------------------------------
def self.make_escape_ratio
@escape_ratio = 1.5 - 1.0 * $game_troop.agi / $game_party.agi
end
Feel free to change it to work with other stats and such.
Maybe use Luck instead of AGI or something for like a custom idea (and then giving enemies 0 Luck and the special armor a Luck boost)
If you want to use the same formula, just with Magic Attack, change
@escape_ratio = 1.5 - 1.0 * $game_troop.agi / $game_party.agito
enemies = $game_troop.membersparty = $game_party.members return 1 if party.size == 0 || enemies.size == 0 enemy_avg_mat = enemies.inject(0) { |r, enemy| r += enemy.mat } / enemies.size party_avg_mat = party.inject(0) { |r, member| r += member.mat } / party.size @escape_ratio = 1.5 - 1.0 * enemy_avg_mat / party_avg_matIt's a lot longer because agi is actually a method in Game_Unit that calculates the average agility of a Game_Unit. You could include a similar method in Game_Unit too:
#--------------------------------------------------------------------------# * Calculate Average Value of Magic Attack#--------------------------------------------------------------------------def mat return 1 if members.size == 0 members.inject(0) {|r, member| r += member.mat } / members.sizeendAnd the function then becomes
#--------------------------------------------------------------------------# * Create Escape Success Probability#--------------------------------------------------------------------------def self.make_escape_ratio @escape_ratio = 1.5 - 1.0 * $game_troop.mat / $game_party.matendHopefully that answers your question!
Cheers,
Duncan