For those who want to understand arrays:
how do i create arrays?
while making a new variable just activate the "array" box and set the number of possible entries.
to call the different entries you have specify the number of the entrie: tinef[1] for the first entrie, tinef[2] for the second entrie (tinef is the name of the variable).
WTF are arrays anyway???
a common variable has only 1 value. by using arrays its possible to store many values in a single variable. this is useful to create certain dynamic things instead of using copy-paste all the time.
HUH?
heres an example:
10 spawnpoints are created (regions in this case).
a variable named "spawnpoints" is created as array with the size 10.
at the beginning of the map the spawnregions are stored in the array:
Set spawnpoint[1] = frist_spawn_region <gen>
Set spawnpunkte[2] = second_spawn_region <gen>
etc.
whatever... now whats the clue with arrays?
besides the overview, arrays have a nice feature: you can replace the index-number by a variable itself.
instead of using this
Unit - Create 1 Soldier for Player 1 (Red) at (Center of spawnpoints[1]) facing Default building facing (270.0) degrees
u can make it like that
Set randomnumber = (Random integer number between 1 and 10)
Unit - Create 1 Soldier for Player 1 (Red) at (Center of spawnpoints[randomnumber]) facing Default building facing (270.0) degrees
=> 1 unit is spawned in a random spawnpoint
of course u could solve this with mass IFs but this wouldnt work anymore if u make a map with 100 possible spawnpoints.
any other examples?
in case u want to spawn 1 unit in each spawnregion u could make a loop reffering to all arrayentries.
For each (Integer A) from 1 to 10, do (Actions)
Loop - Actions
Unit - Create 1 Soldier for Player 1 (Red) at (Center of spawnpoints[(Integer A)]) facing Default building facing (270.0) degrees
=> the action unit-create is executed 10 times. the value of integer A changes each time so another spawnpoint is used in each step. YES u could just copy-paste triggers instead. but that wont work if u have 100.000 spawnregions (theres a maximum triggerlength
)
hf