KItemDesc VX

kyonides

Veteran
Veteran
Joined
Nov 17, 2019
Messages
54
Reaction score
13
First Language
English
Primarily Uses
RMXP
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


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.
 

TengHu

Abscond Games
Veteran
Joined
Mar 16, 2012
Messages
469
Reaction score
119
First Language
English
Primarily Uses
RMVX
Nice script! Good to see RGSS2 scripters around.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Rpg MZ looking good! Not much of a fan of the graphics for world tiles, but love the changes for sprites and movement preview!
Before I am done with even one game, I am going to need Psychiatric assistance after doing all these sprites!
Still I am improving, Spriting not mental fortitude.
It's still early days, and I was going to keep this under wraps until development is a bit further along, but I'm just so damn proud of how robust the integrity-checking in this plugin is that I have to share it.
Do you think the new RPG Maker MZ has support for Android devices ?
JDgoldvox wrote on Mr. Detective's profile.
hey, could u help me with a problem? basically, How do I delete a character from a map after a cut scene is over? I am really new with RPG maker MV. Please help!

Forum statistics

Threads
99,265
Messages
963,659
Members
130,863
Latest member
AdamEternal
Top