HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

GiveItemToHeroSlot

08-19-2009, 09:16 PM#1
Themerion
Is there an easy way to give (the already existing) item X to a hero and make it appear in a certain slot?

Or do I have to use dummy items to fill the empty slots?

(I'm trying to remove certain items from the inventory, then after 0. seconds put them back again, in the right order).
08-19-2009, 09:27 PM#2
Anachron
You have to use dummyitems to fill the slots, there is no way around.
08-19-2009, 09:49 PM#3
moyack
Collapse JASS:
native          UnitAddItemToSlotById   takes unit whichUnit, integer itemId, integer itemSlot returns boolean
?
08-19-2009, 09:53 PM#4
Anachron
Whoot, why don't I have that native on JNGP 5d?
08-20-2009, 10:48 AM#5
Themerion
integer itemId ?

Am I supposed to use GetHandleIndex in order to get the item's ID so I can give it to the unit, or what? :P
08-20-2009, 10:53 AM#6
Tyrande_ma3x
No, that ID can be viewed with Ctrl+D in Object Editor. It would look something like 'I003' or so.
08-20-2009, 10:56 AM#7
Themerion
But that would create an item for the hero, not give it an existing one... That would sort of mess up the cooldown on the items, right?

(AFAIK, Blizzard has given each item a specific cooldown, to disallow people from trading permanent active items)
08-20-2009, 11:14 AM#8
Rising_Dusk
Not if you use the cooldown group field properly in the OE.
08-21-2009, 02:27 PM#9
ToukoAozaki
Use UnitDropItemSlot to put specific item into specific slot. Not sure whether this requires the unit to carry the item...

Edit: Okay, something like this...

Collapse JASS:
function UnitAddItemToSlot takes unit whichUnit, item whichItem, integer slot returns boolean
    if UnitAddItem(whichUnit, whichItem) then
        return UnitDropItemSlot(whichUnit, whichItem, slot)
    endif
    
    return false
endfunction