I
ihatecaps
Guest
Hey guys, I need some help with this function for starting a team game. It has to take a group of players and divide them up into two teams (Red and Blue) and then ally them accordingly and create a random hero from a list at that team's spawn point.
Yes I realize this is very long an hard to read but I really need help on this. Also the method I have here is rather .. messed up because the original Pick every player in Red and then create a hero would only spawn heros for one player. This will at least spawn the heros for every player but not ally properly.
Code:
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)