allowed_to_spawn = FALSE;
}
-float prev_total_players;
+float prev_missing_teams_mask;
float CA_CheckTeams()
{
allowed_to_spawn = TRUE;
CA_count_alive_players();
if(CA_ALIVE_TEAMS_OK())
{
- if(prev_total_players > 0)
+ if(prev_missing_teams_mask > 0)
Kill_Notification(NOTIF_ALL, world, MSG_CENTER_CPID, CPID_MISSING_TEAMS);
- prev_total_players = -1;
+ prev_missing_teams_mask = -1;
return 1;
}
- if(prev_total_players != total_players)
+ if(total_players == 0)
{
- float p1 = 0, p2 = 0, p3 = 0, p4 = 0;
- if(!redalive) p1 = NUM_TEAM_1;
- if(!bluealive) p2 = NUM_TEAM_2;
- if(ca_teams >= 3)
- if(!yellowalive) p3 = NUM_TEAM_3;
- if(ca_teams >= 4)
- if(!pinkalive) p4 = NUM_TEAM_4;
- Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_MISSING_TEAMS, p1, p2, p3, p4);
- prev_total_players = total_players;
+ if(prev_missing_teams_mask > 0)
+ Kill_Notification(NOTIF_ALL, world, MSG_CENTER_CPID, CPID_MISSING_TEAMS);
+ prev_missing_teams_mask = -1;
+ return 0;
+ }
+ float missing_teams_mask = (!redalive) + (!bluealive) * 2;
+ if(ca_teams >= 3) missing_teams_mask += (!yellowalive) * 4;
+ if(ca_teams >= 4) missing_teams_mask += (!pinkalive) * 8;
+ if(prev_missing_teams_mask != missing_teams_mask)
+ {
+ Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_MISSING_TEAMS, missing_teams_mask);
+ prev_missing_teams_mask = missing_teams_mask;
}
return 0;
}
+float ca_isEliminated(entity e)
+{
+ if(e.caplayer == 1 && (e.deadflag != DEAD_NO || e.frags == FRAGS_LMS_LOSER))
+ return TRUE;
+ if(e.caplayer == 0.5)
+ return TRUE;
+ return FALSE;
+}
+
MUTATOR_HOOKFUNCTION(ca_PlayerSpawn)
{
self.caplayer = 1;
+ if(!warmup_stage)
+ eliminatedPlayers.SendFlags |= 1;
return 1;
}
MUTATOR_HOOKFUNCTION(ca_PutClientInServer)
{
if(!allowed_to_spawn)
+ if(IS_PLAYER(self)) // this is true even when player is trying to join
{
self.classname = "observer";
if(self.jointime != time) //not when connecting
{
self.caplayer = 0.5;
if(IS_REAL_CLIENT(self))
- sprint(self, "You will join the game in the next round.\n");
+ Send_Notification(NOTIF_ONE_ONLY, self, MSG_INFO, INFO_CA_JOIN_LATE);
}
}
return 1;
FOR_EACH_CLIENT(self)
{
self.killcount = 0;
+ if(!self.caplayer && IS_BOT_CLIENT(self))
+ {
+ self.team = -1;
+ self.caplayer = 1;
+ }
if(self.caplayer)
{
self.classname = "player";
return 0;
}
+entity ca_LastPlayerForTeam()
+{
+ entity pl, last_pl = world;
+ FOR_EACH_PLAYER(pl)
+ {
+ if(pl.health >= 1)
+ if(pl != self)
+ if(pl.team == self.team)
+ if(!last_pl)
+ last_pl = pl;
+ else
+ return world;
+ }
+ return last_pl;
+}
+
+void ca_LastPlayerForTeam_Notify()
+{
+ if(round_handler_IsActive())
+ if(round_handler_IsRoundStarted())
+ {
+ entity pl = ca_LastPlayerForTeam();
+ if(pl)
+ Send_Notification(NOTIF_ONE, pl, MSG_CENTER, CENTER_ALONE);
+ }
+}
+
MUTATOR_HOOKFUNCTION(ca_PlayerDies)
{
+ ca_LastPlayerForTeam_Notify();
if(!allowed_to_spawn)
self.respawn_flags = RESPAWN_SILENT;
+ if(!warmup_stage)
+ eliminatedPlayers.SendFlags |= 1;
+ return 1;
+}
+
+MUTATOR_HOOKFUNCTION(ca_ClientDisconnect)
+{
+ if(self.caplayer == 1)
+ ca_LastPlayerForTeam_Notify();
return 1;
}
MUTATOR_HOOKFUNCTION(ca_MakePlayerObserver)
{
+ if(self.caplayer == 1)
+ ca_LastPlayerForTeam_Notify();
if(self.killindicator_teamchange == -2)
self.caplayer = 0;
if(self.caplayer)
self.frags = FRAGS_LMS_LOSER;
+ if(!warmup_stage)
+ eliminatedPlayers.SendFlags |= 1;
return 1;
}
addstat(STAT_BLUEALIVE, AS_INT, bluealive_stat);
addstat(STAT_YELLOWALIVE, AS_INT, yellowalive_stat);
addstat(STAT_PINKALIVE, AS_INT, pinkalive_stat);
+
+ EliminatedPlayers_Init(ca_isEliminated);
}
MUTATOR_DEFINITION(gamemode_ca)
MUTATOR_HOOK(reset_map_players, ca_reset_map_players, CBC_ORDER_ANY);
MUTATOR_HOOK(GetTeamCount, ca_GetTeamCount, CBC_ORDER_EXCLUSIVE);
MUTATOR_HOOK(PlayerDies, ca_PlayerDies, CBC_ORDER_ANY);
+ MUTATOR_HOOK(ClientDisconnect, ca_ClientDisconnect, CBC_ORDER_ANY);
MUTATOR_HOOK(ForbidPlayerScore_Clear, ca_ForbidPlayerScore_Clear, CBC_ORDER_ANY);
MUTATOR_HOOK(ForbidThrowCurrentWeapon, ca_ForbidThrowCurrentWeapon, CBC_ORDER_ANY);
MUTATOR_HOOK(GiveFragsForKill, ca_GiveFragsForKill, CBC_ORDER_FIRST);