Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
I'm making an array which must store 20 item types. Every time a unit buys an item, that item is stored in the array. I'm noob at arrays, can some1 pls show me how to do it.
Where do I find the ''If ItemCount Less than or equal to 20'' condition?
And what Index should the 1st itemcount from ''Then Set ItemCount = ItemCount + 1'' have?
The question is, do you want to save the Item Type or the actual Item because these are two different things. Item-Type is saved as an Integer where as Items can be saved using the Item's handle.
For Item-Types you can save them in a Hashtable as Integers like this:
Setup
Events
Map initialization
Conditions
Actions
Hashtable - Create a hashtable
Set VariableSet ItemHashtable = (Last created hashtable)
Acquire Item
Events
Unit - A unit Acquires an item
Conditions
Actions
Set VariableSet Total = (Load 0 of (Key (Triggering unit).) from ItemHashtable.)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Total Less than 20
Then - Actions
Set VariableSet Total = (Total + 1)
Hashtable - Save Total as 0 of (Key (Triggering unit).) in ItemHashtable.
Set VariableSet ItemType = (Item-type of (Item being manipulated))
Custom script: set udg_Item = udg_ItemType
Hashtable - Save Item as Total of (Key (Triggering unit).) in ItemHashtable.
Else - Actions
This is just the basic system without any extra functionality. It will store the first 20 Item-Types you acquire in the Hashtable saving them at positions 1 to 20 using the Acquiring Unit as the Key.
An example of getting and creating a Unit's 5th saved Item from the Hashtable:
Load Item Type
Events
Unit - A unit Starts the effect of an ability
Conditions
Actions
Set VariableSet Item = (Load 5 of (Key (Triggering unit).) from ItemHashtable.)
Custom script: set udg_ItemType = udg_Item
Item - Create ItemType at (Position of (Triggering unit))
I want to have 20 diferent item types with their separated integer. ex: ItemT0 (=claws of attack), ItemT1 (=Gloves of Haste), ItemT2 (=Hood of Cunning)..., itemT19 (=Rod of Necromancy)
Whenever I buy an item it gets to be a variable. The trigger should look like what Warseeker sent the 1st time, but there are 4 unclear things:
A unit Sells an item (from shop)
Item type of (Sold item) Equal to Item X
If ItemCount Less than or equal to 20
Then Set ItemCount = ItemCount + 1
Else Remove (Sold item)
Where do I find the ''If ItemCount Less than or equal to 20'' condition?
And what Index should the 1st itemcount from ''Then Set ItemCount = ItemCount + 1'' have? and ItemCount is an item type, not an iteger, right?
When you go into the conditions and click Integer Comparison, you'll see a bubble at the top that says Variable. Select that and choose ItemCount from the list of Integer variables.
Then hit OK and you'll be able to edit the rest.
Untitled Trigger 001
Events
Unit - A unit Acquires an item
Conditions
ItemCount Less than 20
Actions
Set VariableSet ItemCount = (ItemCount + 1)
Set VariableSet ItemType[ItemCount] = (Item-type of (Item being manipulated))
OR
Untitled Trigger 001
Events
Unit - A unit Sells an item (from shop)
Conditions
ItemCount Less than 20
Actions
Set VariableSet ItemCount = (ItemCount + 1)
Set VariableSet ItemType[ItemCount] = (Item-type of (Sold Item))
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.