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

I need a tutorial that teaches me about custom values.

Status
Not open for further replies.
Level 6
Joined
Feb 10, 2011
Messages
188
Basically I am trying to understand what exactly a units custom value is and how to tell.

I want to use this: http://www.hiveworkshop.com/forums/spells-569/gui-unit-indexer-1-2-0-2-a-197329/ for my map cause it would say me a lot of time. I had someone try to explain it to me but I'm just not understanding it.

I get that the units index is its custom value and that its automatically set, but i guess i dont understand how to correctly refer to the unit. or to figure out what its custom value (or index) is.
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
attachment.php
 

Attachments

  • customval.png
    customval.png
    30.8 KB · Views: 188
Level 16
Joined
Dec 15, 2011
Messages
1,423
A custom value is an integer attached to a unit (hence the name) and can be set/recall freely. The unit indexer assigns a unique custom value to a unit which acts as an identifier of the unit itself. This is very useful because data array indexes can also be attached to the unit with the custom value as key. The index can be recalled through the unit and vice versa.

Here is a simple example of unit indexer usage. You have a red box (with a gold coin inside) that has a shiny sticker on it. If it is put among other identical red boxes, you can identify it easily. Now what if the sticker is removed and you somehow get the red box mixed into the box collection? It would be impossible to find it again. However if you numbered the boxes beforehand, you just need to find the box with the special number on it.

The attached data is the content of the box. You get the box right and voilà, a gold coin.

Opening/weighing each box to check works indeed but yeah, try that with 8192 boxes.

Stuffs are attached like this: arrays with the custom value as index. For instance, set IntArr[index of unit A] = 10. When you pass unit A as an argument, you get the number 10 back. So on and so forth.
 
Level 30
Joined
Nov 29, 2012
Messages
6,637
Custom value can be used for indexing units (as a quick reference to a specific unit or arrayed variables associated with it, for any particular reason) or as a kill counter (or a variety of other things) whereas point value can be used for things that would normally be constant throughout the game, such as the number of points a player might get for killing a unit of that type (so if a Footman had 3 point value, you could trigger a scoring system so that when a Footman dies, <Point value> is added to the killer's score

Just look at here...lol: Click!
 
Level 28
Joined
Sep 26, 2009
Messages
2,520
Custom Value is an integer number that usually serves as an Index number for arrays.

Unit indexing systems set a unique number/unique custom value for each unit - that way you can easily find out unit in a variable array by loading its custom value.

I made a simple trigger - a part of an AoE damage over time spell. For the sake of this thread, I made the trigger simple and didn't remove leaks.
Look in hidden tab
  • AoE DoT
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to AoE_DoT
    • Actions
      • -------- --------------------------------------------------------------------------- --------
      • -------- Sets vital variables --------
      • Set p = (Target point of ability being cast)
      • Set Group = (Units within 250.00 of p matching ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an ally of (Owner of (Triggering unit))) Equal to False)))
      • -------- --------------------------------------------------------------------------- --------
      • -------- --------------------------------------------------------------------------- --------
      • -------- Here's the magic --------
      • Unit Group - Pick every unit in Group and do (Actions)
        • Loop - Actions
          • -------- Unit Indexing Systems already assigned Custom Value to this picked unit --------
          • Set Index = (Custom value of (Picked unit))
          • -------- I have just loaded that custom value into variable to use it as an index --------
          • -------- --------------------------------------------------------------------------- --------
          • -------- --------------------------------------------------------------------------- --------
          • -------- We need to set how long will this Damage over time effect last - we need a duration --------
          • Set Duration[Index] = 10
          • -------- As you can see here, this Duration variable has index called "Index" --------
          • -------- The value of Index is the Custom Value of picked unit - that means it is unique number --------
          • -------- Since that number is unique, we don't have to worry about another unit rewriting that variable array --------
          • -------- simply because it will never have same Index / Custom Value --------
 
Status
Not open for further replies.
Top