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] Action Order

Action Order
by Dargor
Version 1.9


Introduction

This script displays who's turn is next in a battle, based on the battlers attack speed. Exactly like in FF10 for those who have played this game. 

Screenshots



Script

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

# ** Action Order

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

#  Â© Dargor, 2008-2009

#  28/01/09

#  Version 1.9

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

#  VERSION HISTORY:

#   - 1.0 (22/06/08), Initial release

#   - 1.1 (22/06/08), Added options for the window's opacity/height

#   - 1.2 (22/06/08), Removed the window from the Party Command phase

#   - 1.3 (22/06/08), Bug fixed with the window's disposal

#   - 1.4 (27/06/08), Added battlers order for next turn

#   - 1.5 (27/06/08), Added action speed preview

#   - 1.6 (27/06/08), Added options for Item/Skill windows size correction

#   - 1.7 (27/06/08), Removed dependency over the Custom Commands script

#   - 1.8 (28/01/09), Fixed monsters graphics in action order window

#   - 1.9 (28/01/09), Improved precision when defining action order.

#                     The script now redefines only the acting battler's speed

#                     instead of the whole Party + Troop

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

#  INSTRUCTIONS:

#   - Paste this above main

#   - Edit the constants in Action_Order module

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

 

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

# ** Action Order Customization Module

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

 

module Action_Order

  # Actors face graphic offset (X,Y)

  # SYNTAX: Face_Offset = face_name => {face_index => [x,y]}}

  Face_Offset = { 

                  'Actor1' => {0 => [0, 32]},

                  'Evil'   => {4 => [0, 16]}

                }

  Face_Offset.default = [0,32]

  # Ememies battler graphic offset (X,Y)

  Battler_Offset = {'Demon' => [42,72]}

  Battler_Offset.default = [0, 32]

  # Is the action window enabled in the Party Command selection phase?

  Enabled_Party_Phase = true

  # Show Actors name instead of face

  Actor_Names = false

  # Show enemies name instead of battler graphic

  Enemy_Names = false

  # Action Window Opacity

  Window_Opacity = 255

  Window_Back_Opacity = 160

  # Maximum number of battlers visible at the same time in the window

  Battlers_Max = 8

  # Small Windows (True is Recommended)

  Small_Windows = true

  # Maximum number of columns when using small windows (1 is recommended)

  Small_Windows_Column_Max = 1

end

 

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

# ** Game_BattleAction

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

#  This class handles battle actions. This class is used within the

# Game_Battler class.

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

 

class Game_BattleAction

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

  # * Alias Listing

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

  alias dargor_vx_action_order_action_make_speed make_speed

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

  # * Confirm Action Speed

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

  def make_speed

    # The usual

    # dargor_vx_action_order_action_make_speed

    @speed = battler.agi #+ rand(5 + battler.agi / 4)

    @speed += skill.speed if skill?

    @speed += item.speed if item?

    @speed += 2000 if guard?

    @speed += 1000 if attack? and battler.fast_attack

    @speed += battler.index * 2 if attack? and battler.is_a?(Game_Actor)

    @speed += battler.index

  end

end

 

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

# ** Window_Item

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

#  This window displays a list of inventory items for the item screen, etc.

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

 

class Window_Item < Window_Selectable

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

  # * Alias Listing

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

  alias dargor_vx_action_order_window_item_refresh refresh

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

  # * Refresh

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

  def refresh

    if $game_temp.in_battle && Action_Order::Small_Windows

      @column_max = Action_Order::Small_Windows_Column_Max

      self.width = 412

      self.x = 132

    end

    dargor_vx_action_order_window_item_refresh

  end

end

 

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

# ** Window_Skill

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

#  This window displays a list of usable skills on the skill screen, etc.

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

 

class Window_Skill < Window_Selectable

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

  # * Alias Listing

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

  alias dargor_vx_action_order_window_skill_refresh refresh

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

  # * Refresh

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

  def refresh

    if $game_temp.in_battle && Action_Order::Small_Windows

      @column_max = Action_Order::Small_Windows_Column_Max

      self.width = 412

      self.x = 132

    end

    dargor_vx_action_order_window_skill_refresh

  end

end

 

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

# ** Window_ActionOrder

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

#  This window displays action battlers order on the battle screen.

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

 

class Window_ActionOrder < Window_Selectable

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

  # * Object Initialization

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

  def initialize

    super(0,56,132, 40 + Action_Order::Battlers_Max * 24)

    self.active = false

    self.visible = Action_Order::Enabled_Party_Phase

    self.opacity = Action_Order::Window_Opacity

    self.back_opacity = Action_Order::Window_Back_Opacity

    self.index = 0

    @action_battlers = []

    @next_action_battlers = []

  end

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

  # * Make Action Orders

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

  def make_action_orders(action_battlers)

    return if action_battlers == @action_battlers

    @action_battlers = action_battlers

    for battler in @action_battlers

      @action_battlers.delete(battler) if battler.dead?

      @action_battlers.delete(battler) if battler.hidden

    end

    if @next_action_battlers.empty?

      mul = (Action_Order::Battlers_Max.to_f / @action_battlers.size.to_f).ceil

      for i in 0...mul

        @next_action_battlers += @action_battlers.dup

      end

    end

    refresh

  end

  def remove_first_battler

    @action_battlers.delete_at(0)

    refresh

  end

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

  # * Remove Battler

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

  def remove_battler(battler)

    @action_battlers.delete(battler)

    for battler in @action_battlers

      @action_battlers.delete(battler) if battler.dead?

    end

    refresh

  end

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

  # * Refresh

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

  def refresh

    self.contents.clear

    return if @action_battlers.empty?

    @item_max = @action_battlers.size

    @all_action_battlers = @action_battlers + @next_action_battlers

    create_contents

    for i in 0...@all_action_battlers.size

      battler = @all_action_battlers[i]

      if battler.is_a?(Game_Enemy)

        name = "" + battler.battler_name

        hue = 0 + battler.battler_hue

        if Action_Order::Enemy_Names

          self.contents.draw_text(4,i * WLH,128,WLH,battler.name)

        else

          battler_name = "" + battler.battler_name

          battler_hue = 0 + battler.battler_hue

          draw_battler(battler_name, battler_hue, 2, i * WLH + 2)

        end

      else

        if Action_Order::Actor_Names

          self.contents.draw_text(4,i * WLH,128,WLH,battler.name)

        else

          draw_face(battler.face_name, battler.face_index, 2, i * WLH + 2)

        end

      end

    end

  end

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

  # * Draw Face Graphic

  #     face_name  : Face graphic filename

  #     face_index : Face graphic index

  #     x     : draw spot x-coordinate

  #     y     : draw spot y-coordinate

  #     size       : Display size

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

  def draw_face(face_name, face_index, x, y, size = 96)

    bitmap = Cache.face(face_name)

    rect = Rect.new(0, 0, 0, 0)

    rect.x = face_index % 4 * 96 + (96 - size) / 2

    rect.y = face_index / 4 * 96 + (96 - size) / 2

    offset = Action_Order::Face_Offset[face_name][face_index]

    offset = Action_Order::Face_Offset.default if offset.nil?

    rect.x += offset[0]

    rect.y += offset[1]

    rect.width = size

    rect.height = 20

    self.contents.blt(x, y, bitmap, rect)

    bitmap.dispose

  end

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

  # * Draw Battler Graphic

  #     battler_name  : Face graphic filename

  #     battler_hue : Face graphic index

  #     x     : draw spot x-coordinate

  #     y     : draw spot y-coordinate

  #     size       : Display size

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

  def draw_battler(battler_name, battler_hue, x, y, size = 96)

    bitmap = Bitmap.new("Graphics/Battlers/#{battler_name}")

    bitmap.hue_change(battler_hue)

    rect = Rect.new(4, 4, 0, 0)

    offset = Action_Order::Battler_Offset[battler_name]

    offset = Action_Order::Battler_Offset.default if offset.nil?

    rect.x = offset[0]

    rect.y = offset[1]

    rect.width = size

    rect.height = 20

    self.contents.blt(x, y, bitmap, rect)

    bitmap.dispose

  end

end

 

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

# ** Scene_Battle

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

#  This class performs battle screen processing.

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

 

class Scene_Battle < Scene_Base

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

  # * Alias Listing

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

  alias dargor_vx_action_order_battle_make_action_orders make_action_orders

  alias dargor_vx_action_order_battle_execute_action execute_action

  alias dargor_vx_action_order_battle_start start

  alias dargor_vx_action_order_battle_start_main start_main

  alias dargor_vx_action_order_battle_terminate terminate

  alias dargor_vx_action_order_update_basic update_basic

  alias dargor_vx_action_order_next_actor next_actor

  alias dargor_vx_action_order_prior_actor prior_actor

  alias dargor_vx_action_order_start_party_command_selection start_party_command_selection

  alias dargor_vx_action_order_start_actor_command_selection start_actor_command_selection

  alias dargor_vx_action_order_update_actor_command_selection update_actor_command_selection

  alias dargor_vx_action_order_update_item_selection update_item_selection

  alias dargor_vx_action_order_update_skill_selection update_skill_selection

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

  # * Start processing

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

  def start

    dargor_vx_action_order_battle_start

    @action_index = -1

    @action_window = Window_ActionOrder.new

    make_action_orders

    @action_window.make_action_orders(@action_battlers)

  end

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

  # * Terminate processing

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

  def terminate

    dargor_vx_action_order_battle_terminate

    @action_window.dispose

  end

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

  # * Basic Update Processing

  #     main : Call from main update method

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

  def update_basic(main = false)

    dargor_vx_action_order_update_basic(main) 

    @action_window.update

  end

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

  # * Start party command selection

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

  def start_party_command_selection

    @action_window.visible = Action_Order::Enabled_Party_Phase

    if $game_temp.in_battle

      make_action_orders

    end

    dargor_vx_action_order_start_party_command_selection

  end

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

  # * Start party command selection

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

  def start_actor_command_selection

    @action_window.open

    @action_window.visible = true

    dargor_vx_action_order_start_actor_command_selection

  end

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

  # * Start Execution of Battle Processing

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

  def start_main

    @action_window.visible = true

    dargor_vx_action_order_battle_start_main

  end

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

  # * Go to Command Input for Next Actor

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

  def next_actor

    dargor_vx_action_order_next_actor

    make_action_orders

  end

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

  # * Go to Command Input of Previous Actor

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

  def prior_actor

    dargor_vx_action_order_prior_actor

    make_action_orders

  end

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

  # * Create Action Orders

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

  def make_action_orders

    dargor_vx_action_order_battle_make_action_orders

    @action_window.make_action_orders(@action_battlers)

  end

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

  # * Create Action Order (For a single battler)

  #     battler : Battler

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

  def make_action_order(battler)

    @action_battlers = []

    unless $game_troop.surprise

      @action_battlers += $game_party.members

    end

    unless $game_troop.preemptive

      @action_battlers += $game_troop.members

    end

    battler.action.make_speed

    @action_battlers.sort! do |a,b|

      b.action.speed - a.action.speed

    end

    @action_window.make_action_orders(@action_battlers)

  end

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

  # * Execute Battle Actions

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

  def execute_action

    dargor_vx_action_order_battle_execute_action

    @action_window.remove_first_battler

  end

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

  # * Update Actor Command Selection

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

  def update_actor_command_selection

    dargor_vx_action_order_update_actor_command_selection

    return if @active_battler.nil?

    if @actor_command_window.methods.include?('selection')

      case @actor_command_window.selection

      when Vocab::attack

        unless @active_battler.action.attack?

          @active_battler.action.clear

          @active_battler.action.set_attack

          make_action_order(@active_battler)

        end

      when Vocab::guard

        unless @active_battler.action.guard?

          @active_battler.action.clear

          @active_battler.action.set_guard

          make_action_order(@active_battler)

        end

      else

        @active_battler.action.clear

      end

    else

      case @actor_command_window.index

      when 0

        unless @active_battler.action.attack?

          @active_battler.action.clear

          @active_battler.action.set_attack

          make_action_order(@active_battler)

        end

      when 2

        unless @active_battler.action.guard?

          @active_battler.action.clear

          @active_battler.action.set_guard

          make_action_order(@active_battler)

        end

      else

        @active_battler.action.clear

      end

    end

  end

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

  # * Update Item Selection

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

  def update_item_selection

    @item = @item_window.item

    if @active_battler.action.item.id != @item.id

      @active_battler.action.clear

      @active_battler.action.set_item(@item.id)

      make_action_order(@active_battler)

    end

    dargor_vx_action_order_update_item_selection

  end

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

  # * Update Skill Selection

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

  def update_skill_selection

    @skill = @skill_window.skill

    if @active_battler.action.skill.id != @skill.id

      @active_battler.action.clear

      @active_battler.action.set_skill(@skill.id)

      make_action_order(@active_battler)

    end

    dargor_vx_action_order_update_skill_selection

  end

end

 

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

# ** Window_BattleMessage

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

#  Message window displayed during battle. In addition to the normal message

# window functions, it also has a battle progress narration function.

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

 

class Window_BattleMessage < Window_Message

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

  # * Get Text From Last Line

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

  def last_instant_text

    line = @lines[-1]

    line = @lines[0] if line.nil?

    return line

  end

end

 

Credits and Thanks

Thanks to J4iru5 for requesting this script.
 
Dude wow!

Does it work exactly like Final Fantasy X?

Now you just need to do the battle algorithms and it'd be set!
-Krobe
 
Request... can you make it so that the window only appear during the command input phase of the battle.. I'm using a sideview CBS and it obstructs the battle view... great script btw...
 
Great script but it would be nice if window height and opacity could be added to the customisation module.
Also if it showed actions for the next turn as well as the current turn that would be useful as well.
 
@NunoAle
Yes it will.

@iceplosion
I have added the opacity and height options. The height is determined bu the number of battlers visible at the same time in the window.

@van helblaze 
Fixed

@Xemnas13
Done.
 

J4iru5

Member

WOOOOO! Thanks Dargor, this script owns!
lol, i feel so cool being credited, Dargor, you're like a hero dude.
But, do you think it could be so that when a character executes a move, it is done right away, so that the character might have several moves in row (depending on agi)?
Love it, if this were to happen! Thanks again Dargor

Edit: I think this means the one with the most agi goes first in battle
 
I'm curious, would this happen to be compatible with the RPG Tankentai battle system?

EDIT: Never mind...just saw J4iru5's script request.:) This should be really great, (not at my home computer, so can't try it out) considering I'm also using the RPG Tankentai battle system.
 
Hyper Wind":26jaxtl6 said:
I'm curious, would this happen to be compatible with the RPG Tankentai battle system?

EDIT: Never mind...just saw J4iru5's script request.:) This should be really great, (not at my home computer, so can't try it out) considering I'm also using the RPG Tankentai battle system.
the new version of the script works just fine with the SBS
 
Just one question, what does WLH stand for in the script?  (Trying to mod this a bit to get it more to my tastes, I can get it the way I want fine, just was wondering what it stood for, Window_length_height?)
 
Dargor, lets say I wanted to make the faces horizontal, I've already hacked it up so it works like that perfect, only thing is the box that shows the current selection, sort of like a show_choice box or w/e.  How would I get it to resize the thing to go horizontal and only size wide instead of being the entire width and only 20 high?
 

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