- if(self.tag_playernum == -1)
- return 0; // nothing to remove
-
- float i, j;
- /*for (i = self.tag_playernum; i < tag_players_count; ++i)
- {
- tag_players[i] = tag_players[i+1];
- tag_players[i].tag_playernum = tag_players[i].tag_playernum - 1;
- }
- */
-
- tag_players[self.tag_playernum] = world;
- tag_players_count = tag_players_count - 1;
-
- // if other players have our color, randomize their color
- entity e, random_player;
- float temp_tag_players_count;
- temp_tag_players_count = tag_players_count;
-
- if(!next_round) // ... but ONLY if next_round isn't set. We don't care about the colors if the round has already ended
- for(i = 0; i < temp_tag_players_count; ++i) // check other players...
- {
- e = tag_players[i];
- if(e == world) // empty slot, skip to next
- {
- if(temp_tag_players_count < TAGCOLOR_MAX - 1) // just in case
- ++temp_tag_players_count;
- continue;
- }
-
- if(e.tagcolor == self.tagcolor_original) // and see if they have our original tag color
- {
- for(j = 0; j < 100; ++j) // try 100 times to find a color that isn't the same as our color. If this fails we are either damn unlucky, or there are really only players left of our color
- {
- random_player = tag_players[floor(random() * (TAGCOLOR_MAX - 1))];
-
- if(random_player == world) // hit empty slot, try again
- continue;
-
- if(random_player.tagcolor != self.tagcolor_original) // break if we found another color
- {
- break;
- }
- }
- e.tagcolor = random_player.tagcolor;
- setcolor(e, 16 * e.tagcolor + e.tagcolor);
- }
- }
-
- self.tag_playernum = -1;
-
- if(tag_players_count > 1 && time > warmup)
- tag_CheckWinner();