HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

random start location

02-19-2004, 06:42 PM#1
xtacb
how do i make random start locations for the players with any doubles so no more than one player will end up in one space??

Unit - Create 1 hero[rnd] for Player 1 (Red) at ((Random player from (All players)) start location) facing Default building facing degrees

thats basically the action i use for all the players but sometimes they will end up in the exact same spot

how do i make it so they will be random start location but never overlap??
02-19-2004, 06:44 PM#2
RaeVanMorlock
Ummm... Warcraft does that for you, just don't check off the "Fixed Start Location" box on teh players whom you want to start in a random start location.
02-19-2004, 07:07 PM#3
AllPainful
Note: These are just EXAMPLES (That would work) the second one is the easiest.


Put your start locations in a region array.

2 Variables:
Starts = Region Array
RandomInt = Integer

2 Triggers:

Then do something like this:
Code:
Event
  Elapsed Time 1 second
Conditions
Actions
  Pick all players matching codition (matching player is playing) and
    Do Loop
      Set "RandomInt" = Random number between 1 and [color=blue]#[/color]
      If
        Conditions
          Count unit in region (Start[RandomInt]) is = 0
        Then
          Unit - Create 1 hero[rnd] for picked player at Starts[randomint] facing Default building facing degrees
          Pan camera over 0 seconds for picked player to position of (Last created Unit)
        Else
          Set "RandomInt" = Random number between 1 and [color=blue]#[/color]
          If
            Conditions
              Count unit in region (Start[RandomInt]) is = 0
            Then
              Unit - Create 1 hero[rnd] for picked player at Starts[randomint] facing Default building facing degrees
              Pan camera over 0 seconds for picked player to position of (Last created Unit)
            Else
              Set "RandomInt" = Random number between 1 and [color=blue]#[/color]
              If
                Conditions
                  Count unit in region (Start[RandomInt]) is = 0
                Then
                  Unit - Create 1 hero[rnd] for picked player at Starts[randomint] facing Default building facing degrees
                  Pan camera over 0 seconds for picked player to position of (Last created Unit)
                Else
                  Set "RandomInt" = Random number between 1 and [color=blue]#[/color]
                  If
                   Conditions
                     Count unit in region (Start[RandomInt]) is = 0
                  Then
                     Unit - Create 1 hero[rnd] for picked player at Starts[randomint] facing Default building facing degrees
                     Pan camera over 0 seconds for picked player to position of (Last created Unit)
                  Else
                     Set "RandomInt" = Random number between 1 and [color=blue]#[/color]
                     If
                       Conditions
                         Count unit in region (Start[RandomInt]) is = 0
                       Then
                         Unit - Create 1 hero[rnd] for picked player at Starts[randomint] facing Default building facing degrees
                         Pan camera over 0 seconds for picked player to position of (Last created Unit)
                       Else
                          Send message to Picked Player = "The game tried to place you on the map 5 times and failed, to retry type "-place me"


Place Me
Event
  Player 1 types "-place me" as an exact match
  Player 2 types "-place me" as an exact match
  Player 3 types "-place me" as an exact match
  Player 4 types "-place me" as an exact match
  ............. ect ect
Conditions
  Unit count (units owned by Triggering player) = 0
Actions
  Set "RandomInt" = Random number between 1 and [color=blue]#[/color]
   If
     Conditions
       Count unit in region (Start[RandomInt]) is = 0
     Then
       Unit - Create 1 hero[rnd] for Triggering player at Starts[randomint] facing Default building facing degrees
       Pan camera over 0 seconds for Triggering player to position of (Last created Unit)
     Else
       Set "RandomInt" = Random number between 1 and [color=blue]#[/color]
       If
         Conditions
           Count unit in region (Start[RandomInt]) is = 0
         Then
           Unit - Create 1 hero[rnd] for Triggering player at Starts[randomint] facing Default building facing degrees
           Pan camera over 0 seconds for Triggering player to position of (Last created Unit)
         Else
           Set "RandomInt" = Random number between 1 and [color=blue]#[/color]
           If
             Conditions
               Count unit in region (Start[RandomInt]) is = 0
             Then
               Unit - Create 1 hero[rnd] for Triggering player at Starts[randomint] facing Default building facing degrees
               Pan camera over 0 seconds for Triggering player to position of (last created Unit)
             Else
               Set "RandomInt" = Random number between 1 and [color=blue]#[/color]
               If
                Conditions
                  Count unit in region (Start[RandomInt]) is = 0
               Then
                  Unit - Create 1 hero[rnd] for Triggering player at Starts[randomint] facing Default building facing degrees
                  Pan camera over 0 seconds for Triggering player to position of (Last created Unit)
               Else
                  Set "RandomInt" = Random number between 1 and [color=blue]#[/color]
                  If
                    Conditions
                      Count unit in region (Start[RandomInt]) is = 0
                    Then
                      Unit - Create 1 hero[rnd] for Triggering player at Starts[randomint] facing Default building facing degrees
                      Pan camera over 0 seconds for Triggering player to position of (Last created Unit)
                    Else
                       Send message to Triggering player = "The game tried to place you on the map 5 times and failed, to retry type "-place me"

1. the # is how many start positions you have.

2. There are easier ways to do it, this was just an example

Heres another example (an easier way):

3 Variables:
Starts = Region Array
StartCount = Integer
RandomInt = Integer

Put all the start regions in the region array, and put HOW MANY there are in "StartCount" variable
Code:
Start placement
Events
  Elapsed time 1 second
Conditions
Actions
  Pick all players matching codition (matching player is playing) and
    Do Loop
      Set "RandomInt" = Random number between 1 and StartCount
      Unit - Create 1 hero[rnd] for picked player at Starts[randomint] facing Default building facing degrees
      Set Start[randomint] = Start[startcount]
      Set StartCount = Startcount - 1
02-19-2004, 07:16 PM#4
RaeVanMorlock
Umm... I probably shouldn't say anything, but how are either of those methods easier than what I said, AllPainful? You're making way too much work for yourself.
02-20-2004, 04:53 AM#5
AllPainful
Because you method is useful for melee style maps, but creating units at the players start points sometimes has problems with random start points.

PS. And my second trigger takes a whole, what 3 minutes to setup.. Oh yeah, thats just SO much more work.

I was just providing OPTIONS. Some poeple don't like only getting one answer. Deal with it, did I say your way was wrong? No? Ok then.