So a problem that was plaguing my map for quite some time was how to create a random unit for a player. The first thing I tried was making a Unit Type array, but there's a big problem with this.
As soon as you make a Variable = Unit Type an array, it changes to Variable = No Game Link[N] !!! (Pretty sure it's a bug o.O!)
So, how to work around this? Here's my solution: Use a String Array instead.
For example.
Local Variables
Random Unit Type = "" <String[4]>
Actions
Variable - Set Random Unit[1] = (String(Marine))
Variable - Set Random Unit[2] = (String(Zealot))
Variable - Set Random Unit[3] = (String(Zergling))
Unit - Create 1 (Unit type from Random Unit Type[(Random integer between 1 and 3)]) for player 1 at Spawn Region using default facing (No Options)
And a sure fire way to make sure you don't misspell a units name? Simply use a Convert Game Link To String. That way you can choose exactly what unit type you want, it converts that unit type a string, stores it in the Array, and you can call them randomly via a Math -Random.
Hope this helps you all out!
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
So a problem that was plaguing my map for quite some time was how to create a random unit for a player. The first thing I tried was making a Unit Type array, but there's a big problem with this.
As soon as you make a Variable = Unit Type an array, it changes to Variable = No Game Link[N] !!! (Pretty sure it's a bug o.O!)
So, how to work around this? Here's my solution: Use a String Array instead.
For example.
Local Variables
Random Unit Type = "" <String[4]>
Actions
Variable - Set Random Unit[1] = (String(Marine))
Variable - Set Random Unit[2] = (String(Zealot))
Variable - Set Random Unit[3] = (String(Zergling))
Unit - Create 1 (Unit type from Random Unit Type[(Random integer between 1 and 3)]) for player 1 at Spawn Region using default facing (No Options)
And a sure fire way to make sure you don't misspell a units name? Simply use a Convert Game Link To String. That way you can choose exactly what unit type you want, it converts that unit type a string, stores it in the Array, and you can call them randomly via a Math -Random.
Hope this helps you all out!