TasInventoryEx is a custom UI system/addition for Warcraft 3 V1.31 or higher, In vjass or Lua.
With it heroes can equip more items (use item-boni).
There is a version (jass or vjass) for Warcraft 3 V1.26 without customUI, using an Unit as substitude.
Details
The storage UI is a grid of buttons, each contains upto one item. One can scroll up and down by rolling the mouse wheel while the mouse points at the TasInventoryEx UI. The storage is only shown after you clicked the showbutton (default next to the inventory) and it can be closed/hidden again.
The position and amount of buttons can be changed inside the System's setup (top of TasInventorEx script file).
To change the Size of buttons or the highlight on mouse over you need to change the included fdf.
Reuses the Tooltipscale from HeroScoreFrame options when provided.
How this works: When an unit has more than one Inventory skill the unit can equip/carry more items, but the items not in the main inventory have no user Interface.
TasInventoryEx displays the items from this other inventories and allows to move Items into the main inventory or drop them, if the main inventory is full.
Hence to use this System you need to have clones of the inventory hero and tell TasInventoryEx the objectIDs.
There is a bug that custom abilities without any changed field (pink) can not be given to units.
Find these in TasInventoryEx to setup the inventory skills used by TasInventoryEx:
JASS:
private function UserInit takes nothing returns nothing
set InventorySkills[0] = 'AInv'
set InventorySkills[1] = 'A000'
set InventorySkills[2] = 'A001'
endfunction
These inventories are added to an unit which gains an item, when it has the first Inventory-Skill (jass index 0 Lua index 1) (automatic by TasInventoryEx).
This System does not clean dead/removed units.
When there should be units that have an inventory but should not use TasInventoryEx then give them not the first inventory skill (default Inventory Hero 'AInv') (jass index 0 Lua index 1).
As this is based on the Inventory-Skills each provided ability increases the max inventory Size by upto 6.
The default trigger item api does not work for items in the other inventories.
Therefore "unit has Item (of type)" might say false when the item is equiped to the hero.
Items transfered between units only consider main inventory
Item given by trigger only consider main inventory
When the main inventory is full, no items can be gained until there is a free slot again.
TasInventoryEx creates it's events at 0s or 0.01s hence they happen after events created before (all normal created GUI events).
TasInventoryEx destroys & recreates Items to drop/move them. Hence many trigger item changes are gone when using TasInventoryEx. Data kept is:
ItemCharges
ItemInvulnerable
ItemUserData
ItemPlayer
Life
The function ValidUnit can be used to disallow units to use this System. You find it near the top of the code.
vJASS:
private function ValidUnit takes unit u returns boolean
// Units with the Locust skill do not use this System
if GetUnitAbilityLevel(u, 'Aloc') > 0 then
return false
endif
// The extra Players don't use this
if GetPlayerId(GetOwningPlayer(u)) >= bj_MAX_PLAYERS then
return false
endif
if not IsUnitType(u, UNIT_TYPE_HERO) then
return false
endif
return true
endfunction
Lua:
-- filters out units that should not Use TasInventoryEx
,ValidUnit = function(unit)
...
How to install
CustomUI
InventoryUnit
Requiers Warcraft 3 1.31+ or higher
Copy the TasInventoryEx Folder (trigger Editor).
remove the Lua folder, if you are in jass mode. Or remove the vjass folder, if your map is in Lua mode.
export
war3mapImported\TasInventoryEx.fdf
war3mapImported\TasInventoryEx.toc
WHEN USING THE EXPORT ALL BUTTON, IT CAN HAPPEN THAT THE CONTENT OF THIS FILES SWAP
import them into your map
Tell the system the inventory Abilities
Installed
Copy the TasInventoryEx Folder (trigger Editor) or only the vjass script.
Copy the TasInventoryEx abilities
Copy the TasInventoryEx Unit
Update references to abilites and the unit in the TasInventoryExInit (normal jass) otherwise in the globals/UserInit of the vjass script
Tell the system the inventory Abilities
Installed
Credits
Nestharus
Bribe
SmitingDevil
Derdan
Mustang
ChangeLog
V1.5) ShowButton can Close
V1.4b) mp desync fix
V1.4a) (vjass) Reinc fix, hide InventoryEx button for non valid
V1.4) ValidUnit filter function
V1.3c) Hero only
V1.3b) Reincarnation Fix
V1.3a) Revive Fix, Drop update
V1.3)Filters destroyed Gained Items
1.2a) vjass
optional works without table.
Fixed a local reference to an item in function RemoveIndex
V1.2)
Fix prehold Items, purge consumed
V1.1)
Fixed some bug with morphing Heroes
Recreated Items keep more data
After testing the system for a bit, I went into some issues.
When the first grid is filled up and I use the scroll bar to go to the next grid, I get Sammy icons until I move the scroll further.
If the custom inventory and the default inventory are both full and I free up an item slot of the custom inventory, I can't pick up an item because the default one is full.
A suggestion: Perhaps, provide a button to display more than one row at a time. Even though there is the scroll bar and your other system sort of fills the niche here, this feature could potentially make the viewing of items more pleasant.
Updated Post and System to V1.1)
inventories are now made permanent, which fixes problems with morphing heroes.
Recreated Items now copy: Charges, Invul, UserData, Player, Life
A suggestion: Perhaps, provide a button to display more than one row at a time. Even though there is the scroll bar and your other system sort of fills the niche here, this feature could potentially make the viewing of items more pleasant.
Edit: Updated to V1.2)
Items carried before getting TasInventoryEx are now added to TasInventoryEx, before they were unreachable.
Using an item checks for broken items removes them
Edit: Updated vjass to V1.2a)
optional works without table (lighter version, but takes a hashtable).
Fixed a reference leak to an item in function RemoveIndex.
Edit: Updated to V1.3)
Filters now items that are destroyed (ItemCode <= 0) inside the item gain event. Previously they were added as broken item into the inventory UI
Edit: Updated to V1.3a)
Moved the removed Item Filter to the top of the gain item function
Removed the ItemUse check and use the Drop event instead
Fixed additional Inventories after Revive, does not Include Reincarnation. Sadly the last inventory items will droped after revive, if an unit has to many items.
I can not create custom UI in Warcraft 3 V1.26. Some can, but I do not.
I could make a version in which an additional unit replaces the custom UI. It would show 1 inventory Page and has abilities to navigate the current page & move item of the current page to the main inventory. A little bit clunky as one than moves selection but would not require any item specific data (which is the idea of this system works with default items).
Should work in default warcraft 3 V1.26, without any hacks/3.Party additions.
Updated to V1.3b)
Now keeps working after reincarnation.
Edit: Added the Warcraft 3 V1.26 Version, (normal jass). Instead of CustomUI there is an Unit with abilities and a preview inventory.
The game does something quite unexpected:
Warcraft 3 returns rubbish when using GetUnitAbilityLevel onto a inventory skill (at least in V1.26 and V1.31.1). I check for inventory (Hero) > 0, unit has inventory (unit, human) and the game says that is fine and gives the unit the inventories.
Edit: It seems to be only rubbish for the inventory(Hero) 'Ainv'.
Edit: Updated to V1.3c)
Works now only for Heroes, because the inventory Skill check is buggy.
Edit: Updated to V1.4)
Added a function ValidUnit(unit) to filter out unwanted users.
On default now units of Players that can not be real players are excluded (like Neutral Hostile, Neutral Extra..).
Nice job! I thought this was impossible. One small criticism: In the demo map the footman still has the bag icon despite not being a valid unit according to the filter. I tested it with a unit with no inventory, a phoenix, and it doesn't show the bag icon which is normal.
edit: Found another bug. If a hero dies with 18 items they lose/drop (?) 6 of them upon reviving. To reproduce, pick up items until no more can be carried,then kill the hero. I tied commenting out the reference to the 2nd inventory skill and items were still lost so I suspect it has to do with a loop.
edit2: Please test the revive hero actions more. They are very glitchy right now. I was testing on the JASS version. It seems the items are dropped at the hero's feet during revival not deleted.
Ty, for your feedback.
Hiding for non heroes is easy to do.
I am stuck with how I would fix the revive problem.
fixing that revive glitch is not so easy. Problem is that after revive the multiple inventory feature breaks. And hence the inventories have to be removed and readded. But here one also has to be careful because when one just readds all inventories the inventory grows, then the hero could carry 6 items more after each revive/reinc.
Currently I add items than add a skill to move them into the next page, but it seems that InventorySkill[0] somehow breaks and has 0 Size until InventorySkill[1] is regained. Which means the hero will drop 6 items after revive/reinc.
Edit: Updated to V1.4a.
The Bag Button will only show when the unit is a ValidUnit.
(vjass) Fixed a bug with reincarnation not readding inventories. Also for vjass in the V1.26 map.
The current version desynchs very easily, Please fix. If you load the map in LAN mode with 2 players and select a few different units including the heroes and the footman with the host player 2 will get disconnected.
I forgot to reserve a handleId for BlzGetOriginFrame(ORIGIN_FRAME_ITEM_BUTTON, 0) which was called in the update timer when the current local player selection was valid for TasInventoryEx.
Updated to V1.5)
ShowButton can close the UI when clicked and the UI already was shown ( can be enabled/disabled async)
// showButton closes the UI when clicked while the UI is shown?
public boolean ShowButtonCloses = true
Thanks for your feedback.
One has to do the same as after revive/reinc.
Right after you unpause the unit tell the system to readd the inventories and items. Otherwise the unit can only fill the main inventory with items (no more additional inventories).
vjass
call TasInventoryEx_ReAddInventories(unit)
Lua
Can't do that right now as there is no external access to ReAddInventories(unit).
Edit: It also happens when an unit uses a channel abiliy with "disable other abilities" enabled.
Edit: And even for Doom. Probably for all skills/situations that silence inventories.
awesome! i'd love to use it!
but its a bit weird if your Heroes Normal Inventory is full but you have space in your ''bag'' it says that you cant pick up the item because ''Inventory full'' so you have to rearrange your whole inventory - to bag - from bag - to pick up the new item
well the system works with a wonky sideeffect of many inventories. The inventory in the UI needs atleast one empty slot to be able to pick up more items.
Ok, also do you know why items are not stacking when I pick up the same stackable item type? It will create 2 copies instead of stacking and when I click on it, it will add the correct item stack to inventory but it will turn into the placeholder "sammy" icon on the bag
Ok, also do you know why items are not stacking when I pick up the same stackable item type? It will create 2 copies instead of stacking and when I click on it, it will add the correct item stack to inventory but it will turn into the placeholder "sammy" icon on the bag
Perhaps the fix for this lies in the EVENT_PLAYER_UNIT_STACK_ITEM event? edit: I meant this as a suggestion for Tasyen, not a do it yourself way to fix it.
edit2: See if this tweak fixes it. I changed the line right below the comment and enabled item stacking in gameplay constants for testing.
Not built in. you could try: when an item is picked up, destroy it, then disable the secondary inventories and create a new clone of the item and give it to the unit.
Lua:
this.AbilityFieldSize = ConvertAbilityIntegerLevelField(FourCC('inv1'))
for i, v in ipairs(this.Indexes) do
abi = BlzGetUnitAbility(unit, this.InventorySkills[v])
BlzSetAbilityIntegerLevelField(abi, this.AbilityFieldSize, 0, 0)
end
UnitAddItem(unit, newItem)
for i, v in ipairs(this.Indexes) do
abi = BlzGetUnitAbility(unit, this.InventorySkills[v])
BlzSetAbilityIntegerLevelField(abi, this.AbilityFieldSize, 0, 6)
end
I found something useful:
Making the inventories unsilenceable via "call BlzUnitDisableAbility(u,InventorySkills[loopA],false,false)" makes them not glitch out when you are hit with certain spells. I've only tested hex so far but this is an improvement
You add the above line whenever you are adding the inventory skills via UnitAddAbility
the items are inside the heros inventories, the system keeps data of them.
In the Lua version TasInventoryEx[unit][1 to x] are the items.
Jass depends if you have LIBRARY_Table in the map or not. I am not sure how this structs work in vjass.
you probably need to make the struct public and then find out how to access it.
JASS:
// Mode without Table
private struct data extends array
static if LIBRARY_Table then
public static HashTable BagItem
else
public static hashtable Hash
endif
endstruct
public function AddItem takes unit u, item i returns nothing
local integer unitHandle = GetHandleId(u)
static if LIBRARY_Table then
set data.BagItem[unitHandle].integer[0] = data.BagItem[unitHandle].integer[0] + 1
set data.BagItem[unitHandle].item[data.BagItem[unitHandle].integer[0]] = i
else
call SaveInteger(data.Hash, unitHandle, 0, LoadInteger(data.Hash, unitHandle,0) + 1)
call SaveItemHandle(data.Hash, unitHandle, LoadInteger(data.Hash, unitHandle,0), i)
endif
endfunction
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.