Jump to content
Sign in to follow this  
Szibes

Preventing escaping battle when switch is ON

Recommended Posts

In my project you either have 100% or 0% chance of escaping battle,

but depending on circumstances you can escape from otherwise inescapable battle an vice versa.

Question is: How I can bound escape ratio to a switch/variable, I mean, when switch is turned ON/variable changed to 1 battles become inescapable.

Share this post


Link to post
Share on other sites
8 hours ago, Szibes said:

How I can bound escape ratio to a switch/variable

There are a few spots to do this, but a switch would work best

module BattleManager
  #--------------------------------------------------------------------------
  # * Setup
  #--------------------------------------------------------------------------
  def self.setup(troop_id, can_escape = true, can_lose = false)
    init_members
    $game_troop.setup(troop_id)
    $game_switches[1] == true ? @can_escape = false : @can_escape = true
    @can_lose = can_lose
    make_escape_ratio
  end
end

Change the switch number to whatever you want to use.

The when the switch is on, escape is false

Share this post


Link to post
Share on other sites

I am an idiot, I am braindead moron. 

The script that you wrote works perfectly, but I just completly messed up when writing that post.

I wanted a script that would prevent escaping AFTER battle started, i.e. changing escape ratio from 1 to 0, I assumed that your script was doing just that.

But I somehow managed to find solution because of this. I know next to nothing about writing scripts in ruby, but I was able to make small change in the script.

module BattleManager
  #--------------------------------------------------------------------------
  # * Escape Processing
  #--------------------------------------------------------------------------
  def self.process_escape
    $game_message.add(sprintf(Vocab::EscapeStart, $game_party.name))
    success = $game_variables[14] == 1
    Sound.play_escape
    if success
      process_abort
    else
     # @escape_ratio += 0.1
      $game_message.add('\.' + Vocab::EscapeFailure)
      $game_party.clear_actions
    end
    wait_for_message
    return success
  end
end

I don't know if that's optimal solution, but it works for me so happy with it.

I'm sorry for my misleading writing, and thank you for your help.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted