HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

How to get the number of unit ?

04-23-2007, 09:06 PM#1
abriko
How to get the number of a unit ? The one after the unit type name and before the <gen>.
Ex: Peasant 0045 <gen>
04-23-2007, 10:18 PM#2
Mapz_Maker
Why does it matter?
04-23-2007, 11:40 PM#3
Pyrogasm
The only way I know of is to select a unit in the map (while editing, not while playing) and double click. Then, it should say the unit's specific variable.


No clue how to do it in-game. You could make a counter that went up every time a unit entered the map (and included all units pre-placed on the map), and use that as a basis for whatever it is you need to do...
04-23-2007, 11:43 PM#4
Dil999
The units lose these ingame. This number is just used to define preplaced units in world editor.
04-24-2007, 04:45 AM#5
EnderA
If you want to keep track of individual units, you can add variables (Unit/Unit Group variables, or arrays of them) and add the units to them.
04-24-2007, 06:33 AM#6
MaD[Lion]
answer is you cant get that name-number. But there may be other ways to solve ur problem if u tell us.
04-24-2007, 07:40 AM#7
abriko
Quote:
Originally Posted by Dil999
The units lose these ingame. This number is just used to define preplaced units in world editor.

No.....each unit created in game got a number.


Wait, i found something, i'll make some test.
04-24-2007, 11:58 AM#8
Zwan
assign custom values? then you can select them by ther value.
04-24-2007, 12:23 PM#9
Rising_Dusk
Unfortunately, the only way to get this number is to compare with all unit-generated globals.
The issue is that while they are numbered like so in the WE, they are not created in this order in WC3.
That means you can't even do H2I() checks to get said number.
Quote:
No.....each unit created in game got a number.
Yes, a handle index, but that won't work to get the number you're talking about.
If you just want a handle index for a unit, H2I() is your friend.
04-25-2007, 02:47 PM#10
abriko
i tell you what is my purpose. For each unit of the 3differents marine type created in game, i create on it a special effect. No problem for that.
But when a unit of this types die, i want to destroy the special effect because of the memory leak and visual effect floating in the air without unit.
04-25-2007, 03:12 PM#11
zen87
uuuh... why dont u just use the tornado aura/item statbonus ability with no bonus effect just with the attaced special effect ?

---

btw, u can attach the effect on the unit by using the caster sys,
Collapse JASS:
AttachObject(target,"the_effect",AddSpecialEffectTarget(whatever-u-wan-here))
then whenever a unit died, just run this
Collapse JASS:
if GetAttachedEffect(GetTriggerUnit(),"the_effect")!=null then
    call DestroyEffect(GetAttachedEffect(GetTriggerUnit(),"the_effect")
    call AttachObject(GetTriggerUnit(),"the_effect",null)
endif

well im not sure, is this waht you want ?
04-25-2007, 03:27 PM#12
Rising_Dusk
Quote:
uuuh... why dont u just use the tornado aura/item statbonus ability with no bonus effect just with the attaced special effect ?
That's the best way.
Use sphere/life regeneration aura/whatever to attach the effect if you don't want a buff.
Then it automatically clears upon the unit's death.
Done, no code needed.

Getting the unit's "number" means nothing anyways.
There's no need for it anyways if your whole point is as you say.
04-25-2007, 07:28 PM#13
abriko
Ok thx, i'll try this :)
I just thought that it could be interesting to know the unit number when i want... ^^