HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Keeping track of affected units using arrays.

06-30-2004, 05:33 AM#1
cacophony
I want to create a beneficial trigger-based spell that can be used on more than one unit at a time. To do this, I created a unit array with a max value of 3 (the highest number of times the ability can be cast before it diminishes) and wrote a trigger to keep track of this whenever it is cast on an ally.

Here is where I get stuck. I'm not sure which function to use that will have the effect of giving the targeted unit of this spell a variable of Variable[x+1]. Keep in mind that this ability will not use up ALL of the array at one time; it may use only 1, or 2, or zero of the array. It seems that I have to write in a discrete value for the index. Moreover, I do not know how to go about subtracting a unit from this array once the spell finishes or is used (the spell fires when the affected allied unit is killed). I've tried substituting (IntegerA) as the index value, but this screws things up and only keeps track of the first unit the ability is cast upon. To anyone who could help me out with this, I would be in your debt.
06-30-2004, 08:07 AM#2
Anitarf
To remove a unit from the variable, just set the variable to "no unit". When you assign the unit to the array, just go through the array with a loop and put the unit into the first spot that has no unit in it yet (unit comparison: unitVariable(integer A) equal to (no unit)). When you find a spot to put the unit in, use "skip remaining actions" so that the trigger doesn't put the unit in all the other free spots as well.