Is there a way to get a unit's id? I mean, like a real id-number in integers, but for a widget? Or real, I don't really care.
Something like "GetUnitIdNumber( Unit )", which is an integer.
(I know I just made that function up, I just wrote it so you'd understand what I'd like)

I asked this in hiveworkshop.com before, and someone told me that I should use something called Handle2Integer (H2I) but I have no idea how to use it, or what it does.

Now, I have a request too.
Could you please not go too deep into advanced functions and such?
As you might have already seen, I'm very new to this vJass and all. I've just begun using scope for a spell I'm developing, so I don't know squat about anything beyond those bonds (labraries, structs etc.).
Telling me things beyond scopes and such would just be a huge waste of time since I'll probobly end up scratching my head and looking like this dude (although I'm quite sure my face wouldn't be green).

0x100000 is hexadecimal for the first handle's ID, subtracting it will bring the IDs down to a range where they fit inside JASS arrays.

However, it is a common issue that you will still get more than 8191 handles in a map (whether because it's a big map or because you are leaking). To deal with this, you need to use bigger arrays. vJASS has a syntax for extending the size of arrays, but it's slower:

This is starting to sound like a huge pain in the ass, right? It can still break if you keep leaking or creating new handles until you get more than 24573 (or whatever value you've chosen) handles, and it generates tons of extra code.

There are a few alternatives to this. First, you can use gamecache or Table to attach data to the H2I ID of the unit. It's easy because gamecache has no size limits or other nonsense to deal with, but it is slower.

However, the fastest way to deal with it is to use SetUnitUserData/GetUnitUserData to store a unique integer on every unit in your map. Then you can just use the "GetUnitId" function to grab the ID. This is called unit indexing. You can look at UnitIndexingUtils or AutoIndex for that.

H2I gives you an unique value, but note that it is too big to be used as an array index. ( You can always decerease it, or hash it or something )

You can also use GetUnitUserData, but it requires you to set different numbers to all units, by using SetUnitUserData.

I'm actualy using GetUnitUserData() in my spell right now. However, I want to get rid of it.
You see, this work is not for a map, but for a spell. I'm planning on releasing this in public and it should be 100% multi-instancable and self-sufficient.
Problem is that it uses TriggerSleepAction( Duration(level) ) between two loops to state that it's waiting, so if a guy wants this in his map - but use SetUnitUserData() for other purposes - this is an impossibility.

Now you may ask ok, why not use integer array and compare the results? (ok maybe you're not but still)
This is an impossibilty aswell, since it's got a long wait between my two loops, and a map-maker can change the values in-between.

I won't go any deeper since I will just have to explain more and more of my code, I think it will be easier if I just post it here later.

Quote:

Originally Posted by grim001

If you plan to attach data to a unit with the ID number you get from H2I(u) it won't work. The value you get from H2I is too big to fit in JASS's little 8191 sized arrays.

No, I was thinking of making set Integer_Array[UnitIdNumber] = Integer_Array[UnitIdNumber] + 1. Hm... perhaps that's what you asked for :P
Arrays have a size limit in Jass?! Thanks for the info

Quote:

Originally Posted by grim001

You can deal with this in a number of ways. First you could try using this code:

0x100000 is hexadecimal for the first handle's ID, subtracting it will bring the IDs down to a range where they fit inside JASS arrays.

However, it is a common issue that you will still get more than 8191 handles in a map (whether because it's a big map or because you are leaking). To deal with this, you need to use bigger arrays. vJASS has a syntax for extending the size of arrays, but it's slower:

This is starting to sound like a huge pain in the ass, right? It can still break if you keep leaking or creating new handles until you get more than 24573 (or whatever value you've chosen) handles, and it generates tons of extra code.

Well, that's really up to the user. If he wants this spell's area of effect to be 10,000 and fill up a lot of units in it, that's his decision, not mine.
But I think this might solve my problem, I'll try implenting this in my spell and see if I get somewhere.
Since this is a quite small aoe spell I'm making (I don't think anyone will use it with more than 1000 aoe) and it filters a lot of units, I think can make the id-number even smaller, but I'm not sure how...
Just add another 0 at the end of the hexadecimal?

Quote:

Originally Posted by grim001

There are a few alternatives to this. First, you can use gamecache or Table to attach data to the H2I ID of the unit. It's easy because gamecache has no size limits or other nonsense to deal with, but it is slower.

However, the fastest way to deal with it is to use SetUnitUserData/GetUnitUserData to store a unique integer on every unit in your map. Then you can just use the "GetUnitId" function to grab the ID. This is called unit indexing. You can look at UnitIndexingUtils or AutoIndex for that.

Table looks nice, though I don't understan squat of it I'm not that advanced yet.
However, the UnitIndexingUtils uses GetUnitUserData which I already explained why I don't want, and AutoIndex is faaaaar to complex for me

If grim001's function works, I'll give him +rep and this can be considered solved.
If not, I'll just ask for more help (and post the code so you may better understand my problem).

: : EDIT : :
W000000T! It seems to wooooork!
I just need more testing and such, before I give my +rep away.
Thanks a lot you guys for help, and a special thanks to grim001.