Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

escape command (XP)

You're looking for a Escape command in the actor command window? A command that'll make the actors who use it escape individually? I'd love to write you one, but Seph had already beat me to it, its a pretty cool lil' script.

Requirements : SDK 2.0+, parts 3 & 4, Method & Class Library.

(I honestly don't know what part of the MACL is required for this script, you might want to ask Seph yourself.)

[spoiler='Battle Escaping' by SephirothSpawn]
Code:
#==============================================================================
# ** Battle Escaping
#------------------------------------------------------------------------------
# SephirothSpawn
# Version 1
# 2007-07-28
# SDK : Version 2.0+ - Parts I, III & IV
#------------------------------------------------------------------------------
# * Version History :
#
#   Version 1 ---------------------------------------------------- (2007-07-28)
#------------------------------------------------------------------------------
# * Requirements :
#
#   Method & Class Library (2.1+)
#------------------------------------------------------------------------------
# * Description :
#
#   This script was designed to allow make actors escape individulally in 
#   battle.
#------------------------------------------------------------------------------
# * Instructions :
#
#   Place The Script Below the SDK and Above Main.
#------------------------------------------------------------------------------
# * Customization :
#
#   Actors That Can Use the Escape Command By Default
#    - Actors_That_Can_Escape_BD = [actor_id, ...] (0 for all actors)
#
#   Escape Commands By Actor
#    - ::SDK ... ::Escape = { actor_id => 'Escape Word', ... }
#
#   Escape Command By Actor (Default for all non-defined)
#    - ::SDK ... ::Escape.default = 'Escape Word'
#------------------------------------------------------------------------------
# * Syntax :
#
#   Changing if actor can escape
#    - <game_actor>.can_escape_in_battle = true or false
#==============================================================================

#------------------------------------------------------------------------------
# * SDK Log Script
#------------------------------------------------------------------------------
SDK.log('Battle Escaping', 'SephirothSpawn', 1, '2007-07-28')
SDK.check_requirements(2.0, [3, 4], {'Method & Class Library' => 2.1})

#------------------------------------------------------------------------------
# * Begin SDK Enable Test
#------------------------------------------------------------------------------
if SDK.enabled?('Battle Escaping')

#==============================================================================
# ** EscapeCommand
#==============================================================================

module EscapeCommand
  #--------------------------------------------------------------------------
  # * Options
  #
  #   Actors That Can Use the Escape Command By Default
  #    - Actors_That_Can_Escape_BD = [actor_id, ...] (0 for all actors)
  #
  #   Escape Commands By Actor
  #    - ::SDK ... ::Escape = { actor_id => 'Escape Word', ... }
  #
  #   Escape Command By Actor (Default for all non-defined)
  #    - ::SDK ... ::Escape.default = 'Escape Word'
  #--------------------------------------------------------------------------
  Actors_That_Can_Escape_BD         = [0]
  Escape_Animation_ID               = 0
  SDK::Scene_Commands::Scene_Battle::Actor_Escape         = {}
  SDK::Scene_Commands::Scene_Battle::Actor_Escape.default = 'Escape'
end

#==============================================================================
# ** Game_Actor
#==============================================================================

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :can_escape_in_battle
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias_method :seph_btlescape_gmactr_setup, :setup
  #--------------------------------------------------------------------------
  # * Setup
  #--------------------------------------------------------------------------
  def setup(actor_id)
    # Original Setup
    seph_btlescape_gmactr_setup(actor_id)
    # Setup Battle Escapeing Variables
    escape = EscapeCommand::Actors_That_Can_Escape_BD
    @can_escape_in_battle = escape.include?(actor_id) || escape.include?(0)
  end
  #--------------------------------------------------------------------------
  # * Escape Command Word
  #--------------------------------------------------------------------------
  def escape_command_word
    return SDK::Scene_Commands::Scene_Battle::Actor_Escape[@actor_id]
  end
  #--------------------------------------------------------------------------
  # * Escape Success
  #--------------------------------------------------------------------------
  def escape_success?
    # 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
    enemies_agi /= enemies_number if enemies_number > 0
    # Determine if escape is successful
    return rand(100) < 50 * self.agi / enemies_agi
  end
  #--------------------------------------------------------------------------
  # * Escape
  #--------------------------------------------------------------------------
  def escape
    # Set hidden flag
    @hidden = true
    # Clear current action
    self.current_action.clear
  end
end 

#==============================================================================
# ** Game_Party
#==============================================================================

class Game_Party
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias_method :seph_btlescape_gmpty_actors, :actors
  #--------------------------------------------------------------------------
  # * All Escaped
  #--------------------------------------------------------------------------
  def all_escaped?
    @actors.each {|a| return false unless a.hidden}
    return true
  end
  #--------------------------------------------------------------------------
  # * Reset Hidden
  #--------------------------------------------------------------------------
  def reset_hidden
    @actors.each {|a| a.hidden = false}
  end
  #--------------------------------------------------------------------------
  # * Actors
  #--------------------------------------------------------------------------
  def actors
    # Get Original Actors List
    actors = seph_btlescape_gmpty_actors.dup
    # Create New Actors List
    list = []
    # Pass Through Actors
    actors.each {|a| list << a unless a.hidden}
    # Return List
    return list
  end
end

#==============================================================================
# ** Scene_Battle
#==============================================================================

class Scene_Battle
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias_method :seph_btlescape_scnbtl_me,     :main_end
  alias_method :seph_btlescape_scnbtl_p3scw,  :phase3_setup_command_window
  alias_method :seph_btlescape_scnbtl_p3bci,  :phase3_basic_command_input
  alias_method :seph_btlescape_scnbtl_p3bcd?, :phase3_basic_command_disabled?
  alias_method :seph_btlescape_scnbtl_mbar,   :make_basic_action_result
  alias_method :seph_btlescape_scnbtl_up4s4,  :update_phase4_step4
  #--------------------------------------------------------------------------
  # * Main End
  #--------------------------------------------------------------------------
  def main_end
    # Original Main End
    seph_btlescape_scnbtl_me
    # Reset Hidden Actors
    $game_party.reset_hidden
  end
  #--------------------------------------------------------------------------
  # * Actor Command Window Setup
  #--------------------------------------------------------------------------
  def phase3_setup_command_window
    # Original Command Window Setup
    seph_btlescape_scnbtl_p3scw
    # If Actor Can Escape
    if @active_battler.can_escape_in_battle
      # If Escape Command Doesn't Exist
      if @seph_escape_command_is_set.nil?
        # Set Escape Command True
        @seph_escape_command_is_set = true
        # Set Escape Command Word
        @seph_escape_command_word = @active_battler.escape_command_word
        # Get Window Commands
        commands = @actor_command_window.commands.dup
        # Add Escape Command to List
        commands << @seph_escape_command_word
        # Reset Command Window Commands
        @actor_command_window.commands = commands
      # If Escape Command Exist
      else
        # If Escape Word Is Changing
        unless @seph_escape_command_word == @active_battler.escape_command_word
          # Get Window Commands
          commands = @actor_command_window.commands.dup
          # Replaces Existing Command Word
          index = commands.index(@seph_escape_command_word)
          commands[index] = @active_battler.escape_command_word
          # Reset Command Window Commands
          @actor_command_window.commands = commands
          # Set Escape Command Word
          @seph_escape_command_word = @active_battler.escape_command_word
        end
      end
    # If Actor Cannot Swith
    else
      # If Escape Command Does Exist
      unless @seph_escape_command_is_set.nil?
        # Get Window Commands
        commands = @actor_command_window.commands.dup
        # Delete Escape Command
        commands.delete(@seph_escape_command_word)
        # Reset Command Window Commands
        @actor_command_window.commands = commands
        # Erase Escape Command Flag
        @seph_escape_command_is_set = nil
        # Erase Escape Command Word
        @seph_escape_command_word = nil
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Phase 3 - Basic : Command Disabled? Test
  #--------------------------------------------------------------------------
  def phase3_basic_command_disabled?
    # If Command is Escape
    if @actor_command_window.command == @seph_escape_command_word
      # If it's not possible to escape
      if $game_temp.battle_can_escape == false
        return true
      end
    end
    # Return Previous Test
    return seph_btlescape_scnbtl_p3bcd?
  end
  #--------------------------------------------------------------------------
  # * Phase 3 Basic : Command Input
  #--------------------------------------------------------------------------
  def phase3_basic_command_input
    # Original Command Input
    seph_btlescape_scnbtl_p3bci
    # If Command is Escape
    if @actor_command_window.command == @seph_escape_command_word
      # Command Escape
      phase3_command_escape
    end
  end
  #--------------------------------------------------------------------------
  # * Phase 3 Basic : Command - Escape
  #--------------------------------------------------------------------------
  def phase3_command_escape
    # Set action
    @active_battler.current_action.kind  = 0
    @active_battler.current_action.basic = 2
    # Go to command input for next actor
    phase3_next_actor
  end
  #--------------------------------------------------------------------------
  # * Make Basic Action Results
  #--------------------------------------------------------------------------
  def make_basic_action_result
    # If Actor Trying to escape
    if @active_battler.is_a?(Game_Actor) &&
       @active_battler.current_action.basic == 2
      # Display "Trying to Escape" in help window
      @help_window.set_text('Trying to escape...', 1)
      # Set Animation ID
      @animation1_id = EscapeCommand::Escape_Animation_ID
    end
    # Original Make Basic Action Results
    seph_btlescape_scnbtl_mbar
  end
  #--------------------------------------------------------------------------
  # * Frame Update (main phase step 4 : animation for target)
  #--------------------------------------------------------------------------
  def update_phase4_step4
    # If Actor & Escaping
    if @active_battler.is_a?(Game_Actor) &&
       @active_battler.current_action.basic == 2
      # If Escape Success
      if @active_battler.escape_success?
        # Display "Escaped" in help window
        @help_window.set_text('Escaped!', 1)
        # Escape Actor
        @active_battler.escape
        # If All Party Escaped
        if $game_party.all_escaped?
          # Battle ends
          battle_end(1)
        end
        # Refresh Status Window
        @status_window.refresh
      # If Escape Failure
      else
        # Display "Failed to Escaped" in help window
        @help_window.set_text('Failed to escape!', 1)
      end
    end
    # Original Update Phase 4 : Step 4
    seph_btlescape_scnbtl_up4s4
  end
end

#--------------------------------------------------------------------------
# * End SDK Enable Test
#--------------------------------------------------------------------------
end
[/spoiler]

This might not be the newest version, for the latest and greatest version (and the MACL already pre-loaded) you can always visit his website @ http://owai.ipbfree.com/index.php?showtopic=56
 
Kain Nobel":1c3byg3v said:
You're looking for a Escape command in the actor command window? A command that'll make the actors who use it escape individually? I'd love to write you one, but Seph had already beat me to it, its a pretty cool lil' script.

Requirements : SDK 2.0+, parts 3 & 4, Method & Class Library.

(I honestly don't know what part of the MACL is required for this script, you might want to ask Seph yourself.)

[spoiler='Battle Escaping' by SephirothSpawn]
Code:
#==============================================================================
# ** Battle Escaping
#------------------------------------------------------------------------------
# SephirothSpawn
# Version 1
# 2007-07-28
# SDK : Version 2.0+ - Parts I, III & IV
#------------------------------------------------------------------------------
# * Version History :
#
#   Version 1 ---------------------------------------------------- (2007-07-28)
#------------------------------------------------------------------------------
# * Requirements :
#
#   Method & Class Library (2.1+)
#------------------------------------------------------------------------------
# * Description :
#
#   This script was designed to allow make actors escape individulally in 
#   battle.
#------------------------------------------------------------------------------
# * Instructions :
#
#   Place The Script Below the SDK and Above Main.
#------------------------------------------------------------------------------
# * Customization :
#
#   Actors That Can Use the Escape Command By Default
#    - Actors_That_Can_Escape_BD = [actor_id, ...] (0 for all actors)
#
#   Escape Commands By Actor
#    - ::SDK ... ::Escape = { actor_id => 'Escape Word', ... }
#
#   Escape Command By Actor (Default for all non-defined)
#    - ::SDK ... ::Escape.default = 'Escape Word'
#------------------------------------------------------------------------------
# * Syntax :
#
#   Changing if actor can escape
#    - <game_actor>.can_escape_in_battle = true or false
#==============================================================================

#------------------------------------------------------------------------------
# * SDK Log Script
#------------------------------------------------------------------------------
SDK.log('Battle Escaping', 'SephirothSpawn', 1, '2007-07-28')
SDK.check_requirements(2.0, [3, 4], {'Method & Class Library' => 2.1})

#------------------------------------------------------------------------------
# * Begin SDK Enable Test
#------------------------------------------------------------------------------
if SDK.enabled?('Battle Escaping')

#==============================================================================
# ** EscapeCommand
#==============================================================================

module EscapeCommand
  #--------------------------------------------------------------------------
  # * Options
  #
  #   Actors That Can Use the Escape Command By Default
  #    - Actors_That_Can_Escape_BD = [actor_id, ...] (0 for all actors)
  #
  #   Escape Commands By Actor
  #    - ::SDK ... ::Escape = { actor_id => 'Escape Word', ... }
  #
  #   Escape Command By Actor (Default for all non-defined)
  #    - ::SDK ... ::Escape.default = 'Escape Word'
  #--------------------------------------------------------------------------
  Actors_That_Can_Escape_BD         = [0]
  Escape_Animation_ID               = 0
  SDK::Scene_Commands::Scene_Battle::Actor_Escape         = {}
  SDK::Scene_Commands::Scene_Battle::Actor_Escape.default = 'Escape'
end

#==============================================================================
# ** Game_Actor
#==============================================================================

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :can_escape_in_battle
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias_method :seph_btlescape_gmactr_setup, :setup
  #--------------------------------------------------------------------------
  # * Setup
  #--------------------------------------------------------------------------
  def setup(actor_id)
    # Original Setup
    seph_btlescape_gmactr_setup(actor_id)
    # Setup Battle Escapeing Variables
    escape = EscapeCommand::Actors_That_Can_Escape_BD
    @can_escape_in_battle = escape.include?(actor_id) || escape.include?(0)
  end
  #--------------------------------------------------------------------------
  # * Escape Command Word
  #--------------------------------------------------------------------------
  def escape_command_word
    return SDK::Scene_Commands::Scene_Battle::Actor_Escape[@actor_id]
  end
  #--------------------------------------------------------------------------
  # * Escape Success
  #--------------------------------------------------------------------------
  def escape_success?
    # 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
    enemies_agi /= enemies_number if enemies_number > 0
    # Determine if escape is successful
    return rand(100) < 50 * self.agi / enemies_agi
  end
  #--------------------------------------------------------------------------
  # * Escape
  #--------------------------------------------------------------------------
  def escape
    # Set hidden flag
    @hidden = true
    # Clear current action
    self.current_action.clear
  end
end 

#==============================================================================
# ** Game_Party
#==============================================================================

class Game_Party
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias_method :seph_btlescape_gmpty_actors, :actors
  #--------------------------------------------------------------------------
  # * All Escaped
  #--------------------------------------------------------------------------
  def all_escaped?
    @actors.each {|a| return false unless a.hidden}
    return true
  end
  #--------------------------------------------------------------------------
  # * Reset Hidden
  #--------------------------------------------------------------------------
  def reset_hidden
    @actors.each {|a| a.hidden = false}
  end
  #--------------------------------------------------------------------------
  # * Actors
  #--------------------------------------------------------------------------
  def actors
    # Get Original Actors List
    actors = seph_btlescape_gmpty_actors.dup
    # Create New Actors List
    list = []
    # Pass Through Actors
    actors.each {|a| list << a unless a.hidden}
    # Return List
    return list
  end
end

#==============================================================================
# ** Scene_Battle
#==============================================================================

class Scene_Battle
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias_method :seph_btlescape_scnbtl_me,     :main_end
  alias_method :seph_btlescape_scnbtl_p3scw,  :phase3_setup_command_window
  alias_method :seph_btlescape_scnbtl_p3bci,  :phase3_basic_command_input
  alias_method :seph_btlescape_scnbtl_p3bcd?, :phase3_basic_command_disabled?
  alias_method :seph_btlescape_scnbtl_mbar,   :make_basic_action_result
  alias_method :seph_btlescape_scnbtl_up4s4,  :update_phase4_step4
  #--------------------------------------------------------------------------
  # * Main End
  #--------------------------------------------------------------------------
  def main_end
    # Original Main End
    seph_btlescape_scnbtl_me
    # Reset Hidden Actors
    $game_party.reset_hidden
  end
  #--------------------------------------------------------------------------
  # * Actor Command Window Setup
  #--------------------------------------------------------------------------
  def phase3_setup_command_window
    # Original Command Window Setup
    seph_btlescape_scnbtl_p3scw
    # If Actor Can Escape
    if @active_battler.can_escape_in_battle
      # If Escape Command Doesn't Exist
      if @seph_escape_command_is_set.nil?
        # Set Escape Command True
        @seph_escape_command_is_set = true
        # Set Escape Command Word
        @seph_escape_command_word = @active_battler.escape_command_word
        # Get Window Commands
        commands = @actor_command_window.commands.dup
        # Add Escape Command to List
        commands << @seph_escape_command_word
        # Reset Command Window Commands
        @actor_command_window.commands = commands
      # If Escape Command Exist
      else
        # If Escape Word Is Changing
        unless @seph_escape_command_word == @active_battler.escape_command_word
          # Get Window Commands
          commands = @actor_command_window.commands.dup
          # Replaces Existing Command Word
          index = commands.index(@seph_escape_command_word)
          commands[index] = @active_battler.escape_command_word
          # Reset Command Window Commands
          @actor_command_window.commands = commands
          # Set Escape Command Word
          @seph_escape_command_word = @active_battler.escape_command_word
        end
      end
    # If Actor Cannot Swith
    else
      # If Escape Command Does Exist
      unless @seph_escape_command_is_set.nil?
        # Get Window Commands
        commands = @actor_command_window.commands.dup
        # Delete Escape Command
        commands.delete(@seph_escape_command_word)
        # Reset Command Window Commands
        @actor_command_window.commands = commands
        # Erase Escape Command Flag
        @seph_escape_command_is_set = nil
        # Erase Escape Command Word
        @seph_escape_command_word = nil
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Phase 3 - Basic : Command Disabled? Test
  #--------------------------------------------------------------------------
  def phase3_basic_command_disabled?
    # If Command is Escape
    if @actor_command_window.command == @seph_escape_command_word
      # If it's not possible to escape
      if $game_temp.battle_can_escape == false
        return true
      end
    end
    # Return Previous Test
    return seph_btlescape_scnbtl_p3bcd?
  end
  #--------------------------------------------------------------------------
  # * Phase 3 Basic : Command Input
  #--------------------------------------------------------------------------
  def phase3_basic_command_input
    # Original Command Input
    seph_btlescape_scnbtl_p3bci
    # If Command is Escape
    if @actor_command_window.command == @seph_escape_command_word
      # Command Escape
      phase3_command_escape
    end
  end
  #--------------------------------------------------------------------------
  # * Phase 3 Basic : Command - Escape
  #--------------------------------------------------------------------------
  def phase3_command_escape
    # Set action
    @active_battler.current_action.kind  = 0
    @active_battler.current_action.basic = 2
    # Go to command input for next actor
    phase3_next_actor
  end
  #--------------------------------------------------------------------------
  # * Make Basic Action Results
  #--------------------------------------------------------------------------
  def make_basic_action_result
    # If Actor Trying to escape
    if @active_battler.is_a?(Game_Actor) &&
       @active_battler.current_action.basic == 2
      # Display "Trying to Escape" in help window
      @help_window.set_text('Trying to escape...', 1)
      # Set Animation ID
      @animation1_id = EscapeCommand::Escape_Animation_ID
    end
    # Original Make Basic Action Results
    seph_btlescape_scnbtl_mbar
  end
  #--------------------------------------------------------------------------
  # * Frame Update (main phase step 4 : animation for target)
  #--------------------------------------------------------------------------
  def update_phase4_step4
    # If Actor & Escaping
    if @active_battler.is_a?(Game_Actor) &&
       @active_battler.current_action.basic == 2
      # If Escape Success
      if @active_battler.escape_success?
        # Display "Escaped" in help window
        @help_window.set_text('Escaped!', 1)
        # Escape Actor
        @active_battler.escape
        # If All Party Escaped
        if $game_party.all_escaped?
          # Battle ends
          battle_end(1)
        end
        # Refresh Status Window
        @status_window.refresh
      # If Escape Failure
      else
        # Display "Failed to Escaped" in help window
        @help_window.set_text('Failed to escape!', 1)
      end
    end
    # Original Update Phase 4 : Step 4
    seph_btlescape_scnbtl_up4s4
  end
end

#--------------------------------------------------------------------------
# * End SDK Enable Test
#--------------------------------------------------------------------------
end
[/spoiler]

This might not be the newest version, for the latest and greatest version (and the MACL already pre-loaded) you can always visit his website @ http://owai.ipbfree.com/index.php?showtopic=56

Yes I am looking for a Escape command in the  command window but I don't actually
need the actor to escape individually. ( that's a cool idea) :grin:
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top