Blank
Development > Triggers
how to spawn random units
- 16 posts
-
TwoDie Author
- Battle.net
- TwoDie
- #792 EU
- Join date
- Apr 30, 2010
- Location
- Lithuania
- Reputation
- 7
- Posts
- 299
- Projects
- 7
- Last login
- May 23, 2013
-
xDarkZeratulX Regular Shmoe
- Join date
- Jul 07, 2012
- Location
- Singapore
- Reputation
- 1
- Posts
- 11
- Last login
- Mar 06, 2013
................................................................................. step by step maybe? :X
-
SouLCarveRR Author
- Join date
- May 27, 2010
- Location
- United States
- Reputation
- 23
- Posts
- 2,454
- Projects
- 1
- Teams
- Last login
- May 21, 2013
To celebrate my return, I made you an example.....
Skype
KageNinpo = SNMy Libraries
DialogLeaderboard & TeamSortMy Projects
SPACEWAR Tribute
Infinite TD -
xDarkZeratulX Regular Shmoe
- Join date
- Jul 07, 2012
- Location
- Singapore
- Reputation
- 1
- Posts
- 11
- Last login
- Mar 06, 2013
Welcome Back ANd Thank You Very Much
-
xDarkZeratulX Regular Shmoe
- Join date
- Jul 07, 2012
- Location
- Singapore
- Reputation
- 1
- Posts
- 11
- Last login
- Mar 06, 2013
im stupid yeah but how to put those triggers into my predone map >.<
-
xDarkZeratulX Regular Shmoe
- Join date
- Jul 07, 2012
- Location
- Singapore
- Reputation
- 1
- Posts
- 11
- Last login
- Mar 06, 2013
-
mojothejojo Regular Shmoe
- Join date
- Jun 21, 2009
- Location
- Germany
- Reputation
- 0
- Posts
- 15
- Last login
- Nov 21, 2012
@xDarkZeratulX: Go First: no need to bump every minute. A Forum has some kind of response time ;-)
First step: Create a new Variable Array of type Unit and name it RandomUnit. The size names the amount of units you want to be able to spawn (I choose 21). 2: Make a new trigger:
E: Map init C: (empty) A: Set Variable RandomUnit[0] = Space Marine Set Variable RandomUnit[1] = Zergling Set Variable RandomUnit[2] = Zealot Set Variable RandomUnit[3] = Sentry Set Variable RandomUnit[4] = Carrier ... Set Variable RandomUnit[20] = Queen
and so on...
now make a second trigger
E: Every 10seconds Local Variable: int i =0; C: A: i = random int between 0 and 20 Spawn 1 unit (RandomUnit(i)) for player 1 in region (center of Map) facing somewhere.
finished.
-
xDarkZeratulX Regular Shmoe
- Join date
- Jul 07, 2012
- Location
- Singapore
- Reputation
- 1
- Posts
- 11
- Last login
- Mar 06, 2013
i cant get the last part done which action am i supposed to click create unit with default facing? theres no option behind unit to say (randomUnit(i))
-
mojothejojo Regular Shmoe
- Join date
- Jun 21, 2009
- Location
- Germany
- Reputation
- 0
- Posts
- 15
- Last login
- Nov 21, 2012
@xDarkZeratulX: Go maybe this helps http:www.sc2mapster.com/wiki/galaxy/triggers/create-units-with-point-facing/ I didnt write the exact name, dont have Galaxy on this PC so it was a little bit of pseudocode, but this is the action I ment.
-
xDarkZeratulX Regular Shmoe
- Join date
- Jul 07, 2012
- Location
- Singapore
- Reputation
- 1
- Posts
- 11
- Last login
- Mar 06, 2013
errrr im stupid soooo really idk how to do it :X
-
Yaksmanofage Author
- Join date
- Oct 17, 2011
- Location
- United States
- Reputation
- 7
- Posts
- 213
- Projects
- 4
- Team
- Last login
- Mar 27, 2013
I was going to refrain from posing because I figured you'd get help from someone else, but let me see if I can help.
Firstly Mojo was partially right, you need to create a unit array and set each unit that could conceivably be spawned to said array.
Then what you do is create a spawn trigger, set it to run whenever a round is supposed to start (if no rounds, a periodic trigger would work as well).
Set a local variable and call it randomnumber (any name will do).
Then set randomnumber to a random number between 0 and the maximum number of units in your array (you could automate this process or do it manually, do it manually to begin with however).
Pick each integer.
then do an if then else (switch would work, but for a beginner this will make more sense).
If randomnumber is = picked integer then Create X units UnitArray[Picked Integer] at SpawnPoint. Skip Remaining Actions/Break else wait .1 seconds.
I haven't tested this (obviously) but I have done similar things before; it should work for your purposes.
EDIT: actually, you could do this as well to be even more efficient:
Do the whole randomnumber bit, then just do Create X units UnitArray[randomnumber] at SpawnPoint.
This should be much more efficient.
Last edited Nov 06, 2012 by YaksmanofageMy Addition to All Those Leveling Assets Out There.
My Website which contains a list of notable SCII Maps and FtP games and my Journal.
-
xDarkZeratulX Regular Shmoe
- Join date
- Jul 07, 2012
- Location
- Singapore
- Reputation
- 1
- Posts
- 11
- Last login
- Mar 06, 2013
-
Yaksmanofage Author
- Join date
- Oct 17, 2011
- Location
- United States
- Reputation
- 7
- Posts
- 213
- Projects
- 4
- Team
- Last login
- Mar 27, 2013
Create a global variable. Select it's type as unit type, check the array box and set it to the maximum number of units you'll think you'll need to spawn.
and yes, the random number part is correct.
Last edited Nov 07, 2012 by Yaksmanofage -
SouLCarveRR Author
- Join date
- May 27, 2010
- Location
- United States
- Reputation
- 23
- Posts
- 2,454
- Projects
- 1
- Teams
- Last login
- May 21, 2013
Why arnt you using the sample I made you? If you cant figure out how it works pm me.
You just have to have both maps open at the same time and copy and paste all the trigger stuff in.
For the function I made you
you just do
create 1 RandomUNit for player 1 facing default
Last edited Nov 07, 2012 by SouLCarveRR -
Skaffe123 Regular Shmoe
- Join date
- Nov 10, 2012
- Location
- Sweden
- Reputation
- 0
- Posts
- 7
- Last login
- Nov 17, 2012
I made a quite easy random system in my map.
Local variable: Unit type = 0<integer> actions: Variable - Set Unit type = (Random interger between 0 and 10)
General if then do else do
if: Unit type == 0 then: Unit - create zergling for player (triggering player) else
if: Unit type == 1 then: Unit - create zealotfor player (triggering player)
etc.
Last edited Nov 11, 2012 by Skaffe123
- 16 posts

xDarkZeratulX Regular Shmoei couldnt understand the other posts about arrays and smth cause im a noob but how to make a trigger that spawns a random unit of a type (Light/Armored) at a region