[vJass] (System) CustomInventory

This bundle is marked as useful / simple. Simplicity is bliss, low effort and/or may contain minor bugs.
By far the biggest inventory system for Warcraft 3.
It's designed to have optional features, like FullScreenInventory-UI.

With a little bit of modification you can use this Inventory System in the normal Warcraft 3 Inventory too.

It is written in vJASS and has the following features:
- 12 Slot Equipment
- MPI
- Very flexible
- Easy to add bonuses to items
- Item Stacking
- Item Forging
- Item Sets (With bonuses)
- Inventory fixes warcraft 3 bugs (Double pickup bug)
- Fast
- Gives the ability to add your own areas with a little bit of code

A small note on the classes:

##############################################################################
# USER INTERFACE - CUSTOM WINDOW
##############################################################################
---------------
CWDestructable
---------------
It's an object that has an destructable for a local player.
(Such as icons, borders and more)

---------------
CWTrackable
---------------
This is basically an object that triggers player events for hovering the icons (CWDestructable).
Whenever an event occurs, it fires an action to the CustomWindow

---------------
CustomWindow
---------------
A collection of CWTrackable and CWDestructable. Every destructable will have an trackable object.
So whenever you hover over or click a trackable, this will be fired.
You will use this object to create hooks to the inventory system.

##############################################################################
# CUSTOM WINDOW - HOOK AND EXTENDING
##############################################################################

---------------
CIAll
---------------
This is a container object of items. It has conditions for pickup and drop and is the base
class for any container, like Slots, Potions, Equipment or even spell slots that you could create!
It has a variety of methods like adding, removing and checks and throws errors.

---------------
CIActions
---------------
This is a library which only use is to find out what the user wants to do. It supports up to 5
different steps which can be done in a row so if you need to build up something complicated here you go.
This action decides when to move, drop, pick and destroy items. It's bound to CIWindow and uses its
events to trigger / delegate events to the CISlots/CIEquips/CIPotions objects.

---------------
CIContent
---------------
This is a little help class for the CIActions object which puts a wrapper around the Equipment,
Potions and Slots. It will also update the camera.

---------------
CIWindow
---------------
This is the hook between CustomWindow, CIActions and the CustomInventory. It also provides
fake units to provide the Interface Functionality and delegates events to CIActions.

---------------
CISlots / CIEquips / CIPotions
---------------
The containers you see (Top left, top right and bottom left) are basically these objects.
They have special / unique conditions for pickup / drop and handle when to add or remove bonuses from the hero.

##############################################################################
# CUSTOM INVENTORY - CORE
##############################################################################

---------------
CIForging
---------------
This module forges items. You can combine any items and merge them to a bigger item. This will
always happen when your inventory updates.

---------------
CIStacking
---------------
You like items that can stack in your Inventory? Well this module is for you!
Create stackable items and make a maximum conditions. Item stacking is automatic, whenever
inventory updates.

---------------
CISet
---------------
Don't we all love this thing from World of Warcraft? Collecting items of a special set and
then get some bonus stuff once we have all of them. If you are cool, use this feature. It
even supports SET STACKING!

---------------
CIAttachment
---------------
Not done yet.

---------------
CIBonus
---------------
This is the hook between items and the unit state modifier library. You can use this module
to add and remove bonuses to the hero on the fly whenever needed.

---------------
CIError
---------------
Throw errors to the user whenever something bad happens.

---------------
CIEventHandler
---------------
Like every other Inventory system, we need some kind of hook for pickup/drop actions to
connect them with our CustomInventory. This will trigger the CustomInventory events.

---------------
CIEvents
---------------
Name may not be completely self-speaking, but this actually triggers the events on the item.
But only when the unit really has the item. (Safety layer)

---------------
CIItemDrop
---------------
This will allow pickup/drop actions of the items WITHOUT triggering the inventory events.
It will be required for many things so this module is a life safer!

---------------
CIItemInfo
---------------
Wouldn't it be cool if items could display what they are in a multiboard. Yes it would.
This module is exactly for that.

---------------
CIItemBoard
---------------
Yes, this is the multiboard which displays all the item statistics. It uses hooks to get
the attached events from the CUstomWindow.

---------------
CIItemProtection
---------------
Every item has states, like locked, owend, equiped and such. This module gives the ability
to change the states and make them available.

---------------
CIItemDest
---------------
Simple module for setting the destructable (icon) for the CustomWindow.

---------------
CIItemSeek
---------------
Module which is build to search and collect information about the inventory.
Find out how many items of which type you have that are not stacked, find out how many duplicated
items you have and even if you have errors in your inventory indexing.

---------------
CIItemSlot
---------------
Small module that adds classes to the items. You can only equip items with the right class
on the right positions.

---------------
CIItemEffect
---------------
This module allows to attach effects to an item wearer. Do whatever you want, but keep in mind
that one item has a maximum of 3 effects.

---------------
CIPowerup
---------------
Not done yet.

---------------
CISetup
---------------
Changes the area around the inventory to be black and create the UI for all players.


---------------
CustomItem
---------------
The item object itself. Will trigger and get triggered from all kind of sources.
Modules are completing the collection of members and methods.

---------------
CustomInventory
---------------
The main object. It forges, stacks, creates sets, triggers events, gets triggered and uses
optional modules to provide the full repository of features to the user.



-Fixed a bug found by Dr. Boom:
Dead units were able to change the inventory and caused bugs.
-Also added a little bit of documentation.


Keywords:
CustomInventory, Inventory, Custom, Anachron, FullScreen, Module, vJass, Stack, Forge, Combine, Set, Powerup, Drop, Equip, Equipment, Equip, System
Contents

CustomInventory - 0.2.2.6 (Map)

Reviews
18:27, 18th Feb 2010 The_Reborn_Devil: Ohsh- That describes pretty much what I'm thinking. My eyes were sore even before I was done reviewing half of the code. The code looks really good and I couldn't find just one little thing that would be...
Antares
While great at the time, this system uses an outdated implementation and has not survived the test of time. Simple

Moderator

M

Moderator

18:27, 18th Feb 2010
The_Reborn_Devil:
Ohsh-
That describes pretty much what I'm thinking.
My eyes were sore even before I was done reviewing half of the code.
The code looks really good and I couldn't find just one little thing that would be enough to reject this...
This is the best inventory system I've seen and I've seen maaaany.


Edit:
Since you updated I had to review it again. It looks good, but I did notice one thing >:D

1. You don't need those null filters like in CIEventHandler
JASS:
private function InvNullFilter takes nothing returns boolean
    return true
endfunction
That bug has been fixed.

Other than that the code looks good and it's very easy to use.
Would be more awesome if the system had fewer lines though as this system is frikken HUGE. It hurts to review it.


Status: Approved
Rating: Director's Cut! [6/5] Plz?

hvo-busterkomo: After evaluating this system I do not think it meets the standards to be a Director's Cut. However, in respect to The_Reborn_Devil, I have left it as Highly Recommended.
 
Bugfree. Enjoy.

Here is the package of informations:
View attachment CI.zip

Subscribing.
Also please give comments, suggestions, critique, ideas and credits!




Go to the discussion thread.

ToDo:
  • When you mouse over the exit button, drop button or any of the armor slots, the board should say what it is
  • Attachment system
  • (Maybe) UI update when Elenai did so.
  • Vendors
  • Tradesystem

  • Enable swapping between units and trackables as selecters.
  • The potion slots should have potion icons to separate them from the normal slots
  • You used the name "hand" for the weapon slot (I think "weapon" would be better because people can confuse hand and gloves i guess
  • I think it would be less confusing to use the inventory icons i linked to so that people can distinguish the slots
  • Create a save/load code generator for this CI.

How to connect with a save-load system:
JASS:
private function loadItems takes unit theUnit returns nothing
    // Load the inventory
    local CustomInventory inv = CustomInventory.load(GetHandleId(theUnit))
    // Load the item object
    local CustomItem it1 = inv.getItem(0)
    // Get the itemhandle
    local item i1 = it1.getHandle()

    // Print the itemname for testing purposes.
    call BJDebugMsg(GetItemName(i1))
endfunction
This will load the first item of the inventory of unit theUnit and print the item name.
 

Attachments

  • load.jpg
    load.jpg
    482.9 KB · Views: 3,083
Last edited:
Level 5
Joined
Jun 29, 2009
Messages
142
A few things...

1) How do I drop an item? It seems a little confusing and doesn't work half the time.
2) The exit inventory button doesn't work
3) Is there a sell to vendor button?
4) If I right click to move on the empty black part of the inventory, the hero moves there. This might cause some problems.
 
How do I drop an item? It seems a little confusing and doesn't work half the time.
Select an item and press the drop button. It works in 100% of the times.
The exit inventory button doesn't work
but the exit button aint working :S
Fuck, forgot to remove that little bastard! :D
Is there a sell to vendor button?
No, its not a feature in the first official beta.
 
Level 14
Joined
Jun 13, 2007
Messages
1,432
When I equipped the claws of attack and then the Clawns of Attack Powerup the item vanished completely and then when I picked up another item it showed up again.

I can't move my mainhand to offhand, offhand to mainhand.

The borders seems to be flickering and changing when I equip and unequip stuff.

If AdvancedTable is basicly Table then you should change it names to something else as there is a chance that someone will make a system named AdvancedTable.

I think that the multiboard should fill the entire right side from top bottom, that way it feels more UI like.

The lightning settings are at night, you should add something that makes it turn to day everytime you enter the UI so the lightning doesn't mess up the colours.

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

I haven't really gotten into the code but these are stuff that I notice for now.
 
God!
AWESOME!
Finally here!

I'm going to stress test this system!
Thanks, please give feedback and the result of the stress test :p

Where do I go to change the icon placeholders in the equipment section. I looked around in the code but couldn't find it. I'm sure it's somewhere obvious but I'm not a jasser and can't find it :(
CIItemSlot (At modules)
JASS:
        constant integer ITEM_CLASS_ICON_HAND        = 'cihn'
        constant integer ITEM_CLASS_ICON_TWOHANDER   = 'cihn'
        constant integer ITEM_CLASS_ICON_RING        = 'cirg'
        constant integer ITEM_CLASS_ICON_MISC        = 'cimc'
        constant integer ITEM_CLASS_ICON_BOOTS       = 'cibt'
        constant integer ITEM_CLASS_ICON_MAIN        = 'cimn'
        constant integer ITEM_CLASS_ICON_TROUSER     = 'citr'
        constant integer ITEM_CLASS_ICON_AMULET      = 'ciam'
        constant integer ITEM_CLASS_ICON_GLOVE       = 'cigv'
        constant integer ITEM_CLASS_ICON_HELMET      = 'cihd'
        constant integer ITEM_CLASS_ICON_SHOULDER    = 'cish'
You have to change the destructables with these IDs in the object editor.
You will have to put the path to the new icon into the field with id 'texFile'

When I equipped the claws of attack and then the Clawns of Attack Powerup the item vanished completely and then when I picked up another item it showed up again.
I temporary disabled powerups.

Unable to save map a little error :
Error Image
errooor.jpg

I have JNGP thats normal. Fix that.
Which version of JassHelper do you have?

I can't move my mainhand to offhand, offhand to mainhand.
You can't move anything in the equipment.

If AdvancedTable is basicly Table then you should change it names to something else as there is a chance that someone will make a system named AdvancedTable.
Its table for all types, not only integers.

I think that the multiboard should fill the entire right side from top bottom, that way it feels more UI like.
You can easily do that, and I like it that way imho.

The lightning settings are at night, you should add something that makes it turn to day everytime you enter the UI so the lightning doesn't mess up the colours.
Yes, the border stuff is currently not very good. I will change that.
 
Level 21
Joined
Dec 9, 2007
Messages
3,096
After moving the same item on other random slots, the map just crashed! Ô_Ô"
Anyway, very hard coded, has a lot of functionality, but you waste a lot of space with the slots.
I mean, seriously, why so much space between the slots? You can make them bigger or make more of them.
You should also add pages to the inventory. (That you can remove for the D3W project)

I can't wait for the other modules to be in the beta! :D
 
Please make sure you have the latest version of JassHelper.

After moving the same item on other random slots, the map just crashed!
Holy crap, really??? :S

Ô_Ô"
Anyway, very hard coded, has a lot of functionality, but you waste a lot of space with the slots.
With that functionality its hard to not extreme code it.
 
Didn't happend to me next time I tried.
I think it was another windows-related or blizzard-related bug.
So glad it wasn't based of my scripting. I tested that alot and was about:
What the hell? It bugs? but it can't! :D

15 comments and my 16 comments when you post system. Thats popular. I was say that on discussion.
So did you update JassHelper now? Does it work now? :)
 
Hmm my JNGP must be really messed up, I get "Unrecognized character ' (ASCII 39)"
Thats a normal '9' number symbol. Please reinstall JNGP.

How do i change the location of item placeholders. So If i want the boots and the ring to swap places or something how would i change that?
CWEquipment

JASS:
        //! runtextmacro CWEquipment__addItemClasses("RING", "0")
        //! runtextmacro CWEquipment__addItemClasses("RING", "1")
        //! runtextmacro CWEquipment__addItemClasses("MISC", "2")
        //! runtextmacro CWEquipment__addItemClasses("BOOTS", "3")
        //! runtextmacro CWEquipment__addItemClasses("MAIN", "4")
        //! runtextmacro CWEquipment__addItemClasses("TROUSER", "5")
        //! runtextmacro CWEquipment__addItemClasses("AMULET", "6")
        //! runtextmacro CWEquipment__addItemClasses("GLOVE", "7")
        //! runtextmacro CWEquipment__addItemClasses("HELMET", "8")
        //! runtextmacro CWEquipment__addItemClasses("SHOULDER", "9")
        //! runtextmacro CWEquipment__addItemClasses("HAND", "10")
        //! runtextmacro CWEquipment__addItemClasses("HAND", "11")
Change the numbers behind. Please don't double use numbers.
 
Hmm, cant seem to get it to work, how to implement a new jasshelper?
I was say, idk what to do now, copy that in JNGP folder? - or replace something? pls help.
CnP the files of "0.A.2.B.jasshelper\executable" into "\jassnewgenpack5d\jasshelper" and press ok for overwriting.

It actually is told in the readme file of the JassHelper
Yes, but nobody reads readmes at all, because of lazyness >.<.
 
I just picked up 2 pointions then opened the eq and this is what I got.
Excuse me? Really? But why does it work for everyone else? :S

So you didn't intend to have the exit button? If you have the time could you tell me how to get the button to work?
Fixed. Now it works.

And also get the inventory to show when I click an ability button (disable the esc key so it doesn't show it)
JASS:
call CWInventoryWindow.Helpers[PlayerNumberOfThePlayer].changeView()
This changes the view.

JASS:
call CWInventoryWindow.Helpers[PlayerNumberOfThePlayer].show(true)
This shows the inventory of the player
 
Top