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

Unit Indexer? Huh?

Status
Not open for further replies.
Level 22
Joined
Sep 24, 2005
Messages
4,821
It indexes unit; it maps a value (integer) to a unit.

Let's say we have 2 units, footman(0x01) and footman(0x02), we then tell the Unit indexer to index 0x02, it gives it the id 100. Then we index 0x01 too, the indexer assigns 900 to it. Now, whenever we fetch the integer index for the said unit, it will always return a unique, constant integer index. You can then use that index as an array index (or a struct instance id or slot) for your spells and you won't need to worry about collisions (array index collisions).

I hope you got that, I'm bad at explaining.
 
Level 11
Joined
Oct 11, 2012
Messages
711
It gives every unit a unique number, an integer. It sets the custom value of a unit. No other unit has the same number. You can use the number as an index in arrays. So yes, it helps making a spell MUI.

It indexes unit; it maps a value (integer) to a unit.

Let's say we have 2 units, footman(0x01) and footman(0x02), we then tell the Unit indexer to index 0x02, it gives it the id 100. Then we index 0x01 too, the indexer assigns 900 to it. Now, whenever we fetch the integer index for the said unit, it will always return a unique, constant integer index. You can then use that index as an array index (or a struct instance id or slot) for your spells and you won't need to worry about collisions (array index collisions).

I hope you got that, I'm bad at explaining.

Thank you both for the reply. But don't we already have GetHandleId() for that? I mean units already have unique IDs. So my follow up questions are:
1. what distinguish unit indexer from GetHandleId()?
2. if I use unit indexer, how do I fetch or get a unit's unique id? Any function calls for that?

Thank you.
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
1. Handle ID's can't be used raw on arrays, its values are too high.
2. That depends on the Unit Indexer library you are using. (system API)
 
Level 11
Joined
Oct 11, 2012
Messages
711
1. Handle ID's can't be used raw on arrays, its values are too high.
2. That depends on the Unit Indexer library you are using. (system API)

Thanks for the explanation, chobibo. It helps a lot. I am using Nestharus's unit indexer.


Thanks for the clarification, Nes. :)
 
Status
Not open for further replies.
Top