• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[vJass] (System) CustomInventory

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...
Level 8
Joined
May 30, 2009
Messages
266
the thing with 2 players picking up the same item at the same time is possible with other things too

like when you have a hero selection by double clicking (and after that the hero gets disabled for selection) it can still be picked by 2 players at the same time ;)

trust me, i had this with some guy called pedrokahn and it is unavoidable :p
 
Level 13
Joined
Feb 18, 2009
Messages
1,381
There is no such thing as a full screen inventory which does not use up some map space, but consider that it uses like 6x2 of the map or stuff. (Maybe there is something which dosen't use map space, but i don't know it)
 
Level 12
Joined
May 21, 2009
Messages
994
When you are going to make Trade and Vendor system, then you maybe can do it like the Diablo II one? I just really like how they set it up. If you don't know how it looks, look here:
test.jpg - trade system
test2.jpg - shop system
I don't care if the UI is different, but I like the setup. I hope you do too.
I already got future suggestions for this trade system and shop system. But I'll wait abit, I don't want to stress you.
 
Yes, shops will have items by genres, so like "Tabs" in the browser you will have tabs with classes. The good thing is, the user does not need to care about the implementation of such things because its automatically done by the system.
You'll just add a list of itemtypes and the system will do everything for you.

(I thought about this to add items to the vendor
JASS:
call AddItemsToVendor(unit, "'itm1', 'itm2'")

// and this to remove
call RemoveItemsFromVendor(unit, "'itm1', 'itm2'")
However, these are only the concepts.
 
Level 7
Joined
Apr 2, 2009
Messages
249
Imagine that my map have 10 players, so i will need 12 free space on my map? how could i define the co-ordinates for those?
or just simply call:
loop
exitwhen i >= 12

if GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING and GetPlayerController(Player(i)) == MAP_CONTROL_USER then
set fakeInv = CreateInventoryUnit(Player(i), 'h000')
set hero = CreateUnit(Player(i), 'Hpal', 0., 0., 0.)
call CreateInventoryUI(hero, fakeInv)
endif

set i = i +1
endloop
 
Exactly, you only need one area.

JASS:
loop
exitwhen i >= 12

if GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING and GetPlayerController(Player(i)) == MAP_CONTROL_USER then
set fakeInv = CreateInventoryUnit(Player(i), 'h000')
set hero = CreateUnit(Player(i), 'Hpal', 0., 0., 0.)
call CreateInventoryUI(hero, fakeInv)
endif

set i = i +1
endloop

This is what you need, as already shown in the example, why do you thing it would be not like that if it's working?
 
Level 7
Joined
Apr 2, 2009
Messages
249
I am sure i have imported all required libraries.
If i open a new map, and then CnP, it works. Also, if i delete all other triggers in my map (include a lot of systems and mainly done in VJass) i get no errors !

Edit: Ah, i found out the reason, thats because i have both Xepreload and AbilityPreload in my map =)
 
Level 7
Joined
Apr 2, 2009
Messages
249
I am so embarrassed, i've sent hours trying to make it work...aa, whats wrong ???

Its strange, from this screenshot we can see that all icons does not work, but i checked ir carefully, all destructibles is all right !
er4.jpg
 
Level 7
Joined
Apr 2, 2009
Messages
249
ok, ok, founsd out it (took me about two hours ><)..its because thi terrain..sorry for bothering you, Anachron...
I have some questions:

-How to have an item's description/history
-Some infor about set items
-Items for specific heroes/classes
-How could i do something like this:

-Event: xx
-Condition: Triggering unit has an item of type/ GetUnitAbilityLevel(GetTriggeringUnit(), 'ABCD') >0 (item ability)
-Action: yy
 
Last edited:
ok, ok, founsd out it (took me about two hours ><)..its because thi terrain
Glad you figured that out!

-Event: xx
-Condition: Triggering unit has an item of type/ GetUnitAbilityLevel(GetTriggeringUnit(), 'ABCD') >0 (item ability)
-Action: yy
You can register callbacks for the itemtypes.
Did you check my demo?

You can create callbacks for onPick, onDrop, onPawn and onUse.
-How to have an item's description/history
Please check out the examples as well, you do it with set (itemvar).desc = "A LONG STRING, use \n to create linebreaks!"

-Some infor about set items
I haven't add info to setitems until yet, so I guess you have to it. I have added it to my ToDo-List so the itemset will appear in the Multiboard as well.

-Items for specific heroes/classes
Also you can add an conditional function, please check the example how you do such things. I don't remember the correct function name. Something like setOnPickCond.

My example even has that. (As far as I remember)

Thanks again for feedback and such.
 
Top