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

Saving Item Type to Unit Type

Status
Not open for further replies.
Level 33
Joined
Mar 27, 2008
Messages
8,035
You really can't save an Item Type to a Unit Type via Hashtable, do you ?
If you really can't, is there any other suggestions ?

Like you can save Integers, Reals, Boolean to a Unit Type, but not from Item Type to Unit Type.

And before you lecture me about the "fact" why it cannot be saved (why it can't be saved, bla bla bla), I don't want to hear why it can't be saved, I just need a solution to this, or tricks maybe ?
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
I don't really understand what you mean with "from Item Type to Unit Type".
Do you mean save a specific Item Type for a specific Unit Type? (Like save Arthas' Hammer for the unit type Arthas so you don't have to use a million ITE's to see which item you need to give to which unit).

Since item types and unit types are both just integers, you can save the ID of the item type as the ID of the unit type (I don't know what the key would be, that depends on what you're trying to do).
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Like save Arthas' Hammer for the unit type Arthas so you don't have to use a million ITE's to see which item you need to give to which unit
Exactly.

Like saving Item A for Unit A, but note that I want to save multiple of items to Unit A, so it would not be just Item A for Unit A, it's like Item A, B, C for Unit A, while Item D, E, F for Unit B, and so on.

Hmmm since you mention that Item can be returned as Integer in its Raw ID, I suppose getting the Integer first would be appropriate before saving it to the Unit Type, since we can save Integers, but not a direct Item Type.

Will try something like this and post the result, thanks ;p
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
To elaborate, this is what I did:

  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set table = (Last created hashtable)
      • -------- Pandaren --------
      • Custom script: call SaveInteger( udg_table, 'Nsjs', StringHash( "Item1" ), 'I000' )
      • Custom script: call SaveInteger( udg_table, 'Nsjs', StringHash( "Item2" ), 'I001' )
      • Custom script: call SaveInteger( udg_table, 'Nsjs', StringHash( "Item3" ), 'I002' )
      • Custom script: call SaveInteger( udg_table, 'Nsjs', StringHash( "Item4" ), 'I003' )
      • -------- Antonidas --------
      • Custom script: call SaveInteger( udg_table, 'Hgam', StringHash( "Item1" ), 'I004' )
      • Custom script: call SaveInteger( udg_table, 'Hgam', StringHash( "Item2" ), 'I005' )
      • Custom script: call SaveInteger( udg_table, 'Hgam', StringHash( "Item3" ), 'I006' )
      • Custom script: call SaveInteger( udg_table, 'Hgam', StringHash( "Item4" ), 'I007' )
Key = Unit type
Value = "ItemX" (where X is a number)
Saved value = Item type

  • Give Items
    • Events
      • Time - Elapsed game time is 2.00 seconds
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • For each (Integer A) from 1 to 4, do (Actions)
            • Loop - Actions
              • Custom script: set bj_lastCreatedItem = CreateItem( LoadInteger( udg_table, GetUnitTypeId( GetEnumUnit() ), StringHash( "Item"+I2S( bj_forLoopAIndex ) ) ), GetUnitX(GetEnumUnit()), GetUnitY(GetEnumUnit() ) )
              • Custom script: call UnitAddItem( GetEnumUnit(), bj_lastCreatedItem )
It's a test-map, so there are only 2 units anyway :p.
You can also save the amount of items for each hero if they're not all the same.

Seemed to work quite nicely. The setup may be a bit annoying (checking all the raw ID's of all the items), but I don't really have a better solution.
 
the GUI Item-Type/Unit-Type translates directly to the jass rawcodes...

and as Apocalypse posted above, you just need to utilize the custom scripts to use them for creating items...

btw, what's it for?

If its for setting if an item is allowable for a unit, then you could also use the item rawcode as the child key... :)
 
Status
Not open for further replies.
Top