For those not familiar with unit indexers such as
UnitIndexingUtils,
AutoIndex,
Perfect Unit Indexing (PUI),
Advanced Indexing and Data Storage (AIDS) or
Unit Indexer, this can give you a bit of a
crash-course.
You definitely want to make your spell MUI. To do that, you either use a hashtable or use some
complex form of indexing. It is very good to choose
hashtable because you can load data
from a unit instead of from a list (ie. making it very easy to retrieve an index on death).
Using a hashtable has a bit of a learning curve. There are two keys - a
child key, a
parent key and, finally, the actual data being stored. Saving
100 to the casting
unit looks like this:
-
Hashtable - Save 100 as (Key(Damage)) of (Key(Triggering unit)) in (Last created hashtable)
Using a unit indexer, you can super-simplify it to just this:
-
Set Damage[(Custom value of (Triggering unit))] = 100
Instead of using a hashtable with multiple keys, this simply uses an
array with the
custom value of the unit as the array index.
Have you ever used unit custom value before? If so, you may be familiar with this method:
-
Unit - Set custom value of (Triggering unit) to 100
That is definitely the easiest way to attach 100 to the unit, but you really
limit yourself
by doing that. What if you wanted to remember other things, such as the target unit and the
target location?
Using a Unit Indexer, it's like this:
-
Set Key = (Custom value of (Triggering unit))
-
Set Damage[Key] = 100
-
Set Target[Key] = (Target unit of ability being cast)
-
Set TargetPoint[Key] = (Target point of ability being cast)
-
Unit Group - Add (Triggering unit) to SpellGroup
Recalling this data whenever you want becomes truly easy and even
easy to read.
-
Timed Spell
-
Events
-
Time - Every 0.03 seconds of game time
-
Conditions
-
Actions
-
Unit Group - Pick every unit in SpellGroup and do (Actions)
-
Loop - Actions
-
Set Key = (Custom value of (Picked unit))
-
Unit - Cause (Picked unit) to damage Target[Key] for Damage[Key] of attack type Chaos and damage type normal
The possiblities are literally endless. Indexing this way is pretty fun as well, even helping
to reduce total in-game hashtable count (the limit is 256).