• 🏆 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 6
Joined
Apr 26, 2007
Messages
225
If i copy everything from the object editor in my map the destructibles and all wont have the same ID so i need to fix them all right?
 
Level 6
Joined
Apr 26, 2007
Messages
225
What will this boolean do? i mean what does setting this to new map will have to do with object ids?

EDIT: will jngp actualy copy the IDs too? my map already have a pretty loaded object editor so all the IDs from your pack must have already been used in my map..
 
Last edited:
Level 12
Joined
May 21, 2009
Messages
994
What will this boolean do? i mean what does setting this to new map will have to do with object ids?

EDIT: will jngp actualy copy the IDs too? my map already have a pretty loaded object editor so all the IDs from your pack must have already been used in my map..

Im pretty sure that with NEW_MAP set to true then it will generate destructables from the
JASS:
//!
But I'm not sure, better wait for him to answer.
 
Level 6
Joined
Apr 26, 2007
Messages
225
Well anyway i copied all the data in the object editor with jngp so i could manualy put the ID to theire original ones in the inventory system. I got it working somewhat...

EDIT: my problem is that i moved the area where the system is to -4600 -5000 but now it show just the borders. The Drop, Quit, slots, all the icones are not shown. Where can i modify the location of those? I can manage if i get that i think...
 
Last edited:
Level 6
Joined
Apr 26, 2007
Messages
225
I had the inventory fully working but it apeared right in the middle of my map so i had to change it.This is what i changed:
JASS:
        constant    boolean CI_NEW_MAP                  = false
        constant    integer CI_UI_MAX_ITEMS             = 20   
        constant    boolean CI_UI_SHOW_ITEMS            = false
        constant    boolean CI_UI_AUTO_APPLY_BONUSES    = false
        constant    boolean CI_UI_AUTO_REMOVE_BONUSES   = false
        constant    boolean CI_UI_AUTO_CHECK_PICKUP     = false
        constant    real    CI_UI_BASE_X                = -4600.
        constant    real    CI_UI_BASE_Y                = -5000.
        constant    real    CI_UI_WIDTH                 = 2048.
        constant    real    CI_UI_HEIGHT                = 1024.
                    rect    CI_UI_RECT                  = null

but when i changed it all the icones sudently dissapeared...

EDIT: ic an still see all descriptions and click the buttons. Like move a potion to the belt...just see eveerything black
 
Level 6
Joined
Apr 26, 2007
Messages
225
Lollll that was the problem! thanks a lot!

By the way euh... would you care explaining me a bit how the forging work? just an examble of when forging 3 items like clay +6, claw +9 and hood of cunning that would give a bonus for 2 items and another bonus when the 3 items are set... I dont know jass but with my logic i can manage, i already made items and integrated your script to my hero spawning system:grin:

EDIT: wow i just re read my post and i made big mistake lol i was thinking of sets at the same time as forging lol anyway i just need an exemple of sets i think i can figure out forging
 
Last edited:
Level 3
Joined
Jul 26, 2008
Messages
58
Hm, after copy-pasting the system into my map, it's just showing me black tiles by pressing ESC. When I mouse over this space, the inventory notice pop ups, which says 'No item in this slot'. What could be a problem to this? All imports should be alright.
 
Level 3
Joined
Jul 26, 2008
Messages
58
Actually, the most of JASS functions can be done by person who doesnt know a thing about it, just following the example. As I checked the system, it seems to be fairly easy to add your items with all its customization, or, for example, change the interface itself. That way I understood and modified for myself JASS cast bar system already.
But you're right, I can't do a thing in code w/o having an example, neither I can find an explanation why it doesnt work for me. And that is the only thing I need help with. If anyone knows the solution, please, post it here.
 
JASS:
// Put this inside the test trigger
local CISet cs = 0

set cs = CISet.create('ItemTypeOfNewItem')
call cs.addReq('ItemTypeOfNewCondition', AmountOfRequiredType)

// Example - Will create 1x Claws of Attack +6 from 2x Claws of Attack +3
set cs = CISet.create('rat6')
call cs.addReq('rat3', 2)

Please note that I do not officially support this system anymore.
 
Level 3
Joined
Jul 26, 2008
Messages
58
Yes, I know that. And I do not ask for help directly you, maybe some other people more-less familliar with this system would help me. But, as you probably realise, you know the most about the system and its issues, obviously because it was made by you :)
PS: What do you think about that code you've given to another guy? I think it's fairly easy to understand it when the example is given, so I can make some forging possibilies //if my inventory will be working, of course//
The same goes with every other function. Got my opinion now? :)
 
Level 3
Joined
Jul 26, 2008
Messages
58
Ok, I found the solution by myself. It was really simple, but I dont get it - WHY. The 'Model File' at every imported destructible wasnt set as it should be - still confused, why did it happen?.. So I set them all right, and the inventory started working.
Now I gonna lurk the code to know how to make some other hero to use the inventory. Currently, all the item pickups from another heroes make items just to disappear.
So, Scarlet, check your imported destructibles.
 
Level 3
Joined
Jul 26, 2008
Messages
58
Pff, I'm dried. I have to set the inventory to the unit, which enters playable map area, and has player controller of course. That is what I got from the last try >.>

WARNING: Since user does not know anything about JASS, he won't be responsible for any JASSer's brain explosion.

JASS:
scope test initializer init

function Trig_Now_Conditions takes nothing returns boolean
    if ( not ( GetPlayerController(GetOwningPlayer(GetEnteringUnit())) == MAP_CONTROL_USER ) ) then
        return false
    endif
    return true
endfunction

        private function Trig_Now_Actions takes nothing returns nothing
        local unit fakeInv = null
        local unit hero = null
        local integer i = 0
        
        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 = GetEnteringUnit()
                call CreateInventoryUI(hero, fakeInv)
            endif
        
            set i = i +1
        endloop
    endfunction


endscope

//===========================================================================
function InitTrig_Now takes nothing returns nothing
    set gg_trg_Now = CreateTrigger(  )
    call TriggerRegisterEnterRectSimple( gg_trg_Now, GetPlayableMapRect() )
    call TriggerAddCondition( gg_trg_Now, Condition( function Trig_Now_Conditions ) )
    call TriggerAddAction( gg_trg_Now, function Trig_Now_Actions )
endfunction

Any help? :S
 
Level 2
Joined
Feb 26, 2007
Messages
11
this system is amazing, though im having trouble with a certain thing.

The items that are registered work well, but when i want to register an additional item, what do i write in the ci.dest = 'XXXX' in order for it to have an icon in the inventory, not just in the leaderboard, i could not find a place where you preset the it01 it02 it03 coat and other codes to show up?
 
Level 3
Joined
Jul 26, 2008
Messages
58
this system is amazing, though im having trouble with a certain thing.

The items that are registered work well, but when i want to register an additional item, what do i write in the ci.dest = 'XXXX' in order for it to have an icon in the inventory, not just in the leaderboard, i could not find a place where you preset the it01 it02 it03 coat and other codes to show up?

Displayed icons are set in Destructibles. You create the new destructible, set the model file to imported 'iconbase', then set Replaceable texture to which you need. After doing so, press ctrl+D and check the ID of the destructible. That ID is what you're going to put to CI.Dest. Just check the destructibles, and, I'm pretty sure, you're gonna understand everything :)
 
Last edited:
Yes. That's why I hear often. ):

For all those who want to forbid some heroes/types to use/take items of a specific type, you can use this script:

[Put this inside Testing-Items]
JASS:
//: Declared in CustomItem Line 29
    private function check takes CustomItem ciObj, unit ciUnit returns boolean
        if GetUnitTypeId(ciUnit) == 'utyp' then
            if GetItemTypeId(ciObj.getHandle()) == 'itype' then
                return false
            endif
        endif
        return true
    endfunction

And inside the init function you put this in the item creation:
JASS:
        set ci = CreateCustomItem('I001')
        //set ci.class = ITEM_CLASS_TWOHANDER
        //set ci.dmg = 35
        //set ci.str = 7
        //set ci.dest = 'it03'
        //set ci.icon = "ReplaceableTextures\\CommandButtons\\BTNShamanMaster.blp"
        //set ci.name = "Shaman Claw"
        //set ci.desc = "Twohander item."
        //call ci.addSfx("Abilities\\Spells\\Human\\InnerFire\\InnerFireTarget.mdl", "overhead")
        call ci.setOnCheckFunc(check)
And that's it.
 
Level 6
Joined
Apr 26, 2007
Messages
225
If anyone know how to get over the "check is not a member of CustomItem" error to make a hero unable to pick an item i'd appreciate you help me with it. thanks

I added the script anachron tells in CustomItem line 30 to 37, changed utype and itype to the unit and item's id i waned (u004 and imw1 in my case) and get that error. i also added call ci.setOnCheckFunc(check) under item imw1
 
Last edited:
Level 1
Joined
Aug 6, 2010
Messages
1
Heya sorry to bother you but what does this stand for , I understood your code really easy , even not knowing really good jass c++ / php algorithms kinda helped me understand your code

set ci.dest = is setting the original destination , can you explain me what does that mean? because i kinda looked all over the forum
 
Top