HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

How to get unitId or selection ID

01-07-2010, 12:08 PM#1
leric
On every unit that we place on the map it will generate a so call "ID" (e.g. Dyrad 0250) where u can see it at bottom part of the world editor if u click on that unit.

1. How get that "ID"?

or

In order to differentiate a unit between their twins (e.g. a Peasant out of 10 Peasant) there should be a unique ID for each unit.

2. What is that ID call?

3. How do i get it? and which natives will do the job?

I'm try to add each hostile unit to an array (or register as active opponent) that comes in range of a group of unit. A player can have more than one group of unit in different location each group and so i do not want all groups to register the enemy but only 1 group so that (e.g. Group 1 will not go attack enemy near group 2).
01-07-2010, 01:15 PM#2
MeKC
Before we used the return bug to get that ID. But after the newest patch Blizzard added af function that can return that value (integer).

Its called something like GetUnitHandleID i think. - Can't remember now when I do not have WE on this computer.
01-07-2010, 01:33 PM#3
DioD
you cant get this ID...

its just part of variable name.
01-07-2010, 02:26 PM#4
leric
my codes are in AI script so i won't be able to do it in trigger script way.

GetUnitHandleID - can't find this native or function in common.j, blizzard.j or common.ai

then how can i get the unique ID for a specific unit? i need to get all the unitID which is within range of a unit but i can't use triggers since the ai script won't know what is that.
01-07-2010, 04:44 PM#5
akolyt0r
the jass function is GetUnitId ...
But i dont know if it works in ai... or how (or if its possible at all) it could be made working...

Well at least for heroes theres the AI native GetHeroId
01-07-2010, 05:03 PM#6
leric
weird....again i can't find this natives "GetUnitId". Which file is it at?

i've found a native "GetUnitUserData":
GetUnitUserData takes unit whichUnit returns integer

which i wonder is it to get that value which i want. But then i can't even specify which unit to pass it as the parameter so again it is useless for me now.
01-07-2010, 05:15 PM#7
akolyt0r
Quote:
Originally Posted by leric
weird....again i can't find this natives "GetUnitId". Which file is it at?

i've found a native "GetUnitUserData":
GetUnitUserData takes unit whichUnit returns integer

which i wonder is it to get that value which i want. But then i can't even specify which unit to pass it as the parameter so again it is useless for me now.

Ah my error ... its "GetHandleId" not "GetUnitId"

GetUnitUserData returns a custom value which you can set your self using SetUnitUserData (and it should have the value 0 if you dont set this value).
01-07-2010, 05:34 PM#8
Alevice
Quote:
Originally Posted by leric
On every unit that we place on the map it will generate a so call "ID" (e.g. Dyrad 0250) where u can see it at bottom part of the world editor if u click on that unit.

1. How get that "ID"?

or

In order to differentiate a unit between their twins (e.g. a Peasant out of 10 Peasant) there should be a unique ID for each unit.

2. What is that ID call?

3. How do i get it? and which natives will do the job?

I'm try to add each hostile unit to an array (or register as active opponent) that comes in range of a group of unit. A player can have more than one group of unit in different location each group and so i do not want all groups to register the enemy but only 1 group so that (e.g. Group 1 will not go attack enemy near group 2).


Said "ID" is just a fancy display for an automatically generated global ID used in the war3map.j

It really isn't an true unit instance id, and it cannot be accessed by an AI, at least by using .ai scripts.
01-07-2010, 06:48 PM#9
Troll-Brain
I didn't played that much with AI, but for those did, is there any feature available on a .ai script which can't be done in some way in the trigger editor ?
Imho, a .ai is fairly limited (not talking about the gui editor which is a pure joke).

But there is no doubt that some things would be hard to remake, but not impossible i think.

Also coding .ai script is a pain in the ass.
01-08-2010, 08:24 AM#10
leric
Quote:
Originally Posted by akolyt0r
GetUnitUserData returns a custom value which you can set your self using SetUnitUserData (and it should have the value 0 if you dont set this value).

I suppose i can make my own ID for each instances out of this then. Thanks.

But now i'm still having problem to get a unit to be register unique. Anyone have any idea in what circumstances i can uniquely "select" a unit? i plan to register a unit into an array whenever it is created but again, i can't use trigger so the ai dunno when will a unit being created.
01-08-2010, 08:45 AM#11
leric
Quote:
Originally Posted by Troll-Brain
I didn't played that much with AI, but for those did, is there any feature available on a .ai script which can't be done in some way in the trigger editor?

IMO,
one of the example i can give is, if u are to ask AI to expand it's base,

AI script: u can easily call the build in expansion function which the game engine will automatically chooses one of the available spot. Suppose they have already store all spots into their own variable.

Trigger: u have to write ur own expansion script. Which point to build what buildings and such for every gold mine. I suppose you'll have to write up alot of map information related stuff to completely make a good AI using triggers.

Is there a thread limit for triggers? ai script has a max 6 thread per controller.
01-08-2010, 09:10 AM#12
grim001
Quote:
Originally Posted by leric
I suppose i can make my own ID for each instances out of this then. Thanks
So basically you want an indexing system that works in AI scripts? Why do you have to do stuff in AI scripts anyway?
01-08-2010, 09:31 AM#13
Troll-Brain
Sure it would be really a pain in the ass, but all you've said can be done in trigger editor.
And so you could use an UnitIndexer.

Quote:
Is there a thread limit for triggers? ai script has a max 6 thread per controller.
Hmm the jass2 don't fire several threads at the same time, but if i understand you correctly, the answer is "no, there is not practical limit"
01-08-2010, 10:11 AM#14
leric
Quote:

Quote:
Originally Posted by grim001
So basically you want an indexing system that works in AI scripts? Why do you have to do stuff in AI scripts anyway?

Quote:
Originally Posted by Troll-Brain
Sure it would be really a pain in the ass, but all you've said can be done in trigger editor.
And so you could use an UnitIndexer.


Like i've said in my example on the previous post example about the base expansion, there is much pre-define constants (no prove only my opinion) such as location of mine,creep camps, shops and so on where i don't plan to rewrite all this myself as it is time consuming unless i'm able to write up my own map initializer and dynamic construction code. I've time limit (2-3 months) to write the whole AI code so i'll take less risk to go for ai script.

Quote:
Originally Posted by Troll-Brain
Hmm the jass2 don't fire several threads at the same time, but if i understand you correctly, the answer is "no, there is not practical limit".

I need several thread to be run on same time.
01-08-2010, 10:29 AM#15
Troll-Brain
Quote:
I need several thread to be run on same time.
Imho, you don't.
Also i can't believe a .ai can run several threads in the same time, and not closely to each other like inside the trigger editor.
Maybe we don't use the right words.

But yes i'm agree about the usefulness of an .ai here.