How do I make random even teams?

Status
Not open for further replies.
Level 5
Joined
Jan 15, 2009
Messages
80
HMMM smells like a lot of variables... This took me a while to put together but try this xP

  • Random Teams
  • Events
    • Map initialization
  • Conditions
  • Actions
    • Set Player[1] = (Random integer number between 1 and 2)
    • Set Team[Player[1]] = (Team[Player[1]] + 1)
    • Set Player[2] = (Random integer number between 1 and 2)
    • Set Team[Player[2]] = (Team[Player[2]] + 1)
    • Set Player[3] = (Random integer number between 1 and 2)
    • Set Team[Player[3]] = (Team[Player[3]] + 1)
    • Set Player[4] = (Random integer number between 1 and 2)
    • Set Team[Player[4]] = (Team[Player[4]] + 1)
    • Set Player[5] = (Random integer number between 1 and 2)
    • Set Team[Player[5]] = (Team[Player[5]] + 1)
    • Set Player[6] = (Random integer number between 1 and 2)
    • Set Team[Player[6]] = (Team[Player[6]] + 1)
    • If (Team[1] Equal to 6) then do (Set Player[6] = 2) else do (Do nothing)
    • If (Team[2] Equal to 6) then do (Set Player[6] = 1) else do (Do nothing)
    • Set Player[7] = (Random integer number between 1 and 2)
    • Set Team[Player[7]] = (Team[Player[7]] + 1)
    • If (Team[1] Equal to 6) then do (Set Player[7] = 2) else do (Do nothing)
    • If (Team[2] Equal to 6) then do (Set Player[7] = 1) else do (Do nothing)
    • Set Player[8] = (Random integer number between 1 and 2)
    • Set Team[Player[8]] = (Team[Player[8]] + 1)
    • If (Team[1] Equal to 6) then do (Set Player[8] = 2) else do (Do nothing)
    • If (Team[2] Equal to 6) then do (Set Player[8] = 1) else do (Do nothing)
    • Set Player[9] = (Random integer number between 1 and 2)
    • Set Team[Player[9]] = (Team[Player[9]] + 1)
    • If (Team[1] Equal to 6) then do (Set Player[9] = 2) else do (Do nothing)
    • If (Team[2] Equal to 6) then do (Set Player[9] = 1) else do (Do nothing)
    • Set Player[10] = (Random integer number between 1 and 2)
    • Set Team[Player[10]] = (Team[Player[10]] + 1)
    • If (Team[1] Equal to 6) then do (Set Player[10] = 2) else do (Do nothing)
    • If (Team[2] Equal to 6) then do (Set Player[10] = 1) else do (Do nothing)
    • Set Player[11] = (Random integer number between 1 and 2)
    • Set Team[Player[11]] = (Team[Player[11]] + 1)
    • If (Team[1] Equal to 6) then do (Set Player[11] = 2) else do (Do nothing)
    • If (Team[2] Equal to 6) then do (Set Player[11] = 1) else do (Do nothing)
    • Set Player[12] = (Random integer number between 1 and 2)
    • Set Team[Player[12]] = (Team[Player[12]] + 1)
    • If (Team[1] Equal to 6) then do (Set Player[12] = 2) else do (Do nothing)
    • If (Team[2] Equal to 6) then do (Set Player[12] = 1) else do (Do nothing)
    • Trigger - Run Make Teams <gen> (checking conditions)
 
Last edited:
Or try this (not guaranteed to work but it probably should):

  • set number of players
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set numberofplayers = 12
  • randomize
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • currentnumber Greater than numberofplayers
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
      • Set currentnumber = (currentnumber + 1)
      • Set randomnumber = (Random integer number between 1 and 12)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • currentnumber Less than or equal to (numberofplayers / 2)
        • Then - Actions
          • Set team1[randomnumber] = True
          • Player Group - Pick every player in (All players) and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • team1[(Player number of (Picked player))] Equal to True
                • Then - Actions
                  • Player - Make (Player(randomnumber)) treat (Picked player) as an Ally with shared vision
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • team1[(Player number of (Picked player))] Equal to False
                • Then - Actions
                  • Player - Make (Player(randomnumber)) treat (Picked player) as an Enemy
                • Else - Actions
        • Else - Actions
          • Set team1[randomnumber] = False
          • Player Group - Pick every player in (All players) and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • team1[(Player number of (Picked player))] Equal to False
                • Then - Actions
                  • Player - Make (Player(randomnumber)) treat (Picked player) as an Ally with shared vision
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • team1[(Player number of (Picked player))] Equal to True
                • Then - Actions
                  • Player - Make (Player(randomnumber)) treat (Picked player) as an Enemy
                • Else - Actions
 

Attachments

  • example.w3x
    13 KB · Views: 53
Level 6
Joined
Jan 3, 2010
Messages
185
@Darkzealot 128 okay it kinda worked... but it doesnt work when you want to spawn one unit for the player as they are picked (with 6 players it spawned 6 units for each player) and it made an enemy with shared vision?

@jacobemslayer I will try your method now looks like it will do what i want it to
 
@Darkzealot 128 okay it kinda worked... but it doesnt work when you want to spawn one unit for the player as they are picked (with 6 players it spawned 6 units for each player) and it made an enemy with shared vision?

Try 'pick every player in (all players)' then do the action inside that. Don't put the spawn units action inside of the randomizing trigger either put it in a seperate one.
 
Level 6
Joined
Jan 3, 2010
Messages
185
@ Darkzealot 128 okay i fixed the spawn but your method doesnt suit my map because it makes random teams yes but they are not even and you cant control what team gets what unit easily

@jacobemslayer Yours worked a charm, Thanks and + rep
 
Status
Not open for further replies.
Top