• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Need Help with Teamgame Function

Status
Not open for further replies.
Level 3
Joined
Apr 7, 2007
Messages
48
My other thread got buried so I'll try this again.
I have reworked this quite a bit, I removed the rest of the leaks and changed my team distribution function to check for even or odd and then add the last player in. I'm fairly certain that this spawns for every player since I switched Players to AllPlayers and it spawned 6 heros on each side but failed to ally any of us and it didn't appear to put us in a team group. (The respawn trigger put us all at the 2nd teams base)

Help is reeeellllyyyy appreciated, half the content I have planned for the game rides on my ability to team people up.

  • TDM Start
    • Events
    • Conditions
    • Actions
      • Game - Display to (All players) for 20.00 seconds the text: |CFFFF0000Get ready...
      • -------- Distribute Players --------
      • Set tmp_teamplayers = Players
      • Set n = (Number of players in tmp_teamplayers)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (((Real(n)) / 2.00) - (Real((Integer(((Real(n)) / 2.00)))))) Less than or equal to -0.50
        • Then - Actions
          • For each (Integer A) from 1 to ((n - 1) / 2), do (Actions)
            • Loop - Actions
              • Set tmp_player = (Random player from tmp_teamplayers)
              • Player Group - Add tmp_player to RedTeam
              • Player Group - Remove tmp_player from tmp_teamplayers
              • Set tmp_player = (Random player from tmp_teamplayers)
              • Player Group - Add tmp_player to BlueTeam
              • Player Group - Remove tmp_player from tmp_teamplayers
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Random integer number between 1 and 2) Equal to 1
            • Then - Actions
              • Set tmp_player = (Random player from tmp_teamplayers)
              • Player Group - Add tmp_player to RedTeam
              • Player Group - Remove tmp_player from tmp_teamplayers
            • Else - Actions
              • Set tmp_player = (Random player from tmp_teamplayers)
              • Player Group - Add tmp_player to BlueTeam
              • Player Group - Remove tmp_player from tmp_teamplayers
        • Else - Actions
          • For each (Integer A) from 1 to (n / 2), do (Actions)
            • Loop - Actions
              • Set tmp_player = (Random player from tmp_teamplayers)
              • Player Group - Add tmp_player to RedTeam
              • Player Group - Remove tmp_player from tmp_teamplayers
              • Set tmp_player = (Random player from tmp_teamplayers)
              • Player Group - Add tmp_player to BlueTeam
              • Player Group - Remove tmp_player from tmp_teamplayers
      • -------- End Distribution --------
      • Set tmp_spawn = (Center of Red Team Spawn <gen>)
      • Player Group - Remove all players from tmp_teamplayers
      • Set tmp_teamplayers = RedTeam
      • For each (Integer A) from 1 to (Number of players in tmp_teamplayers), do (Actions)
        • Loop - Actions
          • Set tmp_player = (Random player from tmp_teamplayers)
          • Unit - Create 1 Heros[(Random integer number between 0 and (TotalHeros - 1))] for tmp_player at tmp_spawn facing Default building facing degrees
          • Hero - Create |CFFFF8A00Stock|r and give it to (Last created unit)
          • Unit - Change color of (Last created unit) to Red
          • Camera - Pan camera for tmp_player to tmp_spawn over 0.00 seconds
          • Player Group - Remove tmp_player from tmp_teamplayers
      • Player Group - Pick every player in RedTeam and do (Actions)
        • Loop - Actions
          • Set tmp_player = (Picked player)
          • Player Group - Pick every player in RedTeam and do (Actions)
            • Loop - Actions
              • Player - Make tmp_player treat (Picked player) as an Ally with shared vision
          • Player Group - Pick every player in BlueTeam and do (Actions)
            • Loop - Actions
              • Player - Make tmp_player treat (Picked player) as an Enemy
      • Custom script: call RemoveLocation(udg_tmp_spawn)
      • Set tmp_spawn = (Center of Blue Team Spawn <gen>)
      • Player Group - Remove all players from tmp_teamplayers
      • Set tmp_teamplayers = BlueTeam
      • For each (Integer A) from 1 to (Number of players in tmp_teamplayers), do (Actions)
        • Loop - Actions
          • Set tmp_player = (Random player from tmp_teamplayers)
          • Unit - Create 1 Heros[(Random integer number between 0 and (TotalHeros - 1))] for tmp_player at tmp_spawn facing Default building facing degrees
          • Hero - Create |CFFFF8A00Stock|r and give it to (Last created unit)
          • Unit - Change color of (Last created unit) to Blue
          • Camera - Pan camera for tmp_player to tmp_spawn over 0.00 seconds
          • Player Group - Remove tmp_player from tmp_teamplayers
      • Player Group - Pick every player in BlueTeam and do (Actions)
        • Loop - Actions
          • Set tmp_player = (Picked player)
          • Player Group - Pick every player in BlueTeam and do (Actions)
            • Loop - Actions
              • Player - Make tmp_player treat (Picked player) as an Ally with shared vision
          • Player Group - Pick every player in RedTeam and do (Actions)
            • Loop - Actions
              • Player - Make tmp_player treat (Picked player) as an Enemy
      • Trigger - Turn on XP Ticker <gen>
      • Trigger - Turn on TDM Death <gen>
      • Trigger - Turn on Creep Spawn <gen>
      • Custom script: call RemoveLocation(udg_tmp_spawn)
      • Custom script: call DestroyForce(udg_tmp_teamplayers)
 
Level 13
Joined
Nov 22, 2006
Messages
1,260
Two questions:
  1. What fires the trigger?
  2. What is Players? You set the tmp_teamplayers to that variable.
I'm not 100% sure about this, but I'm pretty sure that the problem is when you set a group to another group. That is really tricky, you know why? Because if you set a group variable to another group variable, that means the first group is equal to the second one, but the second one is also equal to the first one, meaning you have two variables pointing to the same group! You clear the tmp_teamplayers variable and you cleaned the RedTeam and the BlueTeam variables also.

What you probably wanted is to duplicate the group, you can do that by clearing one group and use Unit Group - Add Unit group to Unit group (I think that's what it's called, but I'm not sure) to copy all the units from the second group to the first one.
 
Level 3
Joined
Apr 7, 2007
Messages
48
DOH!

What the heck who would make a function that does that?!?! Gah, ok before I head over to Blizzard HQ and shoot every last one of them in the head I have a feeling I'll be able to fix this quickly.

brb . . .

Edit:
Ok back, it works, +rep man.
 
Status
Not open for further replies.
Top