HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Assign a unique name to a created unit?

06-23-2004, 09:25 AM#1
Lunatic_pAOM
Hello,

Here's the problem I encounter in my map:

At map initialization, I do a loop to create all the player's units:

For A = 1 to 6
I create a custom-built hero unit "HumanPeon" for player [Integer A].
Then, I set the CurrentHeroForm[Integer A] to LastCreatedUnit.

But then, CurrentHeroForm[1]=HumanPeon, CurrentHeroForm[2]=HumanPeon... and so on, CurrentHeroForm[6]=HumanPeon.

My question: When I have created all the heroes, how can I assign a unique name, or is it an ID? (like HumanPean01, HumanPeon02...) to them?

Thx in advance!
06-23-2004, 10:32 AM#2
Lunatic_pAOM
After thinking about it, here is the problem in other words:

When you put a unit on the map it gets a unique name, like unit0001.

When you create a unit on the map with a trigger, the "lastcreatedunit" only bears its unit type as an identifier (or maybe I am wrong?).

So, how can I select one only specific unit of several trigger-created units of the same type?
06-23-2004, 09:00 PM#3
LunaSeer
Well there is this unit ID function. But you have to assign the ID to the unit before using it. If it doesn't matter what ID number the unit has then you can do this:

Variables:
OnMap = UnitGroup
NumberOfUnits = Integer

Trig One
Code:
[color=Yellow][b]Events[/b][/color]
Time Elapsed is 0.01 seconds
[color=Red][b]Actions[/b][/color]
Pick every unit in playable map area and add picked unit to OnMap
Run Trig Two checking conditions
Trig Two
Code:
[color=Lime][b]Conditions[/b][/color]
Number of units in OnMap is greater than 0
[color=Red][b]Actions[/b][/color]
Pick every unit in random unit in OnMap and do actions
     Set unit ID of picked unit to NumberOfUnits
     Remove picked unit from OnMap
     Set NumberOfUnits = NumberOfUnits + 1
Run this trigger checking conditions
Trig Three
Code:
[color=Yellow][b]Events[/b][/color]
A unit enters playable map area
[color=Red][b]Actions[/b][/color]
Set unit ID of entering unit to NumberOfUnits
Set NumberOfUnits = NumberOfUnits + 1
Simple. :D

I'm guessing you should know how to use the IDs by now. Works well with "pick every unit", "integerA", and "If/then/else".
06-30-2004, 03:21 PM#4
Lunatic_pAOM
Cool. Sounds nice. I think I've tried to work around this. But I'll try your proposition.

Thx !!