Random Unit and Random Spawn Help

Level 2
Joined
Jul 23, 2009
Messages
16
I am trying to get one out of three units to spawn in one out of three regions. It sounds really simple but I cant seem to get a sequence of triggers to work. I originally approached this with two random integers which then turned into a long work of triggers and didn't work out in the end.
( Im not looking for someone to hand me the work but to lead me in the direction)
Help is appreciated and I will continue to try myself.

:xxd:
 
Level 8
Joined
Aug 2, 2008
Messages
219
I think you´ll need a group variable and a region array. Create a trigger which runs at map initialation and and add the three units into that unit group. Next you have to initialize the regions.
  • Events
    • Map initialization
  • Conditions
    • {Not needed}
  • Actions
    • Group - Add (SomeUnit1) to (YourGroup)
    • Group - Add (SomeUnit2) to (YourGroup)
    • Group - Add (SomeUnit3) to (YourGroup)
    • Set SomeRectArray[1] = FirstRect
    • Set SomeRectArray[2] = SecondRect
    • Set SomeRectArray[3] = ThirdRect
And If you want to spawn the unit you do it like this (you´ll need an location variable to prevent a location leak) :
  • Events
    • {Some Event}
  • Conditions
    • {Some Conditions}
  • Actions
    • Set ANTI_LEAK_LOC = CenterOfRegion(SomeArrayRect[(RandomInteger(1 to 3)])
    • Unit - Create 1 (Unit-type of (Random unit from (YourGroup))) for (SomePlayer) at ANTI_LEAK_LOC facing (SomeDegrees) degrees
    • Custom script: call RemoveLocation(udg_ANTI_LEAK_LOC)
That should do it.
 
Level 2
Joined
Jul 23, 2009
Messages
16
Thats brilliant thanks alot. But there are problems.

I cant add the unit type to the group.

  • Initial Spawn
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Unit Group - Add (Triggering unit) to UnitGroupRange
 
Level 8
Joined
Aug 2, 2008
Messages
219
well ofc you can´t add unit types to a unit group.
i thought you had placed the 3 units on the map already. If not then just place them somewhere on the map and then choose them. If say now i don´t want those units on the map then just add this to the initilation part (after the region setup).

  • Group - Pick every unit in (YourGroup) and do (Actions)
    • ForGroup - Actions
      • Unit - Hide (Picked unit)
      • Unit - Disable supply usage for (Picked unit)
 
It creates new ones. See this:

join.gif
unit.gif
Unit - Create 1 (Unit-type of (Random unit from (YourGroup))) for (SomePlayer) at ANTI_LEAK_LOC facing (SomeDegrees) degrees
 
Level 2
Joined
Jul 23, 2009
Messages
16
I messed up. I have lazy ass brain or am dyslexic loool. ( my brain is lazy as hell when im outta school) where can i find the ACTION Group - add. a
 
Top