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;
}
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
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;
return 1;
}
+MUTATOR_HOOKFUNCTION(ca_ClientDisconnect)
+{
+ if(self.caplayer == 1)
+ ca_LastPlayerForTeam_Notify();
+ return 1;
+}
+
MUTATOR_HOOKFUNCTION(ca_ForbidPlayerScore_Clear)
{
return 1;
MUTATOR_HOOKFUNCTION(ca_MakePlayerObserver)
{
+ if(self.caplayer == 1)
+ ca_LastPlayerForTeam_Notify();
if(self.killindicator_teamchange == -2)
self.caplayer = 0;
if(self.caplayer)
return FALSE;
}
+MUTATOR_HOOKFUNCTION(ca_PlayerRegen)
+{
+ // no regeneration in CA
+ return TRUE;
+}
+
void ca_Initialize()
{
allowed_to_spawn = TRUE;
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);
MUTATOR_HOOK(PlayerDamage_Calculate, ca_PlayerDamage, CBC_ORDER_ANY);
MUTATOR_HOOK(FilterItem, ca_FilterItem, CBC_ORDER_ANY);
MUTATOR_HOOK(PlayerDamage_SplitHealthArmor, ca_PlayerDamage_SplitHealthArmor, CBC_ORDER_ANY);
+ MUTATOR_HOOK(PlayerRegen, ca_PlayerRegen, CBC_ORDER_ANY);
MUTATOR_ONADD
{