• 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.

How to save Item-types in a Hashtable

Status
Not open for further replies.
Level 9
Joined
Dec 12, 2007
Messages
489
item type id is actually integer, so you can just use custom script like this, (sample given based on your system need on the thread)
  • Custom script: call SaveInteger(udg_Hashtable, 'I000', 0, 'tdex')
this line saves 'tdex' (Tome of Agility Item Type Id) into Hashtable with key of itemtype id of a custom item 'I000', like one of your dummy tome and index of 0. you can find these rawcodes from Object Editor by click Ctrl + D.

so when a unit acquire/use item of itemtype 'I000', you can load the value in hashtable, using line like this:
  • onUse
    • Events
    • Conditions
    • Actions
      • Set TempItem = (Item being manipulated)
      • Custom script: set udg_TempItemType = LoadInteger(udg_Hashtable,GetItemTypeId(udg_TempItem),0)
to retrieve the actual item type id and do anything you want with it.

sample made in GUI. TempItem is a Item global variable, TempItemType is a Item-Type global variable
 
Level 8
Joined
Sep 30, 2012
Messages
205
thy
okay so far so good

how do i create that item then?

  • PowerUpIni
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set ItemHashtable = (Last created hashtable)
      • Custom script: call SaveInteger(udg_ItemHashtable, 'I00I', 0, 'manh')
      • Custom script: call SaveInteger(udg_ItemHashtable, 'I00H', 0, 'tdex')
      • Custom script: call SaveInteger(udg_ItemHashtable, 'I00J', 0, 'tdx2')
      • Custom script: call SaveInteger(udg_ItemHashtable, 'I00K', 0, 'texp')
      • Custom script: call SaveInteger(udg_ItemHashtable, 'I019', 0, 'tgxp')
      • Custom script: call SaveInteger(udg_ItemHashtable, 'I00M', 0, 'tin2')
      • Custom script: call SaveInteger(udg_ItemHashtable, 'I00L', 0, 'tint')
      • Custom script: call SaveInteger(udg_ItemHashtable, 'I00N', 0, 'tpow')
      • Custom script: call SaveInteger(udg_ItemHashtable, 'I00O', 0, 'tkno')
      • Custom script: call SaveInteger(udg_ItemHashtable, 'I00Q', 0, 'tst2')
      • Custom script: call SaveInteger(udg_ItemHashtable, 'I00P', 0, 'tstr')
      • Set Item[1] = Tome of Agility
      • Set Item[2] = Tome of Agility +2
      • Set Item[3] = Tome of Strength
      • Set Item[4] = Tome of Strength +2
      • Set Item[5] = Tome of Intelligence
      • Set Item[6] = Tome of Intelligence +2
      • Set Item[7] = Tome of Experience
      • Set Item[8] = Tome of Greater Experience
      • Set Item[9] = Tome of Knowledge
      • Set Item[10] = Tome of Power
      • Set Item[11] = Manual of Health
      • Custom script: call DestroyTrigger(GetTriggeringTrigger())
  • PowerUp
    • Events
      • Unit - A unit Uses an item
    • Conditions
    • Actions
      • Set ItemMani = (Item-type of (Item being manipulated))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • ItemMani Equal to Item[1]
              • ItemMani Equal to Item[2]
              • ItemMani Equal to Item[3]
              • ItemMani Equal to Item[4]
              • ItemMani Equal to Item[5]
              • ItemMani Equal to Item[6]
              • ItemMani Equal to Item[7]
              • ItemMani Equal to Item[8]
              • ItemMani Equal to Item[9]
              • ItemMani Equal to Item[10]
              • ItemMani Equal to Item[11]
        • Then - Actions
          • Set TempUnit = (Triggering unit)
          • Set TempPoint = (Position of TempUnit)
          • Set TempItem = (Item being manipulated)
          • Item - Remove TempItem
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (TempUnit is A Hero) Equal to True
            • Then - Actions
              • Custom script: set udg_ItemMani= LoadInteger(udg_ItemHashtable,GetItemTypeId(udg_TempItem),0)
              • Item - Create ItemMani at TempPoint
              • Set DummyItem = (Last created item)
              • Hero - Give DummyItem to TempUnit
              • Item - Remove DummyItem
              • Set DummyItem = No item
              • Set TempUnit = No unit
              • Custom script: call RemoveLocation( udg_TempPoint )
            • Else - Actions
              • Set tempPlayer = (Triggering player)
              • Set tempPlayerGroup = (Player group(tempPlayer))
              • Game - Display to tempPlayerGroup the text: |cffFFCC00Only Hero...
              • Item - Create ItemMani at TempPoint
              • Set DummyItem = (Last created item)
              • Hero - Give DummyItem to TempUnit
              • Set DummyItem = No item
              • Set TempUnit = No unit
              • Custom script: call RemoveLocation( udg_TempPoint )
              • Custom script: set udg_tempPlayer = null
              • Custom script: call DestroyForce(udg_tempPlayerGroup)
          • Set TempItem = No item
        • Else - Actions
      • Set ItemMani = (Item-type of No item)
 
Level 14
Joined
Jun 27, 2008
Messages
1,325
Not sure if there is a way to do it in GUI directly, but this will always work:

  • Custom script: call CreateItem(LoadInteger(udg_Hashtable, key1, key2), x, y)
Note that you cannot refer to this item with the GUI "Last Created Item". To enable this do
  • Custom script: set bj_lastCreatedItem = CreateItem(LoadInteger(udg_Hashtable, key1, key2), x, y)
instead.

x, y, are the coordinates where the item is created. You can use GUI globals to pass these, same goes for key1, key2.

  • Custom script: set bj_lastCreatedItem = CreateItem(LoadInteger(udg_Hashtable, udg_key1, udg_key2), udg_x, udg_y)
(Dont forget to actually create those gui variables, without the "udg_" prefix)
 
Status
Not open for further replies.
Top