# [General]Spawn unit goes into random region.

#### InSaNe_97

Level 7
Greetings! I have two little, easy-to-solve, problem and I'm asking asking for help. I'm pretty sure that pure title explained it. I make trigger that unit spawn in region "1", and then second trigger when that same unit enters in that region attack-move to another but unit spawn and don't going anywhere. Also, I don't know variables to be able to make that specific unit goes into random region, not just one so please if you explaining variables, go step-by-step. Thank you.

#### Rigborn

Level 7
To create a variable go to your trigger editor, there is a little green x shape thingie named "variable editor". Then create a unit variable and name it whatever you want. Then go to first trigger after you create your create unit action, set yourvariable = last created unit.Then in your second trigger order your variable named unit to attack move

#### InSaNe_97

Level 7
...Thank you. That doesn't worked even for attack-move to single region, and I said I need attack-move to random region .

#### Rigborn

Level 7
Set your regions with array, for example region(1) region(2) then set an integer variable to random number between your region numbers (min, max) then order unit to move attack region(integer)

#### InSaNe_97

Level 7
I don't know how to do this, that is understandable for someone who don't know variables.

#### RG00

Level 6
I don't know how to do this, that is understandable for someone who don't know variables.
I suggest you to read some tutorial about variables, like this one.
What Aeryn is saying is that you need 2 variables, one is a region array variable, and the other is an integer non-array variable(even though you don't really need an integer variable to do this),also, you'll need a point variable to remove the location leak.
Then you should create a trigger like this one:
• Actions
• Set Integer = (Random integer number between 1 and 10)
• Set Point = (Random point in Region[Integer])
• Unit - Order Your_Unit to Attack-move Point
• Custom script: call RemoveLocation(udg_Point)
Or you can do it without the integer variable:
• Actions
• Set Point = (Random point in Region[(Random integer number between 1 and 10)])
• Unit - Order Your_Unit to Attack-move Point
• Custom script: call RemoveLocation(udg_Point)
You'll naturally need to set the region variables in the map initialization:
• Actions
• Set Region[1] = Region 000 <gen>
• Set Region[2] = Region 001 <gen>
• Set Region[...] = Region ... <gen>

#### InSaNe_97

Level 7
Okay, looks like I finally need to learn variables...

#### InSaNe_97

Level 7
This is so terrible hard! Something is wrong!!!!!!!!!!!!!!!!!! Whatever I do I can't make simple unit spawn and move to certain region!!!!!!!!!!!!!!! I know how to do this, I did it before but now is impossible! I can't work like that did Blizard again change it?!

#### RG00

Level 6
This is so terrible hard! Something is wrong!!!!!!!!!!!!!!!!!! Whatever I do I can't make simple unit spawn and move to certain region!!!!!!!!!!!!!!! I know how to do this, I did it before but now is impossible! I can't work like that did Blizard again change it?!
Can you post the triggers?

#### InSaNe_97

Level 7
I can, but will be useless since I try everything, not just one trigger as I said.

Level 7

#### RG00

Level 6
Ok, there are a lot of problems with this trigger:
-You need to consider that there is a possibility that no unit will spawn if all random integers are 0, if that happens the last created unit will be a unit that has already spawned(if you already created a unit via trigger) and he will randomly go to the center of that region even if he's not part of the next spawning wave;
-That trigger can create up to 14 units but only the last created unit will be issued to attack move to the location, so the other 13 will just stand there doing nothing;
-I'm not sure if that event is going to do what you think it's going to do. I think that after it takes a random number(for example 1 sec) it will just keep looping at the chosen number(so in the case of 0 seconds, this trigger is probably going to make your game crash).

#### InSaNe_97

Level 7
Oh, yeah, sure, I forgot about possibility that no units will spawn, thank you, about what you said that only the one unit do action, and that I need 4 regions, that's not true I already did it few times in my previous maps and I needed only two regions and all units will do the action. Now I tried this but same thing, they just spawn and do nothing.

Edit: At least you got a reputation point for trying.

Last edited:

#### RG00

Level 6
Oh, yeah, sure, I forgot about possibility that no units will spawn, thank you, about what you said that only the one unit do action, and that I need 4 regions, that's not true I already did it few times in my previous maps and I needed only two regions and all units will do the action. Now I tried this but same thing, they just spawn and do nothing.View attachment 311532

Edit: At least you got a reputation point for trying.
I don't know what you are talking about, I never said that you need 4 regions.
Other than that I tried recreating your trigger and it works completely fine(other than the fact that you should avoid using neutral hostile because they have an AI that makes them come back to their spawn point after some time). I think that your problem may be caused by the fact that the spawning region(Zabe stvaranje <gen>) is too small(if it's too small the units will spawn at its center point but when you pick every unit in that region there isn't actually any unit in that small place)
So the solutions are 2:
1)make the spawning region bigger;
2)try this trigger:
• Trigger
• Events
• Time - Every 12.00 seconds of game time
• Conditions
• Actions
• For each (Integer A) from 1 to (Random integer number between 1 and 7), do (Actions)
• Loop - Actions
• Set Point = (Center of Zabe stvaranje <gen>)
• Unit - Create 1 Murloc A for Player (Red) at Point facing (Random angle) degrees
• Custom script: call RemoveLocation(udg_Point)
• Set Point = (Center of Zabe mesto <gen>)
• Unit - Order (Last created unit) to Attack-Move To Point
• Custom script: call RemoveLocation(udg_Point)
• For each (Integer A) from 1 to (Random integer number between 0 and 4), do (Actions)
• Loop - Actions
• Set Point = (Center of Zabe stvaranje <gen>)
• Unit - Create 1 Murloc B for Player (Red) at Point facing (Random angle) degrees
• Custom script: call RemoveLocation(udg_Point)
• Set Point = (Center of Zabe mesto <gen>)
• Unit - Order (Last created unit) to Attack-Move Point
• Custom script: call RemoveLocation(udg_Point)
• For each (Integer A) from 1 to (Random integer number between 0 and 2), do (Actions)
• Loop - Actions
• Set Point = (Center of Zabe stvaranje <gen>)
• Unit - Create 1 Murloc C for Player (Red) at Point facing (Random angle) degrees
• Custom script: call RemoveLocation(udg_Point)
• Set Point = (Center of Zabe mesto <gen>)
• Unit - Order (Last created unit) to Attack-Move Point
• Custom script: call RemoveLocation(udg_Point)

#### InSaNe_97

Level 7
Okay, than you, I will try it, probably tomorrow, I don't have time now, thank you <3.

#### InSaNe_97

Level 7
Man, this is so hard :-/.

#### Rigborn

Level 7
Which part didn't you understand ?

Replies
1
Views
207
Replies
4
Views
331
Replies
2
Views
409
Replies
4
Views
503
Replies
4
Views
616