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]One Person CMS

I've noticed the abundant lack of CMS's for RMVX, and because of which, I would like to request one. Basically, this CMS would be used for an one-man RPG.


The menu would be fairly compact, taking up minimal space. It would be located at the top left hand corner of the screen. At the top of the menu, the face of the main character would be shown. Under it, his/her name would be displayed, and below that, his/her class and next to his/her class would be the level of the character. Below that would lie the HP and MP bars. Last but not least, below that, would be where the amount of gold is shown.

The commands would be located at the side. I would prefer if they were animated(they would appear from behind the menu to the right side), but it's not required. The command bars would get shorter as they go. Also, instead of the "Save" command, I would like it if you could put a "System" command similar to L's Custom Menu, except the commands that appear would be: Bestiary, Save, Load, and Quit. If you could call Dargor's Bestiary with the Bestiary command in the menu, that would be great!

Also, I would prefer(again, not required) if you could add a cursor for selecting the menu commands(but not to be used in any other menus, including item, equipment, etc.)

Also, here's some misc. things:
-Please use the vocabulary for names of gold and such, since I'm not going with the usual "G" or "Gil" or even "Zenny".
-Please make it so that the menu recognizes the character in the party, because at the start of the game you have the choice between two different characters.
-You don't have to modify any of the other scenes.

Last but not least, here's a mock-up to give you a general idea of what I want:
http://i56.photobucket.com/albums/g182/ ... mockup.png[/img]
That blue thing is a cursor, by the way.

Thanks in advance, I would really appreciate the help!
 

khmp

Sponsor

Mr. Musashi, I'd be willing to accept your request if that isn't a problem. I just have a few questions. The options that slide out from beneath the status window. Are they actual images in the directory that you want loaded in? Or do you want them to be drawn by RMVX when the Scene starts, text and all? And what do you mean by animated?
 
I really appreciate this, khmp!

To answer your questions, I would like the windows and text to be drawn by RMVX. By animated, I mean that the command windows slide out from beneath the main window(where the face, level, hp, etc. are shown) out to where they are supposed to be. Again, thank you very much!
 

khmp

Sponsor

Code:
#==============================================================================
# ** Math
#------------------------------------------------------------------------------
#  This module holds Math related nonsense which I am extending.
#==============================================================================

module Math
  class << self
    #------------------------------------------------------------------------
    # * Distance Between Two 2D points
    #     pt1 : first 2D point
    #     pt2 : second 2D point
    #------------------------------------------------------------------------
    def distance(pt1, pt2)
      return hypot(pt1[0] - pt2[0], pt1[1] - pt2[1])
    end
    #------------------------------------------------------------------------
    # * Alias Methods
    #------------------------------------------------------------------------
    alias dist distance
  end
end

#==============================================================================
# ** Math_Vector3
#------------------------------------------------------------------------------
#  This class only holds the information of a 3D Vector along with a few
#  helpful methods for using the class. (!No Cross Product!)
#==============================================================================

class Math_Vector3
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :x, :y, :z
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     x : the x component of the vector.
  #     y : the y component of the vector.
  #     z : the z component of the vector.
  #--------------------------------------------------------------------------
  def initialize(x = 0.0, y = 0.0, z = 0.0)
    @x, @y, @z = x.to_f, y.to_f, z.to_f
  end
  #--------------------------------------------------------------------------
  # * Magnitude
  #--------------------------------------------------------------------------
  def magnitude
    return Math.sqrt((@x * @x) + (@y * @y) + (@z * @z))
  end
  #--------------------------------------------------------------------------
  # * Multiply (Dot Product/Scalar)
  #     multiply : the polymorphized object being multiplied with self.
  #--------------------------------------------------------------------------
  def *(multiply)
    return scale(multiply) if multiply.is_a?(Numeric)
    return dot(multiply) if multiply.is_a?(Math_Vector3)
  end
  #--------------------------------------------------------------------------
  # * Addition
  #     add : the vector being added to self.
  #--------------------------------------------------------------------------
  def +(add)
    return Math_Vector3.new(@x + add.x, @y + add.y, @z + add.z)
  end
  #--------------------------------------------------------------------------
  # * Subtraction
  #     add : the vector being taken away from self.
  #--------------------------------------------------------------------------
  def -(sub)
    return Math_Vector3.new(@x - sub.x, @y - sub.y, @z - sub.z)
  end
  #--------------------------------------------------------------------------
  # * Scale
  #     scalar : the multiplier applied to the vector.
  #--------------------------------------------------------------------------
  def scale(scalar)
    return Math_Vector3.new(@x * scalar, @y * scalar, @z * scalar)
  end
  #--------------------------------------------------------------------------
  # * Dot Product
  #     vec : the vector you are dotting with.
  #--------------------------------------------------------------------------
  def dot(vec)
    return ((@x * vec.x) + (@y * vec.y) + (@z * vec.z))
  end
  #--------------------------------------------------------------------------
  # * Returns Normalized Math_Vector3
  #--------------------------------------------------------------------------
  def normalize
    mag = magnitude
    return Math_Vector3.new(@x / mag, @y / mag, @z / mag)
  end
  #--------------------------------------------------------------------------
  # * Normalizes Calling Math_Vector3
  #--------------------------------------------------------------------------
  def normalize!
    mag = magnitude
    @x /= mag
    @y /= mag
    @z /= mag
  end
  #--------------------------------------------------------------------------
  # * Returns Array of Math_Vector3
  #--------------------------------------------------------------------------
  def to_a
    return [@x, @y, @z]
  end
  #--------------------------------------------------------------------------
  # * Get Component
  #     index : the index of the component you want.
  #--------------------------------------------------------------------------
  def [](index)
    case index
    when 0
      return @x
    when 1
      return @y
    when 2
      return @z
    end
  end
  #--------------------------------------------------------------------------
  # * Set Component
  #     index : the index of the component you want to change.
  #     value : the new value of the component.
  #--------------------------------------------------------------------------
  def []=(index, value)
    case index
    when 0
      @x = value.to_f
    when 1
      @y = value.to_f
    when 2
      @z = value.to_f
    end
  end
  #--------------------------------------------------------------------------
  # * Compare
  #     vec : the vec you are comparing against.
  #--------------------------------------------------------------------------
  def ==(vec)
    return false unless vec.is_a?(Math_Vector3)
    return true if (vec.x == self.x && vec.y == self.y && vec.z == self.z)
    return false
  end
  #--------------------------------------------------------------------------
  # * Alias Methods
  #--------------------------------------------------------------------------
  alias_method :length, :magnitude
end

#==============================================================================
# ** Sprite_Float
#------------------------------------------------------------------------------
#  A sprite class with Float based location and movement.
#==============================================================================

class Sprite_Float < Sprite
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :slide
  attr_reader   :active, 
                :sliding
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(viewport = nil)
    super(viewport)
    @fx = @fy = @fz = 0.0
    @fopacity = 255.0
    @slide = false
    @sliding = false
    @active = true
  end
  #--------------------------------------------------------------------------
  # * Slide
  #     x       : the x coordinate to go to.
  #     y       : the y coordinate to go to.
  #     frames  : the number of frames to get to the destination.
  #     opacity : the ending opacity when it reaches its destination.
  #--------------------------------------------------------------------------
  def slide(x, y, z, frames, opacity = 255)
    @slide = true
    @vec = Math_Vector3.new(@to_x = x.to_f, @to_y = y.to_f, @to_z = z.to_f) - 
      Math_Vector3.new(@or_x = self.x, @or_y = self.y, @or_z = self.z)
    @vec = @vec.scale(1 / frames.to_f)
    @delta_opacity = (opacity - self.opacity) / frames.to_f
    @sliding = true
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super()
    # If the user has called slide once. We will do more work.
    if @slide
      # If the sprite is active meaning if it isn't at the destination
      # keep moving it.
      if @active && @sliding
        unless Math.dist([self.x, self.y], [@to_x, @to_y]) > 1.0
          @sliding = false
          return
        end
        
        @sliding = true
        self.x += @vec.x
        self.y += @vec.y
        self.z += @vec.z
        self.opacity += @delta_opacity
      elsif !@active && @sliding
        unless Math.dist([self.x, self.y], [@or_x, @or_y]) > 1.0
          @sliding = false
          return
        end
        
        @sliding = true
        self.x -= @vec.x
        self.y -= @vec.y
        self.z -= @vec.z
        self.opacity -= @delta_opacity
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Set X
  #     x : the new x coordinate
  #--------------------------------------------------------------------------
  def x=(x)
    super(@fx = x.to_f)
  end
  #--------------------------------------------------------------------------
  # * Set Y
  #     y : the new y coordinate
  #--------------------------------------------------------------------------
  def y=(y)
    super(@fy = y.to_f)
  end
  #--------------------------------------------------------------------------
  # * Set Z
  #     z : the new z coordinate
  #--------------------------------------------------------------------------
  def z=(z)
    super(@fz = z.to_f)
  end
  #--------------------------------------------------------------------------
  # * Get X
  #--------------------------------------------------------------------------
  def x
    return @fx
  end
  #--------------------------------------------------------------------------
  # * Get Y
  #--------------------------------------------------------------------------
  def y
    return @fy
  end
  #--------------------------------------------------------------------------
  # * Get Z
  #--------------------------------------------------------------------------
  def z
    return @fz
  end
  #--------------------------------------------------------------------------
  # * Set Active
  #     active : the active flag.
  #--------------------------------------------------------------------------
  def active=(active)
    @active = active
    @sliding = true
  end
  #--------------------------------------------------------------------------
  # * Set (X/Y) Zoom
  #--------------------------------------------------------------------------
  def zoom=(zoom)
    self.zoom_x = self.zoom_y = zoom
  end
end

#==============================================================================
# ** Musashi_Command
#------------------------------------------------------------------------------
#  Simple command menu with rectangular options displayed in reverse step 
#  manner.
#==============================================================================

class Musashi_Command
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader :opening, :closing, :index, :x, :y, :z, :width, :height, :active
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     commands : the commands you want to see.
  #     index    : the index of the option you want to look at.
  #     spacing  : the spacing between each command.
  #--------------------------------------------------------------------------
  def initialize(commands, index = 0, spacing = 5)
    @commands = commands
    @spacing = spacing
    
    @bar_width = 144
    @bar_height = Window_Base::WLH
    @go_to = Window_MonoStatus::Window_Width - 2
    @offset = 10
    
    @sprites = []
    @commands.each_index do |i|
      @sprites << Sprite_Float.new
      @sprites[i].bitmap = Bitmap.new(@bar_width - (i * 8), @bar_height)
      rect = @sprites[i].bitmap.rect
      @sprites[i].bitmap.fill_rect(rect, Color.new(0, 0, 0))
      rect.x = rect.y = 1
      rect.width -= 2
      rect.height -= 2
      @sprites[i].bitmap.gradient_fill_rect(rect, Color.new(120, 120, 120),
        Color.new(180, 180, 180))
      @sprites[i].bitmap.draw_text(5, 1, rect.width - 5, @bar_height - 2, 
        @commands[i])
      @sprites[i].x = 0
      @sprites[i].y = (@bar_height * i) + (@spacing * i) + @offset
      @sprites[i].z = 255
      @sprites[i].opacity = 0
      @sprites[i].slide(@sprites[i].x + @go_to, @sprites[i].y, @sprites[i].z, 10)
      @sprites[i].active = false
      i += 1
    end
    
    @active = false
    @height, @width = @sprites.last.y - @sprites[0].y, 144
    @opening = @closing = false
    self.index = index
    self.openness = 255
  end
  #--------------------------------------------------------------------------
  # * Set Cursor Image
  #     image_dir : the image of the cursor's directory.
  #     image_dir : the filename of the cursor's image.
  #--------------------------------------------------------------------------
  def cursor(image_dir, image_name)
    @cursor = Sprite.new
    @cursor.bitmap = Cache.load_bitmap(image_dir, image_name)
    @cursor.oy = (@cursor.bitmap.height >> 1)
    @cursor.visible = false
  end
  #--------------------------------------------------------------------------
  # * Update Cursor
  #--------------------------------------------------------------------------
  def update_cursor
    return if @cursor.nil?
    @cursor.opacity = @sprites[@index].opacity
    @cursor.x = @sprites[@index].bitmap.width + @sprites[@index].x
    @cursor.y = (@bar_height * @index) + (@spacing * @index) + @offset +
      (@bar_height >> 1)
    @cursor.z = @sprites[@index].z
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    if @opening
      self.openness = 255
      @opening = false
    elsif @closing
      self.openness = 0
      @closing = false
    end
    
    @sprites.each { |sprite| update_cursor; sprite.update }
    
    if @active
      if Input.trigger?(Input::UP)
        Sound.play_cursor
        self.index -= 1
      elsif Input.trigger?(Input::DOWN)
        Sound.play_cursor
        self.index += 1
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Set Active
  #     active : the active flag.
  #--------------------------------------------------------------------------
  def active=(active)
    @active = active
    @sprites.each { |sprite| sprite.active = active }
    @cursor.visible = active
  end
  #--------------------------------------------------------------------------
  # * Set Index
  #     index : the index.
  #--------------------------------------------------------------------------
  def index=(index)
    if @index != index
      @index = index
      @index = 0 if @index == @commands.size
      @index = @commands.size - 1 if @index < 0
      update_cursor
    end
  end
  #--------------------------------------------------------------------------
  # * Set X
  #     x : the x coordinate of the musashi command object.
  #--------------------------------------------------------------------------
  def x=(x)
    @x = x
    @sprites.each do |sprite|
      sprite.x = x
      sprite.slide(sprite.x + @go_to, sprite.y, sprite.z, 10)
    end
  end
  #--------------------------------------------------------------------------
  # * Set Y
  #     x : the y coordinate of the musashi command object.
  #--------------------------------------------------------------------------
  def y=(y)
    @y = y
    @sprites.each_index do |i|
      @sprites[i].y = (@bar_height * i) + (@spacing * i)
      @sprites[i].slide(@sprites[i].x + @go_to, @sprites[i].y, @sprites[i].z, 
        10)
    end
  end
  #--------------------------------------------------------------------------
  # * Set Z
  #     x : the z coordinate of the musashi command object.
  #--------------------------------------------------------------------------
  def z=(z)
    @z = z
    @sprites.each do |sprite|
      sprite.z = z
      sprite.slide(sprite.x + @go_to, sprite.y, sprite.z, 10)
    end
  end
  #--------------------------------------------------------------------------
  # * Set Openness 
  #     openness : the new openness of the window.
  #--------------------------------------------------------------------------
  def openness=(openness)
    @openness = [[openness, 255].min, 0].max
  end
  #--------------------------------------------------------------------------
  # * Get Moving
  #--------------------------------------------------------------------------
  def moving?
    return @sprites[0].sliding
  end
  #--------------------------------------------------------------------------
  # * Open Musashi Command
  #--------------------------------------------------------------------------
  def open
    @opening = true if self.openness < 255
    @closing = false
  end
  #--------------------------------------------------------------------------
  # * Close Musashi Command
  #--------------------------------------------------------------------------
  def close
    @closing = true if self.openness > 0
    @opening = false
  end
  #--------------------------------------------------------------------------
  # * Dispose
  #--------------------------------------------------------------------------
  def dispose
    @sprites.each do |sprite|
      sprite.bitmap.dispose
      sprite.dispose
    end
    
    unless @cursor.nil?
      @cursor.bitmap.dispose
      @cursor.dispose
    end
  end
end

#==============================================================================
# ** Window_MenuStatus
#------------------------------------------------------------------------------
#  This window displays the party leaders information only.
#==============================================================================

class Window_MonoStatus < Window_Base
  #--------------------------------------------------------------------------
  # * Constant Variables
  #--------------------------------------------------------------------------
  Window_Width = 180
  Window_Height = 250
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, Window_Width, Window_Height)
    draw_actor_face($game_party.members[0], ((width - 32) >> 1) - (96 >> 1),
      0)
    draw_actor_name($game_party.members[0], 2, 98)
    draw_actor_class($game_party.members[0], 2, 98 + WLH)
    draw_actor_level($game_party.members[0], 90, 98 + WLH * 1)
    draw_actor_hp($game_party.members[0], 2, 98 + WLH * 2, width - 36)
    draw_actor_mp($game_party.members[0], 2, 98 + WLH * 3, width - 36)
    draw_currency_value($game_party.gold, 2, 98 + WLH * 4, width - 36)
  end
end

#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
#  This class performs the menu screen processing.
#==============================================================================

class Scene_Menu < Scene_Base
  #--------------------------------------------------------------------------
  # * Constant Variables
  #--------------------------------------------------------------------------
  System_String = 'System'
  System_Strings = [
    'Bestiary',
    'Save',
    'Load',
    'Quit'
  ]
  Cursor_Dir = 'graphics/cursors/'
  Cursor_Img = 'cursor'
  #--------------------------------------------------------------------------
  # * Create Command Window                                        !OVERRIDE!
  #--------------------------------------------------------------------------
  def create_command_window
    @command_window = Musashi_Command.new(
      [Vocab::item, Vocab::skill, Vocab::equip, Vocab::status, System_String,
      Vocab::game_end], @menu_index, 18)
    @command_window.cursor(Cursor_Dir, Cursor_Img)
    @command_window.active = true
    @command_system = Musashi_Command.new(System_Strings, 0, 18)
    @command_system.cursor(Cursor_Dir, Cursor_Img)
  end
  #--------------------------------------------------------------------------
  # * Start processing                                             !OVERRIDE!
  #--------------------------------------------------------------------------
  def start
    super
    create_menu_background
    create_command_window
    @status = Window_MonoStatus.new
    @status.z = 256
  end
  #--------------------------------------------------------------------------
  # * Termination Processing                                       !OVERRIDE!
  #--------------------------------------------------------------------------
  def terminate
    super
    dispose_menu_background
    @command_window.dispose
    @command_system.dispose
    @status.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update                                                 !OVERRIDE!
  #--------------------------------------------------------------------------
  def update
    super
    update_menu_background
    @command_window.update
    @command_system.update
    if @command_window.active && !@command_window.moving?
      update_command_selection
    elsif @command_system.active && !@command_system.moving?
      update_system_selection
    end
  end
  #--------------------------------------------------------------------------
  # * Update Command Selection                                     !OVERRIDE!
  #--------------------------------------------------------------------------
  def update_command_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      $scene = Scene_Map.new
    elsif Input.trigger?(Input::C)
      if $game_party.members.size == 0 and @command_window.index < 4
        Sound.play_buzzer
        return
      elsif $game_system.save_disabled and @command_window.index == 4
        Sound.play_buzzer
        return
      end
      Sound.play_decision
      case @command_window.index
      when 0      # Item
        $scene = Scene_Item.new
      when 1      # Skill
        $scene = Scene_Skill.new(0)
      when 2      # Equipment
        $scene = Scene_Equip.new(0)
      when 3      # Status
        $scene = Scene_Status.new(0)
      when 4      # Save
        @command_window.active = false
        @command_system.active = true
      when 5      # End Game
        $scene = Scene_End.new
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Update System Selection
  #--------------------------------------------------------------------------
  def update_system_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      @command_window.active = true
      @command_system.active = false
    elsif Input.trigger?(Input::C)
      case @command_system.index
      when 0      # Bestiary
        $scene = Scene_Bestiary.new
      when 1      # Save
        $scene = Scene_File.new(true, false, false)
      when 2      # Load
        $scene = Scene_File.new(false, false, false)
      when 3      # Quit
        $scene = nil
      end
    end
  end
end

Alright first create a "cursors" directory within your graphics folder. Within that folder place an image called "cursor". This will be the image that appears next to the options. If you have any questions, comments, concerns about it let me know.

Good luck with it Musashi! :thumb:
 
Thanks a bunch! I'm just realized, if it's not too much to ask, if I could also animate the cursor, like have cursor1.png, cursor2.png, etc. and it would animate it in that order. It's not needed, but it would be nice. Also, can you make it so the BGM lowers whenever you you go into the menu? Thanks! 


Edit: Also, I keep getting an error saying that it can't find graphics/cursor/cursor. I made a new folder and put the file in there, and it's name is cursor, so I don't know why I'm getting the error still. Nevermind. I looked in the script, and I accidentally made the folder 'cursor' instead of 'cursors'.

Edit2: OH, and I'm glad to see that you realize where my name comes from.  :thumb:

Edit21390981290382908: OH MY GOD I LOVE YOU IT'S PERFECT.
 

khmp

Sponsor

Yeah here ya go:
Code:
#==============================================================================
# ** Math
#------------------------------------------------------------------------------
#  This module holds Math related nonsense which I am extending.
#==============================================================================

module Math
  class << self
    #------------------------------------------------------------------------
    # * Distance Between Two 2D points
    #     pt1 : first 2D point
    #     pt2 : second 2D point
    #------------------------------------------------------------------------
    def distance(pt1, pt2)
      return hypot(pt1[0] - pt2[0], pt1[1] - pt2[1])
    end
    #------------------------------------------------------------------------
    # * Alias Methods
    #------------------------------------------------------------------------
    alias dist distance
  end
end

#==============================================================================
# ** Math_Vector3
#------------------------------------------------------------------------------
#  This class only holds the information of a 3D Vector along with a few
#  helpful methods for using the class. (!No Cross Product!)
#==============================================================================

class Math_Vector3
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :x, :y, :z
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     x : the x component of the vector.
  #     y : the y component of the vector.
  #     z : the z component of the vector.
  #--------------------------------------------------------------------------
  def initialize(x = 0.0, y = 0.0, z = 0.0)
    @x, @y, @z = x.to_f, y.to_f, z.to_f
  end
  #--------------------------------------------------------------------------
  # * Magnitude
  #--------------------------------------------------------------------------
  def magnitude
    return Math.sqrt((@x * @x) + (@y * @y) + (@z * @z))
  end
  #--------------------------------------------------------------------------
  # * Multiply (Dot Product/Scalar)
  #     multiply : the polymorphized object being multiplied with self.
  #--------------------------------------------------------------------------
  def *(multiply)
    return scale(multiply) if multiply.is_a?(Numeric)
    return dot(multiply) if multiply.is_a?(Math_Vector3)
  end
  #--------------------------------------------------------------------------
  # * Addition
  #     add : the vector being added to self.
  #--------------------------------------------------------------------------
  def +(add)
    return Math_Vector3.new(@x + add.x, @y + add.y, @z + add.z)
  end
  #--------------------------------------------------------------------------
  # * Subtraction
  #     add : the vector being taken away from self.
  #--------------------------------------------------------------------------
  def -(sub)
    return Math_Vector3.new(@x - sub.x, @y - sub.y, @z - sub.z)
  end
  #--------------------------------------------------------------------------
  # * Scale
  #     scalar : the multiplier applied to the vector.
  #--------------------------------------------------------------------------
  def scale(scalar)
    return Math_Vector3.new(@x * scalar, @y * scalar, @z * scalar)
  end
  #--------------------------------------------------------------------------
  # * Dot Product
  #     vec : the vector you are dotting with.
  #--------------------------------------------------------------------------
  def dot(vec)
    return ((@x * vec.x) + (@y * vec.y) + (@z * vec.z))
  end
  #--------------------------------------------------------------------------
  # * Returns Normalized Math_Vector3
  #--------------------------------------------------------------------------
  def normalize
    mag = magnitude
    return Math_Vector3.new(@x / mag, @y / mag, @z / mag)
  end
  #--------------------------------------------------------------------------
  # * Normalizes Calling Math_Vector3
  #--------------------------------------------------------------------------
  def normalize!
    mag = magnitude
    @x /= mag
    @y /= mag
    @z /= mag
  end
  #--------------------------------------------------------------------------
  # * Returns Array of Math_Vector3
  #--------------------------------------------------------------------------
  def to_a
    return [@x, @y, @z]
  end
  #--------------------------------------------------------------------------
  # * Get Component
  #     index : the index of the component you want.
  #--------------------------------------------------------------------------
  def [](index)
    case index
    when 0
      return @x
    when 1
      return @y
    when 2
      return @z
    end
  end
  #--------------------------------------------------------------------------
  # * Set Component
  #     index : the index of the component you want to change.
  #     value : the new value of the component.
  #--------------------------------------------------------------------------
  def []=(index, value)
    case index
    when 0
      @x = value.to_f
    when 1
      @y = value.to_f
    when 2
      @z = value.to_f
    end
  end
  #--------------------------------------------------------------------------
  # * Compare
  #     vec : the vec you are comparing against.
  #--------------------------------------------------------------------------
  def ==(vec)
    return false unless vec.is_a?(Math_Vector3)
    return true if (vec.x == self.x && vec.y == self.y && vec.z == self.z)
    return false
  end
  #--------------------------------------------------------------------------
  # * Alias Methods
  #--------------------------------------------------------------------------
  alias_method :length, :magnitude
end

#==============================================================================
# ** Sprite_Float
#------------------------------------------------------------------------------
#  A sprite class with Float based location and movement.
#==============================================================================

class Sprite_Float < Sprite
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :slide
  attr_reader   :active, 
                :sliding
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(viewport = nil)
    super(viewport)
    @fx = @fy = @fz = 0.0
    @fopacity = 255.0
    @slide = false
    @sliding = false
    @active = true
  end
  #--------------------------------------------------------------------------
  # * Slide
  #     x       : the x coordinate to go to.
  #     y       : the y coordinate to go to.
  #     frames  : the number of frames to get to the destination.
  #     opacity : the ending opacity when it reaches its destination.
  #--------------------------------------------------------------------------
  def slide(x, y, z, frames, opacity = 255)
    @slide = true
    @vec = Math_Vector3.new(@to_x = x.to_f, @to_y = y.to_f, @to_z = z.to_f) - 
      Math_Vector3.new(@or_x = self.x, @or_y = self.y, @or_z = self.z)
    @vec = @vec.scale(1 / frames.to_f)
    @delta_opacity = (opacity - self.opacity) / frames.to_f
    @sliding = true
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super()
    # If the user has called slide once. We will do more work.
    if @slide
      # If the sprite is active meaning if it isn't at the destination
      # keep moving it.
      if @active && @sliding
        unless Math.dist([self.x, self.y], [@to_x, @to_y]) > 1.0
          @sliding = false
          return
        end
        
        @sliding = true
        self.x += @vec.x
        self.y += @vec.y
        self.z += @vec.z
        self.opacity += @delta_opacity
      elsif !@active && @sliding
        unless Math.dist([self.x, self.y], [@or_x, @or_y]) > 1.0
          @sliding = false
          return
        end
        
        @sliding = true
        self.x -= @vec.x
        self.y -= @vec.y
        self.z -= @vec.z
        self.opacity -= @delta_opacity
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Set X
  #     x : the new x coordinate
  #--------------------------------------------------------------------------
  def x=(x)
    super(@fx = x.to_f)
  end
  #--------------------------------------------------------------------------
  # * Set Y
  #     y : the new y coordinate
  #--------------------------------------------------------------------------
  def y=(y)
    super(@fy = y.to_f)
  end
  #--------------------------------------------------------------------------
  # * Set Z
  #     z : the new z coordinate
  #--------------------------------------------------------------------------
  def z=(z)
    super(@fz = z.to_f)
  end
  #--------------------------------------------------------------------------
  # * Get X
  #--------------------------------------------------------------------------
  def x
    return @fx
  end
  #--------------------------------------------------------------------------
  # * Get Y
  #--------------------------------------------------------------------------
  def y
    return @fy
  end
  #--------------------------------------------------------------------------
  # * Get Z
  #--------------------------------------------------------------------------
  def z
    return @fz
  end
  #--------------------------------------------------------------------------
  # * Set Active
  #     active : the active flag.
  #--------------------------------------------------------------------------
  def active=(active)
    @active = active
    @sliding = true
  end
  #--------------------------------------------------------------------------
  # * Set (X/Y) Zoom
  #--------------------------------------------------------------------------
  def zoom=(zoom)
    self.zoom_x = self.zoom_y = zoom
  end
end

#==============================================================================
# ** Musashi_Command
#------------------------------------------------------------------------------
#  Simple command menu with rectangular options displayed in reverse step 
#  manner.
#==============================================================================

class Musashi_Command
  #--------------------------------------------------------------------------
  # * Constant Variables
  #--------------------------------------------------------------------------
  Frames_Anim = 400
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader :opening, :closing, :index, :x, :y, :z, :width, :height, :active
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     commands : the commands you want to see.
  #     index    : the index of the option you want to look at.
  #     spacing  : the spacing between each command.
  #--------------------------------------------------------------------------
  def initialize(commands, index = 0, spacing = 5)
    @commands = commands
    @spacing = spacing
    
    @bar_width = 144
    @bar_height = Window_Base::WLH
    @go_to = Window_MonoStatus::Window_Width - 2
    @offset = 10
    
    @sprites = []
    @commands.each_index do |i|
      @sprites << Sprite_Float.new
      @sprites[i].bitmap = Bitmap.new(@bar_width - (i * 8), @bar_height)
      rect = @sprites[i].bitmap.rect
      @sprites[i].bitmap.fill_rect(rect, Color.new(0, 0, 0))
      rect.x = rect.y = 1
      rect.width -= 2
      rect.height -= 2
      @sprites[i].bitmap.gradient_fill_rect(rect, Color.new(120, 120, 120),
        Color.new(180, 180, 180))
      @sprites[i].bitmap.draw_text(5, 1, rect.width - 5, @bar_height - 2, 
        @commands[i])
      @sprites[i].x = 0
      @sprites[i].y = (@bar_height * i) + (@spacing * i) + @offset
      @sprites[i].z = 255
      @sprites[i].opacity = 0
      @sprites[i].slide(@sprites[i].x + @go_to, @sprites[i].y, @sprites[i].z, 10)
      @sprites[i].active = false
      i += 1
    end
    
    @active = false
    @height, @width = @sprites.last.y - @sprites[0].y, 144
    @opening = @closing = false
    @cursor_anim_frames = Frames_Anim
    @anim_index = 0
    self.index = index
    self.openness = 255
  end
  #--------------------------------------------------------------------------
  # * Set Cursor Image
  #     image_dir : the image of the cursor's directory.
  #     image_dir : the filename of the cursor's image.
  #--------------------------------------------------------------------------
  def cursor(image_dir, image_names)
    @cursor_image_dir = image_dir
    @cursor_image_names = image_names
    @cursor = Sprite.new
    @cursor.bitmap = Cache.load_bitmap(image_dir, image_names.first)
    @cursor.oy = (@cursor.bitmap.height >> 1)
    @cursor.visible = false
  end
  #--------------------------------------------------------------------------
  # * Update Cursor
  #--------------------------------------------------------------------------
  def update_cursor
    return if @cursor.nil?
    @cursor_anim_frames -= 1
    
    if @cursor_anim_frames == 0
      @cursor_anim_frames = Frames_Anim
      @anim_index += 1
      @anim_index = 0 if @anim_index == @cursor_image_names.size
      @cursor.bitmap = Cache.load_bitmap(@cursor_image_dir, 
        @cursor_image_names[@anim_index])
    end
    
    @cursor.opacity = @sprites[@index].opacity
    @cursor.x = @sprites[@index].bitmap.width + @sprites[@index].x
    @cursor.y = (@bar_height * @index) + (@spacing * @index) + @offset +
      (@bar_height >> 1)
    @cursor.z = @sprites[@index].z
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    if @opening
      self.openness = 255
      @opening = false
    elsif @closing
      self.openness = 0
      @closing = false
    end
    
    @sprites.each { |sprite| update_cursor; sprite.update }
    
    if @active
      if Input.trigger?(Input::UP)
        Sound.play_cursor
        self.index -= 1
      elsif Input.trigger?(Input::DOWN)
        Sound.play_cursor
        self.index += 1
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Set Active
  #     active : the active flag.
  #--------------------------------------------------------------------------
  def active=(active)
    @active = active
    @sprites.each { |sprite| sprite.active = active }
    @cursor.visible = active
  end
  #--------------------------------------------------------------------------
  # * Set Index
  #     index : the index.
  #--------------------------------------------------------------------------
  def index=(index)
    if @index != index
      @index = index
      @index = 0 if @index == @commands.size
      @index = @commands.size - 1 if @index < 0
      update_cursor
    end
  end
  #--------------------------------------------------------------------------
  # * Set X
  #     x : the x coordinate of the musashi command object.
  #--------------------------------------------------------------------------
  def x=(x)
    @x = x
    @sprites.each do |sprite|
      sprite.x = x
      sprite.slide(sprite.x + @go_to, sprite.y, sprite.z, 10)
    end
  end
  #--------------------------------------------------------------------------
  # * Set Y
  #     x : the y coordinate of the musashi command object.
  #--------------------------------------------------------------------------
  def y=(y)
    @y = y
    @sprites.each_index do |i|
      @sprites[i].y = (@bar_height * i) + (@spacing * i)
      @sprites[i].slide(@sprites[i].x + @go_to, @sprites[i].y, @sprites[i].z, 
        10)
    end
  end
  #--------------------------------------------------------------------------
  # * Set Z
  #     x : the z coordinate of the musashi command object.
  #--------------------------------------------------------------------------
  def z=(z)
    @z = z
    @sprites.each do |sprite|
      sprite.z = z
      sprite.slide(sprite.x + @go_to, sprite.y, sprite.z, 10)
    end
  end
  #--------------------------------------------------------------------------
  # * Set Openness 
  #     openness : the new openness of the window.
  #--------------------------------------------------------------------------
  def openness=(openness)
    @openness = [[openness, 255].min, 0].max
  end
  #--------------------------------------------------------------------------
  # * Get Moving
  #--------------------------------------------------------------------------
  def moving?
    return @sprites[0].sliding
  end
  #--------------------------------------------------------------------------
  # * Open Musashi Command
  #--------------------------------------------------------------------------
  def open
    @opening = true if self.openness < 255
    @closing = false
  end
  #--------------------------------------------------------------------------
  # * Close Musashi Command
  #--------------------------------------------------------------------------
  def close
    @closing = true if self.openness > 0
    @opening = false
  end
  #--------------------------------------------------------------------------
  # * Dispose
  #--------------------------------------------------------------------------
  def dispose
    @sprites.each do |sprite|
      sprite.bitmap.dispose
      sprite.dispose
    end
    
    unless @cursor.nil?
      @cursor.bitmap.dispose
      @cursor.dispose
    end
  end
end

#==============================================================================
# ** Window_MenuStatus
#------------------------------------------------------------------------------
#  This window displays the party leaders information only.
#==============================================================================

class Window_MonoStatus < Window_Base
  #--------------------------------------------------------------------------
  # * Constant Variables
  #--------------------------------------------------------------------------
  Window_Width = 180
  Window_Height = 250
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, Window_Width, Window_Height)
    draw_actor_face($game_party.members[0], ((width - 32) >> 1) - (96 >> 1),
      0)
    draw_actor_name($game_party.members[0], 2, 98)
    draw_actor_class($game_party.members[0], 2, 98 + WLH)
    draw_actor_level($game_party.members[0], 90, 98 + WLH * 1)
    draw_actor_hp($game_party.members[0], 2, 98 + WLH * 2, width - 36)
    draw_actor_mp($game_party.members[0], 2, 98 + WLH * 3, width - 36)
    draw_currency_value($game_party.gold, 2, 98 + WLH * 4, width - 36)
  end
end

#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
#  This class handles maps. It includes scrolling and passage determination
# functions. The instance of this class is referenced by $game_map.
#==============================================================================

class Game_Map
  attr_reader :map
end

#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
#  This class performs the menu screen processing.
#==============================================================================

class Scene_Menu < Scene_Base
  #--------------------------------------------------------------------------
  # * Constant Variables
  #--------------------------------------------------------------------------
  System_String = 'System'
  System_Strings = [
    'Bestiary',
    'Save',
    'Load',
    'Quit'
  ]
  Cursor_Dir = 'graphics/cursors/'
  Cursor_Imgs = [
    'cursor1',
    'cursor2',
  ]
  Reduce_Sound_To = 70
  #--------------------------------------------------------------------------
  # * Create Command Window                                        !OVERRIDE!
  #--------------------------------------------------------------------------
  def create_command_window
    @old_volume = $game_map.map.bgm.volume
    $game_map.map.bgm.volume = Reduce_Sound_To
    $game_map.map.bgm.play
    @command_window = Musashi_Command.new([Vocab::item, Vocab::skill, 
      Vocab::equip, Vocab::status, System_String,Vocab::game_end], 
      @menu_index, 18)
    @command_window.cursor(Cursor_Dir, Cursor_Imgs)
    @command_window.active = true
    @command_system = Musashi_Command.new(System_Strings, 0, 18)
    @command_system.cursor(Cursor_Dir, Cursor_Imgs)
  end
  #--------------------------------------------------------------------------
  # * Start processing                                             !OVERRIDE!
  #--------------------------------------------------------------------------
  def start
    super
    create_menu_background
    create_command_window
    @status = Window_MonoStatus.new
    @status.z = 256
  end
  #--------------------------------------------------------------------------
  # * Termination Processing                                       !OVERRIDE!
  #--------------------------------------------------------------------------
  def terminate
    super
    dispose_menu_background
    @command_window.dispose
    @command_system.dispose
    @status.dispose
    $game_map.map.bgm.volume = @old_volume
    $game_map.map.bgm.play
  end
  #--------------------------------------------------------------------------
  # * Frame Update                                                 !OVERRIDE!
  #--------------------------------------------------------------------------
  def update
    super
    update_menu_background
    @command_window.update
    @command_system.update
    if @command_window.active && !@command_window.moving?
      update_command_selection
    elsif @command_system.active && !@command_system.moving?
      update_system_selection
    end
  end
  #--------------------------------------------------------------------------
  # * Update Command Selection                                     !OVERRIDE!
  #--------------------------------------------------------------------------
  def update_command_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      $scene = Scene_Map.new
    elsif Input.trigger?(Input::C)
      if $game_party.members.size == 0 and @command_window.index < 4
        Sound.play_buzzer
        return
      elsif $game_system.save_disabled and @command_window.index == 4
        Sound.play_buzzer
        return
      end
      Sound.play_decision
      case @command_window.index
      when 0      # Item
        $scene = Scene_Item.new
      when 1      # Skill
        $scene = Scene_Skill.new(0)
      when 2      # Equipment
        $scene = Scene_Equip.new(0)
      when 3      # Status
        $scene = Scene_Status.new(0)
      when 4      # Save
        @command_window.active = false
        @command_system.active = true
      when 5      # End Game
        $scene = Scene_End.new
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Update System Selection
  #--------------------------------------------------------------------------
  def update_system_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      @command_window.active = true
      @command_system.active = false
    elsif Input.trigger?(Input::C)
      case @command_system.index
      when 0      # Bestiary
        $scene = Scene_Bestiary.new
      when 1      # Save
        $scene = Scene_File.new(true, false, false)
      when 2      # Load
        $scene = Scene_File.new(false, false, false)
      when 3      # Quit
        $scene = nil
      end
    end
  end
end

At the top of "Scene_Menu" you'll see a couple new constants. One will be the array of images to use for the cursor. If you have 3 images named 'hand1', 'flick2', 'hand3'. The array would look like this:
Code:
  Cursor_Imgs = [
    'hand1',
    'flick2',
    'hand3'
  ]
Simple yes? Also the volume turns down to 70 while in the menu. There's a constant for that as well.

Good luck with it Musashi! :thumb:
 
One more request! Thanks again for this! I was also going over some concepts for the game, and I was debating adding more than one person in the party at a time...if it's not to much to ask, could you also add this? If you're too busy, it's fine, just wondering if you could.

Mockup:http://i56.photobucket.com/albums/g182/Musashi999/menumockup-1.png[/img]

Also, if possible, only show the window if the party member is present. The 2nd party member is the one most to the right, 3rd in the middle, and last to the left. Oh, and if you include this option, can you put a command in the System commands that will allow you to change the order of the members, like change the leader of the party and such. Call this "Order", and should go in System, like I said before.

Edit: One last thing, is there a way to increase the speed of which the cursor animates? It's a bit slow.
 

khmp

Sponsor

Speed of the cursor animation is based on a constant at the top of the Musashi_Command class. Just do a search for the class within the script. I set it to 400 frames lower that number to something else if you wish. Next... you're re-designing your menu and including the current party... :pissed:

Do you want them to be selectable? Like if you select equipment do you want to still only manipulate the party leader's equipment? Same for items skills and status? How do you imagine making them selectable, if that is a yes? I'm going to use a command window kind of thing for ordering. If that's not a problem.
 
Avgen, a CMS is a custom menu system. Anyway, yes, I want them selectable. The cursor could appear over the face of the person, and using left and right will change who it's on. For example, if you're on the current party leader, and press right, you'll select the person next most to the left. So, the cursor should also be over the face on the person selected.

A few problems I just found: On maps that have no BGM changed, the backround music stops playing when you enter the menu and exit it. Also, the other scenes have the BGM at 100, where would I copy the lines that change the BGM volume in the other scenes?
 

khmp

Sponsor

Musashi":282cp7hb said:
Avgen, a CMS is a custom menu system. Anyway, yes, I want them selectable. The cursor could appear over the face of the person, and using left and right will change who it's on. For example, if you're on the current party leader, and press right, you'll select the person next most to the left. So, the cursor should also be over the face on the person selected.

A few problems I just found: On maps that have no BGM changed, the backround music stops playing when you enter the menu and exit it. Also, the other scenes have the BGM at 100, where would I copy the lines that change the BGM volume in the other scenes?

BGM problem is resolved. I'll get working on the character selection. No more additions after this. :wink: If you find an error let me know.
 

khmp

Sponsor

Code:
#==============================================================================
# ** Math
#------------------------------------------------------------------------------
#  This module holds Math related nonsense which I am extending.
#==============================================================================

module Math
  class << self
    #------------------------------------------------------------------------
    # * Distance Between Two 2D points
    #     pt1 : first 2D point
    #     pt2 : second 2D point
    #------------------------------------------------------------------------
    def distance(pt1, pt2)
      return hypot(pt1[0] - pt2[0], pt1[1] - pt2[1])
    end
    #------------------------------------------------------------------------
    # * Alias Methods
    #------------------------------------------------------------------------
    alias dist distance
  end
end

#==============================================================================
# ** Math_Vector3
#------------------------------------------------------------------------------
#  This class only holds the information of a 3D Vector along with a few
#  helpful methods for using the class. (!No Cross Product!)
#==============================================================================

class Math_Vector3
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :x, :y, :z
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     x : the x component of the vector.
  #     y : the y component of the vector.
  #     z : the z component of the vector.
  #--------------------------------------------------------------------------
  def initialize(x = 0.0, y = 0.0, z = 0.0)
    @x, @y, @z = x.to_f, y.to_f, z.to_f
  end
  #--------------------------------------------------------------------------
  # * Magnitude
  #--------------------------------------------------------------------------
  def magnitude
    return Math.sqrt((@x * @x) + (@y * @y) + (@z * @z))
  end
  #--------------------------------------------------------------------------
  # * Multiply (Dot Product/Scalar)
  #     multiply : the polymorphized object being multiplied with self.
  #--------------------------------------------------------------------------
  def *(multiply)
    return scale(multiply) if multiply.is_a?(Numeric)
    return dot(multiply) if multiply.is_a?(Math_Vector3)
  end
  #--------------------------------------------------------------------------
  # * Addition
  #     add : the vector being added to self.
  #--------------------------------------------------------------------------
  def +(add)
    return Math_Vector3.new(@x + add.x, @y + add.y, @z + add.z)
  end
  #--------------------------------------------------------------------------
  # * Subtraction
  #     add : the vector being taken away from self.
  #--------------------------------------------------------------------------
  def -(sub)
    return Math_Vector3.new(@x - sub.x, @y - sub.y, @z - sub.z)
  end
  #--------------------------------------------------------------------------
  # * Scale
  #     scalar : the multiplier applied to the vector.
  #--------------------------------------------------------------------------
  def scale(scalar)
    return Math_Vector3.new(@x * scalar, @y * scalar, @z * scalar)
  end
  #--------------------------------------------------------------------------
  # * Dot Product
  #     vec : the vector you are dotting with.
  #--------------------------------------------------------------------------
  def dot(vec)
    return ((@x * vec.x) + (@y * vec.y) + (@z * vec.z))
  end
  #--------------------------------------------------------------------------
  # * Returns Normalized Math_Vector3
  #--------------------------------------------------------------------------
  def normalize
    mag = magnitude
    return Math_Vector3.new(@x / mag, @y / mag, @z / mag)
  end
  #--------------------------------------------------------------------------
  # * Normalizes Calling Math_Vector3
  #--------------------------------------------------------------------------
  def normalize!
    mag = magnitude
    @x /= mag
    @y /= mag
    @z /= mag
  end
  #--------------------------------------------------------------------------
  # * Returns Array of Math_Vector3
  #--------------------------------------------------------------------------
  def to_a
    return [@x, @y, @z]
  end
  #--------------------------------------------------------------------------
  # * Get Component
  #     index : the index of the component you want.
  #--------------------------------------------------------------------------
  def [](index)
    case index
    when 0
      return @x
    when 1
      return @y
    when 2
      return @z
    end
  end
  #--------------------------------------------------------------------------
  # * Set Component
  #     index : the index of the component you want to change.
  #     value : the new value of the component.
  #--------------------------------------------------------------------------
  def []=(index, value)
    case index
    when 0
      @x = value.to_f
    when 1
      @y = value.to_f
    when 2
      @z = value.to_f
    end
  end
  #--------------------------------------------------------------------------
  # * Compare
  #     vec : the vec you are comparing against.
  #--------------------------------------------------------------------------
  def ==(vec)
    return false unless vec.is_a?(Math_Vector3)
    return true if (vec.x == self.x && vec.y == self.y && vec.z == self.z)
    return false
  end
  #--------------------------------------------------------------------------
  # * Alias Methods
  #--------------------------------------------------------------------------
  alias_method :length, :magnitude
end

#==============================================================================
# ** Sprite_Float
#------------------------------------------------------------------------------
#  A sprite class with Float based location and movement.
#==============================================================================

class Sprite_Float < Sprite
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :slide
  attr_reader   :active, 
                :sliding
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(viewport = nil)
    super(viewport)
    @fx = @fy = @fz = 0.0
    @fopacity = 255.0
    @slide = false
    @sliding = false
    @active = true
  end
  #--------------------------------------------------------------------------
  # * Slide
  #     x       : the x coordinate to go to.
  #     y       : the y coordinate to go to.
  #     frames  : the number of frames to get to the destination.
  #     opacity : the ending opacity when it reaches its destination.
  #--------------------------------------------------------------------------
  def slide(x, y, z, frames, opacity = 255)
    @slide = true
    @vec = Math_Vector3.new(@to_x = x.to_f, @to_y = y.to_f, @to_z = z.to_f) - 
      Math_Vector3.new(@or_x = self.x, @or_y = self.y, @or_z = self.z)
    @vec = @vec.scale(1 / frames.to_f)
    @delta_opacity = (opacity - self.opacity) / frames.to_f
    @sliding = true
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super()
    # If the user has called slide once. We will do more work.
    if @slide
      # If the sprite is active meaning if it isn't at the destination
      # keep moving it.
      if @active && @sliding
        unless Math.dist([self.x, self.y], [@to_x, @to_y]) > 1.0
          @sliding = false
          return
        end
        
        @sliding = true
        self.x += @vec.x
        self.y += @vec.y
        self.z += @vec.z
        self.opacity += @delta_opacity
      elsif !@active && @sliding
        unless Math.dist([self.x, self.y], [@or_x, @or_y]) > 1.0
          @sliding = false
          return
        end
        
        @sliding = true
        self.x -= @vec.x
        self.y -= @vec.y
        self.z -= @vec.z
        self.opacity -= @delta_opacity
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Set X
  #     x : the new x coordinate
  #--------------------------------------------------------------------------
  def x=(x)
    super(@fx = x.to_f)
  end
  #--------------------------------------------------------------------------
  # * Set Y
  #     y : the new y coordinate
  #--------------------------------------------------------------------------
  def y=(y)
    super(@fy = y.to_f)
  end
  #--------------------------------------------------------------------------
  # * Set Z
  #     z : the new z coordinate
  #--------------------------------------------------------------------------
  def z=(z)
    super(@fz = z.to_f)
  end
  #--------------------------------------------------------------------------
  # * Get X
  #--------------------------------------------------------------------------
  def x
    return @fx
  end
  #--------------------------------------------------------------------------
  # * Get Y
  #--------------------------------------------------------------------------
  def y
    return @fy
  end
  #--------------------------------------------------------------------------
  # * Get Z
  #--------------------------------------------------------------------------
  def z
    return @fz
  end
  #--------------------------------------------------------------------------
  # * Set Active
  #     active : the active flag.
  #--------------------------------------------------------------------------
  def active=(active)
    @active = active
    @sliding = true
  end
  #--------------------------------------------------------------------------
  # * Set (X/Y) Zoom
  #--------------------------------------------------------------------------
  def zoom=(zoom)
    self.zoom_x = self.zoom_y = zoom
  end
end

#==============================================================================
# ** Musashi_Command
#------------------------------------------------------------------------------
#  Simple command menu with rectangular options displayed in reverse step 
#  manner.
#==============================================================================

class Musashi_Command
  #--------------------------------------------------------------------------
  # * Constant Variables
  #--------------------------------------------------------------------------
  Frames_Anim = 400
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader :opening, :closing, :index, :x, :y, :z, :width, :height, :active
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     commands : the commands you want to see.
  #     index    : the index of the option you want to look at.
  #     spacing  : the spacing between each command.
  #--------------------------------------------------------------------------
  def initialize(commands, index = 0, spacing = 5)
    @commands = commands
    @spacing = spacing
    
    @bar_width = 144
    @bar_height = Window_Base::WLH
    @go_to = Window_MonoStatus::Window_Width - 2
    @offset = 10
    
    @sprites = []
    @commands.each_index do |i|
      @sprites << Sprite_Float.new
      @sprites[i].bitmap = Bitmap.new(@bar_width - (i * 8), @bar_height)
      rect = @sprites[i].bitmap.rect
      @sprites[i].bitmap.fill_rect(rect, Color.new(0, 0, 0))
      rect.x = rect.y = 1
      rect.width -= 2
      rect.height -= 2
      @sprites[i].bitmap.gradient_fill_rect(rect, Color.new(120, 120, 120),
        Color.new(180, 180, 180))
      @sprites[i].bitmap.draw_text(5, 1, rect.width - 5, @bar_height - 2, 
        @commands[i])
      @sprites[i].x = 0
      @sprites[i].y = (@bar_height * i) + (@spacing * i) + @offset
      @sprites[i].z = 255
      @sprites[i].opacity = 0
      @sprites[i].slide(@sprites[i].x + @go_to, @sprites[i].y, @sprites[i].z, 10)
      @sprites[i].active = false
      i += 1
    end
    
    @active = false
    @height, @width = @sprites.last.y - @sprites[0].y, 144
    @opening = @closing = false
    @cursor_anim_frames = Frames_Anim
    @anim_index = 0
    self.index = index
    self.openness = 255
  end
  #--------------------------------------------------------------------------
  # * Set Cursor Image
  #     image_dir : the image of the cursor's directory.
  #     image_dir : the filename of the cursor's image.
  #--------------------------------------------------------------------------
  def cursor(image_dir, image_names)
    @cursor_image_dir = image_dir
    @cursor_image_names = image_names
    @cursor = Sprite.new
    @cursor.bitmap = Cache.load_bitmap(image_dir, image_names.first)
    @cursor.oy = (@cursor.bitmap.height >> 1)
    @cursor.visible = false
  end
  #--------------------------------------------------------------------------
  # * Update Cursor
  #--------------------------------------------------------------------------
  def update_cursor
    return if @cursor.nil?
    @cursor_anim_frames -= 1
    
    if @cursor_anim_frames == 0
      @cursor_anim_frames = Frames_Anim
      @anim_index += 1
      @anim_index = 0 if @anim_index == @cursor_image_names.size
      @cursor.bitmap = Cache.load_bitmap(@cursor_image_dir, 
        @cursor_image_names[@anim_index])
    end
    
    @cursor.opacity = @sprites[@index].opacity
    @cursor.x = @sprites[@index].bitmap.width + @sprites[@index].x
    @cursor.y = (@bar_height * @index) + (@spacing * @index) + @offset +
      (@bar_height >> 1)
    @cursor.z = @sprites[@index].z
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    if @opening
      self.openness = 255
      @opening = false
    elsif @closing
      self.openness = 0
      @closing = false
    end
    
    @sprites.each { |sprite| update_cursor; sprite.update }
    
    if @active
      if Input.trigger?(Input::UP)
        Sound.play_cursor
        self.index -= 1
      elsif Input.trigger?(Input::DOWN)
        Sound.play_cursor
        self.index += 1
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Set Active
  #     active : the active flag.
  #--------------------------------------------------------------------------
  def active=(active)
    @active = active
    @sprites.each { |sprite| sprite.active = active }
    @cursor.visible = active
  end
  #--------------------------------------------------------------------------
  # * Set Index
  #     index : the index.
  #--------------------------------------------------------------------------
  def index=(index)
    if @index != index
      @index = index
      @index = 0 if @index == @commands.size
      @index = @commands.size - 1 if @index < 0
      update_cursor
    end
  end
  #--------------------------------------------------------------------------
  # * Set X
  #     x : the x coordinate of the musashi command object.
  #--------------------------------------------------------------------------
  def x=(x)
    @x = x
    @sprites.each do |sprite|
      sprite.x = x
      sprite.slide(sprite.x + @go_to, sprite.y, sprite.z, 10)
    end
  end
  #--------------------------------------------------------------------------
  # * Set Y
  #     x : the y coordinate of the musashi command object.
  #--------------------------------------------------------------------------
  def y=(y)
    @y = y
    @sprites.each_index do |i|
      @sprites[i].y = (@bar_height * i) + (@spacing * i)
      @sprites[i].slide(@sprites[i].x + @go_to, @sprites[i].y, @sprites[i].z, 
        10)
    end
  end
  #--------------------------------------------------------------------------
  # * Set Z
  #     x : the z coordinate of the musashi command object.
  #--------------------------------------------------------------------------
  def z=(z)
    @z = z
    @sprites.each do |sprite|
      sprite.z = z
      sprite.slide(sprite.x + @go_to, sprite.y, sprite.z, 10)
    end
  end
  #--------------------------------------------------------------------------
  # * Set Openness 
  #     openness : the new openness of the window.
  #--------------------------------------------------------------------------
  def openness=(openness)
    @openness = [[openness, 255].min, 0].max
  end
  #--------------------------------------------------------------------------
  # * Get Moving
  #--------------------------------------------------------------------------
  def moving?
    return @sprites[0].sliding
  end
  #--------------------------------------------------------------------------
  # * Open Musashi Command
  #--------------------------------------------------------------------------
  def open
    @opening = true if self.openness < 255
    @closing = false
  end
  #--------------------------------------------------------------------------
  # * Close Musashi Command
  #--------------------------------------------------------------------------
  def close
    @closing = true if self.openness > 0
    @opening = false
  end
  #--------------------------------------------------------------------------
  # * Dispose
  #--------------------------------------------------------------------------
  def dispose
    @sprites.each do |sprite|
      sprite.bitmap.dispose
      sprite.dispose
    end
    
    unless @cursor.nil?
      @cursor.bitmap.dispose
      @cursor.dispose
    end
  end
end

#==============================================================================
# ** Window_MonoStatus
#------------------------------------------------------------------------------
#  This window displays the party leaders information only.
#==============================================================================

class Window_MonoStatus < Window_Base
  #--------------------------------------------------------------------------
  # * Constant Variables
  #--------------------------------------------------------------------------
  Window_Width = 180
  Window_Height = 250
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, Window_Width, Window_Height)
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    draw_actor_face($game_party.members[0], ((width - 32) >> 1) - (96 >> 1),
      0)
    draw_actor_name($game_party.members[0], 2, 98)
    draw_actor_class($game_party.members[0], 2, 98 + WLH)
    draw_actor_level($game_party.members[0], 90, 98 + WLH * 1)
    draw_actor_hp($game_party.members[0], 2, 98 + WLH * 2, width - 36)
    draw_actor_mp($game_party.members[0], 2, 98 + WLH * 3, width - 36)
    draw_currency_value($game_party.gold, 2, 98 + WLH * 4, width - 36)
  end
end

#==============================================================================
# ** Window_PartyStatus
#------------------------------------------------------------------------------
#  This window displays the party members' status.
#==============================================================================

class Window_PartyStatus < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor : the actor who's information you are trying to draw.
  #     x     : the x coordinate of the window you 
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, 96 * 3 + 32, 200)
    self.opacity = 0
    refresh
  end
  #--------------------------------------------------------------------------
  # * Draw Level
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #--------------------------------------------------------------------------
  def draw_actor_level(actor, x, y, width)
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, width, WLH, Vocab::level_a)
    self.contents.font.color = normal_color
    self.contents.draw_text(x, y, width, WLH, actor.level, 2)
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for i in 1...$game_party.members.size
      actor = $game_party.members[$game_party.members.size - i]
      
      self.contents.font.size = 12
      draw_actor_name(actor, ((i -1) * 96) + 2, 0)
      draw_actor_class(actor, ((i -1) * 96) + (96 >> 1), 0)
      draw_actor_face(actor, ((i -1) * 96), WLH - 2)
      draw_actor_level(actor, ((i -1) * 96) + 2, WLH + 88, 92)
      draw_actor_hp(actor, ((i -1) * 96) + 2, 96 + WLH + 4, 92)
      draw_actor_mp(actor, ((i -1) * 96) + 2, 96 + WLH + 19, 92)
    end
  end
end

#==============================================================================
# ** Game_Party
#------------------------------------------------------------------------------
#  This class handles the party. It includes information on amount of gold 
# and items. The instance of this class is referenced by $game_party.
#==============================================================================

class Game_Party < Game_Unit
  attr_accessor :actors
end

#==============================================================================
# ** Window_Order
#------------------------------------------------------------------------------
#  This window displays the party members' status.
#==============================================================================

class Window_Order < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     width      : window width
  #--------------------------------------------------------------------------
  def initialize(width)
    super(0, 0, width, $game_party.members.size * WLH + 32)
    self.active = false
    self.index = 0
    @column_max = 1
    @item_max = $game_party.members.size
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    $game_party.members.each_index do |i|
      draw_item(i)
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : the index of the item you want to redraw.
  #--------------------------------------------------------------------------
  def draw_item(item_index)
    y = item_index * WLH
    rect = Rect.new(0, y, width - 32, WLH)
    self.contents.clear_rect(rect)
    self.contents.draw_text(rect, $game_party.members[item_index].name, 1)
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    last_index = @index
    
    super

    if Input.trigger?(Input::C)
      Sound.play_decision
      @moving = !@moving
    end
    
    if @index != last_index
      if @moving
        moving_actor = $game_party.actors[last_index]
        swap_actor = $game_party.actors[@index]
        $game_party.actors[last_index] = swap_actor
        $game_party.actors[@index] = moving_actor
        self.refresh
      end
      #Sound.play_cursor
    end
  end
  #--------------------------------------------------------------------------
  # * Set Active
  #     active : the active flag.
  #--------------------------------------------------------------------------
  def active=(active)
    super(active)
    @moving = false
  end
end

#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
#  This class handles maps. It includes scrolling and passage determination
# functions. The instance of this class is referenced by $game_map.
#==============================================================================

class Game_Map
  attr_reader :map
end

#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
#  This class performs the menu screen processing.
#==============================================================================

class Scene_Menu < Scene_Base
  #--------------------------------------------------------------------------
  # * Constant Variables
  #--------------------------------------------------------------------------
  System_String = 'System'
  System_Strings = [
    'Bestiary',
    'Order',
    'Save',
    'Load',
    'Quit'
  ]
  Cursor_Dir = 'graphics/cursors/'
  Cursor_Imgs = [
    'cursor1',
    'cursor2',
  ]
  Reduce_Sound_To = 70
  #--------------------------------------------------------------------------
  # * Create Command Window                                        !OVERRIDE!
  #--------------------------------------------------------------------------
  def create_command_window
    @command_window = Musashi_Command.new([Vocab::item, Vocab::skill, 
      Vocab::equip, Vocab::status, System_String,Vocab::game_end], 
      @menu_index, 18)
    @command_window.cursor(Cursor_Dir, Cursor_Imgs)
    @command_window.active = true
    @command_system = Musashi_Command.new(System_Strings, 0, 18)
    @command_system.cursor(Cursor_Dir, Cursor_Imgs)
  end
  #--------------------------------------------------------------------------
  # * Start processing                                             !OVERRIDE!
  #--------------------------------------------------------------------------
  def start
    super
      
    create_menu_background
    create_command_window
    
    unless RPG::BGM.last.nil?
      @old_volume = RPG::BGM.last.volume
      RPG::BGM.last.volume = Reduce_Sound_To
      RPG::BGM.last.play
    end
    
    @actor_index = 0
    @cursor_timer = Musashi_Command::Frames_Anim
    @cursor_anim = 0
    
    @actor_cursor = Sprite.new
    @actor_cursor.bitmap = Cache.load_bitmap(Cursor_Dir, 
      Cursor_Imgs[@cursor_anim])
    @actor_cursor.visible = false
    @actor_cursor.z = 256
    
    @status = Window_MonoStatus.new
    @status.z = 256
    
    @party_status = Window_PartyStatus.new
    @party_status.x = 544 - @party_status.width + 16
    @party_status.y = 416 - @party_status.height + 16
    
    @command_order = Window_Order.new(Window_MonoStatus::Window_Width)
    @command_order.z = 888
    @command_order.y = @status.height
    @command_order.visible = @command_order.active = false
  end
  #--------------------------------------------------------------------------
  # * Termination Processing                                       !OVERRIDE!
  #--------------------------------------------------------------------------
  def terminate
    super
    dispose_menu_background
    @command_window.dispose
    @command_system.dispose
    @command_order.dispose
    @status.dispose
    @party_status.dispose
    @actor_cursor.bitmap.dispose
    @actor_cursor.dispose
    
    unless RPG::BGM.last.nil?
      RPG::BGM.last.volume = @old_volume
      RPG::BGM.last.play
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update                                                 !OVERRIDE!
  #--------------------------------------------------------------------------
  def update
    super
    update_menu_background
    @command_window.update
    @command_system.update
    if @command_window.active && !@command_window.moving?
      update_command_selection
    elsif @command_system.active && !@command_system.moving?
      update_system_selection
    elsif @command_order.active
      update_order_selection
    elsif !@command_window.active && !@command_system.active && 
        !@command_order.active
      update_actor_selection
    end
  end
  #--------------------------------------------------------------------------
  # * Start Actor Selection                                        !OVERRIDE!
  #--------------------------------------------------------------------------
  def start_actor_selection
    @actor_cursor.visible = true
    @command_window.active = false
    @cursor_timer = Musashi_Command::Frames_Anim >> 3
    @cursor_anim = 0
    @actor_index = 0
  end
  #--------------------------------------------------------------------------
  # * End Actor Selection                                          !OVERRIDE!
  #--------------------------------------------------------------------------
  def end_actor_selection
    @actor_cursor.visible = false
    @command_window.active = true
    @actor_index = 0
  end
  #--------------------------------------------------------------------------
  # * Update Actor Selection                                       !OVERRIDE!
  #--------------------------------------------------------------------------
  def update_actor_selection

    @cursor_timer -= 1
    if @cursor_timer == 0
      @cursor_timer = Musashi_Command::Frames_Anim >> 3
      @cursor_anim += 1
      @cursor_anim = 0 if @cursor_anim == Cursor_Imgs.size
      @actor_cursor.bitmap = Cache.load_bitmap(Cursor_Dir, 
        Cursor_Imgs[@cursor_anim])
    end
      
    if Input.trigger?(Input::LEFT)
      @actor_index -= 1
      @actor_index = $game_party.members.size - 1 if @actor_index < 0
    elsif Input.trigger?(Input::RIGHT)
      @actor_index += 1
      @actor_index = 0 if @actor_index == $game_party.members.size
    end
    
    case @actor_index
    when 0
      @actor_cursor.x = 108
      @actor_cursor.y = 10
    when 1
      @actor_cursor.x = 518
      @actor_cursor.y = 266
    when 2
      @actor_cursor.x = 422
      @actor_cursor.y = 266
    when 3
      @actor_cursor.x = 326
      @actor_cursor.y = 266
    end
    
    if Input.trigger?(Input::B)
      Sound.play_cancel
      end_actor_selection
    elsif Input.trigger?(Input::C)
      Sound.play_decision
      case @command_window.index
      when 1  # Skill
        $scene = Scene_Skill.new(@actor_index)
      when 2  # Equipment
        $scene = Scene_Equip.new(@actor_index)
      when 3  # Status
        $scene = Scene_Status.new(@actor_index)
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Update Command Selection                                     !OVERRIDE!
  #--------------------------------------------------------------------------
  def update_command_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      $scene = Scene_Map.new
    elsif Input.trigger?(Input::C)
      if $game_party.members.size == 0 and @command_window.index < 4
        Sound.play_buzzer
        return
      elsif $game_system.save_disabled and @command_window.index == 4
        Sound.play_buzzer
        return
      end
      Sound.play_decision
      case @command_window.index
      when 0        # Item
        $scene = Scene_Item.new
      when 1, 2, 3      # Skill, Equipment, Status
        start_actor_selection
      when 4      # Save
        @command_window.active = false
        @command_system.active = true
      when 5      # End Game
        $scene = Scene_End.new
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Update Order Selection
  #--------------------------------------------------------------------------
  def update_order_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      @command_order.active = @command_order.visible = false
      @command_system.active = true
      @status.refresh
      @party_status.refresh
    end
    @command_order.update
  end
  #--------------------------------------------------------------------------
  # * Update System Selection
  #--------------------------------------------------------------------------
  def update_system_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      @command_window.active = true
      @command_system.active = false
    elsif Input.trigger?(Input::C)
      case @command_system.index
      when 0      # Bestiary
        $scene = Scene_Bestiary.new
      when 1      # Order
        @command_system.active = false
        @command_order.visible = @command_order.active = true
      when 2      # Save
        $scene = Scene_File.new(true, false, false)
      when 3      # Load
        $scene = Scene_File.new(false, false, false)
      when 4      # Quit
        $scene = nil
      end
    end
  end
end
 
Three things: One, I should've made this clear, sorry, but I wanted the person who was leader to appear on the map. Like, for example, if person A was the leader, they would be the one walking around on the map. If you changed the leader to person B, then it would be person B on the map.

Also, an error. Whenever you have two or three people, the cursor is misplaced. Lemme give you a screenshot so you can see:

http://i56.photobucket.com/albums/g182/ ... /error.png[/img]
Selects "Marcus"

http://i56.photobucket.com/albums/g182/ ... error2.png[/img]
Selects the placeholder.

http://i56.photobucket.com/albums/g182/ ... error3.png[/img]
Selects the placeholder.

One more error. The volume in other scenes like Skills and Items still are at 100%, how do I lower them?
 

khmp

Sponsor

My apology I was only testing with a full party and didn't even think to check that. The scenes that off shoot from Scene_Menu reduce the sound as well. But there is sometimes a little burp with the audio. I truly have no idea how to resolve that.

Code:
#==============================================================================
# ** Math
#------------------------------------------------------------------------------
#  This module holds Math related nonsense which I am extending.
#==============================================================================

module Math
  class << self
    #------------------------------------------------------------------------
    # * Distance Between Two 2D points
    #     pt1 : first 2D point
    #     pt2 : second 2D point
    #------------------------------------------------------------------------
    def distance(pt1, pt2)
      return hypot(pt1[0] - pt2[0], pt1[1] - pt2[1])
    end
    #------------------------------------------------------------------------
    # * Alias Methods
    #------------------------------------------------------------------------
    alias dist distance
  end
end

#==============================================================================
# ** Math_Vector3
#------------------------------------------------------------------------------
#  This class only holds the information of a 3D Vector along with a few
#  helpful methods for using the class. (!No Cross Product!)
#==============================================================================

class Math_Vector3
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :x, :y, :z
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     x : the x component of the vector.
  #     y : the y component of the vector.
  #     z : the z component of the vector.
  #--------------------------------------------------------------------------
  def initialize(x = 0.0, y = 0.0, z = 0.0)
    @x, @y, @z = x.to_f, y.to_f, z.to_f
  end
  #--------------------------------------------------------------------------
  # * Magnitude
  #--------------------------------------------------------------------------
  def magnitude
    return Math.sqrt((@x * @x) + (@y * @y) + (@z * @z))
  end
  #--------------------------------------------------------------------------
  # * Multiply (Dot Product/Scalar)
  #     multiply : the polymorphized object being multiplied with self.
  #--------------------------------------------------------------------------
  def *(multiply)
    return scale(multiply) if multiply.is_a?(Numeric)
    return dot(multiply) if multiply.is_a?(Math_Vector3)
  end
  #--------------------------------------------------------------------------
  # * Addition
  #     add : the vector being added to self.
  #--------------------------------------------------------------------------
  def +(add)
    return Math_Vector3.new(@x + add.x, @y + add.y, @z + add.z)
  end
  #--------------------------------------------------------------------------
  # * Subtraction
  #     add : the vector being taken away from self.
  #--------------------------------------------------------------------------
  def -(sub)
    return Math_Vector3.new(@x - sub.x, @y - sub.y, @z - sub.z)
  end
  #--------------------------------------------------------------------------
  # * Scale
  #     scalar : the multiplier applied to the vector.
  #--------------------------------------------------------------------------
  def scale(scalar)
    return Math_Vector3.new(@x * scalar, @y * scalar, @z * scalar)
  end
  #--------------------------------------------------------------------------
  # * Dot Product
  #     vec : the vector you are dotting with.
  #--------------------------------------------------------------------------
  def dot(vec)
    return ((@x * vec.x) + (@y * vec.y) + (@z * vec.z))
  end
  #--------------------------------------------------------------------------
  # * Returns Normalized Math_Vector3
  #--------------------------------------------------------------------------
  def normalize
    mag = magnitude
    return Math_Vector3.new(@x / mag, @y / mag, @z / mag)
  end
  #--------------------------------------------------------------------------
  # * Normalizes Calling Math_Vector3
  #--------------------------------------------------------------------------
  def normalize!
    mag = magnitude
    @x /= mag
    @y /= mag
    @z /= mag
  end
  #--------------------------------------------------------------------------
  # * Returns Array of Math_Vector3
  #--------------------------------------------------------------------------
  def to_a
    return [@x, @y, @z]
  end
  #--------------------------------------------------------------------------
  # * Get Component
  #     index : the index of the component you want.
  #--------------------------------------------------------------------------
  def [](index)
    case index
    when 0
      return @x
    when 1
      return @y
    when 2
      return @z
    end
  end
  #--------------------------------------------------------------------------
  # * Set Component
  #     index : the index of the component you want to change.
  #     value : the new value of the component.
  #--------------------------------------------------------------------------
  def []=(index, value)
    case index
    when 0
      @x = value.to_f
    when 1
      @y = value.to_f
    when 2
      @z = value.to_f
    end
  end
  #--------------------------------------------------------------------------
  # * Compare
  #     vec : the vec you are comparing against.
  #--------------------------------------------------------------------------
  def ==(vec)
    return false unless vec.is_a?(Math_Vector3)
    return true if (vec.x == self.x && vec.y == self.y && vec.z == self.z)
    return false
  end
  #--------------------------------------------------------------------------
  # * Alias Methods
  #--------------------------------------------------------------------------
  alias_method :length, :magnitude
end

#==============================================================================
# ** Sprite_Float
#------------------------------------------------------------------------------
#  A sprite class with Float based location and movement.
#==============================================================================

class Sprite_Float < Sprite
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :slide
  attr_reader   :active, 
                :sliding
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(viewport = nil)
    super(viewport)
    @fx = @fy = @fz = 0.0
    @fopacity = 255.0
    @slide = false
    @sliding = false
    @active = true
  end
  #--------------------------------------------------------------------------
  # * Slide
  #     x       : the x coordinate to go to.
  #     y       : the y coordinate to go to.
  #     frames  : the number of frames to get to the destination.
  #     opacity : the ending opacity when it reaches its destination.
  #--------------------------------------------------------------------------
  def slide(x, y, z, frames, opacity = 255)
    @slide = true
    @vec = Math_Vector3.new(@to_x = x.to_f, @to_y = y.to_f, @to_z = z.to_f) - 
      Math_Vector3.new(@or_x = self.x, @or_y = self.y, @or_z = self.z)
    @vec = @vec.scale(1 / frames.to_f)
    @delta_opacity = (opacity - self.opacity) / frames.to_f
    @sliding = true
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super()
    # If the user has called slide once. We will do more work.
    if @slide
      # If the sprite is active meaning if it isn't at the destination
      # keep moving it.
      if @active && @sliding
        unless Math.dist([self.x, self.y], [@to_x, @to_y]) > 1.0
          @sliding = false
          return
        end
        
        @sliding = true
        self.x += @vec.x
        self.y += @vec.y
        self.z += @vec.z
        self.opacity += @delta_opacity
      elsif !@active && @sliding
        unless Math.dist([self.x, self.y], [@or_x, @or_y]) > 1.0
          @sliding = false
          return
        end
        
        @sliding = true
        self.x -= @vec.x
        self.y -= @vec.y
        self.z -= @vec.z
        self.opacity -= @delta_opacity
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Set X
  #     x : the new x coordinate
  #--------------------------------------------------------------------------
  def x=(x)
    super(@fx = x.to_f)
  end
  #--------------------------------------------------------------------------
  # * Set Y
  #     y : the new y coordinate
  #--------------------------------------------------------------------------
  def y=(y)
    super(@fy = y.to_f)
  end
  #--------------------------------------------------------------------------
  # * Set Z
  #     z : the new z coordinate
  #--------------------------------------------------------------------------
  def z=(z)
    super(@fz = z.to_f)
  end
  #--------------------------------------------------------------------------
  # * Get X
  #--------------------------------------------------------------------------
  def x
    return @fx
  end
  #--------------------------------------------------------------------------
  # * Get Y
  #--------------------------------------------------------------------------
  def y
    return @fy
  end
  #--------------------------------------------------------------------------
  # * Get Z
  #--------------------------------------------------------------------------
  def z
    return @fz
  end
  #--------------------------------------------------------------------------
  # * Set Active
  #     active : the active flag.
  #--------------------------------------------------------------------------
  def active=(active)
    @active = active
    @sliding = true
  end
  #--------------------------------------------------------------------------
  # * Set (X/Y) Zoom
  #--------------------------------------------------------------------------
  def zoom=(zoom)
    self.zoom_x = self.zoom_y = zoom
  end
end

#==============================================================================
# ** Musashi_Command
#------------------------------------------------------------------------------
#  Simple command menu with rectangular options displayed in reverse step 
#  manner.
#==============================================================================

class Musashi_Command
  #--------------------------------------------------------------------------
  # * Constant Variables
  #--------------------------------------------------------------------------
  Frames_Anim = 400
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader :opening, :closing, :index, :x, :y, :z, :width, :height, :active
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     commands : the commands you want to see.
  #     index    : the index of the option you want to look at.
  #     spacing  : the spacing between each command.
  #--------------------------------------------------------------------------
  def initialize(commands, index = 0, spacing = 5)
    @commands = commands
    @spacing = spacing
    
    @bar_width = 144
    @bar_height = Window_Base::WLH
    @go_to = Window_MonoStatus::Window_Width - 2
    @offset = 10
    
    @sprites = []
    @commands.each_index do |i|
      @sprites << Sprite_Float.new
      @sprites[i].bitmap = Bitmap.new(@bar_width - (i * 8), @bar_height)
      rect = @sprites[i].bitmap.rect
      @sprites[i].bitmap.fill_rect(rect, Color.new(0, 0, 0))
      rect.x = rect.y = 1
      rect.width -= 2
      rect.height -= 2
      @sprites[i].bitmap.gradient_fill_rect(rect, Color.new(120, 120, 120),
        Color.new(180, 180, 180))
      @sprites[i].bitmap.draw_text(5, 1, rect.width - 5, @bar_height - 2, 
        @commands[i])
      @sprites[i].x = 0
      @sprites[i].y = (@bar_height * i) + (@spacing * i) + @offset
      @sprites[i].z = 255
      @sprites[i].opacity = 0
      @sprites[i].slide(@sprites[i].x + @go_to, @sprites[i].y, @sprites[i].z, 10)
      @sprites[i].active = false
      i += 1
    end
    
    @active = false
    @height, @width = @sprites.last.y - @sprites[0].y, 144
    @opening = @closing = false
    @cursor_anim_frames = Frames_Anim
    @anim_index = 0
    self.index = index
    self.openness = 255
  end
  #--------------------------------------------------------------------------
  # * Set Cursor Image
  #     image_dir : the image of the cursor's directory.
  #     image_dir : the filename of the cursor's image.
  #--------------------------------------------------------------------------
  def cursor(image_dir, image_names)
    @cursor_image_dir = image_dir
    @cursor_image_names = image_names
    @cursor = Sprite.new
    @cursor.bitmap = Cache.load_bitmap(image_dir, image_names.first)
    @cursor.oy = (@cursor.bitmap.height >> 1)
    @cursor.visible = false
  end
  #--------------------------------------------------------------------------
  # * Update Cursor
  #--------------------------------------------------------------------------
  def update_cursor
    return if @cursor.nil?
    @cursor_anim_frames -= 1
    
    if @cursor_anim_frames == 0
      @cursor_anim_frames = Frames_Anim
      @anim_index += 1
      @anim_index = 0 if @anim_index == @cursor_image_names.size
      @cursor.bitmap = Cache.load_bitmap(@cursor_image_dir, 
        @cursor_image_names[@anim_index])
    end
    
    @cursor.opacity = @sprites[@index].opacity
    @cursor.x = @sprites[@index].bitmap.width + @sprites[@index].x
    @cursor.y = (@bar_height * @index) + (@spacing * @index) + @offset +
      (@bar_height >> 1)
    @cursor.z = @sprites[@index].z
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    if @opening
      self.openness = 255
      @opening = false
    elsif @closing
      self.openness = 0
      @closing = false
    end
    
    @sprites.each { |sprite| update_cursor; sprite.update }
    
    if @active
      if Input.trigger?(Input::UP)
        Sound.play_cursor
        self.index -= 1
      elsif Input.trigger?(Input::DOWN)
        Sound.play_cursor
        self.index += 1
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Set Active
  #     active : the active flag.
  #--------------------------------------------------------------------------
  def active=(active)
    @active = active
    @sprites.each { |sprite| sprite.active = active }
    @cursor.visible = active
  end
  #--------------------------------------------------------------------------
  # * Set Index
  #     index : the index.
  #--------------------------------------------------------------------------
  def index=(index)
    if @index != index
      @index = index
      @index = 0 if @index == @commands.size
      @index = @commands.size - 1 if @index < 0
      update_cursor
    end
  end
  #--------------------------------------------------------------------------
  # * Set X
  #     x : the x coordinate of the musashi command object.
  #--------------------------------------------------------------------------
  def x=(x)
    @x = x
    @sprites.each do |sprite|
      sprite.x = x
      sprite.slide(sprite.x + @go_to, sprite.y, sprite.z, 10)
    end
  end
  #--------------------------------------------------------------------------
  # * Set Y
  #     x : the y coordinate of the musashi command object.
  #--------------------------------------------------------------------------
  def y=(y)
    @y = y
    @sprites.each_index do |i|
      @sprites[i].y = (@bar_height * i) + (@spacing * i)
      @sprites[i].slide(@sprites[i].x + @go_to, @sprites[i].y, @sprites[i].z, 
        10)
    end
  end
  #--------------------------------------------------------------------------
  # * Set Z
  #     x : the z coordinate of the musashi command object.
  #--------------------------------------------------------------------------
  def z=(z)
    @z = z
    @sprites.each do |sprite|
      sprite.z = z
      sprite.slide(sprite.x + @go_to, sprite.y, sprite.z, 10)
    end
  end
  #--------------------------------------------------------------------------
  # * Set Openness 
  #     openness : the new openness of the window.
  #--------------------------------------------------------------------------
  def openness=(openness)
    @openness = [[openness, 255].min, 0].max
  end
  #--------------------------------------------------------------------------
  # * Get Moving
  #--------------------------------------------------------------------------
  def moving?
    return @sprites[0].sliding
  end
  #--------------------------------------------------------------------------
  # * Open Musashi Command
  #--------------------------------------------------------------------------
  def open
    @opening = true if self.openness < 255
    @closing = false
  end
  #--------------------------------------------------------------------------
  # * Close Musashi Command
  #--------------------------------------------------------------------------
  def close
    @closing = true if self.openness > 0
    @opening = false
  end
  #--------------------------------------------------------------------------
  # * Dispose
  #--------------------------------------------------------------------------
  def dispose
    @sprites.each do |sprite|
      sprite.bitmap.dispose
      sprite.dispose
    end
    
    unless @cursor.nil?
      @cursor.bitmap.dispose
      @cursor.dispose
    end
  end
end

#==============================================================================
# ** Window_MonoStatus
#------------------------------------------------------------------------------
#  This window displays the party leaders information only.
#==============================================================================

class Window_MonoStatus < Window_Base
  #--------------------------------------------------------------------------
  # * Constant Variables
  #--------------------------------------------------------------------------
  Window_Width = 180
  Window_Height = 250
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, Window_Width, Window_Height)
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    draw_actor_face($game_party.members[0], ((width - 32) >> 1) - (96 >> 1),
      0)
    draw_actor_name($game_party.members[0], 2, 98)
    draw_actor_class($game_party.members[0], 2, 98 + WLH)
    draw_actor_level($game_party.members[0], 90, 98 + WLH * 1)
    draw_actor_hp($game_party.members[0], 2, 98 + WLH * 2, width - 36)
    draw_actor_mp($game_party.members[0], 2, 98 + WLH * 3, width - 36)
    draw_currency_value($game_party.gold, 2, 98 + WLH * 4, width - 36)
  end
end

#==============================================================================
# ** Window_PartyStatus
#------------------------------------------------------------------------------
#  This window displays the party members' status.
#==============================================================================

class Window_PartyStatus < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor : the actor who's information you are trying to draw.
  #     x     : the x coordinate of the window you 
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, 96 * 3 + 32, 200)
    self.opacity = 0
    refresh
  end
  #--------------------------------------------------------------------------
  # * Draw Level
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #--------------------------------------------------------------------------
  def draw_actor_level(actor, x, y, width)
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, width, WLH, Vocab::level_a)
    self.contents.font.color = normal_color
    self.contents.draw_text(x, y, width, WLH, actor.level, 2)
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    starting_x = [192, 96, 0]
    for i in 1...$game_party.members.size
      actor = $game_party.members[i]
      next if actor.nil?
      
      self.contents.font.size = 12
      draw_actor_name(actor, starting_x[i - 1] + 2, 0)
      draw_actor_class(actor, starting_x[i - 1] + (96 >> 1), 0)
      draw_actor_face(actor, starting_x[i - 1], WLH - 2)
      draw_actor_level(actor, starting_x[i - 1] + 2, WLH + 88, 92)
      draw_actor_hp(actor, starting_x[i - 1] + 2, 96 + WLH + 4, 92)
      draw_actor_mp(actor, starting_x[i - 1] + 2, 96 + WLH + 19, 92)
    end
  end
end

#==============================================================================
# ** Game_Party
#------------------------------------------------------------------------------
#  This class handles the party. It includes information on amount of gold 
# and items. The instance of this class is referenced by $game_party.
#==============================================================================

class Game_Party < Game_Unit
  attr_accessor :actors
end

#==============================================================================
# ** Window_Order
#------------------------------------------------------------------------------
#  This window displays the party members' status.
#==============================================================================

class Window_Order < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     width      : window width
  #--------------------------------------------------------------------------
  def initialize(width)
    super(0, 0, width, $game_party.members.size * WLH + 32)
    self.active = false
    self.index = 0
    @column_max = 1
    @item_max = $game_party.members.size
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    $game_party.members.each_index do |i|
      draw_item(i)
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : the index of the item you want to redraw.
  #--------------------------------------------------------------------------
  def draw_item(item_index)
    y = item_index * WLH
    rect = Rect.new(0, y, width - 32, WLH)
    self.contents.clear_rect(rect)
    self.contents.draw_text(rect, $game_party.members[item_index].name, 1)
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    last_index = @index
    
    super

    if Input.trigger?(Input::C)
      Sound.play_decision
      @moving = !@moving
    end
    
    if @index != last_index
      if @moving
        moving_actor = $game_party.actors[last_index]
        swap_actor = $game_party.actors[@index]
        $game_party.actors[last_index] = swap_actor
        $game_party.actors[@index] = moving_actor
        self.refresh
      end
      #Sound.play_cursor
    end
  end
  #--------------------------------------------------------------------------
  # * Set Active
  #     active : the active flag.
  #--------------------------------------------------------------------------
  def active=(active)
    super(active)
    @moving = false
  end
end

#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
#  This class handles maps. It includes scrolling and passage determination
# functions. The instance of this class is referenced by $game_map.
#==============================================================================

class Game_Map
  attr_reader :map
end

#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
#  This class performs the menu screen processing.
#==============================================================================

class Scene_Menu < Scene_Base
  #--------------------------------------------------------------------------
  # * Constant Variables
  #--------------------------------------------------------------------------
  System_String = 'System'
  System_Strings = [
    'Bestiary',
    'Order',
    'Save',
    'Load',
    'Quit'
  ]
  Cursor_Dir = 'graphics/cursors/'
  Cursor_Imgs = [
    'cursor1',
    'cursor2',
  ]
  Reduce_Sound_To = 70
  #--------------------------------------------------------------------------
  # * Create Command Window                                        !OVERRIDE!
  #--------------------------------------------------------------------------
  def create_command_window
    @command_window = Musashi_Command.new([Vocab::item, Vocab::skill, 
      Vocab::equip, Vocab::status, System_String,Vocab::game_end], 
      @menu_index, 18)
    @command_window.cursor(Cursor_Dir, Cursor_Imgs)
    @command_window.active = true
    @command_system = Musashi_Command.new(System_Strings, 0, 18)
    @command_system.cursor(Cursor_Dir, Cursor_Imgs)
  end
  #--------------------------------------------------------------------------
  # * Start processing                                             !OVERRIDE!
  #--------------------------------------------------------------------------
  def start
    super
      
    create_menu_background
    create_command_window
    
    unless RPG::BGM.last.nil?
      @old_volume = RPG::BGM.last.volume
      RPG::BGM.last.volume = Reduce_Sound_To
      RPG::BGM.last.play
    end
    
    @actor_index = 0
    @cursor_timer = Musashi_Command::Frames_Anim
    @cursor_anim = 0
    
    @actor_cursor = Sprite.new
    @actor_cursor.bitmap = Cache.load_bitmap(Cursor_Dir, 
      Cursor_Imgs[@cursor_anim])
    @actor_cursor.visible = false
    @actor_cursor.z = 256
    
    @status = Window_MonoStatus.new
    @status.z = 256
    
    @party_status = Window_PartyStatus.new
    @party_status.x = 544 - @party_status.width + 16
    @party_status.y = 416 - @party_status.height + 16
    
    @command_order = Window_Order.new(Window_MonoStatus::Window_Width)
    @command_order.z = 888
    @command_order.y = @status.height
    @command_order.visible = @command_order.active = false
  end
  #--------------------------------------------------------------------------
  # * Termination Processing                                       !OVERRIDE!
  #--------------------------------------------------------------------------
  def terminate
    super
    dispose_menu_background
    @command_window.dispose
    @command_system.dispose
    @command_order.dispose
    @status.dispose
    @party_status.dispose
    @actor_cursor.bitmap.dispose
    @actor_cursor.dispose
    
    unless RPG::BGM.last.nil?
      RPG::BGM.last.volume = @old_volume
      RPG::BGM.last.play
    end
    
    $game_player.set_graphic($game_party.members[0].character_name,
      $game_party.members[0].character_index)
  end
  #--------------------------------------------------------------------------
  # * Frame Update                                                 !OVERRIDE!
  #--------------------------------------------------------------------------
  def update
    super
    update_menu_background
    @command_window.update
    @command_system.update
    if @command_window.active && !@command_window.moving?
      update_command_selection
    elsif @command_system.active && !@command_system.moving?
      update_system_selection
    elsif @command_order.active
      update_order_selection
    elsif !@command_window.active && !@command_system.active && 
        !@command_order.active
      update_actor_selection
    end
  end
  #--------------------------------------------------------------------------
  # * Start Actor Selection                                        !OVERRIDE!
  #--------------------------------------------------------------------------
  def start_actor_selection
    @actor_cursor.visible = true
    @command_window.active = false
    @cursor_timer = Musashi_Command::Frames_Anim >> 3
    @cursor_anim = 0
    @actor_index = 0
  end
  #--------------------------------------------------------------------------
  # * End Actor Selection                                          !OVERRIDE!
  #--------------------------------------------------------------------------
  def end_actor_selection
    @actor_cursor.visible = false
    @command_window.active = true
    @actor_index = 0
  end
  #--------------------------------------------------------------------------
  # * Update Actor Selection                                       !OVERRIDE!
  #--------------------------------------------------------------------------
  def update_actor_selection

    @cursor_timer -= 1
    if @cursor_timer == 0
      @cursor_timer = Musashi_Command::Frames_Anim >> 3
      @cursor_anim += 1
      @cursor_anim = 0 if @cursor_anim == Cursor_Imgs.size
      @actor_cursor.bitmap = Cache.load_bitmap(Cursor_Dir, 
        Cursor_Imgs[@cursor_anim])
    end
      
    if Input.trigger?(Input::LEFT)
      @actor_index -= 1
      @actor_index = $game_party.members.size - 1 if @actor_index < 0
    elsif Input.trigger?(Input::RIGHT)
      @actor_index += 1
      @actor_index = 0 if @actor_index == $game_party.members.size
    end
    
    case @actor_index
    when 0
      @actor_cursor.x = 108
      @actor_cursor.y = 10
    when 1
      @actor_cursor.x = 518
      @actor_cursor.y = 266
    when 2
      @actor_cursor.x = 422
      @actor_cursor.y = 266
    when 3
      @actor_cursor.x = 326
      @actor_cursor.y = 266
    end
    
    if Input.trigger?(Input::B)
      Sound.play_cancel
      end_actor_selection
    elsif Input.trigger?(Input::C)
      Sound.play_decision
      case @command_window.index
      when 1  # Skill
        $scene = Scene_Skill.new(@actor_index)
      when 2  # Equipment
        $scene = Scene_Equip.new(@actor_index)
      when 3  # Status
        $scene = Scene_Status.new(@actor_index)
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Update Command Selection                                     !OVERRIDE!
  #--------------------------------------------------------------------------
  def update_command_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      $scene = Scene_Map.new
    elsif Input.trigger?(Input::C)
      if $game_party.members.size == 0 and @command_window.index < 4
        Sound.play_buzzer
        return
      elsif $game_system.save_disabled and @command_window.index == 4
        Sound.play_buzzer
        return
      end
      Sound.play_decision
      case @command_window.index
      when 0        # Item
        $scene = Scene_Item.new
      when 1, 2, 3      # Skill, Equipment, Status
        start_actor_selection
      when 4      # Save
        @command_window.active = false
        @command_system.active = true
      when 5      # End Game
        $scene = Scene_End.new
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Update Order Selection
  #--------------------------------------------------------------------------
  def update_order_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      @command_order.active = @command_order.visible = false
      @command_system.active = true
      @status.refresh
      @party_status.refresh
    end
    @command_order.update
  end
  #--------------------------------------------------------------------------
  # * Update System Selection
  #--------------------------------------------------------------------------
  def update_system_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      @command_window.active = true
      @command_system.active = false
    elsif Input.trigger?(Input::C)
      case @command_system.index
      when 0      # Bestiary
        $scene = Scene_Bestiary.new
      when 1      # Order
        @command_system.active = false
        @command_order.visible = @command_order.active = true
      when 2      # Save
        $scene = Scene_File.new(true, false, false)
      when 3      # Load
        $scene = Scene_File.new(false, false, false)
      when 4      # Quit
        $scene = nil
      end
    end
  end
end

class Scene_Skill < Scene_Base
  #--------------------------------------------------------------------------
  # * Alias Methods
  #--------------------------------------------------------------------------
  alias mush_cms_sceneskill_start start
  alias mush_cms_sceneskill_terminate terminate
  #--------------------------------------------------------------------------
  # * Start processing                                                !ALIAS!
  #--------------------------------------------------------------------------
  def start
    unless RPG::BGM.last.nil?
      @old_volume = RPG::BGM.last.volume
      RPG::BGM.last.volume = Scene_Menu::Reduce_Sound_To
      RPG::BGM.last.play
    end
    mush_cms_sceneskill_start
  end
  #--------------------------------------------------------------------------
  # * Termination Processing                                          !ALIAS!
  #--------------------------------------------------------------------------
  def terminate
    mush_cms_sceneskill_terminate
    unless RPG::BGM.last.nil?
      RPG::BGM.last.volume = @old_volume
      RPG::BGM.last.play
    end
  end
end

class Scene_Item < Scene_Base
  #--------------------------------------------------------------------------
  # * Alias Methods
  #--------------------------------------------------------------------------
  alias mush_cms_sceneskill_start start
  alias mush_cms_sceneskill_terminate terminate
  #--------------------------------------------------------------------------
  # * Start processing                                                !ALIAS!
  #--------------------------------------------------------------------------
  def start
    unless RPG::BGM.last.nil?
      @old_volume = RPG::BGM.last.volume
      RPG::BGM.last.volume = Scene_Menu::Reduce_Sound_To
      RPG::BGM.last.play
    end
    mush_cms_sceneskill_start
  end
  #--------------------------------------------------------------------------
  # * Termination Processing                                          !ALIAS!
  #--------------------------------------------------------------------------
  def terminate
    mush_cms_sceneskill_terminate
    unless RPG::BGM.last.nil?
      RPG::BGM.last.volume = @old_volume
      RPG::BGM.last.play
    end
  end
end

class Scene_Status < Scene_Base
  #--------------------------------------------------------------------------
  # * Alias Methods
  #--------------------------------------------------------------------------
  alias mush_cms_scenestatus_start start
  alias mush_cms_scenestatus_terminate terminate
  #--------------------------------------------------------------------------
  # * Start processing                                                !ALIAS!
  #--------------------------------------------------------------------------
  def start
    unless RPG::BGM.last.nil?
      @old_volume = RPG::BGM.last.volume
      RPG::BGM.last.volume = Scene_Menu::Reduce_Sound_To
      RPG::BGM.last.play
    end
    mush_cms_scenestatus_start
  end
  #--------------------------------------------------------------------------
  # * Termination Processing                                          !ALIAS!
  #--------------------------------------------------------------------------
  def terminate
    mush_cms_scenestatus_terminate
    unless RPG::BGM.last.nil?
      RPG::BGM.last.volume = @old_volume
      RPG::BGM.last.play
    end
  end
end

class Scene_Equip < Scene_Base
  #--------------------------------------------------------------------------
  # * Alias Methods
  #--------------------------------------------------------------------------
  alias mush_cms_scenequip_start start
  alias mush_cms_scenequip_terminate terminate
  #--------------------------------------------------------------------------
  # * Start processing                                                !ALIAS!
  #--------------------------------------------------------------------------
  def start
    unless RPG::BGM.last.nil?
      @old_volume = RPG::BGM.last.volume
      RPG::BGM.last.volume = Scene_Menu::Reduce_Sound_To
      RPG::BGM.last.play
    end
    mush_cms_scenequip_start
  end
  #--------------------------------------------------------------------------
  # * Termination Processing                                          !ALIAS!
  #--------------------------------------------------------------------------
  def terminate
    mush_cms_scenequip_terminate
    unless RPG::BGM.last.nil?
      RPG::BGM.last.volume = @old_volume
      RPG::BGM.last.play
    end
  end
end

class Scene_File < Scene_Base
  #--------------------------------------------------------------------------
  # * Alias Methods
  #--------------------------------------------------------------------------
  alias mush_cms_scenefile_start start
  alias mush_cms_scenefile_terminate terminate
  #--------------------------------------------------------------------------
  # * Start processing                                                !ALIAS!
  #--------------------------------------------------------------------------
  def start
    mush_cms_scenefile_start
    unless @from_title
      unless RPG::BGM.last.nil?
        @old_volume = RPG::BGM.last.volume
        RPG::BGM.last.volume = Scene_Menu::Reduce_Sound_To
        RPG::BGM.last.play
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Termination Processing                                          !ALIAS!
  #--------------------------------------------------------------------------
  def terminate
    mush_cms_scenefile_terminate
    unless @from_title
      unless RPG::BGM.last.nil?
        RPG::BGM.last.volume = @old_volume
        RPG::BGM.last.play
      end
    end
  end
end
 

khmp

Sponsor

Code:
if $game_party.members[0] == actor
  # do something.
end

You might be more comfortable with a name comparison:
Code:
if $game_party.members[0].name == 'Something'
  # do something.
end

Hope that helps.
 

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