RCXDan

Champion of Brightmoon Tor
Veteran
Joined
Jan 4, 2019
Messages
341
Reaction score
760
First Language
English
Primarily Uses
RMVXA
So a disclaimer: I'm not looking for something that changes the formula for escaping from combat like making it based on agility or something. I've already modified my escape to be always guaranteed.

Instead I'm looking for a script that makes it so you can't escape immediately until a turn count passes or a enemy HP threshold is reached.

This is not something for every fight in the game. It is important because I want to have encounters where you are forced to survive against unbeatable enemies that track you down, and weakening them or outlasting them frees up the Escape command.
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
6,621
Reaction score
8,598
First Language
Indonesian
Primarily Uses
RMVXA
I made a similar system in my game, so here is the quick snatch (and modified version) of it.
The quickest implementation would be like this
Ruby:
class << BattleManager
  def can_escape?
    @can_escape && escape_eval
  end
 
  def escape_eval
    return true if $game_system.escape_eval.nil?
    return eval($game_system.escape_eval)
  end
end

class Game_System
  attr_accessor :escape_eval
end

class Scene_Battle
 
  alias turn_end_aed_escape turn_end
  def turn_end
    turn_end_aed_escape
    unless $game_system.escape_eval.nil?
      @party_command_window.clear_command_list
      @party_command_window.make_command_list
      @party_command_window.refresh  
    end
  end
 
end
This works for turn-based battle. Because the ability to escape is refreshed per turn. For other turn systems, such as ATB, I'm not sure how it behaves.

How to use:
Use script call before the battle started.

Turn-based escape condition
Ruby:
$game_system.escape_eval = "$game_troop.turn_count >= 10"

HP-based condition (replace the enemy index)
Ruby:
$game_system.escape_eval = "$game_troop.members[enemy_index].hp_rate <= 0.5"

If you want to disable the escape condition, make sure to revert back to nil
Ruby:
$game_system.escape_eval = nil

Of course, I haven't tested this yet. So, please do me a favor.

On an unrelated note, this could be good for another of my random MZ plugins, now that I think about it.
 

RCXDan

Champion of Brightmoon Tor
Veteran
Joined
Jan 4, 2019
Messages
341
Reaction score
760
First Language
English
Primarily Uses
RMVXA
@TheoAllen So it works! But testing revealed some things:

#1: Once a condition is set, it is like that for every fight in the game. Like Fight A will set the condition with the script, and once escaped and you leave to initiate Fight B, the same condition will apply even when I haven't applied the script there.

#2: The HP threshold version works with Yanfly Instant Cast moves, as using a move that does enough damage to a tagged enemy without taking up a turn allows you to escape by un-graying the escape function.

Something interesting would be adding a visible turn count near Escape like "Escape [x]T" with x representing the amount of turns needed.

Does this also allow And operands to be used? Like "enemy A && enemy B hp threshold >= 0.9" - that kind of thing.
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
6,621
Reaction score
8,598
First Language
Indonesian
Primarily Uses
RMVXA
#1: Once a condition is set, it is like that for every fight in the game. Like Fight A will set the condition with the script, and once escaped and you leave to initiate Fight B, the same condition will apply even when I haven't applied the script there.
This is why I said, you have to disable it manually by using script call
Ruby:
$game_system.escape_eval = nil
Or else, it would affect all other battles.

Something interesting would be adding a visible turn count near Escape like "Escape [x]T" with x representing the amount of turns needed.
Since I wrote this for various cases as possible (not just specific for turn condition), this is what I came up with
Ruby:
class << BattleManager
  def can_escape?
    @can_escape && escape_eval
  end
 
  def escape_eval
    return true if $game_system.escape_eval.nil?
    return eval($game_system.escape_eval)
  end
end

class << Vocab
  alias escape_origin escape
  def escape
    return $game_system.get_escape_text
  end
end

class Game_System
  attr_accessor :escape_eval
  attr_accessor :escape_text
 
  def get_escape_text
    return Vocab::escape_origin unless escape_text
    return escape_text.gsub(/\{(.+)\}/i) { eval($1.to_s) }
  end
 
end

class Scene_Battle
 
  alias turn_end_aed_escape turn_end
  def turn_end
    turn_end_aed_escape
    unless $game_system.escape_eval.nil?
      @party_command_window.clear_command_list
      @party_command_window.make_command_list
      @party_command_window.refresh 
    end
  end
 
end

How to use:
To print whatever escape text you want, use script call
Ruby:
$game_system.escape_text = "Escape {ruby code here}"

In your case, specifically, it should look like
Ruby:
$game_system.escape_text = "Escape [{10 - $game_troop.turn_count}]T"

Although, if the turn count is over 10, it would draw a negative value, thus this would be better.
Ruby:
$game_system.escape_text = "Escape {t = 10 - $game_troop.turn_count; t > 0 ? \"[\" + t.to_s + \"]T\" : \"\"} }"

Yes, unfortunately, you have to have ruby coding knowledge to use.

Similar to the escape condition, you have to set it to nil to disable it.
Ruby:
$game_system.escape_text = nil

Does this also allow And operands to be used? Like "enemy A && enemy B hp threshold >= 0.9" - that kind of thing.
Yes, you can. The condition would be a bit longer like.
Ruby:
$game_system.escape_eval = "$game_troop.members[index_1].hp_rate >= 0.9 && $game_troop.members[index_2].hp_rate >= 9"
 
Last edited:

RCXDan

Champion of Brightmoon Tor
Veteran
Joined
Jan 4, 2019
Messages
341
Reaction score
760
First Language
English
Primarily Uses
RMVXA
This is why I said, you have to disable it manually by using script call
Ruby:
$game_system.escape_eval = nil
Or else, it would affect all other battles.


Since I wrote this for various cases as possible (not just specific for turn condition), this is what I came up with
Ruby:
class << BattleManager
  def can_escape?
    @can_escape && escape_eval
  end
 
  def escape_eval
    return true if $game_system.escape_eval.nil?
    return eval($game_system.escape_eval)
  end
end

class << Vocab
  alias escape_origin escape
  def escape
    return $game_system.get_escape_text
  end
end

class Game_System
  attr_accessor :escape_eval
  attr_accessor :escape_text
 
  def get_escape_text
    return Vocab::escape_origin unless escape_text
    return escape_text.gsub(/\{(.+)\}/i) { eval($1.to_s) }
  end
 
end

class Scene_Battle
 
  alias turn_end_aed_escape turn_end
  def turn_end
    turn_end_aed_escape
    unless $game_system.escape_eval.nil?
      @party_command_window.clear_command_list
      @party_command_window.make_command_list
      @party_command_window.refresh
    end
  end
 
end

How to use:
To print whatever escape text you want, use script call
Ruby:
$game_system.escape_text = "Escape {ruby code here}"

In your case, specifically, it should look like
Ruby:
$game_system.escape_text = "Escape [{10 - $game_troop.turn_count}]T"

Although, if the turn count is over 10, it would draw a negative value, thus this would be better.
Ruby:
$game_system.escape_text = "Escape {t = 10 - $game_troop.turn_count; t > 0 ? \"[\" + t.to_s + \"]T\" : \"\"} }"

Yes, unfortunately, you have to have ruby coding knowledge to use.

Similar to the escape condition, you have to set it to nil to disable it.
Ruby:
$game_system.escape_text = nil


Yes, you can. The condition would be a bit longer like.
Ruby:
$game_system.escape_eval = "$game_troop.members[index_1].hp_rate >= 0.9 && $game_troop.members[index_2].hp_rate >= 9"

Oh wow. Thanks @TheoAllen , I can see many uses for this.

I've tested it in different scenarios enough to justify saying that it does pretty much what I want. :LZScheeze:
 
Last edited:

Latest Threads

Latest Profile Posts

Micro rant. The worst part of working from home when you live with your family is seeing how inconsiderate they are. "Hey, you're sitting in front of your computer, that means you're not doing anything! I want to put the TV at 200 decibels!"

If I was working in the office would you still talking me like that?
It's definitely discouraging when streamers give a try-to-say-it-nicely (i.e. bad) review of your game demo. It's like jumping into a cold pool. Bad initally, but it gets better with time. And you are now more alert and see better.
Some screenshots of the pub and lodging with the beginnings of clutter taking shape
TTp8uCw.png

jtC202e.png

bSXgyVl.png

eRx9PUF.png
Backgrounds are not my strong suit... :kaodes:
DazI8jt.jpg

Just realized I forgot doing the clouds... woops
Went to get some stuff for February 10, the birthday of my favorite ink monster...
I have a little one-person party for Bendy every year, complete with the life-size plushie I made. And yes, I bake a birthday cake!

Forum statistics

Threads
118,500
Messages
1,116,422
Members
155,498
Latest member
Neocops
Top