Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

A Different Type of Inventory

Ignore the other thread I made, I thought of a better inventory I need.

If anybody can make it, please help. It's basically the same thing as the default inventory, only having the items arranged depending on what kind they are, and with some other things moved around.

This should explain everything:
http://www.carrotworks.net/Items.png
 
Key items are just items you need and can't use or sell.
Battle items are items that can only be used in battle, and can be sold.

And in my game, none of the items restore both HP and SP.

I guess it could be done like this:

If the item can NEVER be used, it goes in the first column
If the item can ALWAYS be used, it goes in the second column
If the item can be used ONLY IN BATTLE, it goes in the third column

I'm not too worried about separating HP and SP items, so if they go in the same column, it's okay.
 
How's this look?
http://img292.imageshack.us/img292/3439/newwindowitemjf9.th.png[/img]

I left the icons in the list. And the "+500 HP" is just part of the description. 

Paste the following script above Main.

Code:
#==============================================================================
# ** Window_Item
#------------------------------------------------------------------------------
#  This window displays items in possession on the item and battle screens.
#==============================================================================

class Window_Item < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 64, 640, 416)
    @column_max = 3
    refresh
    self.index = 0
    # If in battle, move window to center of screen
    # and make it semi-transparent
    if $game_temp.in_battle
      self.y = 64
      self.height = 256
      self.back_opacity = 160
    end
  end
  #--------------------------------------------------------------------------
  # * Get Item
  #--------------------------------------------------------------------------
  def item
    return @data[self.index]
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    reg_items = []
    battle_items = []
    key_items = []
    item_count = 0
    # Sort items by occasion type
    for i in 1...$data_items.size
      if $game_party.item_number(i) > 0
        if $data_items[i].occasion == 0    # ALWAYS
          reg_items.push($data_items[i])
          item_count += 1
        end
        if $data_items[i].occasion == 1    # BATTLE
          battle_items.push($data_items[i])
          item_count += 1
        end
        if $data_items[i].occasion == 3    # NEVER
          key_items.push($data_items[i])
          item_count += 1
        end
      end
    end
    # add the items to the data array
    rows = [reg_items.size, battle_items.size, key_items.size].max
    for i in 0...rows
      if i < key_items.size
        @data.push(key_items[i])
      else
        @data.push($data_items[33])        # Empty item
      end
      if i < reg_items.size
        @data.push(reg_items[i])
      else
        @data.push($data_items[33])        # Empty item
      end
      if i < battle_items.size
        @data.push(battle_items[i])
      else
        @data.push($data_items[33])        # Empty item
      end
    end
   # If item count is not 0, make a bit map and draw all items
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #--------------------------------------------------------------------------
  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 % 3 * (216)
    y = index / 3 * 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, 132, 32, item.name, 0)
  end
  #--------------------------------------------------------------------------
  # * Help Text Update
  #--------------------------------------------------------------------------
  def update_help
    number = "x"
    number += $game_party.item_number(self.item.id).to_s
    @help_window.set_text(self.item == nil ? "" : self.item.description, 0, number)
  end
end

class Window_Help < Window_Base
  #--------------------------------------------------------------------------
  # * Set Text
  #  text  : text string displayed in window
  #  align : alignment (0..flush left, 1..center, 2..flush right)
  #--------------------------------------------------------------------------
  def set_text(text, align = 0, right_text = "")
    # If at least one part of text and alignment differ from last time
    if text != @text or align != @align
      # Redraw text
      self.contents.clear
      self.contents.font.color = normal_color
      self.contents.draw_text(4, 0, self.width - 40, 32, text, align)
      if right_text != ""
        self.contents.draw_text(4, 0, self.width - 40, 32, right_text, 2)
      end
      @text = text
      @align = align
      @actor = nil
    end
    self.visible = true
  end
end

Be Well
 
Ah crap. We need an "Empty" item to fill in the blank spots.

In the database, create a new item. (Change the maximum +1).
Don't change anything EXCEPT set the "Occasion" to "Never"  (no Name, no Icon, no nothing)
Note the number of this new item.

Now look in the script. There are 3 lines that read:

        @data.push($data_items[33])        # Empty item

Change the '33' to the number of your Empty (blank) item.

that should do it.

Be Well
 
Well, it makes the items appear, but it's glitched up.

Everytime I add more than 1 kind of item to the inventory, it doesn't add the last one at all, but if another item category has more columns filled up than the other, it will add it.

Is it maybe possible to stick the item categories in 3 separate windows on the inventory screen? That sounds like it might solve the problem.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top