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

[JASS] Why using UnitIndex?

Status
Not open for further replies.
Level 22
Joined
Sep 24, 2005
Messages
4,821
You mean in unit indexers? Well, because you can't use the handle ids directly as array indices, that's why.
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
That's not an array though. I was talking about arrays... The point of unit indexers is to maximize code execution speed.

EDIT: To answer the question: Yes, you can do that.
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
as chobibo said, Unit indexer gives your units a values from 0 to 8191(maybe higher, but you will never have 8000 units in one map). This is made to maximize speed, therefore use arrays. GetHandleId returns handleid of given handle. It is also unique, but for agents(unit is agent) the returned value starts at 0x100000(roughly 1.4 million). You cant use 1,400,000 inside array :D
 
GetHandleId returns pretty big value, 0x100000++ (for agents), thus you can not operate with arrays since thier max index value is 8191. Arrays are fast, we like to use them.
Indexer manages and assigns unique index for every unit on the map ranging from 1 to 8191. You can use that to your advantage in numerous ways. They also provide _INDEX/ _DEINDEX event adding more convenient enter/leave events.

Basically, you do not need UnitIndexer if you don't want to. Unique handle id for each unit allows you to create MUI spells and systems anyway. Although, to gain some efficiency, it's good to have one within a map.

Look in jass section or spell section for examples of why and how you can use UI to your advantage.

Edit: In between another posts, was writing :p
 
Level 15
Joined
Aug 7, 2013
Messages
1,338
Thanks for asking this question Geshishouhu, it helped me a lot in understanding the purpose behind a UnitIndexer, and I was thinking of creating a similar thread too.

So the gist is that unit indexer gives a performance boost to code that requires MUI, if I understand correctly.
 
Level 11
Joined
Oct 11, 2012
Messages
711
Thanks for asking this question Geshishouhu, it helped me a lot in understanding the purpose behind a UnitIndexer, and I was thinking of creating a similar thread too.

So the gist is that unit indexer gives a performance boost to code that requires MUI, if I understand correctly.

You are welcome, sethmachine. :)
I think your understanding is correct. With Unit Indexer it comes with performance boost and maybe more convenient coding.
You may also find this post helpful http://www.hiveworkshop.com/forums/...x-unit-indexer-248209/index6.html#post2562752 because there are so many Unit Indexers systems around. Credit goes to Bannar.
 
Status
Not open for further replies.
Top