• Check out the results of the Techtree Contest #19!
  • 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!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

[Trigger] Array +1 with limit

Status
Not open for further replies.
If you want to store 20 Items for more than 1 unit you should use a Hashtable.
A Complete Beginners Guide to Hashtables

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))
 

Attachments

Last edited:
Do you mean like this?

  • Item Type Array
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set VariableSet Items[1] = Claws of Attack +15
      • Set VariableSet Items[2] = Crown of Kings +5
      • Set VariableSet Items[3] = Kelen's Dagger of Escape
      • Set VariableSet Items[4] = Mask of Death
      • Set VariableSet Items[5] = Orb of Frost
 
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?
 
ItemCount is an Integer.

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))
ItemCount = Integer
ItemType = Item-Type (Array)
 
Last edited:
Status
Not open for further replies.
Back
Top