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.

[VX] Auto Battle

Auto Battle
by Dargor
Version 1.2


Introduction

I made this little script a while ago and I forgot to post it.
It adds an Auto Battle command to the party command window and will make the whole party attack automatically.

Hope you like it!

Script

Code:
#==============================================================================

# ** Auto Battle

#------------------------------------------------------------------------------

#  © Dargor, 2008

#  13/05/08

#  Version 1.2

#------------------------------------------------------------------------------

#  VERSION HISTORY:

#   - 1.0 (24/03/08), Initial release

#   - 1.1 (13/05/08), Added auto-battle modes (Single Turn/Whole Battle)

#   - 1.2 (13/05/08), Added auto-battle cancelation (use SHIFT)

#------------------------------------------------------------------------------

#  INSTRUCTIONS:

#   1) Paste the script above main

#   2) To change an actor's auto battle option, use:

#         $game_actors[actor_id].auto_battle = true/false

#   3) To enable/disable the auto battle option, useL

#         $game_system.auto_battle_disabled = true/false

#==============================================================================

 

# Vocabulary: Auto Battle Command

Vocab::AutoBattle = 'Auto'

 

#==============================================================================

# ** Game_System

#------------------------------------------------------------------------------

#  This class handles system-related data. Also manages vehicles and BGM, etc.

# The instance of this class is referenced by $game_system.

#==============================================================================

 

class Game_System

  #--------------------------------------------------------------------------

  # * Public Instance Variables

  #--------------------------------------------------------------------------

  attr_accessor :auto_battle_disabled

  attr_accessor :auto_battle_mode

  #--------------------------------------------------------------------------

  # * Alias Listing

  #--------------------------------------------------------------------------

  alias dargor_vx_system_auto_battle_initialize initialize

  #--------------------------------------------------------------------------

  # * Object Initialization

  #--------------------------------------------------------------------------

  def initialize

    @auto_battle_disabled = false               # Enable/Disable flag

    @auto_battle_mode = 0                       # 0: Single Turn 1: Whole Battle

    dargor_vx_system_auto_battle_initialize

  end

end

 

#==============================================================================

# ** Game_Temp

#------------------------------------------------------------------------------

#  This class handles temporary data that is not included with save data.

# The instance of this class is referenced by $game_temp.

#==============================================================================

 

class Game_Temp

  #--------------------------------------------------------------------------

  # * Public Instance Variables

  #--------------------------------------------------------------------------

  attr_accessor :in_auto_battle                # in-battle flag

  attr_accessor :auto_battle_canceled

  #--------------------------------------------------------------------------

  # * Alias Listing

  #--------------------------------------------------------------------------

  alias dargor_vx_temp_auto_battle_initialize initialize

  #--------------------------------------------------------------------------

  # * Object Initialization

  #--------------------------------------------------------------------------

  def initialize

    @in_auto_battle = false

    @auto_battle_canceled = false

    dargor_vx_temp_auto_battle_initialize

  end

end

 

#==============================================================================

# ** Game_Actor

#------------------------------------------------------------------------------

#  This class handles actors. It's used within the Game_Actors class

# ($game_actors) and referenced by the Game_Party class ($game_party).

#==============================================================================

 

class Game_Actor < Game_Battler

  #--------------------------------------------------------------------------

  # * Public Instance Variables

  #--------------------------------------------------------------------------

  attr_accessor :auto_battle

  #--------------------------------------------------------------------------

  # * Alias Listing

  #--------------------------------------------------------------------------

  alias dargor_vx_actor_auto_battle_setup setup

  #--------------------------------------------------------------------------

  # * Setup

  #     actor_id : actor ID

  #--------------------------------------------------------------------------

  def setup(actor_id)

    actor = $data_actors[actor_id]

    @auto_battle = actor.auto_battle

    dargor_vx_actor_auto_battle_setup(actor_id)

  end

end

 

#==============================================================================

# ** Scene_Battle

#------------------------------------------------------------------------------

#  This class performs battle screen processing.

#==============================================================================

 

class Scene_Battle < Scene_Base

  #--------------------------------------------------------------------------

  # * Alias Listing

  #--------------------------------------------------------------------------

  alias dargor_vx_battle_auto_battle_update_basic update_basic

  alias dargor_vx_battle_auto_battle_create_info_viewport create_info_viewport

  alias dargor_vx_battle_auto_battle_start_party_command_selection start_party_command_selection

  alias dargor_vx_battle_auto_battle_update_party_command_selection update_party_command_selection

  alias dargor_vx_battle_auto_battle_process_victory process_victory

  #--------------------------------------------------------------------------

  # * Basic Update Processing

  #     main : Call from main update method

  #--------------------------------------------------------------------------

  def update_basic(main = false)

    if Input.trigger?(Input::SHIFT)

      $game_temp.in_auto_battle = false 

      $game_temp.auto_battle_canceled = true

    end

    dargor_vx_battle_auto_battle_update_basic(main)

  end

  #--------------------------------------------------------------------------

  # * Create Information Display Viewport

  #--------------------------------------------------------------------------

  def create_info_viewport

    commands = $game_system.party_commands

    $game_system.add_party_command(commands.size-1, Vocab::AutoBattle)

    dargor_vx_battle_auto_battle_create_info_viewport

    index = commands.index(Vocab::AutoBattle)

    @party_command_window.draw_item(index, !$game_system.auto_battle_disabled)

  end

  #--------------------------------------------------------------------------

  # * Start party command selection

  #--------------------------------------------------------------------------

  def start_party_command_selection

    if $game_system.auto_battle_mode == 1 && $game_temp.in_auto_battle

      for actor in $game_party.members

        actor.make_action

      end

      start_main

      return

    end

    dargor_vx_battle_auto_battle_start_party_command_selection

  end

  #--------------------------------------------------------------------------

  # * Update Party Command Selection

  #--------------------------------------------------------------------------

  def update_party_command_selection

    dargor_vx_battle_auto_battle_update_party_command_selection

    if Input.trigger?(Input::C)

      case $game_system.party_commands[@party_command_window.index]

      when Vocab::AutoBattle  # Auto Battle

        if $game_system.auto_battle_disabled

          Sound.play_buzzer

          return

        end

        if $game_system.auto_battle_mode == 1

          $game_temp.in_auto_battle = true

        end

        for actor in $game_party.members

          actor.make_action

        end

        Sound.play_decision

        start_main

      end

    end

  end

  #--------------------------------------------------------------------------

  # * Victory Processing

  #--------------------------------------------------------------------------

  def process_victory

    $game_temp.in_auto_battle = false

    dargor_vx_battle_auto_battle_process_victory

  end

end

Notes

The script requires my Custom Commands script.
And as always, don't forget to give me credit!

-Dargor
 
I've been using your script but there's something I'm wondering. It seems that you can only AutoBattle one turn, is there a way we can make it to where it will AutoBattle the entire battle?

~Inno
 
Why don't you simply choose the Auto command each time? I think it's pointless to Autobattle the whole battle, but if you desperately need it, I can do it.
 
Interesting script, but just one thing... Wouldn't this script ruin the battles in most games if used, like allow the player to be lazy especially when fighting easy enemies?

Owell I guess some people may like that xD
 
syvkal":2b538qwl said:
Interesting script, but just one thing... Wouldn't this script ruin the battles in most games if used, like allow the player to be lazy especially when fighting easy enemies?

It's great for grinding or making battles more enjoyable, IMO. I don't use this script but I do use TYPE-RX74's (or whatever his name is). That + implementing battle speed options = near instant battles for the win. :)
 
I have updated the script. Innoccence will be happy!

I added auto-battle modes, available in Game_System. Simply set the value of @auto_battle_mode to 0 or 1.
- 0 means that the auto-battle will be effective for one turn. (Single Turn)
- 1 means that the auto-battle will be effective until the party or the opposing troop wins. (Whole Battle)

I've also added a cancellation feature. If the auto-battle mode is set to 1 and the player press SHIFT, the auto-battle will be turned off at the next turn.
 

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