[Script] [ACE] [MENU] Custom Item Screen - Version 1.3

nhoxboy73nhoxboy73 Posts: 776Registered
GIỚI THIỆU:
Script thay đổi menu item mặc định bằng menu khác đẹp hơn

TÍNH NĂNG:
- Change categories with Left and Right arrows. Cursor position is remembered per category.
- Display an enlarged item graphic
- Display HP, MP and TP recovery along with states added and removed on item
- Display stats (MaxHP, Def, Agi, etc) and State/Element Resistances on Armour and stats with State/Element infliction on Weapons
-TP Recovery is hidden if "Display TP In Battle" is unticked

SCREENSHOT:
scaled.php?server=443&filename=screenshot001n.png&res=landing
scaled.php?server=818&filename=screenshot002dk.png&res=landing
scaled.php?server=23&filename=screenshot003cb.png&res=landing
scaled.php?server=831&filename=screenshot004sv.png&res=landing
DEMO:
Không có
SCRIPT:
#=====================================#
#--Notunknown99's Custom Item Screen--#
#------V1.3 for RPG MAKER VX ACE------#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
# This script alters the item screen, #
#showing the stats of items and allows#
#users to scroll through the different#
# categories using the left and right #
#        arrow keys on their keyboard.   #
#=====================================#
module CustomItemScreen
  Recover                          = "Recover"   #Used for recovery EG: 'Recover HP'
  StateAdds                      = "Adds"         #Used for 'State Added' icons
  StateRemoves            = "Removes"   #Used for 'State Added' icons
  Resists                          = "Resists"   #Used for showing armour state/element resists
  Inflicts                        = "Inflicts"  #Used for showing weapon element damage
  MaxIcons                        = 7              #How many state icons can be displayed (Will scroll if number of states exceeds this number, crash if 1 or less)
  EmptyIcon                      = 187           #Used when inventory slot is empty
  Icons = [                                                #Icons for element resistance
  116,                                                          #Physical
  120,                                                          #Absorb
  96,                                                            #Fire
  97,                                                            #Ice
  98,                                                            #Thunder
  99,                                                            #Water
  100,                                                          #Earth
  101,                                                          #Wind
  102,                                                          #Holy
  103                                                            #Dark
  ]
end
#========================================#
#--WARNING: EDIT BELOW AT YOUR OWN RISK--#
#========================================#
class Window_ItemList < Window_Selectable
  def initialize(x, y, width, height)
        super(x, y, width, fitting_height(11))
        @category = :none
        @data = []
        @index_last_item = 0
        @index_last_weapon = 0
        @index_last_armor = 0
        @index_last_key_item = 0
  end
  def category_window=(category_window)
        @category_window = category_window
  end
  def info_window=(info_window)
        @info_window = info_window
  end
  def col_max
        return 1
  end
  def cursor_movable?
        active && open? && !@cursor_fix && !@cursor_all
  end
  def process_cursor_move
        return unless cursor_movable?
        last_index = @index
        last_category = @category
        cursor_down (Input.trigger?(:DOWN))  if Input.repeat?(:DOWN) && item_max > 0
        cursor_up   (Input.trigger?(:UP))          if Input.repeat?(:UP)   && item_max > 0
        cursor_right if Input.repeat?(:RIGHT)
        cursor_left  if Input.repeat?(:LEFT)
        cursor_pagedown   if !handle?(:pagedown) && Input.trigger?(:R)
        cursor_pageup   if !handle?(:pageup)   && Input.trigger?(:L)
        Sound.play_cursor if @index != last_index or @category != last_category
        @info_window.category = @category if @info_window
        @info_window.item = item if @info_window
  end
  def cursor_left
        if @category == :item
          @index_last_item = @index
          self.category = :key_item
          @index = @index_last_key_item
          update_cursor
        else
          if @category == :key_item
                @index_last_key_item = @index
                self.category = :armor
                @index = @index_last_armor
                update_cursor
          else
                if @category == :armor
                  @index_last_armor = @index
                  self.category = :weapon
                  @index = @index_last_weapon
                  update_cursor
                else
                  @index_last_weapon = @index
                  self.category = :item
                  @index = @index_last_item
                  update_cursor
                end
          end
        end
        update_category
        update_help
  end
  def cursor_right
        if @category == :item
          @index_last_item = @index
          self.category = :weapon
          @index = @index_last_weapon
          update_cursor
        else
          if @category == :weapon
                @index_last_weapon = @index
                self.category = :armor
                @index = @index_last_armor
                update_cursor
          else
                if @category == :armor
                  @index_last_armor = @index
                  self.category = :key_item
                  @index = @index_last_key_item
                  update_cursor
                else
                  @index_last_key_item = @index
                  self.category = :item
                  @index = @index_last_item
                  update_cursor
                end
          end
        end
        update_category
        update_help
  end
  def update_category
        @category_window.text = get_text
        @category_window.refresh
  end
  def get_text
        return Vocab::item if @category == :item
        return Vocab::weapon if @category == :weapon
        return Vocab::armor if @category == :armor
        return Vocab::key_item if @category == :key_item
        return "----"
  end
end
class Window_ItemCategoryCentre < Window_Base
  def initialize(x, y, w, h = 0)
          super(x, y, w, fitting_height(1) + h)
          @text = "----"
          @extra_h = h
          refresh
  end
  def text=(text)
        @text = text
  end
 
  def get_width
        return width - standard_padding * 2
  end
  def refresh
        contents.clear
        draw_text(0, @extra_h / 2, get_width, line_height, @text, 1)
        change_color(system_color)
        draw_text(0, @extra_h / 2, get_width, line_height, "←", 0)
        draw_text(0, @extra_h / 2, get_width, line_height, "→", 2)
        change_color(normal_color)
  end
end
   
class Window_ItemInfo < Window_Base
  def initialize(x, y, w, h)
        super(x, y, w, h)
        @item = nil
        @category = :item
        @start_frame = Graphics.frame_count
        @iconsprites = []
        refresh
  end
  def category=(category)
        @category = category
        refresh
  end
  def item=(item)
        @item = item
        refresh
  end
 
  def window_x
        return x
  end
 
  def window_y
        return y
  end
 
  def draw_rect(x, y, width, height)
        contents.fill_rect(x, y, width, height, Font.default_out_color)
  end
  def get_rect_y(line)
        return (line_height + 16) * (line / 2).floor
  end
  def rect_width
        return width - standard_padding * 2
  end
  def rect_height
        return height - standard_padding * 2
  end
  def get_resists(weapon = false)
        icons = []
        for feature in @item.features
          #icons.push(feature.code) #Debugging! Yay!
          if weapon
                case feature.code
                when 31
                  icons.push(CustomItemScreen::Icons[feature.value])
                when 32
                  icons.push($data_states[feature.data_id].icon_index)
                end
          else
                case feature.code
                when 14
                  icons.push($data_states[feature.data_id].icon_index)
                when 13
                  if feature.value < 1
                                icons.push($data_states[feature.data_id].icon_index)
                  end
                when 11
                  if feature.value < 1
                                icons.push(CustomItemScreen::Icons[feature.data_id])
                  end
                end
          end
        end
        return icons
  end
  def draw_dicons(x, y, icons) #Debugging! Yay!
        x -= (icons.size + 1) * 24
        for icon_id in icons
          x += 24
          draw_text(x, y, 24, 24, icon_id)
        end
  end
  def draw_equip_rects
        draw_rect(rect_width / 2 - 52, 8, 104, 104)
        for i in 0..7
          side = i % 2
          x = (side * (rect_width / 2 + 4))
          y = get_rect_y(i)
          param_text = Vocab::param(i) + ": "
          draw_rect(x, y + 128, rect_width / 2 - 4, line_height + 8)
          change_color(system_color)
          draw_text(x + 4, y + 132, rect_width / 2 - 8, line_height, param_text)
          change_color(normal_color)
        end
        draw_rect(0, 288, rect_width, line_height + 8)
        change_color(system_color)
        draw_text(4, 292, rect_width - 8, line_height,
          (@item.is_a?(RPG::Weapon) ? CustomItemScreen::Inflicts :
          CustomItemScreen::Resists) + ":")
        change_color(normal_color)
  end
  def draw_equip_stats(draw = true)
        return if @item.is_a?(RPG::Item)
        if draw
          index = @item.icon_index
          bitmap = Cache.system("Iconset")
          rect = Rect.new(index % 16 * 24, index / 16 * 24, 24, 24)
          target = Rect.new(rect_width / 2 - 48, 16, 96, 96)
          contents.stretch_blt(target, bitmap, rect)
          for i in 0..7
                side = i % 2
                x = (side * (rect_width / 2 + 4))
                y = get_rect_y(i)
                param_text = Vocab::param(i) + ": "
                stat = @item.params[i]
                draw_text(x + 4, y + 132, rect_width / 2 - 8, line_height, stat, 2)
          end
          draw_icons(0, 292, get_resists(@item.is_a?(RPG::Weapon)))
        else
          index = CustomItemScreen::EmptyIcon
          bitmap = Cache.system("Iconset")
          rect = Rect.new(index % 16 * 24, index / 16 * 24, 24, 24)
          target = Rect.new(rect_width / 2 - 44, 12, 96, 96)
          contents.stretch_blt(target, bitmap, rect)
          for i in 0..7
                side = i % 2
                x = (side * (rect_width / 2 + 4))
                y = get_rect_y(i)
                draw_text(x + 4, y + 132, rect_width / 2 - 8, line_height, "----", 2)
          end
          draw_text(4, 292, rect_width - 4, line_height, "----", 2)
        end
  end
  def get_recover(code)
        per = 0
        inc = 0
        for effect in @item.effects
          next unless effect.code == code
          per += (effect.value1 * 100).to_i()
          inc += (effect.value2).to_i()
        end
        per_text = per > 1 ? ("+" + per.to_s() + "%")  : (per.to_s() + "%")
        inc_text = inc > 1 ? ("+" + inc.to_s())  : inc.to_s()
        if (per != 0 && inc != 0)
          return per_text + " " + inc_text
        else if (per == 0 && inc != 0)
                return inc_text
          else if (per != 0 && inc == 0)
                  return per_text
                else
                  return "----"
                end
          end
        end
  end
  def get_rem_states
        icons = []
        for effect in @item.effects
          case effect.code
          when 22
                        icons.push($data_states[effect.data_id].icon_index)
          when 33
                        icons.push($game_actors[1].buff_icon_index(1, effect.data_id))
          when 34
                        icons.push($game_actors[1].buff_icon_index(-1, effect.data_id))
          end
        end
        return icons
  end
  def get_add_states
        icons = []
        for effect in @item.effects
          case effect.code
          when 21
                        icons.push($data_states[effect.data_id].icon_index)
          when 31
                        icons.push($game_actors[1].buff_icon_index(1, effect.data_id))
          when 32
                        icons.push($game_actors[1].buff_icon_index(-1, effect.data_id))
          end
        end
        return icons
  end
 
  def icon_frame(overflow)
        (((Graphics.frame_count - @start_frame) / Graphics.frame_rate %
        (overflow * 24)) - (overflow * 12)).abs
  end
  def draw_icons(x, y, icons)
        inum = CustomItemScreen::MaxIcons
        overflow = icons.size > inum ? icon_frame(icons.size % inum) : 0
        @iconviewport.rect =
          Rect.new(window_x + x + rect_width - (inum * 24 - 8), window_y + y + 12,
          inum * 24, 24)
        @iconviewport.ox = (overflow * 2)
        x = 144 - (icons.size > inum ? inum * 24 : icons.size * 24)
        for icon_id in icons
          x += 24
          sprite = Sprite.new(@iconviewport)
          sprite.bitmap = Cache.system("Iconset")
          sprite.src_rect = Rect.new(icon_id % 16 * 24, icon_id / 16 * 24, 24, 24)
          sprite.x = x
          @iconsprites.push(sprite)
          end
        draw_text(4, y, rect_width - 8, line_height, "----", 2) if icons.size == 0
  end
  def draw_item_rects(type)
        if type
          draw_rect(rect_width / 2 - 52, 8, 104, 104)
          tp = $data_system.opt_display_tp
          for i in 0..(tp ? 2 : 1)
                y = i * (line_height + 16)
                draw_rect(0, y + 128, rect_width, line_height + 8)
                change_color(system_color)
                draw_text(4, y + 132, rect_width, line_height,
                  CustomItemScreen::Recover + " " + Vocab::basic(3 + (2 * i)) + ":")
                change_color(normal_color)
          end
          icons_y = (tp ? 3 * (line_height + 16) : 2 * (line_height + 12))
          draw_rect(0, icons_y + 128, rect_width, line_height + 8)
          draw_rect(0, icons_y + line_height + 144, rect_width, line_height + 8)
          change_color(system_color)
          draw_text(4, icons_y + 132, rect_width - 8, line_height,
                        CustomItemScreen::StateAdds + ":")
          draw_text(4, icons_y + line_height + 148, rect_width - 8, line_height,
                        CustomItemScreen::StateRemoves + ":")
          change_color(normal_color)
        else
          draw_rect(rect_width / 2 - 72, rect_height / 2 - 72, 144, 144)
        end
  end
  def draw_item_stats(key_items = false, draw = true)
        return if @item.is_a?(RPG::Weapon) || @item.is_a?(RPG::Armor)
        if draw
          if @item.itype_id == 1
                index = @item.icon_index
                bitmap = Cache.system("Iconset")
                rect = Rect.new(index % 16 * 24, index / 16 * 24, 24, 24)
                target = Rect.new(rect_width / 2 - 48, 16, 96, 96)
                contents.stretch_blt(target, bitmap, rect)
                tp = $data_system.opt_display_tp
                for i in 0..(tp ? 2 : 1)
                  y = i * (line_height + 16)
                  draw_text(4, y + 132, rect_width - 4, line_height, get_recover(11 + i), 2)
                end
                icons_y = (tp ? 3 * (line_height + 16) : 2 * (line_height + 12))
                draw_icons(0, icons_y + 132, get_add_states)
                draw_icons(0, icons_y + line_height + 148, get_rem_states)
          else
                index = @item.icon_index
                bitmap = Cache.system("Iconset")
                rect = Rect.new(index % 16 * 24, index / 16 * 24, 24, 24)
                target = Rect.new(rect_width / 2 - 64, rect_height / 2 - 64, 128, 128)
                contents.stretch_blt(target, bitmap, rect)
          end
        else if !key_items
                index = CustomItemScreen::EmptyIcon
                bitmap = Cache.system("Iconset")
                rect = Rect.new(index % 16 * 24, index / 16 * 24, 24, 24)
                target = Rect.new(rect_width / 2 - 44, 12, 96, 96)
                contents.stretch_blt(target, bitmap, rect)
                tp = $data_system.opt_display_tp
                for i in 0..(tp ? 2 : 1)
                  y = i * (line_height + 16)
                  draw_text(4, y + 132, rect_width - 4, line_height, "----", 2)
                end
                icons_y = (tp ? 3 * (line_height + 16) : 2 * (line_height + 12))
                draw_text(4, icons_y + 132, rect_width - 4, line_height, "----", 2)
                draw_text(4, icons_y + line_height + 148, rect_width - 4,
                  line_height, "----", 2)
          else
                index = CustomItemScreen::EmptyIcon
                bitmap = Cache.system("Iconset")
                rect = Rect.new(index % 16 * 24, index / 16 * 24, 24, 24)
                target = Rect.new(rect_width / 2 - 64, rect_height / 2 - 64, 128, 128)
                contents.stretch_blt(target, bitmap, rect)
          end
        end
  end
  def refresh
        for sprite in @iconsprites
          sprite.dispose
        end
        contents.clear
        @iconviewport.dispose if @iconviewport
        @iconviewport = Viewport.new
        @iconviewport.z = 200
        if @category == :item || @category == :key_item
          draw_item_rects(@category == :item)
          draw_item_stats(@category == :key_item, @item)
        else
          draw_equip_rects
          draw_equip_stats(@item)
        end
  end
end
class Scene_Item < Scene_ItemBase
  def start
        super
        create_help_window
        create_category_window
        create_item_window
        create_info_window
  end
  def create_category_window
        wy = @help_window.height
        ww = 252
        @category_window = Window_ItemCategoryCentre.new(0, wy, ww, 8)
        @category_window.viewport = @viewport
  end
  def create_info_window
        wy = @help_window.height
        ww = Graphics.width - 252
        @info_window = Window_ItemInfo.new(252, wy, ww, Graphics.height - wy)
        @info_window.viewport = @viewport
        @item_window.info_window = @info_window
        @info_window.item = @item_window.item
  end
  def create_item_window
        wy = @help_window.height + @category_window.height
        wh = Graphics.height - wy
        ww = 252
        @item_window = Window_ItemList.new(0, wy, ww, wh)
        @item_window.viewport = @viewport
        @item_window.help_window = @help_window
        @item_window.category_window = @category_window
        @item_window.set_handler(:ok,   method(:on_item_ok))
        @item_window.set_handler(:cancel, method(:return_scene))
        @item_window.category = :item
        @item_window.update_category
        @item_window.select_last
        @item_window.activate
  end
  def on_item_ok
        $game_party.last_item.object = item
        determine_item
  end
  def show_sub_window(window)
        width_remain = Graphics.width - window.width
        window.x = width_remain / 2
        @viewport.rect.x = @viewport.ox = 0
        @viewport.rect.width = 0
        window.show.activate
  end
end
HƯỚNG DẪN:
Chèn trên Main
Có thể chỉnh sửa lại trong phần module CustomItemScreen nếu cần thiết

GHI CHÚ:
Không có

CREDIT:
Notunknown
Chú cún của Notunknown
SOURCE:
rpgmakervxace.net

Comments

  • Focker_cFocker_c Posts: 1,577Registered
    Chẳng có gì đáng để nói là "đẹp hơn" cả. Hay bạn đang nói cái hình Item đc phóng to bự bừ (đến nỗi nồi cả pixel) và đặt ra bên cạnh ?
Sign In or Register to comment.