HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Keeping track of an array variabe

07-11-2004, 02:30 PM#1
sATARa
Imagine you made an array of 50 destructibles...
Also imagine you have a trigger with an event "destructible dies".
Now my question is, is it possible to get the index of the dieing destrucible in your array without using a very, very complicated if/then statement?
07-11-2004, 04:24 PM#2
Milkman
The system i would use for this would be to have units have the doodad models and then set a custom value for each one of them which corresponds to the index in the array.

Example: For each integer A from 1 to number of destructabels(units, really)
Loop - Actions
Unit - Set the custom value of (Last created unit/triggering/whatever event you wish to use.) to i
Set i = (i + 1)

This way, the units have the same custom value as their index in the array and when they die you can do YourArray[custom value of dying unit]


Thats all i can think of.
07-11-2004, 06:30 PM#3
sATARa
Heh... that is a nice way of doing it, in fact I use the same method when I find a need to. But the thing is, this array "must" be an array of destructibles, gates to be more specific... so its no good here :(

Quote:
Originally Posted by Milkman
The system i would use for this would be to have units have the doodad models and then set a custom value for each one of them which corresponds to the index in the array.

Example: For each integer A from 1 to number of destructabels(units, really)
Loop - Actions
Unit - Set the custom value of (Last created unit/triggering/whatever event you wish to use.) to i
Set i = (i + 1)

This way, the units have the same custom value as their index in the array and when they die you can do YourArray[custom value of dying unit]


Thats all i can think of.
07-11-2004, 08:11 PM#4
Anitarf
Well, you do have an array. You just, in addition to the array, set the custom values to the index of the array. If you don't do this, you can still get the results with a loop:

Code:
For each integer A from 1 to numberOfDestructibles
    loop - actions
        if - then - else multiple functions
            if - conditions
                destructibleArray(integer A) = dying destructible
            then - actions
                ~do your stuff here~
                skip remaining actions
            else - actions
                do nothing
07-11-2004, 08:32 PM#5
sATARa
Man I cant use custom values, because we are talking about destructibles here o_O ...
About your code... it is kind of lag prone for the thing I intend to use it for... but I guess it will do the trick, so thx :>

Quote:
Originally Posted by Anitar
Well, you do have an array. You just, in addition to the array, set the custom values to the index of the array. If you don't do this, you can still get the results with a loop:

Code:
For each integer A from 1 to numberOfDestructibles
    loop - actions
        if - then - else multiple functions
            if - conditions
                destructibleArray(integer A) = dying destructible
            then - actions
                ~do your stuff here~
                skip remaining actions
            else - actions
                do nothing
07-11-2004, 08:39 PM#6
Anitarf
Right, I wasn't thinking at all, lol... Yeah, with destructibles, you can't use custom values.
07-11-2004, 11:50 PM#7
th15
Use a loop.

Since you're usign less than 64 destructibles, you can use the destructible dies event.

Code:
Event:
Destructible within forest region <gen> dies

Condition:
None

Action:
For each integer 1-50 do:
      If then else: - Conditions:
                 If dying destructible = TreeArray[Integer A]
         Then:
                 Set DeadTreeNumber = Integer A
         Else:
                 Do Nothing

A pretty standard operation in any programming language.