Improved Peripheral Menus

6 de fevereiro de 2013

Improved Peripheral Menus é um script desenvolvido por mewsterus que, ao ser adicionado em algum game ou projeto do RPG Maker XP, ele implementa um menu periférico alternativo ao padrão deste maker.

Ele pode ser customizado (linhas  79-84) e é de fácil instalação, precisando apenas copiar e colar o script abaixo, logo acima do Main:

# * Improved Peripheral Menus (IPM) by mewsterus
# * To install, just insert this in a descriptive code slot right above Main
# *
# * Place this above any CBS scripts!
# * Diego's resistance wheel script is customizable with lines 79-84
#===============================================================================
# ¦ Bitmap
#-------------------------------------------------------------------------------
#   Edited by Diego
#===============================================================================

class Bitmap
end
  # @ Draw line
  #-----------------------------------------------------------------------------
  def draw_line(start_x, start_y, end_x, end_y, start_color, width = 1,
                end_color = start_color)
    distance = (start_x - end_x).abs + (start_y - end_y).abs
    if end_color == start_color
      for i in 1..distance
        x = (start_x + 1.0 * (end_x - start_x) * i / distance).to_i
        y = (start_y + 1.0 * (end_y - start_y) * i / distance).to_i
        if width == 1
          self.set_pixel(x, y, start_color)
        else
          self.fill_rect(x, y, width, width, start_color)
        end
      end
    else
      for i in 1..distance
        x = (start_x + 1.0 * (end_x - start_x) * i / distance).to_i
        y = (start_y + 1.0 * (end_y - start_y) * i / distance).to_i
        r = start_color.red   * (distance - i) / distance + end_color.red   *
            i / distance
        g = start_color.green * (distance - i) / distance + end_color.green *
            i / distance
        b = start_color.blue  * (distance - i) / distance + end_color.blue  *
            i / distance
        a = start_color.alpha * (distance - i) / distance + end_color.alpha *
            i / distance
        if width == 1
          self.set_pixel(x, y, Color.new(r, g, b, a))
        else
          self.fill_rect(x, y, width, width, Color.new(r, g, b, a))
        end
      end
    end
  end

#===============================================================================
# ¦ Window_Base
#-------------------------------------------------------------------------------
#   Edited by mewsterus; resistance wheel by Diego
#===============================================================================

class Window_Base
  #-----------------------------------------------------------------------------
  # @ Draw state
  #-----------------------------------------------------------------------------
  def draw_actor_state(actor, x, y, width = 120)
    text = make_battler_state_text(actor, width, true)
    self.contents.font.color = actor.hp == 0 ? knockout_color : normal_color
    self.contents.draw_text(x, y, width, 32, text, 2)
  end
  #-----------------------------------------------------------------------------
  # @ Draw battler graphic
  #-----------------------------------------------------------------------------
  def draw_actor_battler(actor, x, y)
    if $game_party.actors.size != 0
      bitmap = RPG::Cache.battler(actor.battler_name, actor.battler_hue)
      src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
      self.contents.blt(x-(bitmap.width/2), y-bitmap.height, bitmap, src_rect)
    end
  end
  #-----------------------------------------------------------------------------
  # @ Draw EXP
  #-----------------------------------------------------------------------------
  def draw_actor_exp(actor, x, y, width = 144)
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 48, 32, "Exp")
    self.contents.font.color = normal_color
    self.contents.draw_text(x + width - 48, y, 48, 32, actor.exp_s, 2)
  end
  #-----------------------------------------------------------------------------
  # @ Draw resistance wheel
  #-----------------------------------------------------------------------------
  ELEMENT_ORDER = [1, 2, 3, 4, 5, 6, 7, 8]
  GRAPH_SCALINE_COLOR        = Color.new(255, 255, 255, 128)
  GRAPH_SCALINE_COLOR_SHADOW = Color.new(  0,   0,   0, 192)
  GRAPH_LINE_COLOR           = Color.new(255, 255,  64, 255)
  GRAPH_LINE_COLOR_MINUS     = Color.new( 64, 255, 255, 255)
  GRAPH_LINE_COLOR_PLUS      = Color.new(255,  64,  64, 255)
  def draw_actor_element_radar_graph(actor, x, y, radius = 43)
    cx = x + radius + 64
    cy = y + radius + 48
    for loop_i in 0..ELEMENT_ORDER.size
      unless loop_i == 0
        @pre_x  = @now_x
        @pre_y  = @now_y
        @pre_ex = @now_ex
        @pre_ey = @now_ey
        @color1 = @color2
      end
      if loop_i == ELEMENT_ORDER.size
        eo = ELEMENT_ORDER[0]
      else
        eo = ELEMENT_ORDER[loop_i]
      end
      er = actor.element_rate(eo)
      estr = $data_system.elements[eo]
      @color2 = er < 0 ? GRAPH_LINE_COLOR_MINUS : er > 100 ?
                GRAPH_LINE_COLOR_PLUS : GRAPH_LINE_COLOR
      er = er.abs
      th = Math::PI * (0.5 - 2.0 * loop_i / ELEMENT_ORDER.size)
      @now_x  = cx + (radius * Math.cos(th)).floor
      @now_y  = cy - (radius * Math.sin(th)).floor
      @now_wx = cx-6+((radius + 24) * Math.cos(th)).floor - 16
      @now_wy = cy - ((radius + 8)  * Math.sin(th)).floor - 8
      @now_vx = cx + ((radius + 64) * Math.cos(th)).floor - 16
      @now_vy = cy - ((radius + 24) * Math.sin(th)).floor - 8
      @now_ex = cx + (er*radius/100 * Math.cos(th)).floor
      @now_ey = cy - (er*radius/100 * Math.sin(th)).floor
      if loop_i == 0
        @pre_x  = @now_x
        @pre_y  = @now_y
        @pre_ex = @now_ex
        @pre_ey = @now_ey
        @color1 = @color2
      end
      next if loop_i == 0
      self.contents.draw_line(cx + 1, cy + 1, @now_x + 1, @now_y + 1,
                              GRAPH_SCALINE_COLOR_SHADOW)
      self.contents.draw_line(@pre_x + 1, @pre_y + 1, @now_x + 1, @now_y + 1,
                              GRAPH_SCALINE_COLOR_SHADOW)
      self.contents.draw_line(cx,cy, @now_x,@now_y, GRAPH_SCALINE_COLOR)
      self.contents.draw_line(@pre_x,@pre_y, @now_x,@now_y, GRAPH_SCALINE_COLOR)
      self.contents.draw_line(@pre_ex,@pre_ey,@now_ex,@now_ey,@color1,2,@color2)
      self.contents.font.color = system_color
      self.contents.draw_text(@now_wx, @now_wy, 48, 16, estr, 1)
      self.contents.font.color = Color.new(255,255,255,128)
      self.contents.draw_text(@now_vx, @now_vy, 32, 16, er.to_s + "%", 2)
      self.contents.font.color = normal_color
    end
  end
end

#===============================================================================
# ¦ Window_SideCommand
#-------------------------------------------------------------------------------
#   Written by mewsterus
#===============================================================================

class Window_SideCommand < Window_Selectable
  #-----------------------------------------------------------------------------
  # @ Make the window
  #-----------------------------------------------------------------------------
  def initialize(commands)
    super(0, 0, 640, 480)
    @item_max = commands.size
    @commands = commands
    @column_max = @item_max
    self.contents = Bitmap.new(width - 32, 32)
    self.contents.font.name = $fontface
    self.contents.font.size = $fontsize
    self.back_opacity = 160
    refresh
    self.index = 0
  end
  #-----------------------------------------------------------------------------
  # @ Refresh the window
  #-----------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for i in 0...@item_max
      draw_item(i, normal_color)
    end
  end
  #-----------------------------------------------------------------------------
  # @ Draw item
  #-----------------------------------------------------------------------------
  def draw_item(index, color)
    self.contents.font.color = color
    rect = Rect.new(608 / @item_max * index, 0, 608 / @item_max, 32)
    self.contents.draw_text(rect, @commands[index], 1)
  end
  #-----------------------------------------------------------------------------
  # @ Disable an item
  #-----------------------------------------------------------------------------
  def disable_item(index)
    draw_item(index, disabled_color)
  end
  #-----------------------------------------------------------------------------
  # @ Update the cursor
  #-----------------------------------------------------------------------------
  def update_cursor_rect
    self.cursor_rect.set(608 / @item_max * index, 0, 608 / @item_max, 32)
  end
end

#===============================================================================
# ¦ Window_Item
#-------------------------------------------------------------------------------
#   Edited by mewsterus
#===============================================================================

class Window_Item
  #-----------------------------------------------------------------------------
  # @ Make window
  #-----------------------------------------------------------------------------
  def initialize(element_id = 20)
    super(-320, 64, 320, 416)
    self.contents_opacity = 5
    @element_id = element_id
    @column_max = 1
    self.back_opacity = 0
    if $game_temp.in_battle
      self.x = 0
      self.width = 640
      self.height = 256
      self.contents_opacity = 255
      self.back_opacity = 160
      @column_max = 2
    end
    self.index = 0
    refresh
  end
  #-----------------------------------------------------------------------------
  # @ Accept column max input
  #-----------------------------------------------------------------------------
  def column_max=(column_max)
    @column_max = column_max
    refresh
  end
  #-----------------------------------------------------------------------------
  # @ Draw item
  #-----------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    case item
    when RPG::Item
      number = $game_party.item_number(item.id)
    when RPG::Weapon
      number = $game_party.weapon_number(item.id)
    when RPG::Armor
      number = $game_party.armor_number(item.id)
    end
    if item.is_a?(RPG::Item) and
       $game_party.item_can_use?(item.id)
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
    x = 4 + index % @column_max * (320)
    y = index / @column_max * 32
    rect = Rect.new(x, y, self.width / @column_max - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(item.icon_name)
    opacity = self.contents.font.color == normal_color ? 255 : 128
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
    self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
    self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
    if @index >= @item_max
      @index = @item_max - 1
    end
  end
end

#===============================================================================
# ¦ Window_Skill
#-------------------------------------------------------------------------------
#   Edited by mewsterus
#===============================================================================

class Window_Skill < Window_Selectable
  #-----------------------------------------------------------------------------
  # @ Create the window
  #-----------------------------------------------------------------------------
  def initialize(actor)
    super(0, 504, 320, 296)
    self.contents_opacity = 5
    self.back_opacity = 0
    @actor = actor
    self.index = 0
    if $game_temp.in_battle
      @column_max = 2
      self.contents_opacity = 255
      self.y = 64
      self.width = 640
      self.height = 256
      self.back_opacity = 160
    end
    refresh
  end
  #-----------------------------------------------------------------------------
  # @ Display skill
  #-----------------------------------------------------------------------------
  def draw_item(index)
    skill = @data[index]
    if @actor.skill_can_use?(skill.id)
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
    x = 4 + index % @column_max * 320
    y = index / @column_max * 32
    rect = Rect.new(x, y, self.width / @column_max - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(skill.icon_name)
    opacity = self.contents.font.color == normal_color ? 255 : 128
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0)
    self.contents.draw_text(x + 232, y, 48, 32, skill.sp_cost.to_s, 2)
  end
end

#===============================================================================
# ¦ Window_SkillStatus
#-------------------------------------------------------------------------------
#   Edited by mewsterus
#===============================================================================

class Window_SkillStatus < Window_Base
  #-----------------------------------------------------------------------------
  # @ Create the window
  #-----------------------------------------------------------------------------
  def initialize(actor)
    super(-320, 64, 320, 120)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = $fontface
    self.contents.font.size = $fontsize
    self.contents_opacity = 5
    self.back_opacity = 0
    self.opacity = 5
    @actor = actor
    refresh
    self.active = false
  end
  #-----------------------------------------------------------------------------
  # @ Draw contents
  #-----------------------------------------------------------------------------
  def refresh
    self.contents.clear
    draw_actor_graphic(@actor, 40, 88)
    draw_actor_name(@actor, 88, 0)
    draw_actor_state(@actor, 160, 0)
    draw_actor_level(@actor, 88, 20)
    draw_actor_class(@actor, 152, 20)
    draw_actor_hp(@actor, 88, 40, 172)
    draw_actor_sp(@actor, 88, 60, 172)
  end
  #-----------------------------------------------------------------------------
  # @ Accept whether window is selected
  #-----------------------------------------------------------------------------
  def selected=(selected)
    @selected = selected
    update_cursor_rect
  end
  #-----------------------------------------------------------------------------
  # @ Update the cursor
  #-----------------------------------------------------------------------------
  def update_cursor_rect
    if @selected
      self.cursor_rect.set(-8, -8, 304, 104)
    else
      self.cursor_rect.empty
    end
  end
end

#===============================================================================
# ¦ Window_Target
#-------------------------------------------------------------------------------
#   Edited by mewsterus
#===============================================================================

class Window_Target < Window_Selectable
  #-----------------------------------------------------------------------------
  # @ Make the window
  #-----------------------------------------------------------------------------
  def initialize(omitactor = -1)
    super(640, 64, 320, 416)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = $fontface
    self.contents.font.size = $fontsize
    self.contents_opacity = 5
    self.z += 10
    self.back_opacity = 0
    self.opacity = 5
    @item_max = $game_party.actors.size
    @omitactor = omitactor
    if @omitactor != -1
      @item_max -= 1
    end
    refresh
  end
  #-----------------------------------------------------------------------------
  # @ Refresh the contents
  #-----------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for i in 0...@item_max
      actor = $game_party.actors[i]
      if @omitactor != -1
        y = i * 130 + 16
        if i >= @omitactor
          actor = $game_party.actors[i + 1]
        end
      else
        y = i * 96
      end
      draw_actor_graphic(actor, 240, y + 88)
      draw_actor_name(actor, 4, y)
      draw_actor_state(actor, 94, y)
      draw_actor_level(actor, 4, y + 20)
      draw_actor_class(actor, 68, y + 20)
      draw_actor_hp(actor, 4, y + 40, 172)
      draw_actor_sp(actor, 4, y + 60, 172)
    end
  end
  #-----------------------------------------------------------------------------
  # @ Update the cursor
  #-----------------------------------------------------------------------------
  def update_cursor_rect
    if self.active
      if @omitactor != -1
        if @index == -1
          self.cursor_rect.set(0, 16, self.width - 32, @item_max * 130 - 32)
        else
          self.cursor_rect.set(0, @index * 130 + 16, 288, 96)
        end
      else
        if @index == -1
          self.cursor_rect.set(0, 0, self.width - 32, @item_max * 96)
        else
          self.cursor_rect.set(0, @index * 96, 288, 96)
        end
      end
    else
      self.cursor_rect.empty
    end
  end
end

#===============================================================================
# ¦ Window_EquipLeft
#-------------------------------------------------------------------------------
#   Edited by RPGAdvocate and mewsterus
#===============================================================================

class Window_EquipLeft < Window_Base
  attr_accessor :mode
  attr_accessor :changes
  #-----------------------------------------------------------------------------
  # @ Make the window
  #-----------------------------------------------------------------------------
  def initialize(actor)
    super(-384, 64, 272, 352)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = "Arial"
    self.contents.font.size = 24
    self.back_opacity = 0
    self.z += 100
    @actor = actor
    @mode = 0
    @changes = [0, 0, 0, 0, 0, 0, 0, 0]
    refresh
  end
  #-----------------------------------------------------------------------------
  # @ Refresh the window
  #-----------------------------------------------------------------------------
  def refresh
    self.contents.clear
    draw_actor_graphic(@actor, 200, 80)
    draw_actor_name(@actor, 4, 0)
    draw_actor_level(@actor, 4, 32)
    draw_actor_class(@actor, 68, 32)
    draw_actor_parameter(@actor, 4, 80, 0)
    draw_actor_parameter(@actor, 4, 112, 1)
    draw_actor_parameter(@actor, 4, 144, 2)
    draw_actor_parameter(@actor, 4, 196, 3)
    draw_actor_parameter(@actor, 4, 224, 4)
    draw_actor_parameter(@actor, 4, 256, 5)
    draw_actor_parameter(@actor, 4, 288, 6)
    if @new_atk != nil
      self.contents.font.color = system_color
      self.contents.draw_text(160, 80, 40, 32, "?", 1)
      if @changes[0] == 0
        self.contents.font.color = normal_color
      elsif @changes[0] < 0
        self.contents.font.color = disabled_color
      end
      self.contents.draw_text(200, 80, 36, 32, @new_atk.to_s, 2)
    end
    if @new_pdef != nil
      self.contents.font.color = system_color
      self.contents.draw_text(160, 112, 40, 32, "?", 1)
      if @changes[1] == 0
        self.contents.font.color = normal_color
      elsif @changes[1] < 0
        self.contents.font.color = disabled_color
      end
      self.contents.draw_text(200, 112, 36, 32, @new_pdef.to_s, 2)
    end
    if @new_mdef != nil
      self.contents.font.color = system_color
      self.contents.draw_text(160, 144, 40, 32, "?", 1)
      if @changes[2] == 0
        self.contents.font.color = normal_color
      elsif @changes[2] < 0
        self.contents.font.color = disabled_color
      end
      self.contents.draw_text(200, 144, 36, 32, @new_mdef.to_s, 2)
    end
    if @new_str != nil
      self.contents.font.color = system_color
      self.contents.draw_text(160, 196, 40, 32, "?", 1)
      if @changes[3] == 0
        self.contents.font.color = normal_color
      elsif @changes[3] < 0
        self.contents.font.color = disabled_color
      end
      self.contents.draw_text(200, 196, 36, 32, @new_str.to_s, 2)
    end
    if @new_dex != nil
      self.contents.font.color = system_color
      self.contents.draw_text(160, 224, 40, 32, "?", 1)
      if @changes[4] == 0
        self.contents.font.color = normal_color
      elsif @changes[4] < 0
        self.contents.font.color = disabled_color
      end
      self.contents.draw_text(200, 224, 36, 32, @new_dex.to_s, 2)
    end
    if @new_agi != nil
      self.contents.font.color = system_color
      self.contents.draw_text(160, 256, 40, 32, "?", 1)
      if @changes[5] == 0
        self.contents.font.color = normal_color
      elsif @changes[5] < 0
        self.contents.font.color = disabled_color
      end
      self.contents.draw_text(200, 256, 36, 32, @new_agi.to_s, 2)
    end
    if @new_int != nil
      self.contents.font.color = system_color
      self.contents.draw_text(160, 288, 40, 32, "?", 1)
      if @changes[6] == 0
        self.contents.font.color = normal_color
      elsif @changes[6] < 0
        self.contents.font.color = disabled_color
      end
      self.contents.draw_text(200, 288, 36, 32, @new_int.to_s, 2)
    end
  end
  #-----------------------------------------------------------------------------
  # @ Accept new parameter values
  #-----------------------------------------------------------------------------
  def set_new_parameters(new_atk, new_pdef, new_mdef, new_str, new_dex,
    new_agi, new_int, new_eva)
    flag = false
    if new_atk != @new_atk || new_pdef != @new_pdef || new_mdef != @new_mdef
      flag = true
    end
    if new_str != @new_str || new_dex != @new_dex || new_agi != @new_agi
      flag = true
    end
    if new_eva != @new_eva
      flag = true
    end
    @new_atk = new_atk
    @new_pdef = new_pdef
    @new_mdef = new_mdef
    @new_str = new_str
    @new_dex = new_dex
    @new_agi = new_agi
    @new_int = new_int
    @new_eva = new_eva
    if flag
      refresh
    end
  end
end

#===============================================================================
# ¦ Window_EquipItem
#-------------------------------------------------------------------------------
#   Edited by RPGAdvocate
#===============================================================================

class Window_EquipItem < Window_Selectable
  attr_reader   :data
  #-----------------------------------------------------------------------------
  # @ Make the window
  #-----------------------------------------------------------------------------
  def initialize(actor, equip_type)
    super(272, 256, 368, 160)
    self.back_opacity = 0
    self.visible = false
    @actor = actor
    @equip_type = equip_type
    @column_max = 1
    refresh
    self.active = false
    self.index = -1
  end
  #-----------------------------------------------------------------------------
  # @ Make the window
  #-----------------------------------------------------------------------------
  def item
    return @data[self.index]
  end
  #-----------------------------------------------------------------------------
  # @ Refresh the window
  #-----------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    if @equip_type == 0
      weapon_set = $data_classes[@actor.class_id].weapon_set
      for i in 1...$data_weapons.size
        if $game_party.weapon_number(i) > 0 and weapon_set.include?(i)
          @data.push($data_weapons[i])
        end
      end
    end
    if @equip_type != 0
      armor_set = $data_classes[@actor.class_id].armor_set
      for i in 1...$data_armors.size
        if $game_party.armor_number(i) > 0 and armor_set.include?(i)
          if $data_armors[i].kind == @equip_type-1
            @data.push($data_armors[i])
          end
        end
      end
    end
    @item_max = @data.size
    if @data.size != 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      self.contents.font.name = "Arial"
      self.contents.font.size = 24
    end
    for i in 0...@item_max
      draw_item(i)
    end
  end
  #-----------------------------------------------------------------------------
  # @ Draw item
  #-----------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    x = 4
    y = index * 32
    case item
    when RPG::Weapon
      number = $game_party.weapon_number(item.id)
    when RPG::Armor
      number = $game_party.armor_number(item.id)
    end
    bitmap = RPG::Cache.icon(item.icon_name)
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
    self.contents.font.color = normal_color
    self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
    self.contents.draw_text(x + 288, y, 16, 32, ":", 1)
    self.contents.draw_text(x + 304, y, 24, 32, number.to_s, 2)
  end
  #-----------------------------------------------------------------------------
  # @ Update the help window
  #-----------------------------------------------------------------------------
  def update_help
    @help_window.set_text(self.item == nil ? "" : self.item.description)
  end
end

#===============================================================================
# ¦ Window_Status
#-------------------------------------------------------------------------------
#   Written by mewsterus
#===============================================================================

class Window_Status < Window_Base
  #-----------------------------------------------------------------------------
  # @ Make the window
  #-----------------------------------------------------------------------------
  def initialize(actor)
    super(100, -480, 440, 480)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = $fontface
    self.contents.font.size = $fontsize
    self.contents_opacity = 5
    self.back_opacity = 160
    self.opacity = 5
    @actor = actor
    refresh
  end
  #-----------------------------------------------------------------------------
  # @ Refresh the window
  #-----------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.font.size = $fontsize
    draw_actor_battler(@actor, 104, 192)
    draw_actor_name(@actor, 4, 0)
    draw_actor_hp(@actor, 0, 192, 172)
    draw_actor_sp(@actor, 0, 224, 172)
    draw_actor_exp(@actor, 0, 256, 172)
    draw_item_name($data_weapons[@actor.weapon_id], 0, 282)
    draw_item_name($data_armors[@actor.armor1_id], 0, 314)
    draw_item_name($data_armors[@actor.armor2_id], 0, 346)
    draw_item_name($data_armors[@actor.armor3_id], 0, 378)
    draw_item_name($data_armors[@actor.armor4_id], 0, 410)
    draw_actor_level(@actor, 150, 0)
    draw_actor_class(@actor, 224, 0)
    draw_actor_state(@actor, 288, 0)
    draw_actor_parameter(@actor, 224, 32, 0)
    draw_actor_parameter(@actor, 224, 64, 1)
    draw_actor_parameter(@actor, 224, 96, 2)
    draw_actor_parameter(@actor, 224, 128, 3)
    draw_actor_parameter(@actor, 224, 160, 4)
    draw_actor_parameter(@actor, 224, 193, 5)
    draw_actor_parameter(@actor, 224, 224, 6)
    self.contents.font.color = system_color
    self.contents.draw_text(192, 256, 224, 32, "Elemental Vulnerability")
    self.contents.font.size = 16
    draw_actor_element_radar_graph(@actor, 172, 280)
  end
end

#===============================================================================
# ¦ Window_Save
#-------------------------------------------------------------------------------
#   Edited by mewsterus
#===============================================================================

class Window_Save < Window_Base
  attr_reader   :filename
  attr_reader   :selected
  #-----------------------------------------------------------------------------
  # @ Make the window
  #-----------------------------------------------------------------------------
  def initialize(file_index)
    super(0, 64 + file_index % 4 * 104, 640, 104)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = $fontface
    self.contents.font.size = $fontsize
    self.contents_opacity = 5
    self.back_opacity = 160
    self.opacity = 5
    @file_index = file_index
    @filename = "Save#{@file_index + 1}.rxdata"
    @selected = false
    refresh
    update
  end
  #-----------------------------------------------------------------------------
  # @ Update the window
  #-----------------------------------------------------------------------------
  def update
    super
    if @selected
      if self.contents_opacity < 255
        self.contents_opacity += 10
      end
    else
      if self.contents_opacity > 155
        self.contents_opacity -= 10
      elsif self.contents_opacity < 155
        self.contents_opacity += 25
      end
    end
  end
  #-----------------------------------------------------------------------------
  # @ Refresh the window
  #-----------------------------------------------------------------------------
  def refresh
    self.contents.clear
    @time_stamp = Time.at(0)
    @file_exist = FileTest.exist?(@filename)
    if @file_exist
      file = File.open(@filename, "r")
      @time_stamp = file.mtime
      @characters          = Marshal.load(file)
      @frame_count         = Marshal.load(file)
      @game_system         = Marshal.load(file)
      @game_switches       = Marshal.load(file)
      @game_variables      = Marshal.load(file)
      @game_self_switches  = Marshal.load(file)
      @game_screen         = Marshal.load(file)
      @game_actors         = Marshal.load(file)
      @game_party          = Marshal.load(file)
      @game_troop          = Marshal.load(file)
      @game_map            = Marshal.load(file)
      @game_player         = Marshal.load(file)
      @total_sec           = @frame_count / Graphics.frame_rate
      file.close
      self.windowskin = RPG::Cache.windowskin(@game_system.windowskin_name)
      for i in 0...@characters.size
        if $face_enabled
          bitmap = RPG::Cache.picture(@characters[i][0])
          cw = 80
          ch = 80
        else
          bitmap = RPG::Cache.character(@characters[i][0], @characters[i][1])
          cw = bitmap.rect.width / 4
          ch = bitmap.rect.height / 4
        end
        src_rect = Rect.new(0, 0, cw, ch)
        x = 608 + (i - @characters.size) * 84
        self.contents.blt(x, 80 - ch, bitmap, src_rect)
      end
      hour = @total_sec / 60 / 60
      min = @total_sec / 60 % 60
      sec = @total_sec % 60
      text = sprintf("%02d:%02d:%02d", hour, min, sec)
      self.contents.font.color = normal_color
      self.contents.draw_text(4, 8, 256, 32, text, 2)
      time_string = @time_stamp.strftime("%Y/%m/%d %H:%M")
      self.contents.draw_text(4, 40, 256, 32, time_string, 2)
      if $location_enabled
        name = @game_map.name.delete("*").to_s
      else
        name = @game_party.actors[0].name
      end
    else
      self.windowskin = RPG::Cache.windowskin($game_system.windowskin_name)
      name = "[Empty]"
    end
    self.contents.font.color = normal_color
    self.contents.draw_text(4, 8, 600, 32, name)
  end
  #-----------------------------------------------------------------------------
  # @ Accept whether window is selected
  #-----------------------------------------------------------------------------
  def selected=(selected)
    @selected = selected
    update
  end
end

#===============================================================================
# ¦ Scene_Item
#-------------------------------------------------------------------------------
#   Edited by mewsterus
#===============================================================================

class Scene_Item
  #-----------------------------------------------------------------------------
  # @ Accept item type
  #-----------------------------------------------------------------------------
  def initialize(itemtype = 20)
    @itemtype = itemtype
  end
  #-----------------------------------------------------------------------------
  # @ Main loop
  #-----------------------------------------------------------------------------
  def main
    @sprite = Spriteset_Map.new
    @bg_window = Window_Base.new(0, 0, 640, 480)
    @bg_window.back_opacity = 160
    @bg_window.opacity = 5
    @help_window = Window_Help.new
    if @itemtype <= 20
      @help_window.y = -320
    else
      @help_window.y = -416
    end
    @help_window.back_opacity = 0
    @help_window.opacity = 5
    if $itemdrop_enabled
      @item_window = Window_Item.new(@itemtype)
    else
      @item_window = Window_Item.new
    end
    @item_window.help_window = @help_window
    @item_window.opacity = 5
    if @itemtype > 20
      @item_window.x = 0
      @item_window.y = 480
      @item_window.width = 640
      @item_window.column_max = 2
    end
    @target_window = Window_Target.new
    @target_window.active = false
    @target_window.opacity = 5
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      if @help_window.y < 0
        @help_window.y += 32
      end
      if @item_window.x < 0 and @itemtype <= 20
        @item_window.x += 32
      end
      if @item_window.y > 64 and @itemtype > 20
        @item_window.y -= 32
      end
      if @target_window.x > 320 and @itemtype <= 20
        @target_window.x -= 32
      end
      if @bg_window.opacity < 255
        @bg_window.opacity += 25
        @help_window.opacity += 25
        @help_window.contents_opacity += 25
        @item_window.opacity += 25
        @item_window.contents_opacity += 25
        @target_window.opacity += 25
        @target_window.contents_opacity += 25
      else
        update
      end
      if $scene != self
        break
      end
    end
    for i in 0..15
      @bg_window.opacity -= 25
      @help_window.y -= 32
      @help_window.opacity -=25
      @help_window.contents_opacity -=25
      if @itemtype <= 20
        @item_window.x -= 32
      else
        @item_window.y += 32
      end
      @item_window.opacity -=25
      @item_window.contents_opacity -=25
      @target_window.x += 32
      @target_window.opacity -=25
      @target_window.contents_opacity -=25
      Graphics.update
    end
    Graphics.freeze
    @sprite.dispose
    @bg_window.dispose
    @help_window.dispose
    @item_window.dispose
    @target_window.dispose
  end
  #-----------------------------------------------------------------------------
  # @ Update the scene
  #-----------------------------------------------------------------------------
  def update
    @sprite.update
    @bg_window.update
    @help_window.update
    @item_window.update
    @target_window.update
    if @item_window.active
      update_item
      return
    end
    if @target_window.active
      update_target
      return
    end
  end
  #-----------------------------------------------------------------------------
  # @ Update the main window
  #-----------------------------------------------------------------------------
  def update_item
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Menu.new(0)
      return
    end
    if Input.trigger?(Input::C)
      @item = @item_window.item
      unless @item.is_a?(RPG::Item)
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      unless $game_party.item_can_use?(@item.id)
        $game_system.se_play($data_system.buzzer_se)
        return

      end
      $game_system.se_play($data_system.decision_se)
      if @item.scope >= 3
        @item_window.active = false
        @target_window.active = true
        if @item.scope == 4 || @item.scope == 6
          @target_window.index = -1
        else
          @target_window.index = 0
        end
      else
        if @item.common_event_id > 0
          $game_temp.common_event_id = @item.common_event_id
          $game_system.se_play(@item.menu_se)
          if @item.consumable
            $game_party.lose_item(@item.id, 1)
            @item_window.draw_item(@item_window.index)
          end
          $scene = Scene_Map.new
          return
        end
      end
      return
    end
    if Input.trigger?(Input::R) and $itemdrop_enabled
      $game_system.se_play($data_system.cursor_se)
      $scene = Scene_Item.new(((@itemtype - 19) % 3) + 20)
      return
    end
    if Input.trigger?(Input::L) and $itemdrop_enabled
      $game_system.se_play($data_system.cursor_se)
      $scene = Scene_Item.new(((@itemtype - 18) % 3) + 20)
      return
    end
  end
  #-----------------------------------------------------------------------------
  # @ Update the target window
  #-----------------------------------------------------------------------------
  def update_target
    if $game_party.item_number(@item.id) == 0
      @target_window.active = false
      @item_window.refresh
      @item_window.active = true
      return
    end
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      unless $game_party.item_can_use?(@item.id)
        @item_window.refresh
      end
      @item_window.active = true
      @target_window.active = false
      return
    end
    if Input.trigger?(Input::C)
      if $game_party.item_number(@item.id) == 0
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      if @target_window.index == -1
        used = false
        for i in $game_party.actors
          used |= i.item_effect(@item)
        end
      end
      if @target_window.index >= 0
        target = $game_party.actors[@target_window.index]
        used = target.item_effect(@item)
      end
      if used
        $game_system.se_play(@item.menu_se)
        if @item.consumable
          $game_party.lose_item(@item.id, 1)
          @item_window.draw_item(@item_window.index)
        end
        @target_window.refresh
        if $game_party.all_dead?
          $scene = Scene_Gameover.new
          return
        end
        if @item.common_event_id > 0
          $game_temp.common_event_id = @item.common_event_id
          $scene = Scene_Map.new
          return
        end
      end
      unless used
        $game_system.se_play($data_system.buzzer_se)
      end
      return
    end
  end
end

#===============================================================================
# ¦ Scene_Skill
#-------------------------------------------------------------------------------
#   Edited by mewsterus
#===============================================================================

class Scene_Skill
  #-----------------------------------------------------------------------------
  # @ Accept indeces
  #-----------------------------------------------------------------------------
  def initialize(actor_index = 0, equip_index = 0)
    @actor_index = actor_index
  end
  #-----------------------------------------------------------------------------
  # @ Main loop
  #-----------------------------------------------------------------------------
  def main
    @sprite = Spriteset_Map.new
    @bg_window = Window_Base.new(0, 0, 640, 480)
    @bg_window.back_opacity = 160
    @bg_window.opacity = 5
    @actor = $game_party.actors[@actor_index]
    @help_window = Window_Help.new
    @help_window.y = -320
    @help_window.back_opacity = 0
    @help_window.opacity = 5
    @help_window.contents_opacity = 5
    @status_window = Window_SkillStatus.new(@actor)
    @status_window.opacity = 5
    @skill_window = Window_Skill.new(@actor)
    @skill_window.help_window = @help_window
    @skill_window.opacity = 5
    @target_window = Window_Target.new(@actor_index)
    @target_window.active = false
    @target_window.opacity = 5
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      if @help_window.y < 0
        @help_window.y += 32
      end
      if @status_window.x < 0
        @status_window.x += 32
      end
      if @skill_window.y > 184
        @skill_window.y -= 32
      end
      if @target_window.x > 320
        @target_window.x -= 32
      end
      if @bg_window.opacity < 255
        @bg_window.opacity += 25
        @help_window.opacity += 25
        @help_window.contents_opacity += 25
        @status_window.opacity += 25
        @status_window.contents_opacity += 25
        @skill_window.opacity += 25
        @skill_window.contents_opacity += 25
        @target_window.opacity += 25
        @target_window.contents_opacity += 25
      else
        update
      end
      if $scene != self
        break
      end
    end
    for i in 0..10
      @bg_window.opacity -= 25
      @help_window.y -= 32
      @help_window.opacity -=25
      @help_window.contents_opacity -=25
      @status_window.x -= 32
      @status_window.opacity -=25
      @status_window.contents_opacity -=25
      @skill_window.y += 32
      @skill_window.opacity -=25
      @skill_window.contents_opacity -=25
      @target_window.x += 32
      @target_window.opacity -=25
      @target_window.contents_opacity -=25
      Graphics.update
    end
    Graphics.freeze
    @sprite.dispose
    @bg_window.dispose
    @help_window.dispose
    @status_window.dispose
    @skill_window.dispose
    @target_window.dispose
  end
  #-----------------------------------------------------------------------------
  # @ Update the screen
  #-----------------------------------------------------------------------------
  def update
    @sprite.update
    @bg_window.update
    @help_window.update
    @status_window.update
    @skill_window.update
    @target_window.update
    if @skill_window.active
      update_skill
      return
    end
    if @target_window.active
      update_target
      return
    end
    if @status_window.active
      update_status
      return
    end
  end
  #-----------------------------------------------------------------------------
  # @ Update the skill window
  #-----------------------------------------------------------------------------
  def update_skill
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Menu.new(1)
      return
    end
    if Input.trigger?(Input::C)
      @skill = @skill_window.skill
      if @skill == nil or not @actor.skill_can_use?(@skill.id)
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      $game_system.se_play($data_system.decision_se)
      if @skill.scope >= 3
        @skill_window.active = false
        @target_window.active = true
        if @skill.scope == 4 || @skill.scope == 6
          @target_window.index = -1
          @status_window.selected = true
          @status_window.active = true
        elsif @skill.scope == 7
          @skillstatus_window.selected = true
          @skillstatus_window.active = true
        else
          @target_window.index = 0
        end
      else
        if @skill.common_event_id > 0
          $game_temp.common_event_id = @skill.common_event_id
          $game_system.se_play(@skill.menu_se)
          @actor.sp -= @skill.sp_cost
          @status_window.refresh
          @skill_window.refresh
          @target_window.refresh
          $scene = Scene_Map.new
          return
        end
      end
      return
    end
    if Input.trigger?(Input::R)
      $game_system.se_play($data_system.cursor_se)
      @actor_index += 1
      @actor_index %= $game_party.actors.size
      $scene = Scene_Skill.new(@actor_index)
      return
    end
    if Input.trigger?(Input::L)
      $game_system.se_play($data_system.cursor_se)
      @actor_index += $game_party.actors.size - 1
      @actor_index %= $game_party.actors.size
      $scene = Scene_Skill.new(@actor_index)
      return
    end
  end
  #-----------------------------------------------------------------------------
  # @ Update the target window
  #-----------------------------------------------------------------------------
  def update_target
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @skill_window.active = true
      @target_window.active = false
      @status_window.selected = false
      @status_window.active = false
      return
    end
    if Input.trigger?(Input::C)
      unless @actor.skill_can_use?(@skill.id)
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      if @target_window.index == -1
        used = false
        for i in $game_party.actors
          used |= i.skill_effect(@actor, @skill)
        end
      end
      if @target_window.index <= -2
        target = $game_party.actors[@target_window.index + 10]
        used = target.skill_effect(@actor, @skill)
      end
      if @target_window.index >= 0
        if @target_window.index >= @actor_index
          target = $game_party.actors[@target_window.index + 1]
        else
          target = $game_party.actors[@target_window.index]
        end
        used = target.skill_effect(@actor, @skill)
      end
      if used
        $game_system.se_play(@skill.menu_se)
        @actor.sp -= @skill.sp_cost
        @status_window.refresh
        @skill_window.refresh
        @target_window.refresh
        if $game_party.all_dead?
          $scene = Scene_Gameover.new
          return
        end
        if @skill.common_event_id > 0
          $game_temp.common_event_id = @skill.common_event_id
          $scene = Scene_Map.new
          return
        end
      end
      unless used
        $game_system.se_play($data_system.buzzer_se)
      end
      return
    end
    if Input.repeat?(Input::RIGHT) or Input.repeat?(Input::LEFT)
      $game_system.se_play($data_system.cursor_se)
      @target_window.active = false
      @status_window.active = true
      @status_window.selected = true
      return
    end
  end
  #-----------------------------------------------------------------------------
  # @ Update the skill status window
  #-----------------------------------------------------------------------------
  def update_status
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @skill_window.active = true
      @target_window.active = false
      @status_window.selected = false
      return
    end
    if Input.trigger?(Input::C)
      unless @actor.skill_can_use?(@skill.id)
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      if @target_window.index == -1
        used = false
        for i in $game_party.actors
          used |= i.skill_effect(@actor, @skill)
        end
      end
      if @target_window.index <= -2
        target = @actor
        used = target.skill_effect(@actor, @skill)
      end
      if @target_window.index >= 0
        target = @actor
        used = target.skill_effect(@actor, @skill)
      end
      if used
        $game_system.se_play(@skill.menu_se)
        @actor.sp -= @skill.sp_cost
        @status_window.refresh
        @skill_window.refresh
        @target_window.refresh
        if $game_party.all_dead?
          $scene = Scene_Gameover.new
          return
        end
        if @skill.common_event_id > 0
          $game_temp.common_event_id = @skill.common_event_id
          $scene = Scene_Map.new
          return
        end
      end
      unless used
        $game_system.se_play($data_system.buzzer_se)
      end
      return
    end
    if Input.repeat?(Input::RIGHT) or Input.repeat?(Input::LEFT)
      if @skill.scope == 7
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      $game_system.se_play($data_system.cursor_se)
      @status_window.active = false
      @status_window.selected = false
      @target_window.active = true
      return
    end
  end
end

#===============================================================================
# ¦ Scene_Equip
#-------------------------------------------------------------------------------
#   Edited by RPGAdvocate and mewsterus
#===============================================================================

class Scene_Equip
  #-----------------------------------------------------------------------------
  # @ Main loop
  #-----------------------------------------------------------------------------
  def main
    @actor = $game_party.actors[@actor_index]
    @sprite = Spriteset_Map.new
    @commands = ["Equip", "Optimize", "Remove", "Empty", "Cancel"]
    @command_window = Window_SideCommand.new(@commands)
    @command_window.opacity = 5
    @command_window.contents_opacity = 0
    @dummy_window = Window_Base.new(0, 0, 640, 64)
    @dummy_window.back_opacity = 0
    @dummy_window.opacity = 0
    @help_window = Window_Help.new
    @help_window.y = 800
    @help_window.back_opacity = 0
    @help_window.opacity = 5
    @help_window.contents_opacity = 5
    @left_window = Window_EquipLeft.new(@actor)
    @right_window = Window_EquipRight.new(@actor)
    @right_window.y = -320
    @right_window.back_opacity = 0
    @right_window.opacity = 5
    @right_window.contents_opacity = 5
    @right_window.active = false
    @right_window.help_window = @help_window
    @blank_window = Window_Base.new(656, 256, 368, 160)
    @blank_window.back_opacity = 0
    @blank_window.active = false
    @item_window1 = Window_EquipItem.new(@actor, 0)
    @item_window2 = Window_EquipItem.new(@actor, 1)
    @item_window3 = Window_EquipItem.new(@actor, 2)
    @item_window4 = Window_EquipItem.new(@actor, 3)
    @item_window5 = Window_EquipItem.new(@actor, 4)
    @item_window1.help_window = @help_window
    @item_window2.help_window = @help_window
    @item_window3.help_window = @help_window
    @item_window4.help_window = @help_window
    @item_window5.help_window = @help_window
    @right_window.index = -1
    @remove = false
    refresh
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      if @left_window.x < 0
        @left_window.x += 32
      end
      if @right_window.y < 64
        @right_window.y += 32
      end
      if @blank_window.x > 272
        @blank_window.x -= 32
      end
      if @help_window.y > 416
        @help_window.y -= 32
      end
      if @command_window.opacity < 255
        @command_window.opacity += 25
        @left_window.opacity += 25
        @left_window.contents_opacity += 25
        @right_window.opacity += 25
        @right_window.contents_opacity += 25
        @blank_window.opacity += 25
        @blank_window.contents_opacity += 25
        @help_window.opacity += 25
        @help_window.contents_opacity += 25
      else
        @command_window.contents_opacity = 255
        @dummy_window.opacity = 255
        update
      end
      if $scene != self
        break
      end
    end
    @command_window.contents_opacity = 0
    @dummy_window.opacity = 0
    for i in 0..10
      @command_window.opacity -= 25
      @command_window.contents_opacity -= 25
      @dummy_window.opacity -= 25
      @left_window.x -= 32
      @left_window.opacity -=25
      @left_window.contents_opacity -=25
      @right_window.y -= 32
      @right_window.opacity -=25
      @right_window.contents_opacity -=25
      @blank_window.x += 32
      @blank_window.opacity -=25
      @blank_window.contents_opacity -=25
      @help_window.y += 32
      @help_window.opacity -=25
      @help_window.contents_opacity -=25
      Graphics.update
    end
    Graphics.freeze
    @sprite.dispose
    @command_window.dispose
    @dummy_window.dispose
    @help_window.dispose
    @left_window.dispose
    @right_window.dispose
    @blank_window.dispose
    @item_window1.dispose
    @item_window2.dispose
    @item_window3.dispose
    @item_window4.dispose
    @item_window5.dispose
  end
  #-----------------------------------------------------------------------------
  # @ Refresh the screen
  #-----------------------------------------------------------------------------
  def refresh
    unless @remove
      @item_window1.visible = (@right_window.index == 0)
      @item_window2.visible = (@right_window.index == 1)
      @item_window3.visible = (@right_window.index == 2)
      @item_window4.visible = (@right_window.index == 3)
      @item_window5.visible = (@right_window.index == 4)
    end
    item1 = @right_window.item
    case @right_window.index
    when -2
      @item_window = @blank_window
    when -1
      @item_window = @blank_window
    when 0
      @item_window = @item_window1
      newmode = 0
    when 1
      @item_window = @item_window2
      newmode = 1
    when 2
      @item_window = @item_window3
      newmode = 1
    when 3
      @item_window = @item_window4
      newmode = 1
    when 4
      @item_window = @item_window5
      newmode = 1
    end
    if @remove
      @item_window = @blank_window
    end
    if newmode != @left_window.mode
      @left_window.mode = newmode
      @left_window.refresh
    end
    if @item_window.active or @remove
      if @item_window.active
        item2 = @item_window.item
      end
      last_hp = @actor.hp
      last_sp = @actor.sp
      old_atk = @actor.atk
      old_pdef = @actor.pdef
      old_mdef = @actor.mdef
      old_str = @actor.str
      old_dex = @actor.dex
      old_agi = @actor.agi
      old_int = @actor.int
      old_eva = @actor.eva
      @actor.equip(@right_window.index, item2 == nil ? 0 : item2.id)
      new_atk = @actor.atk
      new_pdef = @actor.pdef
      new_mdef = @actor.mdef
      new_str = @actor.str
      new_dex = @actor.dex
      new_agi = @actor.agi
      new_int = @actor.int
      new_eva = @actor.eva
      @left_window.changes = [0, 0, 0, 0, 0, 0, 0, 0]
      @left_window.changes[0] = new_atk - old_atk
      @left_window.changes[1] = new_pdef - old_pdef
      @left_window.changes[2] = new_mdef - old_mdef
      @left_window.changes[3] = new_str - old_str
      @left_window.changes[4] = new_dex - old_dex
      @left_window.changes[5] = new_agi - old_agi
      @left_window.changes[6] = new_int - old_int
      @left_window.changes[7] = new_eva - old_eva
      @actor.equip(@right_window.index, item1 == nil ? 0 : item1.id)
      @actor.hp = last_hp
      @actor.sp = last_sp
      @left_window.set_new_parameters(new_atk, new_pdef, new_mdef, new_str,
      new_dex, new_agi, new_int, new_eva)
    else
      @left_window.set_new_parameters(nil, nil, nil, nil, nil, nil, nil, nil)
    end
  end
  #-----------------------------------------------------------------------------
  # @ Update the screen
  #-----------------------------------------------------------------------------
  def update
    @command_window.update
    @left_window.update
    @right_window.update
    @item_window.update
    refresh
    if @command_window.active
      update_command
      return
    end
    if @right_window.active
      update_right
      return
    end
    if @item_window.active
      update_item
      return
    end
  end
  #-----------------------------------------------------------------------------
  # @ Update the command window
  #-----------------------------------------------------------------------------
  def update_command
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Menu.new(2)
      return
    end
    if Input.trigger?(Input::C)
      $game_system.se_play($data_system.decision_se)
      case @command_window.index
      when 0
        @command_window.active = false
        @right_window.active = true
        @right_window.index = @equip_index
      when 1
        optimize
        @left_window.refresh
        @right_window.refresh
        @item_window1.refresh
        @item_window2.refresh
        @item_window3.refresh
        @item_window4.refresh
        @item_window5.refresh
      when 2
        @remove = true
        @command_window.active = false
        @right_window.active = true
        @right_window.index = @equip_index
      when 3
        for i in 0..4
          @actor.equip(i, 0)
        end
        @left_window.refresh
        @right_window.refresh
        @item_window1.refresh
        @item_window2.refresh
        @item_window3.refresh
        @item_window4.refresh
        @item_window5.refresh
      when 4
        $scene = Scene_Menu.new(2)
      end
      return
    end
    if Input.trigger?(Input::R)
      $game_system.se_play($data_system.cursor_se)
      @actor_index += 1
      @actor_index %= $game_party.actors.size
      $scene = Scene_Equip.new(@actor_index, @right_window.index)
      return
    end
    if Input.trigger?(Input::L)
      $game_system.se_play($data_system.cursor_se)
      @actor_index += $game_party.actors.size - 1
      @actor_index %= $game_party.actors.size
      $scene = Scene_Equip.new(@actor_index, @right_window.index)
      return
    end
  end
  #-----------------------------------------------------------------------------
  # @ Update the right window
  #-----------------------------------------------------------------------------
  def update_right
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @right_window.active = false
      @command_window.active = true
      if @right_window.index >= 0
        @equip_index = @right_window.index
      end
      @right_window.index = -1
      @remove = false
      @help_window.set_text("")
      @left_window.refresh
      return
    end
    if Input.trigger?(Input::C)
      if @remove
        $game_system.se_play($data_system.decision_se)
        @actor.equip(@right_window.index, 0)
        @left_window.refresh
        @right_window.refresh
        return
      end
      if @actor.equip_fix?(@right_window.index) or @item_window.data.size == 0
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      $game_system.se_play($data_system.decision_se)
      @right_window.active = false
      @item_window.active = true
      @item_window.index = 0
      return
    end
  end
  #-----------------------------------------------------------------------------
  # @ Update the item window
  #-----------------------------------------------------------------------------
  def update_item
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @right_window.active = true
      @item_window.active = false
      @item_window.index = -1
      return
    end
    if Input.trigger?(Input::C)
      $game_system.se_play($data_system.equip_se)
      item = @item_window.item
      @actor.equip(@right_window.index, item.id)
      @right_window.active = true
      @item_window.active = false
      @item_window.index = -1
      @right_window.refresh
      @item_window.refresh
      return
    end
  end
  #-----------------------------------------------------------------------------
  # @ Optimize equipment (by RPGAdvocate)
  #-----------------------------------------------------------------------------
  def optimize
    object = $data_weapons[@actor.weapon_id]
    optimal = object.id
    current = 0.00
    if @actor.weapon_id != 0
      current = object.atk
    else
      optimal = 0
    end
    max_eval = current
    @actor.equip(0, 0)
    flag = false
    zero_flag = true
    for weapon in $data_weapons
      if !flag
        flag = true
        next
      end
      evaluation = weapon.atk
      if evaluation > 0
        zero_flag = false
      end
      if @actor.equippable?(weapon) && 
        $game_party.weapon_number(weapon.id) > 0 && evaluation > max_eval
        max_eval = evaluation
        optimal = weapon.id
      end
    end
    if zero_flag
      optimal = 0
    end
    @actor.equip(0, optimal)
    not_equipped = false
    for i in 1..4
      case i
      when 1
        if @actor.armor1_id == 0
          not_equipped = true
        else
          object = $data_armors[@actor.armor1_id]
        end
      when 2
        if @actor.armor2_id == 0
          not_equipped = true
        else
          object = $data_armors[@actor.armor2_id]
        end
      when 3
        if @actor.armor3_id == 0
          not_equipped = true
        else
          object = $data_armors[@actor.armor3_id]
        end
      when 4
        if @actor.armor4_id == 0
          not_equipped = true
        else
          object = $data_armors[@actor.armor4_id]
        end
      end
      optimal = object.id
      current = 0.00
      if not_equipped = false
        current = object.pdef * 0.75 + object.mdef * 0.25
      else
        optimal = 0
      end
      max_eval = current
      @actor.equip(i, 0)
      flag = false
      zero_flag = true
      for armor in $data_armors
        if !flag
          flag = true
          next
        end
        if armor.kind != i-1
          next
        end
        evaluation = armor.pdef * 0.75 + armor.mdef * 0.25
        if evaluation > 0
          zero_flag = false
        end
        if @actor.equippable?(armor) && 
          $game_party.armor_number(armor.id) > 0 && evaluation > max_eval
          max_eval = evaluation
          optimal = armor.id
        end
      end
      if zero_flag
        optimal = 0
      end
      @actor.equip(i, optimal)
    end
  end
end

#===============================================================================
# ¦ Scene_Status
#-------------------------------------------------------------------------------
#   Edited by mewsterus
#===============================================================================

class Scene_Status
  #-----------------------------------------------------------------------------
  # @ Main loop
  #-----------------------------------------------------------------------------
  def main
    @sprite = Spriteset_Map.new
    @actor = $game_party.actors[@actor_index]
    @status_window = Window_Status.new(@actor)
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      if @status_window.opacity < 255
        @status_window.opacity += 25
        @status_window.contents_opacity += 25
      end
      if @status_window.y < 0
        @status_window.y += 40
      else
        update
      end
      if $scene != self
        break
      end
    end
    for i in 0..12
      @status_window.y += 40
      if i >= 2
        @status_window.opacity -= 25
        @status_window.contents_opacity -= 25
      end
      Graphics.update
    end
    Graphics.freeze
    @sprite.dispose
    @status_window.dispose
  end
end

#===============================================================================
# ¦ Scene_Save
#-------------------------------------------------------------------------------
#   Edited by mewsterus
#===============================================================================

class Scene_Save
  #-----------------------------------------------------------------------------
  # @ Main loop
  #-----------------------------------------------------------------------------
  def main
    @sprite = Spriteset_Map.new
    @help_window = Window_Help.new
    @help_window.set_text("Which file do you want to save to?", 1)
    @help_window.x = -640
    @help_window.back_opacity = 160
    @help_window.opacity = 5
    @help_window.contents_opacity = 5
    @savefile_windows = []
    for i in 0..3
      @savefile_windows.push(Window_Save.new(i))
    end
    @file_index = $game_temp.last_file_index
    @savefile_windows[@file_index].selected = true
    @savefile_windows[0].x = 640
    @savefile_windows[1].x = -640
    @savefile_windows[2].x = 640
    @savefile_windows[3].x = -640
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      if @help_window.opacity < 255
        @help_window.opacity += 25
        @help_window.contents_opacity += 25
        for i in 0..3
          @savefile_windows[i].update
          @savefile_windows[i].opacity += 25
        end
      end
      if @savefile_windows[0].x > 0
        @savefile_windows[0].x -= 64
      end
      if @savefile_windows[1].x < 0
        @savefile_windows[1].x += 64
      end
      if @savefile_windows[2].x > 0
        @savefile_windows[2].x -= 64
      end
      if @savefile_windows[3].x < 0
        @savefile_windows[3].x += 64
      end
      if @help_window.x < 0
        @help_window.x += 64
      else
        update
      end
      if $scene != self
        break
      end
    end
    for i in 0..10
      @help_window.x += 64
      @help_window.opacity -= 25
      @help_window.contents_opacity -= 25
      @savefile_windows[0].x -= 64
      @savefile_windows[1].x += 64
      @savefile_windows[2].x -= 64
      @savefile_windows[3].x += 64
      for i in 0..3
        @savefile_windows[i].opacity -= 25
        @savefile_windows[i].contents_opacity -= 25
      end
      Graphics.update
    end
    Graphics.freeze
    @sprite.dispose
    @help_window.dispose
    for i in @savefile_windows
      i.dispose
    end
  end
  #-----------------------------------------------------------------------------
  # @ Update the screen
  #-----------------------------------------------------------------------------
  def update
    @help_window.update
    for i in @savefile_windows
      i.update
    end
    if Input.trigger?(Input::C)
      on_decision("Save#{@file_index + 1}.rxdata")
      $game_temp.last_file_index = @file_index
      return
    end
    if Input.trigger?(Input::B)
      on_cancel
      return
    end
    if Input.repeat?(Input::DOWN)
      if Input.trigger?(Input::DOWN) or @file_index < 3
        $game_system.se_play($data_system.cursor_se)
        @savefile_windows[@file_index].selected = false
        @file_index = (@file_index + 1) % 4
        @savefile_windows[@file_index].selected = true
        return
      end
    end
    if Input.repeat?(Input::UP)
      if Input.trigger?(Input::UP) or @file_index > 0
        $game_system.se_play($data_system.cursor_se)
        @savefile_windows[@file_index].selected = false
        @file_index = (@file_index + 3) % 4
        @savefile_windows[@file_index].selected = true
        return
      end
    end
  end
  #-----------------------------------------------------------------------------
  # @ Decision command
  #-----------------------------------------------------------------------------
  def on_decision(filename)
    $game_system.se_play($data_system.save_se)
    file = File.open(filename, "wb")
    characters = []
    for i in 0...$game_party.actors.size
      actor = $game_party.actors[i]
      characters.push([actor.character_name, actor.character_hue])
    end
    Marshal.dump(characters, file)
    Marshal.dump(Graphics.frame_count, file)
    $game_system.save_count += 1
    $game_system.magic_number = $data_system.magic_number
    Marshal.dump($game_system, file)
    Marshal.dump($game_switches, file)
    Marshal.dump($game_variables, file)
    Marshal.dump($game_self_switches, file)
    Marshal.dump($game_screen, file)
    Marshal.dump($game_actors, file)
    Marshal.dump($game_party, file)
    Marshal.dump($game_troop, file)
    Marshal.dump($game_map, file)
    Marshal.dump($game_player, file)
    file.close
    @savefile_windows[@file_index].refresh
    if $game_temp.save_calling
      $game_temp.save_calling = false
      $scene = Scene_Map.new
      return
    end
    $scene = Scene_Menu.new(4)
  end
  #-----------------------------------------------------------------------------
  # @ Cancel command
  #-----------------------------------------------------------------------------
  def on_cancel
    $game_system.se_play($data_system.cancel_se)
    if $game_temp.save_calling
      $game_temp.save_calling = false
      $scene = Scene_Map.new
      return
    end
    $scene = Scene_Menu.new(4)
  end
end

#===============================================================================
# ¦ Main
#-------------------------------------------------------------------------------
#   Edited by mewsterus
#===============================================================================

begin
  $ipm_enabled = true
  #-----------------------------------------------------------------------------
end

Observação: se você gostou deste post ou ele lhe foi útil de alguma forma, por favor considere apoiar financeiramente a Gaming Room. Fico feliz só de ajudar, mas a contribuição do visitante é muito importante para que este site continua existindo e para que eu possa continuar provendo este tipo de conteúdo e melhorar cada vez mais. Clique aqui e saiba como. Obrigado!

Deixe um comentário

Inscreva-se na nossa newsletter!