KItemDesc VX

KItemDesc VX Zilsel Version
version 1.0.2

by Kyonides Arkanthes
​


Introduction


This scriptlet just pretends to implement zlsl's need of a different item description menu by adding an extra window to display an icon or picture plus the hero's comment.

You may also want to activate a global switch to show skills as if they were simple items! :shocked: Don't worry! You can deactivate that at any given time!

Warning: The player cannot change this on his own so you would need to let them use an event as a trigger.

Just paste it in a script section above Main but below Scene_Debug.

Screenshot

kitemdescvx01.jpg
​

The Script
Code:
# * KItemDesc VX Zilsel Version
#   Scripter : Kyonides Arkanthes
#   v1.0.2 - 2019-11-30

# This scriptlet allows you to show custom icons and comments in the Inventory
# Menu scene. It will show the party leader's opinion on a given item.
# Optional: Place large icons in Graphics/Pictures folder with their item names.
# You may also allow the player to check out his or her skills on the same menu
# by activating a global switch via an event command. It can be deactivated at
# any given time!

module KItemDesc
  INCLUDE_SKILLS_SWITCH_ID = 1
  PICTURE_X = 12
  PICTURE_Y = 12
  PICTURE_CENTER_X = true # true - Ignores X coordinate, false - uses X
  PICTURE_CENTER_Y = true # true - Ignores Y coordinate, false - uses Y
  COMMENTS_Y = 180
  ACTOR_OPINION_LABEL = "%s's Opinion"
  # Comments may include newlines alias \n if needed.
  DEFAULT_COMMENT = "The hero has nothing to say\nabout this"
  @comments = {} # There's no need to edit this line.
  # [[Kind, ID]] = { ActorID => "Hero's comment on current item", etc. }
  # Kind Options - :item, :weapon, :armor, :skill - Check the following example.
  @comments[[:item, 1]] = {
    1 => "You know, I'll never need\npotions for I'm invincible!"
  }
  @comments.default = {} # Do not touch this! It will eat you alive!
  def self.comments() @comments end
end

module Cache
  def self.picture(filename) load_bitmap('Graphics/Pictures', filename) end
end

class Game_Party
  def leader() $game_actors[@actors[0]] end
end

class ItemDescWindow < Window_Base
  include KItemDesc
  def initialize
    super(272, 56, 272, 360)
    self.contents = Bitmap.new(width - 32, height - 32)
  end

  def refresh(new_item)
    return if @item == new_item
    @item = new_item
    c = self.contents
    c.clear
    return if @item.nil?
    lid = $game_party.leader.id
    name = $game_party.leader.name
    key = [@item.type, @item.id]
    comments = KItemDesc.comments[key][lid] || DEFAULT_COMMENT
    comments = comments.split("\n")
    text = sprintf(ACTOR_OPINION_LABEL, name)
    w = width - 32
    begin
      bit = Cache.picture(@item.name)
      rect = Rect.new(0, 0, bit.width, bit.height)
      icon_x = PICTURE_CENTER_X ? w / 2 - bit.width / 2 : PICTURE_X
      icon_y = PICTURE_CENTER_Y ? COMMENTS_Y / 2 - bit.height / 2 : PICTURE_Y
      c.blt(icon_x, icon_y, bit, rect)
    rescue
      icon_x = PICTURE_CENTER_X ? w / 2 - 12 : PICTURE_X
      icon_y = PICTURE_CENTER_Y ? COMMENTS_Y / 2 - 12 : PICTURE_Y
      draw_icon(@item.icon_index, icon_x, icon_y)
    end
    c.draw_text(0, COMMENTS_Y, 288, 24, text)
    comments.size.times do |n|
      c.draw_text(0, COMMENTS_Y + 28 + n * 24, 288, 24, comments[n])
    end
  end
end

module RPG
  class Item
    def type() :item end
  end

  class Weapon
    def type() :weapon end
  end

  class Armor
    def type() :armor end
  end

  class Skill
    def type() :skill end
  end
end

class Game_Party
  def item_number(item)
    number = case item
    when RPG::Item then @items[item.id]
    when RPG::Weapon then @weapons[item.id]
    when RPG::Armor then @armors[item.id]
    when RPG::Skill then skill_number(item.id)
    end
    number || 0
  end
  def item_keys() @items.keys.sort end
  def weapon_keys() @weapons.keys.sort end
  def armor_keys() @armors.keys.sort end
  def skills() @actors.map{|a| a.skills } end
  def skill_number(item_id) skills.select{|n| n == item_id}.size end
end

class Window_Item
  alias :kyon_itemdesc_win_item_up_help :update_help
  def initialize(x, y, width, height)
    super(x, y, width, height)
    self.index = 0
    @column_max = 2 if $game_temp.in_battle
    refresh
  end

  def refresh
    @data = []
    $game_party.item_keys.each do |i|
      @data << $data_items[i]
      self.index = @data.size - 1 if i == $game_party.last_item_id
    end
    unless $game_temp.in_battle
      $game_party.weapon_keys.each{|i| @data << $data_weapons[i] }
      $game_party.armor_keys.each{|i| @data << $data_armors[i] }
      if $game_switches[KItemDesc::INCLUDE_SKILLS_SWITCH_ID]
        $game_party.skills.each{|i| @data << $data_skills[i] }
      end
    end
    @data << nil if include?(nil)
    @item_max = @data.size
    create_contents
    @item_max.times{|i| draw_item(i) }
    @desc_window.refresh(@data[@index]) if @desc_window
  end

  def desc_window=(new_window)
    @desc_window = new_window
    @desc_window.refresh(@data[@index])
  end

  def update_help
    kyon_itemdesc_win_item_up_help
    @desc_window.refresh(@data[@index]) if @desc_window
  end
end

class Scene_Item
  alias :kyon_itemdesc_scn_item_term :terminate
  def start
    create_menu_background
    @viewport = Viewport.new(0, 0, 544, 416)
    @item_desc = ItemDescWindow.new
    @help_window = Window_Help.new
    @help_window.viewport = @viewport
    @item_window = Window_Item.new(0, 56, 272, 360)
    @item_window.viewport = @viewport
    @item_window.active = false
    @item_window.help_window = @help_window
    @item_window.desc_window = @item_desc
    @target_window = Window_MenuStatus.new(0, 0)
    hide_target_window
  end

  def terminate
    kyon_itemdesc_scn_item_term
    @item_desc.dispose
  end
end

Terms & Conditions

Free for use in any kind of videogame, but you must include my nickname and the URL in your game credits.
Nice script! Good to see RGSS2 scripters around.

Original thread: https://forums.rpgmakerweb.com/threads/kitemdesc-vx.115824/