Custom Value for Units
From TDGwiki
Written by TheZizz
NOTE: This tutorial requires a basic understanding of triggers and variables. Got it? Then let's go!
Introduction
As you all know, Frozen Throne gave us mappers a renewed reason to live. The Blizzard gods bestowed unto us, among other things, custom values for our units.
What they are
Custom values are, in short, numbers for each unit. When a unit is created in the game, they are given a custom value of 0. The custom value serves no purpose on its own, in ladder games, and indeed in many of your favorite maps. It is up to the mapper to use them, by method of this trigger action:
| Unit - Set the custom value of (Unit) to (Integer) |
What they can do for you
It's up to you. They can represent anything, whether it be a unit's number of kills, a unit's ammo, or the number of times a unit got to second base. Haha, what a loser.
But truth be told, you're cutting yourself short if you don't use them as unique IDs. Before I explain that I give you this trigger:
Sample trigger
|
This trigger is very simple. Whenever a new unit is created, its custom value will be set to a unique value that no other unit will possess, ever.
As you may have deduced, this little operation opens up an encyclopedia of possibilities. With the magic of variable arrays, you suddenly have at your disposal not one, but a million billion custom values per unit, and what's more they can be strings, reals, etc. Whatever you want!
Be warned though, for if your map will have TONS of units (thousands) then you really should do the responsible thing and recycle your long-dead units' IDs. This requires a bit more work that makes some suggestive flirts at the Intermediate category, so I won't get into that here.
Well, that's it. I hope to have been of service. Thanks for reading and God speed!

