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

Storing and managing a specific unit

Status
Not open for further replies.
Level 2
Joined
Nov 26, 2019
Messages
10
Hey guys!

I was wondering if there is a cleaner or more efficient way on handling a specific unit throughout the game.
I am currently working with a unit-group array that has a unit group for every player in which the main hero of every player is stored.

Here's the way I'm storing them:
  • Unit Group - Add (tempUnit) to UnitGroupArray[tempInteger]
And here's the way I'm calling them:
  • Unit Group - Pick every unit in UnitGroupArray[tempInteger] and do (Action)
I would love to hear other ideas. Thanks!
 
Last edited:
Level 2
Joined
Nov 26, 2019
Messages
10
Can players have more than one hero? If not then just use a unit array instead of a group array. If multiple heroes (and every player doesn't necessarily have the same number) then the group is an acceptable solution.

Oh wow, I always thought the unit variable wouldn't keep hero levels and so on, but I guess that's the Unit-Type variable. Thanks for enlighting me and letting me check back on that. I'll switch from Unit-Group to Unit then, because I'm currently not planning on having more than one hero for each player.

Thanks Pyro!
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
Yes a unit variable points to the specific unit you assign it to. This persists through death and revival. If you ever use the “Replace Unit” command (which I wouldn’t recommend) the variable will not be re-assigned automatically, you’ll have to do it yourself.
 
Status
Not open for further replies.
Top