• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

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 39
Joined
Feb 27, 2007
Messages
5,010
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