Main Menu
  • Welcome to The RPG Maker Resource Kit.

Grid Inventory 1.0f

Started by modern algebra, July 31, 2009, 06:32:22 AM

0 Members and 2 Guests are viewing this topic.

modern algebra

Grid Inventory
Version: 1.0f
Author: modern algebra
Date: August 22, 2010

Version History




  • <Version 1.0f> 08.22.2010 - A bug fix with regard to non-consumable items becoming unusable after one use
  • <Version 1.0e> 06.16.2010 - A bug fix with regard to selling items within a non-lead actor's inventory
  • <Version 1.0d> 05.22.2010 - Several bug fixes, including the bug when opening loot after battle
  • <Version 1.0b> 08.03.2009 - Several Bug Fixes including disappearing items when unequipping, and a false disabling of the Unequip option occasionally. Also, a game crashing bug would occur when trying to draw the capacity stats of an inventory. If that problem occurs to you, redownload the script.
  • <Version 1.0> 07.31.2009 - Original Release

Description



  This script does multiple things. First: it gives each actor their own inventory. Second: that inventory is displayed through a grid, with each item taking up a specific amount of squares. How many squares is completely customizable for each and every item.

  You are also able to set a maximum number of instances of that item each slot can hold. This means that for each item, say for instance, arrows, you can define how many arrows could fit into one displayed slot of arrows. See the demo for clarification.

  You can also set a picture graphic for each item, though if you do not it will default to using the item's icon. Beyond that, you can easily set up permanent storage events, each of which are easy to set up and save what items are stored in them at any given time. When received, items will be automatically distributed amongst the party in order, meaning that they will be given to the first party member, then the second once the first party member's inventory is full, and so on. If, upon gaining an item, you cannot fit that item or items into the party member's inventories, it will call up a loot inventory and the player can decide which items to discard and which to keep. As well, you can customize the size of each actor's inventory and you can modify that at any time with a simple script call.

  A good system to compare this to is the system from Betrayal at Krondor, as that is what it was based on, but as that is not very well known, this system is similar to the item system of the Diablo series.

Features


  • Actors have individual inventories that are based on a grid system, much like Betrayal at Krondor
  • Items can be assigned a width and height, as well as a maximum stack size
  • You can use Item Graphics created by grafikal or create your own, and you can also set the hue so that the same graphic can be used for multiple items
  • Has a full Information screen that allows the player to see the actual stats of an item
  • You can Use, Equip, Unequip, Transfer, Discard, and Move items around all from the Inventory. The player has full control over his inventories.
  • You can create permanent storage items to hold the party's items and give them new ones
  • If the party gains too many items, it will automatically open a loot inventory as a temporary inventory until all the items can be arranged

Screenshots


The options when selecting an item in an actor's inventory


The options when selecting an item in Loot


The options when selecting a blank space in an actor's inventory


The Information Screen

Instructions
All of the item setup is done in the Notes box of the item you are setting up. There are six commands you can use:
     \width[integer]
       integer : any positive integer. This represents how many squares the item requires horizontally

     \height[integer]
       integer : any positive integer. This represents how many squares the item requires vertically

     \maxstack[integer]
       integer : any positive integer. This represents how many of the same item can occupy the same space before a new slot for the item has to be created.

     \picture[filename]
       filename : a name of a picture file in the Inventory folder. This will be the picture of the item in the inventory. if you don't set a picture, it will use the icon of the item instead.

     \picture_hue[integer]
       integer : any positive or negative integer. This allows you to change the hue of the picture used.

      \nondiscard
        this option sets the item as undiscardable through the inventory scene. Bear in mind that it does not prevent the player from storing the item, and if the item is in Loot, then it can still be destroyed.

     \colour[red, green, blue, alpha]
       this option allows you to give any item a unique colour, and not just the default colour for its type. The arguments to pass are self-explanatory. alpha for the default colours is 160.

    To open a storage unit, you can simply use this code in a call script:

      open_storage (storage_id[, items[, name[, icon[, size]]]])
        storage_id : the ID of the storage box to open
        items      : the items array, each entry: [type, id, amount]     
        name       : the name of the storage box being opened 
        icon       : the name of the bitmap associated with this storage item
        size       : the size array for this item => [width, height]

   items, name, icon, and size can be excluded when opening the storage and the storage will start with default settings. Further, they are only valid the very first time the storage is accessed. Thus, if you set up items to have three items in it, the only time those will be added is the first time the storage has been opened. If you wish to add items to the storage after having opened it, then you must use the command:

      add_to_storage (storage_id, items)
        storage_id : the ID of the storage box to open
        items      : the items array, each entry: [type, id, amount] 

    You can also resize inventories with the commands:

      resize_actor_inventory (actor_id, width, height)
        actor_id      : the actor whose inventory is to be resized 
        width, height : the new size parameters for the inventory
     
      resize_storage_inventory (storage_id, width, height)
        storage_id    : the actor whose inventory is to be resized
        width, height : the new size parameters for the inventory

      resize_loot_inventory (width, height)
        width, height : the new size parameters for the inventory

If you want a specific actor to receive an item, you can use this code in a call script:

  actor_gain_item (actor_id, item_type, item_id, amount)
    actor_id : ID of actor to receive item
    item_type : 0 => Item, 1 => Weapon, 2 => Armor
    item_id     : Id of item
    amount : the amount of that item to receive.

For the system and vocabulary settings, please see the editable regions at lines 107, 167, and 904

Script



See the Attached Text Document

It is recommended, however, that you retrieve the script from the demo as that way you can see how it works.

Note that this script REQUIRES the Paragraph Formatter and the Bitmap Addons script is RECOMMENDED. Both can be retrieved from the demo.

Credit




  • modern algebra
  • grafikal, if you use the item graphics included with this script

Thanks


  • Zeriab, for his table-debuggging script and for his help with the paragraph formatter

Support



Please post here in this topic if you encounter any bugs at all

Known Compatibility Issues

[spoiler=Tankentai ATB + Grid Inventory Compatibility]
Thanks to Mr. Bubble for making these scripts compatible. Just follow the directions he gives here:
Quote from: Mr. Bubble on May 07, 2011, 08:31:37 AM
[T]his script can be made compatible with the Tankentai ATB with technically one change.

On line 3215, find this line:

@item_window.ma_inventory = @active_battler.inventory

Replace that line with this:

if $imported != nil && $imported["TankentaiATB"]
  @item_window.ma_inventory = @commander.inventory
else
  @item_window.ma_inventory = @active_battler.inventory
end


It'll work with the latest version of the ATB. This is not needed without ATB.
[/spoiler]



[spoiler=Composite Characters + Grid Inventory Compatibility Patch]
Equipment does not refresh upon exiting the Inventory, so this patch fixes that. Place it in its own section below the Grid Inventory script, but still above Main.


#==============================================================================
#  Composite Characters + Grid Inventory Compatibility Patch
#  Author: modern algebra
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#    Place this in its own slot beneath the Grid Inventory script
#==============================================================================
# ** Scene GridInventory
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased method - return_scene
#==============================================================================

class Scene_GridInventory
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Return Scene
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias monalg_compchar_gridinry_ptch_rtrnscn_2jj3 return_scene
  def return_scene (*args)
    # Run Original Method
    monalg_compchar_gridinry_ptch_rtrnscn_2jj3 (*args)
    $game_player.refresh
  end
end

[/spoiler]

[spoiler=ziifee's WGB + Grid Inventory Patch]

An error will popup in battle if you are using the Wait-Guage battle. The code below fixes that error. Just place the Grid Inventory script into a slot BELOW ziifee's scripts and then put the following code in its own slot BELOW Grid Inventory.


#==============================================================================
#    Grid Inventory + ziifee's WGB Compatibility Patch
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#
#    Place Grid Inventory below ziifee's scripts and this patch beneath the
#   Grid Inventory
#==============================================================================

#==============================================================================
# ** Scene Battle
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    overwritten method - start_item_selection
#==============================================================================

class Scene_Battle
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Start Item Selection
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def start_item_selection (*args)
    # Run Original Method
    modalr_invgrid_slctitm_windo_4h21 (*args)
    return unless  ModernAlgebra::GI_PERSONAL_ITEM_USE
    # Setup inventory
    @item_window.ma_inventory = @select_battler.inventory
    @item_window.refresh
  end
end
[/spoiler]

I imagine it would have some problems with exotic CMSes and scripts that alter Equip and Item significantly. Note that it is possible to not hide the Item and Equip scenes, if that is something you require.

It ought to work with Scene Menu REDUX as long as it is UNDER the Scene Menu Redux Script and all other scripts that utilize the Scene Menu REDUX. It should not need to be setup - it should work as soon as it is plugged in.

Though I have not tested them, it should work with KGC Custom Commands as long as you follow the same directions as for Scene Menu REDUX

I imagine it will have menu problems with my Quest Journal and my Integrated Reserve Party if you choose to hide Item and Equip, so I will be writing compatibility patches for both those scripts eventually.

Please put it Above Main but below any other custom scripts you have.

Demo



Grid Inventory System Attached

Author's Notes



I wrote this script for RMXP a long long time ago and it was riddled with bugs. I then decided to rewrite it, but VX came out and it slipped away from me, so I was left with a half-finished version of this script for XP. When I tried to go back to it, I found it hard to figure out what I was doing, and so I thought it might be a good idea to convert what I had to VX and that way I would figure out what I had done and do something productive in the process. So that is where we are now - I don't expect it to be bug-free, but I am committed to resolving any bugs you might find, so please please please report them to me! I am not taking another two years before this script finally comes out.




Grafikal

Hah! this is so awesome. I totally expected this in XP first, but this is great :)

Zero2008

DUDE! Thank you SO MUCH!
Although i am a bit confused about the grid stuff, i love the in individual inventory thing!
THANK YOU!
now my EarthBound game is complete!

You my good friend will get a special Thank You spot in the credits!

Grafikal

Lol, dude he has another Inventory script without the grid here as well.

markchapman

  is it possible to use this without knowing any scripting? it looks perfect for almost every game!
Im a RPG Maker Vetren, ive used 2K, 2K3, RMXP, and RMVX, I have my likes and dislikes with them all.

modern algebra

Yeah, it's possible to use it without knowing how to script. Just put it in the game and it's practically plug & play. Items are set up through notes boxes.

@grafikal - I have another Inventory script, but it doesn't have individual inventories for actors :(

markchapman

i hate to be the newb of the conversation but how do i do that exactly?
Im a RPG Maker Vetren, ive used 2K, 2K3, RMXP, and RMVX, I have my likes and dislikes with them all.

Grafikal

Quote from: modern algebra on August 01, 2009, 01:41:00 AM
@grafikal - I have another Inventory script, but it doesn't have individual inventories for actors :(

THIS CAN DO INDIVIDUAL ACTORS? O_o

Edit: Oh well, duh, I guess it should since it does make more sense the way the inventory is set up lol

modern algebra

Quote from: Instructions
All of the item setup is done in the Notes box of the item you are setting up. There are six commands you can use:
     \width[integer]
       integer : any positive integer. This represents how many squares the item requires horizontally

     \height[integer]
       integer : any positive integer. This represents how many squares the item requires vertically

     \maxstack[integer]
       integer : any positive integer. This represents how many of the same item can occupy the same space before a new slot for the item has to be created.

     \picture[filename]
       filename : a name of a picture file in the Inventory folder. This will be the picture of the item in the inventory. if you don't set a picture, it will use the icon of the item instead.

     \picture_hue[integer]
       integer : any positive or negative integer. This allows you to change the hue of the picture used.

      \nondiscard
        this option sets the item as undiscardable through the inventory scene. Bear in mind that it does not prevent the player from storing the item, and if the item is in Loot, then it can still be destroyed.


Multiaego

Reckon u could add Gemming into the script, for example in item description show a box 2x2 aquares and when u buy a gem it adds benefits,
First gem for example could be a green 1 , appears in the first box and adds 5% bonus to all stats , and a red one as the seocund with a further 15% stat bonus? and the cost goes up after each gem as well, just something to work on if u want i reckon it would be a handy idea :)

modern algebra

Yeah, a socketing system like in Diablo is nice; I might add one in the future, but not right now. I am also thinking of adding inventoried items (so like, you could buy a quiver which takes up 1x3, but then you can open it up and it has 2x3 slots, but the only thing that can be added to it are arrow items).

However, I am taking a break from this script for a while and only fixing bugs that people discover. In a bit, I will consider adding those extra features.

markchapman

Im a RPG Maker Vetren, ive used 2K, 2K3, RMXP, and RMVX, I have my likes and dislikes with them all.

Eruvis

#12
greetings i love your scripts! been checking out a few lately, i just tried to paste the two required scripts into my game and got this error:

Script 'Grid Inventory 1.0' Line 954: NoMethodError occurred. undefined method 'lose_item for nil:NillClass

--------------

im trying to read through your post to make sure i didnt miss anything, line 954 is:

       n = @inventory.lose_item (type, id, 1)

--------------

so far i see no instructions detailing if i need to adjust anything inside the script, they look optional.. *goes to look again*


---------------------- edit!! ---------------

i have another script called Item/Equipment/Skill Conditions which i believe is also by you, Modern Algebra, and when i removed it, the grid thing works , so im guessing thats why =) cant really see how they are interfering with each other, i'll have to sit here and scan through the scripts

========== edit #2- ==============

unequip bug:

when inventory is empty and you unequip, lets say, longsword appears in a blank space on the upper left, but the menu that says "unequip" and "optimize" is still open. if you select unequip again, the second item you choose to unequip replaces the first (the sword that was there, was overwritten by the shield i selected, making my sword disappear). i hope that made sense. basically the unequip menu needs to be terminated after one action to avoid destroying items?

modern algebra

For the first one - I can see why they would interfere. Try placing the Grid Inventory BELOW the Item/Equipment/Skill Conditions script and see if it works. Keep it above Main though.

For the second - yeah, that was an oversight on my part. Version 1.0b will fix that problem and be released momentarily.

Eruvis

hmm i tried my best, put the other script above, below, both crash. i also tried putting it in your demo for the grid inventory just to make sure i had nothing else interfering with it and no dice. once again above and below. and ideas? if u have the time to toss the script in your demo of the grid and figure out how to get it to work just by placement that would be cool. its your equipment constraints script =) both very good

modern algebra

#15
First things first, 1.0b has been up for a while, and so you can get rid of the error you reported by downloading that. Please do.

OK, I haven't tested it any further, but you can get rid of the error in this way:

You can initialize the inventory before calling setup in Game_Actor;

so, at about line 936 of the Grid Inventory, you'll see:


   modalg_grid_invtry_init_inventory_w0275 (actor_id)
   icon = ModernAlgebra::GI_DEFAULT_INVENTORY_ICON
   case actor_id
   #\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
   #  EDITABLE REGION
   #``````````````````````````````````````````````````````````````````````
   #    Here you can set individual icons for the inventories of actors,
   #   if desired. Just set it up as follows:
   #
   #       when <actor_id>
   #         icon = <integer>
   #
   #    EXAMPLE:
   #
   #       when 1
   #         icon = 50
   #
   #   would mean that actor 1's inventory (Ralph, by default), would show
   #  icon 50 next to the name of the inventory.
   #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
   when 1
     icon = 50
   #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
   #  END EDITABLE REGION
   #//////////////////////////////////////////////////////////////////////
   end
   @inventory = Game_InventoryGrid.new (actor_id, icon)


Make it:



   icon = ModernAlgebra::GI_DEFAULT_INVENTORY_ICON
   case actor_id
   #\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
   #  EDITABLE REGION
   #``````````````````````````````````````````````````````````````````````
   #    Here you can set individual icons for the inventories of actors,
   #   if desired. Just set it up as follows:
   #
   #       when <actor_id>
   #         icon = <integer>
   #
   #    EXAMPLE:
   #
   #       when 1
   #         icon = 50
   #
   #   would mean that actor 1's inventory (Ralph, by default), would show
   #  icon 50 next to the name of the inventory.
   #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
   when 1
     icon = 50
   #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
   #  END EDITABLE REGION
   #//////////////////////////////////////////////////////////////////////
   end
   @inventory = Game_InventoryGrid.new (actor_id, icon)
   modalg_grid_invtry_init_inventory_w0275 (actor_id)



Also, it was brought to my attention that the Composite Characters script would not refresh the actor graphic after changing equipment in the Inventory Scene. I have added a patch under Known Compatibility Issues that fixes that problem.

Eruvis

woot! you are awesome it works , both scripts now love each other. by just moving that one line so that you initialise inventory before calling Game_Actor? wow... i'll be trying to learn these things with time. by the way, have you ever payed ultima underworld? on PC? very old game, has similar inventory system. besides having backpacks inside of one another and arrow quivers etc that have been mentioned as possible updates, the npc's also have inventories and you can trade with them. im pretty sure its possible starting from what you have made. there is some A.I involved in terms of :

each npc has a race and each race has certain likes and dislikes, for example, if you trade a viking, you can barter almost anything they have for gold, but lizardmen like gems, so you might be able to trade 1 coin for 1 gem on a viking, but not possible for the same trade on a lizardman. it would involve making an interface and all that but, from what i see, the two chests in your demo have their own inventory, which you can remove and place items into (placing possible? i have to check again) so each npc would likewise have an inventory that acts as the chest, plus A.I and an interface.

try the game if you have not yet and keep up the great work.

Zero2008

hey i finally got around to implementing the script into the game.
But i have got an error screen. You see im using Woranata's Neo Menu script and the Grid Inventory script and the other have compatibility issues. Could you please make a patch for that? I really need this menu script...

modern algebra

To be honest, I've never heard of the Neo Menu System. Is it the same as Lite Menu?

Whatever the case, try putting the Grid Inventory script in a slot BELOW the Menu System in the script editor, but keep it above Main. If they still don't work together, then please link me to the menu script you are using and I will see what I can do.

Zero2008

LOL woops yeah i ment the Lite Menu system!

Well i did what u said and it work except now the menu is at the Top left and the menu options are lined from top to bottom..

How do i put them in the original position and order? which is the window is in the center and the menu items are 3 on each side...

modern algebra

Yeah, I can see where that might become a problem.

Go to about line 3323 and you should see this:


    @magi_equip_index = c.index (Vocab::equip) if ModernAlgebra::GI_MENU_HIDE_EQUIP && c.include? (Vocab::equip)
    @magi_item_index = c.index (Vocab::item) if ModernAlgebra::GI_MENU_HIDE_ITEM && c.include? (Vocab::item)
    c.delete (Vocab::equip) if ModernAlgebra::GI_MENU_HIDE_EQUIP
    c.delete (Vocab::item) if ModernAlgebra::GI_MENU_HIDE_ITEM
    # Add Grid Inventory Command
    c.insert (ModernAlgebra::GI_MENU_INDEX, Vocab::GI_INVENTORY_LABEL)
    @command_window = @command_window.class.new(width, c)
    if @ma_correct_index
      @command_window.index = @menu_index
    else
      @command_window.ma_temp_index = @menu_index
    end


Change it so that it looks like this:


    @magi_equip_index = c.index (Vocab::equip) if ModernAlgebra::GI_MENU_HIDE_EQUIP && c.include? (Vocab::equip)
    @magi_item_index = c.index (Vocab::item) if ModernAlgebra::GI_MENU_HIDE_ITEM && c.include? (Vocab::item)
    c.delete (Vocab::equip) if ModernAlgebra::GI_MENU_HIDE_EQUIP
    c.delete (Vocab::item) if ModernAlgebra::GI_MENU_HIDE_ITEM
    # Add Grid Inventory Command
    c.insert (ModernAlgebra::GI_MENU_INDEX, Vocab::GI_INVENTORY_LABEL)
    @command_window = @command_window.class.new(width, c, 2, 3)
    @command_window.x = (554 /2) - (@command_window.width/2) #167
    @command_window.y = Wor_Litemenu::MENU_WINDOW_Y
    if @ma_correct_index
      @command_window.index = @menu_index
    else
      @command_window.ma_temp_index = @menu_index
    end

Zero2008

#21
Um... u sure dude?
cuz there isn't even a line 3323 on my script...


Edit:
I found it! it works great Thanks man!
the Line is 3223.

Holkeye

I think MA is secretly working on Diablo 3, and not telling anyone about it. This is a really cool script.

modern algebra

haha, thanks Holk. I'm pretty sure I'd have to be a damn good con artist though, to get a job at Blizzard :P

Zero2008

LOL anyways I found an error in ur script MA
When i tried giving a weapon to another person i would get an error window.
The window said:

Line 1879: No Method Error Occurred
Undefined method 'each' for nil: NilClass.

Here is the Line:

@placements.each { |slot| count -= (slot.rect.width*slot.rect.height) }

I hope i gave you everything you need to fix it!