daily pastebin goal
42%
SHARE
TWEET

nestharus

a guest Jan 30th, 2010 40 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. library TeamManager uses PlayerTracker {
  2. /*Utility Information
  3. ===================================================================
  4. Name: C Team Player Manager
  5. Version: 1.3
  6. Author: Nestharus
  7.  
  8. Settings:
  9. *///===================================================================
  10.     define private TEAM_MAX_SIZE = 12 //how many players can be in a team, should be max players for your current game
  11.     define private DO_TEAM_ALLIANCES = true //can teams ally and be neutral to each other?
  12.     define private AUTO_REMOVE_TEAMS = true //if a team has no players after a player is removed, remove that team?
  13.     define private AUTO_GAME_OVER_CHECK = true //if a team is destroyed and all remaining teams are allies, game over?
  14.     define private DO_PLAYER_DRIVEN_SETUP = true //if this is enabled, use TeamManager.playerSetup to set your teams up
  15.    
  16.     //Whether or not to do specific team alliance properties. If something here is false, it is removed from system
  17.     define private DO_SHARED_XP = true
  18.     define private DO_SHARED_SPELLS = true
  19.     define private DO_SHARED_VISION = true
  20.     define private DO_SHARED_CONTROL = false
  21.     define private DO_SHARED_ADV_CONTROL = false
  22.    
  23.     //these will only run if AUTO_GAME_OVER_CHECK is true
  24.     //////////////////////////////////////////////////////////////////////////////
  25.     //Code to run when game is over and there are winners. ActiveTeams will always be winners
  26.     //! textmacro GAME_OVER_CODE
  27.     //! endtextmacro
  28.    
  29.     //Code to run when there is no winner
  30.     //! textmacro GAME_OVER_CODE_NO_WINNER
  31.     //! endtextmacro
  32.     //////////////////////////////////////////////////////////////////////////////
  33.    
  34.     //What PLAYER_TYPE do you want?
  35.     //Supported Player Types- Human, Computer, InactivePlayer, ActivePlayer
  36.     define <TeamManager.PLAYER_TYPE> = Human
  37.    
  38.     //these will only be applicable if DO_PLAYER_DRIVEN_SETUP
  39.     //////////////////////////////////////////////////////////////////////////////
  40.     //This is where you put your structs and globals etc for your interface code
  41.     //! textmacro PlayerDrivenInterfaceData
  42.     //! endtextmacro
  43.    
  44.     //this is where run time code goes for your interface
  45.     //! textmacro PlayerDrivenInterfaceCode
  46.     //! endtextmacro
  47.    
  48.     define private PlayerDrivenInterfaceProperties = {
  49.         private int GetPlayerVoteCount() {//used to retrieve total vote count
  50.             return Get##TeamManager.PLAYER_TYPE##Count() //default value, can change it but not suggested
  51.         }//GetPlayerVoteCount
  52.     }//PlayerDrivenInterfaceProperties
  53.     //////////////////////////////////////////////////////////////////////////////
  54.    
  55.     //Default Values for Team Alliance Properties
  56.     define private TEAM_DEFAULT_ALLIANCE_VALUES = {
  57.         #if DO_SHARED_XP
  58.             public static constant bool SHARED_XP = true
  59.         #endif
  60.         #if DO_SHARED_SPELLS
  61.             public static constant bool SHARED_SPELLS = true
  62.         #endif
  63.         #if DO_SHARED_VISION
  64.             public static constant bool SHARED_VISION = true
  65.         #endif
  66.         #if DO_SHARED_CONTROL
  67.             public static constant bool SHARED_CONTROL = false
  68.         #endif
  69.         #if DO_SHARED_ADV_CONTROL
  70.             public static constant bool SHARED_ADV_CONTROL = false
  71.         #endif
  72.     }
  73. /*//===================================================================
  74.  
  75. Description:
  76.     Team Manager was made to replace forces and do better force alliances and alliances between forces.
  77.     Teams are much faster than forces (direct array reads) and handle better alliances as well (array reads).
  78.     Furthermore, player alliances are automatically modified when they join/leave a team (ally/unally all players on that
  79.     team and all players on allied teams). You can access all teams a player is on and all players within a given team.
  80.     You can also quickly access all allied and neutral teams of a given team.
  81.    
  82.     If you want alliances between players, Team Manager can still be used (each player is on their own team).
  83.     If you want shared alliances, add players to a common team and you are set.
  84.    
  85.     If you are ever doing alliances for player teams, Team Manager is the way to go.
  86.  
  87.     Team Manager requires that all players that are to be in TeamManager teams be unallied. This can be done in
  88.     Force Properties under Scenario. Uncheck all the check boxes if you want the force to run. Don't mess with the
  89.     alliances either or that'll screw with the flags. Do all alliances through Team Manager teams.
  90.    
  91. Big Features-
  92.     Automatic Management of Alliances
  93.         When DO_TEAM_ALLIANCES is marked as true, Team Manager will manage alliances between teams quickly and easily.
  94.         Alliances include neutral and allied alliance. If a team is neither of those, it's an enemy. As players
  95.         are added and removed from teams, their alliances with all players on all teams with a standing to the team
  96.         they are joining/leaving will be modified.
  97.        
  98.         Team 1 is allied to Team 2
  99.         Team 2 has player 6
  100.         Player 1 joins Team 1
  101.         Player 6 and Player 1 are automatically allied
  102.        
  103.         When allying/unallying two teams, all players on each team will be modified accordingly
  104.         Team 1 unallies Team 2
  105.         Player 6 and Player 1 are no longer allies
  106.        
  107.     Automatic Team Removal
  108.         If AUTO_REMOVE_TEAMS is true, teams will be automatically destroyed when there are no players left in them
  109.         as .removePlayer is used.
  110.        
  111.     Automatic Game Over Check
  112.         If AUTO_GAME_OVER_CHECK is true, TeamManager will automatically check if the game is over as teams
  113.         are destroyed by seeing if all remaining teams are allied or if there is only one team left.
  114.        
  115.         GAME_OVER_CODE is run when the game ends and all active teams are the winners.
  116.        
  117.         GAME_OVER_CODE_NO_WINNER is run if for some reason there are no active teams left (no winners)
  118.        
  119.     Automatic Team Setup with 3 ways of doing it and an open interface
  120.         StaticSetup-
  121.             1- The teams will be set up based on what teams the players are in in the game lobby (your forces)
  122.             2- The teams will be set up based on a team count. In this case, players are put into teams based on their
  123.                 player id. If team count is 4, players 0-2 will be on team 1, 3-5 on team 2, etc.
  124.                
  125.         DynamicSetup-
  126.             Balances out the teams as much as possible given a team count. If there are 10 players and 6 teams,
  127.             teams 1 through 5 will have 2 players and team 6 will have 0
  128.             2, 2, 2, 2
  129.             1, 1 -> 2
  130.            
  131.         PlayerDrivenSetup-
  132.             Players vote for how big they want their teams to be and teams are set up accordingly so
  133.             everyone is as happy as possible. It allows a user defined interface (data area and run time area)
  134.             and provides an API for recording votes. It also has a time limit feature.
  135.            
  136.             It also tries to keep bigger team players happy by making it so no team can be bigger
  137.             than remaining players - remaining open slots on that team. Also, no player that wants
  138.             a small team will be put on a bigger team.
  139.            
  140.             Example 1-
  141.                 Player 1 votes team size of 6
  142.                 Player 2 votes team size of 6
  143.                 Player 3 votes team size of 6
  144.                 Player 4 votes team size of 4
  145.                 Player 5 votes team size of 4
  146.                
  147.                 First it gives smaller votes priority (votes are entered in a sorted array)
  148.                 1 - empty
  149.                 2 - empty
  150.                 3- empty
  151.                 4- player 4, 5
  152.                 5- 1, 2, 3
  153.                 6-12 empty
  154.                
  155.                 So this would be-
  156.                 Team 1- Player 4, 5
  157.                 Team 2- player 1, 2, 3
  158.                
  159.                 The reason for this isn't because they voted differently.
  160.                 Team 1 had 2 open slots left (smallest vote was 4, so 4 players preferred)
  161.                
  162.                 The issue is that the team size of team 1 became >= to the remaining players and there weren't
  163.                 enough slots to fit all the players into the team.
  164.                
  165.                 Because the votes are sorted, as the teams are made, each subsequent player wants a bigger team.
  166.                 In this way, no current team can be equal to the remaining players. At the very least, the last
  167.                 team will always be the biggest (big votes clumped together).
  168.                
  169.                 Smallest votes get priority by getting processed first
  170.                 Biggest votes get priority by getting biggest possible team size
  171.                
  172.                 Another example-
  173.                 Team 1- Player 4, 5, 6 (max size 4)
  174.                 Team 2- Player 7, 8, 9 (max size 6)
  175.                
  176.                 As can be seen, the teams turn out balanced.
  177.  
  178.         Loops-
  179.             tloop(team loop)- loop through active teams
  180.             tploop(team's players loop)- loop through players on a team
  181.             ptloop(player's teams loop)- loop through teams a player is on
  182.             taloop(team alliances)- loop through a team's alliance teams
  183.             tnloop(team neutrals)- loop through a team's neutral teams
  184.        
  185. Requirements: PlayerTracker
  186.  
  187. Installation: Unallied Forces
  188.    
  189. API
  190. ------------------------------------------------------------------
  191. ActiveTeam-
  192. public int operator count()
  193.     Returns how many teams there are
  194.    
  195. public int get(int index)
  196.     Retrieves an active team given an indexed index
  197.    
  198.     Example-
  199.         Team myTeam = ActiveTeam.get(ActiveTeam.count-1)
  200.        
  201. TeamPlayer-
  202. ------------------------------------------------------------------
  203. public int operator teamCount()
  204.     Returns how many teams the player is on
  205.    
  206.     Example-
  207.         int playerTeamCount = TeamPlayer[0].teamCount
  208.        
  209. public int getTeam(int index)
  210.     Retrieves a team a player is on given an indexed id
  211.    
  212.     Example-
  213.         Team myTeam = TeamPlayer[0].getTeam(TeamPlayer[0].teamCount)
  214.        
  215. public bool isOnTeam(int teamId)
  216.     Determines whether or not a player is on a team
  217.    
  218.     Example-
  219.         bool isOnTeam = Player[0].isOnTeam(GetActiveTeam(0))
  220.        
  221. public bool isAllied(int playerId)
  222.     Determines whether a player is allied or not to another player
  223.    
  224.     Example-
  225.         if TeamPlayer[0].isAllied(1) {
  226.             prinf("Player 0 is allied to Player 1")
  227.         }//if
  228.         else {
  229.             printf("Player 0 is not allied to Player 1")
  230.         }//else
  231.        
  232. public bool isNeutral(int playerId) - DO_TEAM_ALLIANCES
  233.     Determines whether a player is neutral or not to another player
  234.    
  235.     Example-
  236.         if TeamPlayer[0].isNeutral(1) {
  237.             prinf("Player 0 is neutral to Player 1")
  238.         }//if
  239.         else {
  240.             printf("Player 0 is not neutral to Player 1")
  241.         }//else
  242.        
  243. Team-
  244. ------------------------------------------------------------------
  245. Default Team Alliance Values-
  246.     public static constant bool SHARED_XP - DO_SHARED_XP
  247.     public static constant bool SHARED_SPELLS - DO_SHARED_SPELLS
  248.     public static constant bool SHARED_VISION - DO_SHARED_VISION
  249.     public static constant bool SHARED_CONTROL - DO_SHARED_CONTROL
  250.     public static constant bool SHARED_ADV_CONTROL - DO_SHARED_ADV_CONTROL
  251.    
  252. Team Specific Alliance Values-
  253.     public bool sharedXp - DO_SHARED_XP
  254.     public bool sharedSpells - DO_SHARED_SPELLS
  255.     public bool sharedVision - DO_SHARED_VISION
  256.     public bool sharedControl - DO_SHARED_CONTROL
  257.     public bool sharedAdvControl - DO_SHARED_ADV_CONTROL
  258.  
  259. public int teamNumber-
  260.     A number that can be assigned to a team. Doesn't do anything, but useful for games with specific areas
  261.     for different teams.
  262.    
  263. public int operator size()
  264.     Retrieves how many players are on the team
  265.    
  266. public int operator neutralCount() - DO_TEAM_ALLIANCES
  267.     Retrieves how many neutral alliances the team has with other teams
  268.    
  269. public int operator allyCount() - DO_TEAM_ALLIANCES
  270.     Retrieves how many allied alliances the team has with other teams
  271.    
  272. public int getPlayer(int index)
  273.     Retrieves a player id from a team given an indexed id for that team
  274.    
  275.     Example-
  276.         int myPlayerId = myTeam.getPlayer(myTeam.size-1)
  277.        
  278. public int getNeutral(int index) - DO_TEAM_ALLIANCES
  279.     Retrieves a team that has a neutral alliance with this team given an indexed id for this team
  280.    
  281.     Example-
  282.         Team neutralTeam = myTeam.getNeutral(myTeam.neutralCount-1)
  283.        
  284. public int getAlly(int index) - DO_TEAM_ALLIANCES
  285.     Retrieves a team that has an allied alliance with this team given an indexed id for this team
  286.    
  287.     Example-
  288.         Team alliedTeam = myTeam.getAlly(myTeam.allyCount-1)
  289.  
  290. public void destroy()
  291.     Destroys the team clearing out all alliancs and players
  292.    
  293. public bool isAllied(Team team2) - DO_TEAM_ALLIANCES
  294.     Determines whether this team is allied with another team
  295.    
  296.     Example-
  297.         bool areTheyAllied = myTeam.isAllied(shadyTeam)
  298.        
  299. public bool isNeutral(Team team2) - DO_TEAM_ALLIANCES
  300.     Determines whether this team is neutral to another team
  301.    
  302.     Example-
  303.         bool areTheyNeutral = myTeam.isNeutral(shadyTeam)
  304.        
  305. public static void neutralTeam(Team team1, Team team2) - DO_TEAM_ALLIANCES
  306.     Adds a neutral flag to two teams. The teams won't be neutral unless they aren't allies, but the flag
  307.     will be there in case they stop being allies.
  308.    
  309.     Example-
  310.         Team.neutralTeam(myTeam, shadyTeam)
  311.    
  312. public static void allyTeams(Team team1, Team team2) - DO_TEAM_ALLIANCES
  313.     Adds an ally flag to two teams. The teams will become allies no matter what.
  314.    
  315.     Example-
  316.         Team.allyTeams(myTeam, shadyTeam)
  317.        
  318. public static void unallyTeams(Team team1, Team team2) - DO_TEAM_ALLIANCES
  319.     Removes an ally flag from two teams. The teams will stop being allies. If they have a neutral flag,
  320.     they will become neutral rather than become enemies.
  321.    
  322.     Example-
  323.         Team.unallyTeams(myTeam, shadyTeam)
  324.        
  325. public static void removeNeutralTeams(Team team1, Team team2) - DO_TEAM_ALLIANCES
  326.     Removes a neutral flag from two teams. If the teams are allied, they will still be allied.
  327.    
  328.     Example-
  329.         Team.removeNeutralTeams(myTeam, shadyTeam)
  330.  
  331. public void addPlayer(int playerId)
  332.     Adds a player to a team given a player id. Players added to teams will automatically have their alliances
  333.     altered in regards to all players on that team. The alliances will also be altered for all players on allied and
  334.     neutral teams for that team.
  335.    
  336.     Example-
  337.         myTeam.addPlayer(4)
  338.        
  339. public void removePlayer(int playerId)
  340.     Removes a player from a team given a player id. Players removed from teams will automatically have their alliances
  341.     altered in regards to all players on that team. The alliances will also be altered for all players on allied and
  342.     neutral teams for that team.
  343.    
  344.     Example-
  345.         myTeam.removePlayer(4)
  346.        
  347. public static Team create()
  348.     Creates a new team
  349.  
  350. Team Setups-
  351. ------------------------------------------------------------------
  352. TeamManager.staticSetup
  353.     Generates run time code for automatically setting up teams. Teams set up in this way
  354.     will be based on the forces they are on in the game lobby.
  355.    
  356.     Force 1-
  357.         Player 0
  358.         Empty
  359.         Empty
  360.    
  361.     Force 2-
  362.         Player 2
  363.         Empty
  364.         Player 3
  365.        
  366.     With automatic team setup-
  367.         Force 1- Player 0
  368.         Force 2- Player 2, 3
  369.        
  370.     scope Test initializer Initialization {
  371.         private void Initialization() {
  372.             TeamManager.staticSetup
  373.         }//Initialization
  374.     }//Test
  375.        
  376. TeamManager.staticSetup(teamCount)
  377.     Generates run time code for automatically setting up teams. Teams set up in this way
  378.     will be based on the player ids and the teamCount specified.
  379.    
  380.     Team Count = 6
  381.    
  382.     Force 1-
  383.         Player 0
  384.         Empty
  385.         Empty
  386.        
  387.     Force 2-
  388.         Player 2
  389.         Player 3
  390.         Player 6
  391.        
  392.     With automatic team setup-
  393.         Force 1- Player 0
  394.         Force 2- Player 2, 3
  395.         Force 3- Empty
  396.         Force 4- Player 6
  397.        
  398.     scope Test initializer Initialization {
  399.         private void Initialization() {
  400.             TeamManager.staticSetup(6)
  401.         }//Initialization
  402.     }//Test
  403.        
  404. TeamManager.dynamicSetup(teamCount, teamSize)
  405.     Generates run time code for automatically setting up teams. Teams set up in this way
  406.     will be based on the total player count and team count. The teams will be as balanced as possible across
  407.     as many teams as possible
  408.    
  409.     Team Count = 3
  410.     Team Size = 4
  411.    
  412.     Force 1-
  413.         Player 0
  414.         Empty
  415.         Empty
  416.        
  417.     Force 2-
  418.         Player 2
  419.         Player 3
  420.         Player 6
  421.        
  422.     With automatic team setup-
  423.         Force 1- Player 0, 2
  424.         Force 2- Player 3, 6
  425.    
  426.     scope Test initializer Initialization {
  427.         private void Initialization() {
  428.             TeamManager.dynamicSetup(3, 4)
  429.         }//Initialization
  430.     }//Test
  431.  
  432. DO_PLAYER_DRIVEN_SETUP-
  433. ------------------------------------------------------------------
  434. These are accessible only from within DO_PLAYER_DRIVEN_SETUP areas
  435.  
  436. private void SetVoteTimeLimit(real timeLimit)
  437.     Sets a time limit for voting
  438.    
  439.     Example-
  440.         SetVoteTimeLimit(20)
  441.        
  442. private bool HasPlayerVoted(int playerId)
  443.     Checks to see whether or not a player has voted
  444.        
  445. private void SetPlayerVote(int playerId, int vote)
  446.     Sets how big of a team a player votes for
  447.    
  448.     Player 6 votes for a team size of 3
  449.     Example-
  450.         SetPlayerVote(6, 3)
  451.        
  452. void TeamManager.playerSetup()
  453.     Runs player driven auto team creation
  454.    
  455.     scope Test initializer Initialization {
  456.         private void Initialization() {
  457.             TeamManager.playerSetup()
  458.         }//Initialization
  459.     }//Test
  460.    
  461. PlayerDrivenInterfaceData
  462.     Place all of your interface data like structs, globals, functions, and etc goes here
  463.    
  464.     //! textmacro PlayerDrivenInterfaceData
  465.         dialog crappyMenu = DialogCreate()
  466.         trigger crappyMenuButtonEvent = CreateTrigger()
  467.        
  468.         private bool DialogClicked() {
  469.         }//DialogClicked
  470.     //! endtextmacro
  471.  
  472. PlayerDrivenInterfaceCode
  473.     Place all of your run time code here
  474.    
  475.     //! textmacro PlayerDrivenInterfaceCode
  476.         TriggerRegisterDialogButtonEvent(crappyMenuButtonEvent, DialogAddButton(crappyMenu, "0", '0'))
  477.         TriggerAddCondition(crappyMenuButtonEvent, Condition(function DialogClicked))
  478.     //! endtextmacro
  479.    
  480. PlayerDrivenInterfaceProperties
  481.     Place various interface properties for the system and tinker with default ones.
  482.  
  483. AUTO_GAME_OVER_CHECK-
  484. ------------------------------------------------------------------
  485. //! textmacro GAME_OVER_CODE
  486.     Place code to run for when the game is over
  487.    
  488.     //! textmacro GAME_OVER_CODE
  489.         bool playerWon[]
  490.         int curTeam
  491.         ploop(curPlayer, Human, true)
  492.             tloop(curTeam, false)
  493.                 if TeamPlayer[curPlayer].isOnTeam[curTeam] {
  494.                     DisplayTextToPlayer(Player(curPlayer), 0, 0, "YOU WON "+GetPlayerName(Player(curPlayer))+"!!")
  495.                     playerWon[curPlayer] = true
  496.                     exitwhen true
  497.                 }//if
  498.             endtloop(curTeam)
  499.         endploop(curPlayer)
  500.         ploop(curPlayer, Human, false)
  501.             if !playerWon[curPlayer] {
  502.                 DisplayTextToPlayer(Player(curPlayer), 0, 0, "YOU LOST "+GetPlayerName(Player(curPlayer))+"!!")
  503.             }//if
  504.         endploop(curPlayer)
  505.     //! endtextmacro
  506.    
  507. //! textmacro GAME_OVER_CODE_NO_WINNER
  508.     Place code to run for when the game is over and there is no winner
  509.    
  510.     //! textmacro GAME_OVER_CODE_NO_WINNER
  511.         printf("You lost " + GetPlayerName(GetLocalHuman())+"!!")
  512.     //! endtextmacro
  513.  
  514. Syntax Features
  515. ------------------------------------------------------------------
  516.     tloop(processVar, processDeclare)
  517.         loop through active teams
  518.        
  519.     tploop(processTeam, processVar, processDeclare)
  520.         loop through players on a team
  521.    
  522.     ptloop(processTeamPlayer, processVar, processDeclare)
  523.         loop through teams a player is on
  524.    
  525.     taloop(processTeam, processVar, processDeclare)
  526.         loop through a team's alliance teams
  527.    
  528.     tnloop(processTeam, processVar, processDeclare)
  529.         loop through a team's neutral teams
  530. ===================================================================*/
  531.     private constant int TEAM_COUNT = 89 //max amount of teams
  532.     private int curPlayerId
  533.     private int curPlayerId2
  534.     private int runPlayerId
  535.     private int runPlayerId2
  536.     private int curTeamId
  537.     private int curTeam
  538.     private int winTeam
  539.    
  540.     private player curPlayer1
  541.     private player curPlayer2
  542.    
  543.     private int activeTeamCount = 0
  544.     private int activeTeam[TEAM_COUNT]
  545.    
  546.     private struct Players extends array {//stores player information
  547.         public static int teamCount[TEAM_MAX_SIZE] //how many teams player is in
  548.         public static int alliance[TEAM_MAX_SIZE][TEAM_MAX_SIZE] //alliance between 2 players
  549.         #if DO_TEAM_ALLIANCES
  550.             public static int neutral[TEAM_MAX_SIZE][TEAM_MAX_SIZE] //neutrality between 2 players
  551.         #endif
  552.        
  553.         public static bool playerTeamCheck[TEAM_MAX_SIZE][TEAM_COUNT] //is player in team
  554.         public static int playerTeamId[TEAM_MAX_SIZE][TEAM_COUNT] //the player's indexed id in a team
  555.         public static int indexedTeam[TEAM_MAX_SIZE][TEAM_COUNT] //stored team for a player
  556.         public static int teamId[TEAM_MAX_SIZE][TEAM_COUNT] //use team id to retrieve indexed team id for a player
  557.     }//Players
  558.    
  559.     struct TeamPlayer extends array {
  560.         public int operator teamCount() {
  561.             return Players.teamCount[this]
  562.         }//teamCount
  563.        
  564.         public int getTeam(int index) {//retrieves a team the player is on via an index
  565.             return Players.indexedTeam[this][index]
  566.         }//getTeam
  567.        
  568.         public bool isOnTeam(int teamId) {//checks to see if a player is on a team
  569.             return Players.playerTeamCheck[this][teamId]
  570.         }//isOnTeam
  571.        
  572.         public bool isAllied(int playerId) {//checks if two players are allied
  573.             return Players.alliance[this][playerId] > 0
  574.         }//isAllied
  575.        
  576.         #if DO_TEAM_ALLIANCES
  577.             public bool isNeutral(int playerId) {//checks if two players are neutral
  578.                 return Players.alliance[this][playerId] == 0 && Players.neutral[this][playerId] > 0
  579.             }//isNeutral
  580.         #endif
  581.     }//PlayerManager
  582.    
  583.     #if DO_TEAM_ALLIANCES
  584.         private int teamNeutralAlliance[TEAM_COUNT][TEAM_COUNT]
  585.         private int teamAlliedAlliance[TEAM_COUNT][TEAM_COUNT]
  586.         private int teamNeutralAllianceId[TEAM_COUNT][TEAM_COUNT]
  587.         private int teamAlliedAllianceId[TEAM_COUNT][TEAM_COUNT]
  588.     #endif
  589.        
  590.     struct ActiveTeam extends array {//determines game status by teams
  591.         public int operator count() {//returns how many teams are active
  592.             return activeTeamCount
  593.         }//activeCount
  594.        
  595.         public int get(int index) {//returns an active team given an index
  596.             return activeTeam[index]
  597.         }//active
  598.     }//TeamGame
  599.    
  600.     struct Team extends array {
  601.         private static int teamCount = 0 //count of teams
  602.         private static int teamRecycleCount = 0 //recycled team count
  603.         private static int teamRecycle[TEAM_COUNT] //stores a recycled team id
  604.         #if DO_TEAM_ALLIANCES
  605.             private static int neutralAlliances[TEAM_COUNT] //neutral alliance count
  606.             private static int alliedAlliances[TEAM_COUNT] //allied alliance count
  607.         #endif
  608.         private static int activeId[TEAM_COUNT] //active team id
  609.        
  610.         private static int teamSize[TEAM_COUNT] //how many players currently in team
  611.         private static int teamPlayers[TEAM_COUNT][TEAM_MAX_SIZE] //stores player ids
  612.        
  613.         public int teamNumber
  614.        
  615.         TEAM_DEFAULT_ALLIANCE_VALUES
  616.        
  617.         public int operator size() {
  618.             return Team.teamSize[this]
  619.         }//size
  620.        
  621.         #if DO_TEAM_ALLIANCES
  622.             public int operator neutralCount() {
  623.                 return Team.neutralAlliances[this]
  624.             }//neutralCount
  625.            
  626.             public int operator allyCount() {
  627.                 return Team.alliedAlliances[this]
  628.             }//allianceCount
  629.            
  630.             public int getNeutral(int index) {
  631.                 return teamNeutralAlliance[this][index]
  632.             }//getNeutral
  633.            
  634.             public int getAlly(int index) {
  635.                 return teamAlliedAlliance[this][index]
  636.             }//getAlly
  637.         #endif
  638.        
  639.         public int getPlayer(int index) {//returns player via an index
  640.             return Team.teamPlayers[this][index]
  641.         }//getPlayer
  642.        
  643.         #if DO_SHARED_XP
  644.             public bool sharedXp
  645.         #endif
  646.         #if DO_SHARED_SPELLS
  647.             public bool sharedSpells
  648.         #endif
  649.         #if DO_SHARED_VISION
  650.             public bool sharedVision
  651.         #endif
  652.         #if DO_SHARED_CONTROL
  653.             public bool sharedControl
  654.         #endif
  655.         #if DO_SHARED_ADV_CONTROL
  656.             public bool sharedAdvControl
  657.         #endif
  658.        
  659.         //retrieve current player's team count
  660.         define private PLAYER_TEAM_COUNT = Players.teamCount[playerId]
  661.        
  662.         //retrieve the current team's player count
  663.         define private TEAM_PLAYER_COUNT = Team.teamSize[this]
  664.        
  665.         //team id for current team on player
  666.         define private TEAM_ID = Players.teamId[playerId][this]
  667.        
  668.         //player id for current player on team
  669.         define private PLAYER_ID = Players.playerTeamId[playerId][TEAM_ID]
  670.        
  671.         define private teamNeutral(player1, player2, flag) = {
  672.             SetPlayerAlliance(player1, player2, ALLIANCE_HELP_REQUEST,  false)
  673.             SetPlayerAlliance(player1, player2, ALLIANCE_HELP_RESPONSE, false)
  674.             SetPlayerAlliance(player2, player1, ALLIANCE_HELP_REQUEST,  false)
  675.             SetPlayerAlliance(player2, player1, ALLIANCE_HELP_RESPONSE, false)
  676.            
  677.             #if DO_SHARED_XP
  678.                 SetPlayerAlliance(player1, player2, ALLIANCE_SHARED_XP,     false)
  679.                 SetPlayerAlliance(player2, player1, ALLIANCE_SHARED_XP,     false)
  680.             #endif
  681.             #if DO_SHARED_SPELLS
  682.                 SetPlayerAlliance(player1, player2, ALLIANCE_SHARED_SPELLS, false)
  683.                 SetPlayerAlliance(player2, player1, ALLIANCE_SHARED_SPELLS, false)
  684.             #endif
  685.             #if DO_SHARED_VISION
  686.                 SetPlayerAlliance(player1, player2, ALLIANCE_SHARED_VISION, false)
  687.                 SetPlayerAlliance(player2, player1, ALLIANCE_SHARED_VISION, false)
  688.             #endif
  689.             #if DO_SHARED_CONTROL
  690.                 SetPlayerAlliance(player1, player2, ALLIANCE_SHARED_CONTROL, false)
  691.                 SetPlayerAlliance(player2, player1, ALLIANCE_SHARED_CONTROL, false)
  692.             #endif
  693.             #if DO_SHARED_ADV_CONTROL
  694.                 SetPlayerAlliance(player1, player2, ALLIANCE_SHARED_ADVANCED_CONTROL, false)
  695.                 SetPlayerAlliance(player2, player1, ALLIANCE_SHARED_ADVANCED_CONTROL, false)
  696.             #endif
  697.            
  698.             SetPlayerAlliance(player1, player2, ALLIANCE_PASSIVE, flag)
  699.             SetPlayerAlliance(player2, player1, ALLIANCE_PASSIVE, flag)
  700.         }//teamNeutral
  701.  
  702.         define private teamAlly(player1, player2, flag, instance, instance2) = {
  703.             SetPlayerAlliance(player1, player2, ALLIANCE_PASSIVE,       flag)
  704.             SetPlayerAlliance(player1, player2, ALLIANCE_HELP_REQUEST,  flag)
  705.             SetPlayerAlliance(player1, player2, ALLIANCE_HELP_RESPONSE, flag)
  706.            
  707.             SetPlayerAlliance(player2, player1, ALLIANCE_PASSIVE,       flag)
  708.             SetPlayerAlliance(player2, player1, ALLIANCE_HELP_REQUEST,  flag)
  709.             SetPlayerAlliance(player2, player1, ALLIANCE_HELP_RESPONSE, flag)
  710.             #if instance != instance2
  711.                 #if DO_SHARED_XP
  712.                     if Team[instance].sharedXp {SetPlayerAlliance(player1, player2, ALLIANCE_SHARED_XP,     flag)}
  713.                     if Team[instance2].sharedXp {SetPlayerAlliance(player2, player1, ALLIANCE_SHARED_XP,     flag)}
  714.                 #endif
  715.                 #if DO_SHARED_SPELLS
  716.                     if Team[instance].sharedSpells {SetPlayerAlliance(player1, player2, ALLIANCE_SHARED_SPELLS, flag)}
  717.                     if Team[instance2].sharedSpells {SetPlayerAlliance(player2, player1, ALLIANCE_SHARED_SPELLS, flag)}
  718.                 #endif
  719.                 #if DO_SHARED_VISION
  720.                     if Team[instance].sharedVision {SetPlayerAlliance(player1, player2, ALLIANCE_SHARED_VISION, flag)}
  721.                     if Team[instance2].sharedVision {SetPlayerAlliance(player2, player1, ALLIANCE_SHARED_VISION, flag)}
  722.                 #endif
  723.                 #if DO_SHARED_CONTROL
  724.                     if Team[instance].sharedControl {SetPlayerAlliance(player1, player2, ALLIANCE_SHARED_CONTROL, flag)}
  725.                     if Team[instance2].sharedControl {SetPlayerAlliance(player2, player1, ALLIANCE_SHARED_CONTROL, flag)}
  726.                 #endif
  727.                 #if DO_SHARED_ADV_CONTROL
  728.                     if Team[instance].sharedAdvControl {SetPlayerAlliance(player1, player2, ALLIANCE_SHARED_ADVANCED_CONTROL, flag)}
  729.                     if Team[instance2].sharedAdvControl {SetPlayerAlliance(player2, player1, ALLIANCE_SHARED_ADVANCED_CONTROL, flag)}
  730.                 #endif
  731.             #else
  732.                 #if DO_SHARED_XP
  733.                     if Team[instance].sharedXp {
  734.                         SetPlayerAlliance(player1, player2, ALLIANCE_SHARED_XP,     flag)
  735.                         SetPlayerAlliance(player2, player1, ALLIANCE_SHARED_XP,     flag)
  736.                     }
  737.                 #endif
  738.                 #if DO_SHARED_SPELLS
  739.                     if Team[instance].sharedSpells {
  740.                         SetPlayerAlliance(player1, player2, ALLIANCE_SHARED_SPELLS, flag)
  741.                         SetPlayerAlliance(player2, player1, ALLIANCE_SHARED_SPELLS, flag)
  742.                     }
  743.                 #endif
  744.                 #if DO_SHARED_VISION
  745.                     if Team[instance].sharedVision {
  746.                         SetPlayerAlliance(player1, player2, ALLIANCE_SHARED_VISION, flag)
  747.                         SetPlayerAlliance(player2, player1, ALLIANCE_SHARED_VISION, flag)
  748.                     }
  749.                 #endif
  750.                 #if DO_SHARED_CONTROL
  751.                     if Team[instance].sharedControl {
  752.                         SetPlayerAlliance(player1, player2, ALLIANCE_SHARED_CONTROL, flag)
  753.                         SetPlayerAlliance(player2, player1, ALLIANCE_SHARED_CONTROL, flag)
  754.                     }
  755.                 #endif
  756.                 #if DO_SHARED_ADV_CONTROL
  757.                     if Team[instance].sharedAdvControl {
  758.                         SetPlayerAlliance(player1, player2, ALLIANCE_SHARED_ADVANCED_CONTROL, flag)
  759.                         SetPlayerAlliance(player2, player1, ALLIANCE_SHARED_ADVANCED_CONTROL, flag)
  760.                     }
  761.                 #endif
  762.             #endif
  763.         }//teamAlly
  764.        
  765.         define private TeamIni(instance) = {//does team initialization
  766.             Team.teamSize[instance] = 0
  767.             Team.activeId[instance] = activeTeamCount
  768.             activeTeam[activeTeamCount++] = instance
  769.             #if DO_SHARED_XP
  770.                 Team[instance].sharedXp = Team.SHARED_XP
  771.             #endif
  772.             #if DO_SHARED_SPELLS
  773.                 Team[instance].sharedSpells = Team.SHARED_SPELLS
  774.             #endif
  775.             #if DO_SHARED_VISION
  776.                 Team[instance].sharedVision = Team.SHARED_VISION
  777.             #endif
  778.             #if DO_SHARED_CONTROL
  779.                 Team[instance].sharedControl = Team.SHARED_CONTROL
  780.             #endif
  781.             #if DO_SHARED_ADV_CONTROL
  782.                 Team[instance].sharedAdvControl = Team.SHARED_ADV_CONTROL
  783.             #endif
  784.             return instance
  785.         }//TeamIni
  786.        
  787.         public static Team create() {
  788.             if Team.teamRecycleCount != 0 {
  789.                 TeamIni(Team.teamRecycle[--Team.teamRecycleCount])
  790.             }
  791.             Team.teamCount++
  792.             TeamIni(Team.teamCount-1)
  793.         }//create
  794.        
  795.         public void destroy() {
  796.             int playerId
  797.             int team1
  798.             int team2
  799.             if Team.activeId[this] != --activeTeamCount {
  800.                 activeTeam[Team.activeId[this]] = activeTeam[activeTeamCount]
  801.                 Team.activeId[activeTeam[activeTeamCount]] = Team.activeId[this]
  802.             }//if
  803.             Team.activeId[this] = 0
  804.             Team.teamRecycle[Team.teamRecycleCount++] = this
  805.            
  806.             #if DO_TEAM_ALLIANCES
  807.                 team1 = this
  808.                 //Neutral Alliances
  809.                 ////////////////////////////////////////////////////////////////////////
  810.                 whilenot Team.neutralAlliances[team1] == 0 {//clear out neutral alliances
  811.                     team2 = teamNeutralAlliance[team1][Team.neutralAlliances[team1]]
  812.                     if teamNeutralAllianceId[team2][team1] != Team.neutralAlliances[team2] {//try to index team
  813.                         teamNeutralAllianceId[team2][Team.neutralAlliances[team2]] = teamNeutralAllianceId[team2][team1]
  814.                         teamNeutralAlliance[team2][teamNeutralAllianceId[team2][team1]] = teamNeutralAlliance[team2][Team.neutralAlliances[team2]]
  815.                     }//if
  816.                     teamNeutralAllianceId[team1][team2] = 0
  817.                     teamNeutralAllianceId[team2][team1] = 0
  818.                     Team.neutralAlliances[team1]--
  819.                     Team.neutralAlliances[team2]--
  820.                     curPlayerId = Team.teamSize[team1]
  821.                     whilenot curPlayerId == 0 {//cycle through team 1
  822.                         curPlayerId--
  823.                         runPlayerId = Team.teamPlayers[team1][curPlayerId]
  824.                         curPlayer1 = Player(runPlayerId)
  825.                         curPlayerId2 = Team.teamSize[team2]
  826.                         whilenot curPlayerId2 == 0 {//cycle through team 2
  827.                             curPlayerId2--
  828.                             runPlayerId2 = Team.teamPlayers[team2][curPlayerId2]
  829.                             if runPlayerId != runPlayerId2 {//make sure players aren't the same
  830.                                 Players.neutral[runPlayerId][runPlayerId2]--
  831.                                 Players.neutral[runPlayerId2][runPlayerId]--
  832.                                 curPlayer2 = Player(runPlayerId2)
  833.                                 if Players.neutral[runPlayerId][runPlayerId2] == 0 && Players.alliance[runPlayerId][runPlayerId2] == 0 {//make sure not allied or neutral
  834.                                     teamNeutral(curPlayer1, curPlayer2, false)
  835.                                 }//if
  836.                             }//if
  837.                         }//whilenot
  838.                     }//whilenot
  839.                 }//whilenot
  840.                 ////////////////////////////////////////////////////////////////////////
  841.                
  842.                 //Allied Alliances
  843.                 ////////////////////////////////////////////////////////////////////////
  844.                 whilenot Team.alliedAlliances[team1] == 0 {//clear out allied alliances
  845.                     team2 = teamAlliedAlliance[team1][Team.alliedAlliances[team1]]
  846.                     if teamAlliedAllianceId[team2][team1] != Team.alliedAlliances[team2] {//try to index team
  847.                         teamAlliedAllianceId[team2][Team.alliedAlliances[team2]] = teamAlliedAllianceId[team2][team1]
  848.                         teamAlliedAlliance[team2][teamAlliedAllianceId[team2][team1]] = teamAlliedAlliance[team2][Team.alliedAlliances[team2]]
  849.                     }//if
  850.                     teamAlliedAllianceId[team1][team2] = 0
  851.                     teamAlliedAllianceId[team2][team1] = 0
  852.                     Team.alliedAlliances[team1]--
  853.                     Team.alliedAlliances[team2]--
  854.                     curPlayerId = Team.teamSize[team1]
  855.                     whilenot curPlayerId == 0 {//cycle through team 1
  856.                         curPlayerId--
  857.                         runPlayerId = Team.teamPlayers[team1][curPlayerId]
  858.                         curPlayer1 = Player(runPlayerId)
  859.                         curPlayerId2 = Team.teamSize[team2]
  860.                         whilenot curPlayerId2 == 0 {//cycle through team 2
  861.                             curPlayerId2--
  862.                             runPlayerId2 = Team.teamPlayers[team2][curPlayerId2]
  863.                             if runPlayerId != runPlayerId2 {//make sure players aren't the same
  864.                                 Players.alliance[runPlayerId][runPlayerId2]--
  865.                                 Players.alliance[runPlayerId2][runPlayerId]--
  866.                                 if Players.alliance[runPlayerId][runPlayerId2] == 0 {//make sure not allied
  867.                                     curPlayer2 = Player(runPlayerId2)
  868.                                     if Players.neutral[runPlayerId][runPlayerId2] > 0 {//try to make them neutral
  869.                                         teamNeutral(curPlayer1, curPlayer2, true)
  870.                                     }//if
  871.                                     else {
  872.                                         teamAlly(curPlayer1, curPlayer2, false, team1, team2)
  873.                                     }//else
  874.                                 }//if
  875.                             }//if
  876.                         }//whilenot
  877.                     }//whilenot
  878.                 }//whilenot
  879.                 ////////////////////////////////////////////////////////////////////////
  880.             #endif
  881.            
  882.             //Remove All Players
  883.             ////////////////////////////////////////////////////////////////////////
  884.             whilenot TEAM_PLAYER_COUNT == 0 {//remove players
  885.                 //Team Alliances
  886.                 PLAYER_TEAM_COUNT--
  887.                 playerId = Team.teamPlayers[this][--TEAM_PLAYER_COUNT]
  888.                 curPlayer1 = Player(playerId)
  889.                 curPlayerId = TEAM_PLAYER_COUNT
  890.                 whilenot curPlayerId == 0 {//unally players on the same team
  891.                     curPlayerId--
  892.                     //decrease the alliance count between the two players
  893.                     Players.alliance[playerId][Team.teamPlayers[this][curPlayerId]]--
  894.                     Players.alliance[Team.teamPlayers[this][curPlayerId]][playerId]--
  895.                     if Players.alliance[playerId][Team.teamPlayers[this][curPlayerId]] == 0 {//if they have no more ties, unally
  896.                         curPlayer2 = Player(Team.teamPlayers[this][curPlayerId])
  897.                         teamAlly(curPlayer1, curPlayer2, false, this, this)
  898.                     }//if
  899.                 }//whilenot
  900.  
  901.                 if TEAM_ID != PLAYER_TEAM_COUNT {//remove the team from an indexed array for player and index
  902.                     Players.indexedTeam[playerId][TEAM_ID] = Players.indexedTeam[playerId][PLAYER_TEAM_COUNT]
  903.                 }//if
  904.                 //mark the team flag for player as false for this team
  905.                 Players.playerTeamCheck[playerId][TEAM_ID] = false
  906.                
  907.                 //reset PLAYER_ID and TEAM_ID
  908.                 PLAYER_ID = 0
  909.                 TEAM_ID = 0
  910.             }//whilenot
  911.             ////////////////////////////////////////////////////////////////////////
  912.             #if AUTO_GAME_OVER_CHECK
  913.                 //see if a fast game over check is possible
  914.                 if activeTeamCount != 0 {
  915.                     #if DO_TEAM_ALLIANCES
  916.                         curTeam = activeTeamCount
  917.                         whilenot curTeam == 0 {//go through all the teams
  918.                             //check to see if they aren't allied/neutral and that the activeTeam isn't this team
  919.                             if activeTeam[curTeam] != this && teamAlliedAllianceId[this][activeTeam[curTeam]] == 0 {
  920.                                 return
  921.                             }//if
  922.                             curTeam--
  923.                         }//whilenot
  924.                         //! runtextmacro GAME_OVER_CODE()
  925.                     #else
  926.                         if activeTeamCount == 1 {
  927.                             //! runtextmacro GAME_OVER_CODE()
  928.                         }//if
  929.                     #endif
  930.                 }//if
  931.                 else {//no winners
  932.                     //! runtextmacro GAME_OVER_CODE_NO_WINNER()
  933.                 }//else
  934.             #endif
  935.         }//destroy
  936.  
  937.         #if DO_TEAM_ALLIANCES
  938.             public bool isAllied(Team team2) {//checks if team is allied with another team
  939.                 return teamAlliedAllianceId[this][team2] > 0
  940.             }//isAllied
  941.            
  942.             public bool isNeutral(Team team2) {//checks if team is neutral with another team
  943.                 return teamAlliedAllianceId[this][team2] == 0 && teamNeutralAllianceId[this][team2] > 0
  944.             }//isNeutral
  945.            
  946.             public static void neutralTeam(Team team1, Team team2) {//makes two teams neutral. Will only run if they aren't allied
  947.                 if teamNeutralAllianceId[team1][team2] == 0 {//make sure two teams aren't neutral
  948.                     teamNeutralAllianceId[team1][team2] = ++Team.neutralAlliances[team1]
  949.                     teamNeutralAllianceId[team2][team1] = ++Team.neutralAlliances[team2]
  950.                     teamNeutralAlliance[team1][Team.neutralAlliances[team1]] = team2
  951.                     teamNeutralAlliance[team2][Team.neutralAlliances[team2]] = team1
  952.                     curPlayerId = Team.teamSize[team1]
  953.                     whilenot curPlayerId == 0 {//cycle through team 1
  954.                         curPlayerId--
  955.                         runPlayerId = Team.teamPlayers[team1][curPlayerId]
  956.                         curPlayer1 = Player(runPlayerId)
  957.                         curPlayerId2 = Team.teamSize[team2]
  958.                         whilenot curPlayerId2 == 0 {//cycle through team 2
  959.                             curPlayerId2--
  960.                             runPlayerId2 = Team.teamPlayers[team2][curPlayerId2]
  961.                             if runPlayerId != runPlayerId2 {//make sure players aren't the same
  962.                                 if Players.alliance[runPlayerId][runPlayerId2] == 0 && Players.neutral[runPlayerId][runPlayerId2] == 0 {//make sure not allied and not neutral
  963.                                     curPlayer2 = Player(runPlayerId2)
  964.                                     teamNeutral(curPlayer1, curPlayer2, true)
  965.                                 }//if
  966.                                 Players.neutral[runPlayerId][runPlayerId2]++
  967.                                 Players.neutral[runPlayerId2][runPlayerId]++
  968.                             }//if
  969.                         }//whilenot
  970.                     }//whilenot
  971.                 }//if
  972.             }//neutralTeam
  973.            
  974.             public static void allyTeams(Team team1, Team team2) {//makes two teams allied
  975.                 if teamAlliedAllianceId[team1][team2] == 0 {//make sure two teams aren't allied
  976.                     teamAlliedAllianceId[team1][team2] = ++Team.alliedAlliances[team1]
  977.                     teamAlliedAllianceId[team2][team1] = ++Team.alliedAlliances[team2]
  978.                     teamAlliedAlliance[team1][Team.alliedAlliances[team1]] = team2
  979.                     teamAlliedAlliance[team2][Team.alliedAlliances[team2]] = team1
  980.                     curPlayerId = Team.teamSize[team1]
  981.                     whilenot curPlayerId == 0 {//cycle through team 1
  982.                         curPlayerId--
  983.                         runPlayerId = Team.teamPlayers[team1][curPlayerId]
  984.                         curPlayer1 = Player(runPlayerId)
  985.                         curPlayerId2 = Team.teamSize[team2]
  986.                         whilenot curPlayerId2 == 0 {//cycle through team 2
  987.                             curPlayerId2--
  988.                             runPlayerId2 = Team.teamPlayers[team2][curPlayerId2]
  989.                             if runPlayerId != runPlayerId2 {//make sure players aren't the same
  990.                                 if Players.alliance[runPlayerId][runPlayerId2] == 0 {//make sure not allied
  991.                                     curPlayer2 = Player(runPlayerId2)
  992.                                     teamAlly(curPlayer1, curPlayer2, true, team1, team2)
  993.                                 }//if
  994.                                 Players.alliance[runPlayerId][runPlayerId2]++
  995.                                 Players.alliance[runPlayerId2][runPlayerId]++
  996.                             }//if
  997.                         }//whilenot
  998.                     }//whilenot
  999.                 }//if
  1000.             }//allyTeams
  1001.            
  1002.             public static void unallyTeams(Team team1, Team team2) {//makes two teams unallied
  1003.                 if teamAlliedAllianceId[team1][team2] > 0 {//make sure two teams are allied
  1004.                     if teamAlliedAllianceId[team1][team2] != Team.alliedAlliances[team1] {//try to index team
  1005.                         teamAlliedAllianceId[team1][Team.alliedAlliances[team1]] = teamAlliedAllianceId[team1][team2]
  1006.                         teamAlliedAlliance[team1][teamAlliedAllianceId[team1][team2]] = teamAlliedAlliance[team1][Team.alliedAlliances[team1]]
  1007.                     }//if
  1008.                     if teamAlliedAllianceId[team2][team1] != Team.alliedAlliances[team2] {//try to index team
  1009.                         teamAlliedAllianceId[team2][Team.alliedAlliances[team2]] = teamAlliedAllianceId[team2][team1]
  1010.                         teamAlliedAlliance[team2][teamAlliedAllianceId[team2][team1]] = teamAlliedAlliance[team2][Team.alliedAlliances[team2]]
  1011.                     }//if
  1012.                     teamAlliedAllianceId[team1][team2] = 0
  1013.                     teamAlliedAllianceId[team2][team1] = 0
  1014.                     Team.alliedAlliances[team1]--
  1015.                     Team.alliedAlliances[team2]--
  1016.                     curPlayerId = Team.teamSize[team1]
  1017.                     whilenot curPlayerId == 0 {//cycle through team 1
  1018.                         curPlayerId--
  1019.                         runPlayerId = Team.teamPlayers[team1][curPlayerId]
  1020.                         curPlayer1 = Player(runPlayerId)
  1021.                         curPlayerId2 = Team.teamSize[team2]
  1022.                         whilenot curPlayerId2 == 0 {//cycle through team 2
  1023.                             curPlayerId2--
  1024.                             runPlayerId2 = Team.teamPlayers[team2][curPlayerId2]
  1025.                             if runPlayerId != runPlayerId2 {//make sure players aren't the same
  1026.                                 Players.alliance[runPlayerId][runPlayerId2]--
  1027.                                 Players.alliance[runPlayerId2][runPlayerId]--
  1028.                                 if Players.alliance[runPlayerId][runPlayerId2] == 0 {//make sure not allied
  1029.                                     curPlayer2 = Player(runPlayerId2)
  1030.                                     if Players.neutral[runPlayerId][runPlayerId2] > 0 {//try to make them neutral
  1031.                                         teamNeutral(curPlayer1, curPlayer2, true)
  1032.                                     }//if
  1033.                                     else {
  1034.                                         teamAlly(curPlayer1, curPlayer2, false, team1, team2)
  1035.                                     }//else
  1036.                                 }//if
  1037.                             }//if
  1038.                         }//whilenot
  1039.                     }//whilenot
  1040.                 }//if
  1041.             }//unally teams
  1042.            
  1043.             public static void removeNeutralTeams(Team team1, Team team2) {//removes neutrality between two teams
  1044.                 if teamNeutralAllianceId[team1][team2] > 0 {//make sure two teams are allied
  1045.                     if teamNeutralAllianceId[team1][team2] != Team.neutralAlliances[team1] {//try to index team
  1046.                         teamNeutralAllianceId[team1][Team.neutralAlliances[team1]] = teamNeutralAllianceId[team1][team2]
  1047.                         teamNeutralAlliance[team1][teamNeutralAllianceId[team1][team2]] = teamNeutralAlliance[team1][Team.neutralAlliances[team1]]
  1048.                     }//if
  1049.                     if teamNeutralAllianceId[team2][team1] != Team.neutralAlliances[team2] {//try to index team
  1050.                         teamNeutralAllianceId[team2][Team.neutralAlliances[team2]] = teamNeutralAllianceId[team2][team1]
  1051.                         teamNeutralAlliance[team2][teamNeutralAllianceId[team2][team1]] = teamNeutralAlliance[team2][Team.neutralAlliances[team2]]
  1052.                     }//if
  1053.                     teamNeutralAllianceId[team1][team2] = 0
  1054.                     teamNeutralAllianceId[team2][team1] = 0
  1055.                     Team.neutralAlliances[team1]--
  1056.                     Team.neutralAlliances[team2]--
  1057.                     curPlayerId = Team.teamSize[team1]
  1058.                     whilenot curPlayerId == 0 {//cycle through team 1
  1059.                         curPlayerId--
  1060.                         runPlayerId = Team.teamPlayers[team1][curPlayerId]
  1061.                         curPlayer1 = Player(runPlayerId)
  1062.                         curPlayerId2 = Team.teamSize[team2]
  1063.                         whilenot curPlayerId2 == 0 {//cycle through team 2
  1064.                             curPlayerId2--
  1065.                             runPlayerId2 = Team.teamPlayers[team2][curPlayerId2]
  1066.                             if runPlayerId != runPlayerId2 {//make sure players aren't the same
  1067.                                 Players.neutral[runPlayerId][runPlayerId2]--
  1068.                                 Players.neutral[runPlayerId2][runPlayerId]--
  1069.                                 curPlayer2 = Player(runPlayerId2)
  1070.                                 if Players.neutral[runPlayerId][runPlayerId2] == 0 && Players.alliance[runPlayerId][runPlayerId2] == 0 {//make sure not allied or neutral
  1071.                                     teamNeutral(curPlayer1, curPlayer2, false)
  1072.                                 }//if
  1073.                             }//if
  1074.                         }//whilenot
  1075.                     }//whilenot
  1076.                 }//if
  1077.             }//removeNeutralTeams
  1078.         #endif
  1079.        
  1080.         public void addPlayer(int playerId) {
  1081.             debug if !Players.playerTeamCheck[playerId][this] && TEAM_PLAYER_COUNT < TEAM_MAX_SIZE
  1082.                 //Team Alliances
  1083.                 curPlayer1 = Player(playerId)
  1084.                 curPlayerId = TEAM_PLAYER_COUNT
  1085.                 whilenot curPlayerId == 0 {//ally players on the same team
  1086.                     curPlayerId--
  1087.                     //if the two players aren't allied then ally them
  1088.                     if Players.alliance[playerId][Team.teamPlayers[this][curPlayerId]] == 0 {
  1089.                         curPlayer2 = Player(Team.teamPlayers[this][curPlayerId])
  1090.                         teamAlly(curPlayer1, curPlayer2, true, this, this)
  1091.                     }//if
  1092.                     //increase the alliance count between the two players
  1093.                     Players.alliance[playerId][Team.teamPlayers[this][curPlayerId]]++
  1094.                     Players.alliance[Team.teamPlayers[this][curPlayerId]][playerId]++
  1095.                 }//whilenot
  1096.                
  1097.                 #if DO_TEAM_ALLIANCES
  1098.                 //Allied Alliances
  1099.                     curTeamId = Team.alliedAlliances[this]
  1100.                     whilenot curTeamId == 0 {//ally players on allied teams
  1101.                         curTeamId--
  1102.                         curTeam = teamAlliedAlliance[this][curTeamId]
  1103.                         curPlayerId = Team.teamSize[curTeam]
  1104.                         whilenot curPlayerId == 0 {//ally players on allied teams
  1105.                             curPlayerId--
  1106.                             if Team.teamPlayers[curTeam][curPlayerId] != playerId {//make sure players aren't the same
  1107.                                 //if two players aren't allied then ally them
  1108.                                 if Players.alliance[playerId][Team.teamPlayers[curTeam][curPlayerId]] == 0 {//make sure not allied
  1109.                                     curPlayer2 = Player(Team.teamPlayers[curTeam][curPlayerId])
  1110.                                     teamAlly(curPlayer1, curPlayer2, true, this, this)
  1111.                                 }//if
  1112.                                 Players.alliance[playerId][Team.teamPlayers[curTeam][curPlayerId]]++
  1113.                                 Players.alliance[Team.teamPlayers[curTeam][curPlayerId]][playerId]++
  1114.                             }//if
  1115.                         }//whilenot
  1116.                     }//whilenot
  1117.                    
  1118.                     //Neutral Alliances
  1119.                     curTeamId = Team.neutralAlliances[this]
  1120.                     whilenot curTeamId == 0 {//make players on neutral teams neutral
  1121.                         curTeamId--
  1122.                         curTeam = teamNeutralAlliance[this][curTeamId]
  1123.                         curPlayerId = Team.teamSize[curTeam]
  1124.                         whilenot curPlayerId == 0 {//make players on neutral teams neutral
  1125.                             curPlayerId--
  1126.                             if Team.teamPlayers[curTeam][curPlayerId] != playerId {//make sure players aren't the same
  1127.                                 //if two players aren't neutral and not allied then make them neutral them
  1128.                                 if Players.alliance[playerId][Team.teamPlayers[curTeam][curPlayerId]] == 0 && Players.neutral[playerId][Team.teamPlayers[curTeam][curPlayerId]] == 0 {//make sure not allied or neutral
  1129.                                     curPlayer2 = Player(Team.teamPlayers[curTeam][curPlayerId])
  1130.                                     teamNeutral(curPlayer1, curPlayer2, true)
  1131.                                 }//if
  1132.                                 Players.neutral[playerId][Team.teamPlayers[curTeam][curPlayerId]]++
  1133.                                 Players.neutral[Team.teamPlayers[curTeam][curPlayerId]][playerId]++
  1134.                             }//if
  1135.                         }//whilenot
  1136.                     }//whilenot
  1137.                 #endif
  1138.                
  1139.                 //make player id equal to team size
  1140.                 PLAYER_ID = TEAM_PLAYER_COUNT
  1141.                 //make team id equal to player team count
  1142.                 TEAM_ID = PLAYER_TEAM_COUNT
  1143.                 //add player to team
  1144.                 Team.teamPlayers[this][TEAM_PLAYER_COUNT] = playerId
  1145.                 //store the team into an indexed array for player
  1146.                 Players.indexedTeam[playerId][PLAYER_TEAM_COUNT] = this
  1147.                
  1148.                 //mark the team flag for player as true for this team
  1149.                 Players.playerTeamCheck[playerId][PLAYER_TEAM_COUNT] = true
  1150.                
  1151.                 //increase the size of this team
  1152.                 TEAM_PLAYER_COUNT++
  1153.                 //increase how many teams the player is in
  1154.                 PLAYER_TEAM_COUNT++
  1155.             debug endif
  1156.         }//addPlayer
  1157.        
  1158.         public void removePlayer(int playerId) {
  1159.             debug if !Players.playerTeamCheck[playerId][this] && TEAM_PLAYER_COUNT > 0
  1160.                 #if AUTO_REMOVE_TEAMS
  1161.                     if TEAM_PLAYER_COUNT == 1 {//if only one player left and auto remove is on, just destroy the team
  1162.                         .destroy()
  1163.                         return
  1164.                     }//if
  1165.                 #endif
  1166.                 //Team Alliances
  1167.                 curPlayer1 = Player(playerId)
  1168.                 curPlayerId = TEAM_PLAYER_COUNT
  1169.                 whilenot curPlayerId == 0 {//unally players on the same team
  1170.                     curPlayerId--
  1171.                     //decrease the alliance count between the two players
  1172.                     Players.alliance[playerId][Team.teamPlayers[this][curPlayerId]]--
  1173.                     Players.alliance[Team.teamPlayers[this][curPlayerId]][playerId]--
  1174.                     if Players.alliance[playerId][Team.teamPlayers[this][curPlayerId]] == 0 {//if they have no more ties, unally
  1175.                         curPlayer2 = Player(Team.teamPlayers[this][curPlayerId])
  1176.                         teamAlly(curPlayer1, curPlayer2, false, this, this)
  1177.                     }//if
  1178.                 }//whilenot
  1179.                
  1180.                 #if DO_TEAM_ALLIANCES
  1181.                     //Allied Alliances
  1182.                     curTeamId = Team.alliedAlliances[this]
  1183.                     whilenot curTeamId == 0 {//unally players on allied teams
  1184.                         curTeamId--
  1185.                         curTeam = teamAlliedAlliance[this][curTeamId]
  1186.                         curPlayerId = Team.teamSize[curTeam]
  1187.                         whilenot curPlayerId == 0 {//unally players on allied teams
  1188.                             curPlayerId--
  1189.                             if Team.teamPlayers[curTeam][curPlayerId] != playerId {//make sure players aren't the same
  1190.                                 //if two players are allied then unally them
  1191.                                 Players.alliance[playerId][Team.teamPlayers[curTeam][curPlayerId]]--
  1192.                                 Players.alliance[Team.teamPlayers[curTeam][curPlayerId]][playerId]--
  1193.                                 if Players.alliance[playerId][Team.teamPlayers[curTeam][curPlayerId]] == 0 {//make sure no more ties
  1194.                                     curPlayer2 = Player(Team.teamPlayers[curTeam][curPlayerId])
  1195.                                     if Players.neutral[playerId][Team.teamPlayers[curTeam][curPlayerId]] > 0 {//try to make them neutral
  1196.                                         teamNeutral(curPlayer1, curPlayer2, true)
  1197.                                     }//if
  1198.                                     else {
  1199.                                         teamAlly(curPlayer1, curPlayer2, false, this, this)
  1200.                                     }//else
  1201.                                 }//if
  1202.                             }//if
  1203.                         }//whilenot
  1204.                     }//whilenot
  1205.                    
  1206.                     //Neutral Alliances
  1207.                     curTeamId = Team.neutralAlliances[this]
  1208.                     whilenot curTeamId == 0 {//make players on neutral teams not neutral
  1209.                         curTeamId--
  1210.                         curTeam = teamNeutralAlliance[this][curTeamId]
  1211.                             curPlayerId = Team.teamSize[curTeam]
  1212.                             whilenot curPlayerId == 0 {//make players on neutral teams not neutral
  1213.                                 curPlayerId--
  1214.                                 if Team.teamPlayers[curTeam][curPlayerId] != playerId {//make sure players aren't the same
  1215.                                     Players.neutral[playerId][Team.teamPlayers[curTeam][curPlayerId]]++
  1216.                                     Players.neutral[Team.teamPlayers[curTeam][curPlayerId]][playerId]++
  1217.                                     if Players.alliance[playerId][Team.teamPlayers[curTeam][curPlayerId]] == 0 && Players.neutral[playerId][Team.teamPlayers[curTeam][curPlayerId]] == 0 {//make sure not allied or neutral
  1218.                                         curPlayer2 = Player(Team.teamPlayers[curTeam][curPlayerId])
  1219.                                         teamNeutral(curPlayer1, curPlayer2, false)
  1220.                                     }//if
  1221.                                 }//if
  1222.                             }//whilenot
  1223.                     }//whilenot
  1224.                 #endif
  1225.                
  1226.                 //decrase the size of this team
  1227.                 TEAM_PLAYER_COUNT--
  1228.                 //decrease how many teams the player is in
  1229.                 PLAYER_TEAM_COUNT--
  1230.                
  1231.                
  1232.                 if PLAYER_ID != TEAM_PLAYER_COUNT {//remove player from team and index
  1233.                     Team.teamPlayers[this][PLAYER_ID] = Team.teamPlayers[this][TEAM_PLAYER_COUNT]
  1234.                 }//if
  1235.                 if TEAM_ID != PLAYER_TEAM_COUNT {//remove the team from an indexed array for player and index
  1236.                     Players.indexedTeam[playerId][TEAM_ID] = Players.indexedTeam[playerId][PLAYER_TEAM_COUNT]
  1237.                 }//if
  1238.                 //mark the team flag for player as false for this team
  1239.                 Players.playerTeamCheck[playerId][TEAM_ID] = false
  1240.                
  1241.                 //reset PLAYER_ID and TEAM_ID
  1242.                 PLAYER_ID = 0
  1243.                 TEAM_ID = 0
  1244.             debug endif
  1245.         }//removePlayer
  1246.     }//Team
  1247.    
  1248.     define <TeamManager.staticSetup> = {//static team setup
  1249.         Team TeamManager_curTeam
  1250.         int TeamManager_curPlayerTeam = -1
  1251.         ploop(TeamManager_curPlayer, TeamManager.PLAYER_TYPE, true)
  1252.             if GetPlayerTeam(Get##TeamManager.PLAYER_TYPE##(TeamManager_curPlayer)) != TeamManager_curPlayerTeam {//new team?
  1253.                 TeamManager_curPlayerTeam = GetPlayerTeam(Get##TeamManager.PLAYER_TYPE##(TeamManager_curPlayer))
  1254.                 TeamManager_curTeam = Team.create()
  1255.                 TeamManager_curTeam.teamNumber = TeamManager_curPlayerTeam
  1256.             }//if
  1257.             TeamManager_curTeam.addPlayer(Get##TeamManager.PLAYER_TYPE##Id(TeamManager_curPlayer))
  1258.         endploop(TeamManager_curPlayer)
  1259.     }//staticSetup
  1260.    
  1261.     define <TeamManager.staticSetup>(teamCount) = {//static setup with team count
  1262.         Team TeamManager_curTeam
  1263.         int TeamManager_curPlayerTeam = -1
  1264.         ploop(TeamManager_curPlayer, TeamManager.PLAYER_TYPE, true)
  1265.             if Get##TeamManager.PLAYER_TYPE##Id(TeamManager_curPlayer)/teamCount > curPlayerTeam {//new team?
  1266.                 TeamManager_curPlayerTeam = Get##TeamManager.PLAYER_TYPE##Id(TeamManager_curPlayer)/teamCount
  1267.                 TeamManager_curTeam = Team.create()
  1268.                 TeamManager_curTeam.teamNumber = TeamManager_curPlayerTeam
  1269.             }//if
  1270.             TeamManager_curTeam.addPlayer(Get##TeamManager.PLAYER_TYPE##Id(TeamManager_curPlayer))
  1271.         endploop(TeamManager_curPlayer)
  1272.     }//staticSetup
  1273.    
  1274.     define <TeamManager.dynamicSetup>(teamCount, teamSize) = {//keep the teams as even as possible given a team count
  1275.         Team TeamManager_curTeam
  1276.         int TeamManager_curPlayerTeam = 0
  1277.         int TeamManager_teamCount = 0
  1278.         int TeamManager_teamSize = Get##TeamManager.PLAYER_TYPE##Count/teamCount
  1279.         int TeamManager_unevenTeams = Get##TeamManager.PLAYER_TYPE##Count-(TeamManager_teamSize*teamCount)
  1280.         bool TeamManager_doUneven
  1281.         int curTryBalance = teamCount
  1282.        
  1283.         if TeamManager_unevenTeams > 0 {//try to make uneven teams 0
  1284.             whilenot curTryBalance > 1 && Get##TeamManager.PLAYER_TYPE##Count/curTryBalance <= teamSize {
  1285.                 if I2R(Get##TeamManager.PLAYER_TYPE##Count)/curTryBalance-Get##TeamManager.PLAYER_TYPE##Count/curTryBalance == 0 {
  1286.                     exitwhen true
  1287.                 }//if
  1288.                 curTryBalance--
  1289.             }//whilenot
  1290.             if Get##TeamManager.PLAYER_TYPE##Count/curTryBalance <= teamSize {//can perfectly balance
  1291.                 TeamManager_teamSize = curTryBalance
  1292.                 TeamManager_unevenTeams = 0
  1293.             }//if
  1294.         }//if
  1295.        
  1296.         ploop(TeamManager_curPlayer, TeamManager.PLAYER_TYPE, true)
  1297.             if TeamManager_curPlayerTeam == 0 {//new team?
  1298.                 TeamManager_doUneven = true
  1299.                 TeamManager_curTeam = Team.create()
  1300.                 TeamManager_curTeam.teamNumber = TeamManager_teamCount++
  1301.                 TeamManager_curPlayerTeam = TeamManager_teamSize
  1302.             }//if
  1303.             if !(TeamManager_unevenTeams > 0 && TeamManager_doUneven) {
  1304.                 TeamManager_curPlayerTeam--
  1305.             }//if
  1306.             TeamManager_doUneven = false
  1307.             TeamManager_curTeam.addPlayer(Get##TeamManager.PLAYER_TYPE##Id(TeamManager_curPlayer))
  1308.         endploop(TeamManager_curPlayer)
  1309.     }//dynamicSetup
  1310.    
  1311.     #if DO_PLAYER_DRIVEN_SETUP
  1312.         scope PlayerDrivenSetup {
  1313.             private constant int PLAYER_DRIVEN_MAX_SIZE = TEAM_MAX_SIZE+1
  1314.             private int playerVote[PLAYER_DRIVEN_MAX_SIZE][12] //stores player ids given a vote
  1315.             private int playerVoteCount[PLAYER_DRIVEN_MAX_SIZE] //stores vote counts given a vote
  1316.             private int votePlayer[PLAYER_DRIVEN_MAX_SIZE] //stores a players vote via player id
  1317.            
  1318.             private timer voteTimerLimit = null //should there be a time limit
  1319.             private int curVote
  1320.             private Team curPlayerTeam = 0
  1321.             private int curTeamMaxSize = 0//the current team max size
  1322.            
  1323.             private int playersToProcess //players left, for balancing and voting
  1324.            
  1325.             private bool HasPlayerVoted(int playerId) {
  1326.                 return votePlayer[playerId] > 0
  1327.             }//HasPlayerVoted
  1328.            
  1329.             //! runtextmacro PlayerDrivenInterfaceData()
  1330.             PlayerDrivenInterfaceProperties
  1331.            
  1332.             private void RunVotes() {
  1333.                 if voteTimerLimit != null {
  1334.                     PauseTimer(voteTimerLimit)
  1335.                     DestroyTimer(voteTimerLimit)
  1336.                     voteTimerLimit = null
  1337.                 }//if
  1338.                 if playersToProcess < GetPlayerVoteCount() {
  1339.                     curVote = 12
  1340.                     whilenot curVote == 0 {
  1341.                         curVote--
  1342.                         if votePlayer[curVote] == 0 && IsPlayerActive(curVote) {
  1343.                             playerVote[12][playerVoteCount[12]++] = curVote
  1344.                         }//if
  1345.                     }//whilenot
  1346.                 }//if
  1347.                
  1348.                 curVote = 0
  1349.                 playersToProcess = GetPlayerVoteCount()
  1350.                 whilenot curVote == 12 {
  1351.                     curVote++
  1352.                     whilenot playerVoteCount[curVote] == 0 {
  1353.                         playersToProcess--
  1354.                         playerVoteCount[curVote]--
  1355.                         if IsPlayerActive(playerVote[curVote][playerVoteCount[curVote]]) {
  1356.                             //the current team size is equal to the vote, the team will be too big for the player to want
  1357.                             //if the curTeamMaxSize is 0, then there are no open slots
  1358.                             //if size > remaining players and remaining players - remaining team slots is greater than 0 (meaning remaining teams too small)
  1359.                             //make a new team
  1360.                             if curPlayerTeam.size == curVote || curTeamMaxSize == 0 || (curPlayerTeam.size >= playersToProcess && playersToProcess-curTeamMaxSize > 0) {
  1361.                                 curPlayerTeam = Team.create()
  1362.                                 curTeamMaxSize = curVote
  1363.                             }//if
  1364.                             curTeamMaxSize--
  1365.                             curPlayerTeam.addPlayer(playerVote[curVote][playerVoteCount[curVote]])
  1366.                         }//if
  1367.                     }//whilenot
  1368.                 }//whilenot
  1369.             }//RunVotes
  1370.            
  1371.             private void SetVoteTimeLimit(real timeLimit) {
  1372.                 voteTimerLimit = CreateTimer()
  1373.                 TimerStart(voteTimerLimit, timeLimit, false, function RunVotes)
  1374.             }//SetVoteTimeLimit
  1375.            
  1376.             private void SetPlayerVote(int playerId, int vote) {
  1377.                 playerVote[vote][playerVoteCount[vote]++] = playerId
  1378.                 if ++playersToProcess == GetPlayerVoteCount() {
  1379.                     RunVotes()
  1380.                 }//if
  1381.             }//SetPlayerVote
  1382.            
  1383.             struct TeamManager extends array {
  1384.                 public static void playerSetup() {
  1385.                     //! runtextmacro PlayerDrivenInterfaceCode()
  1386.                 }//Initialization
  1387.             }//TeamManager
  1388.         }//PlayerDrivenSetup
  1389.     #endif
  1390.    
  1391.     //ActiveTeam- count, get
  1392.     //////////////////////////////////////////////////
  1393.     define tloop(processVar, processDeclare) = {
  1394.         #if processDeclare
  1395.             int processVar = ActiveTeam.count
  1396.         #else
  1397.             processVar = ActiveTeam.count
  1398.         #endif
  1399.         loop
  1400.             processVar--
  1401.     }//tloop
  1402.    
  1403.     define endtloop(processVar) = {
  1404.             exitwhen processVar == 0
  1405.         endloop
  1406.     }//endtloop
  1407.    
  1408.     //Team- size, getPlayer
  1409.     //////////////////////////////////////////////////
  1410.     define tploop(processTeam, processVar, processDeclare) = {
  1411.         #if processDeclare
  1412.             int processVar = processTeam.size
  1413.         #else
  1414.             processVar = processTeam.size
  1415.         #endif
  1416.         loop
  1417.             processVar--
  1418.     }//tploop
  1419.    
  1420.     define endtploop(processVar) = {
  1421.             exitwhen processVar == 0
  1422.         endloop
  1423.     }//endtploop
  1424.    
  1425.     //TeamPlayer- teamCount, getTeam
  1426.     //////////////////////////////////////////////////
  1427.     define ptloop(processTeamPlayer, processVar, processDeclare) = {
  1428.         #if processDeclare
  1429.             int var = processTeamPlayer.teamCount
  1430.         #else
  1431.             processVar = processTeamPlayer.teamCount
  1432.         #endif
  1433.         loop
  1434.             processVar--
  1435.     }//ptloop
  1436.    
  1437.     define endptloop(processVar) = {
  1438.             exitwhen processVar == 0
  1439.         endloop
  1440.     }//endptloop
  1441.    
  1442.     //Team- allyCount, getAlly
  1443.     //////////////////////////////////////////////////
  1444.     define taloop(processTeam, processVar, processDeclare) = {
  1445.         #if processDeclare
  1446.             int processVar = processTeam.allyCount
  1447.         #else
  1448.             processVar = processTeam.allyCount
  1449.         #endif
  1450.         loop
  1451.     }//taloop
  1452.    
  1453.     define endtaloop(processVar) = {
  1454.             exitwhen --processVar == 0
  1455.         endloop
  1456.     }//endtaloop
  1457.    
  1458.     //Team- neutralCount, getNeutral
  1459.     //////////////////////////////////////////////////
  1460.     define tnloop(processTeam, processVar, processDeclare) = {
  1461.         #if processDeclare
  1462.             int processVar = processTeam.neutralCount
  1463.         #else
  1464.             processVar = processTeam.neutralCount
  1465.         #endif
  1466.         loop
  1467.     }//tnloop
  1468.    
  1469.     define endtnloop(processVar) = {
  1470.             exitwhen --processVar == 0
  1471.         endloop
  1472.     }//endtnloop
  1473. }//TeamManager
RAW Paste Data
Top