#define FREEZETAG_ALIVE_TEAMS() ((redalive > 0) + (bluealive > 0) + (yellowalive > 0) + (pinkalive > 0))
#define FREEZETAG_ALIVE_TEAMS_OK() (FREEZETAG_ALIVE_TEAMS() == freezetag_teams)
-float prev_total_players;
+float prev_missing_teams_mask;
float freezetag_CheckTeams()
{
if(FREEZETAG_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(freezetag_teams >= 3)
- if(!yellowalive) p3 = NUM_TEAM_3;
- if(freezetag_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(freezetag_teams >= 3) missing_teams_mask += (!yellowalive) * 4;
+ if(freezetag_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;
}
return 1;
}
+entity freezetag_LastPlayerForTeam()
+{
+ entity pl, last_pl = world;
+ FOR_EACH_PLAYER(pl)
+ {
+ if(pl.health >= 1)
+ if(!pl.freezetag_frozen)
+ if(pl != self)
+ if(pl.team == self.team)
+ if(!last_pl)
+ last_pl = pl;
+ else
+ return world;
+ }
+ return last_pl;
+}
+
+void freezetag_LastPlayerForTeam_Notify()
+{
+ if(round_handler_IsActive())
+ if(round_handler_IsRoundStarted())
+ {
+ entity pl = freezetag_LastPlayerForTeam();
+ if(pl)
+ Send_Notification(NOTIF_ONE, pl, MSG_CENTER, CENTER_ALONE);
+ }
+}
+
// this is needed to allow the player to turn his view around (fixangle can't
// be used to freeze his view, as that also changes the angles), while not
// turning that ice object with the player
MUTATOR_HOOKFUNCTION(freezetag_RemovePlayer)
{
self.health = 0; // neccessary to update correctly alive stats
+ if(!self.freezetag_frozen)
+ freezetag_LastPlayerForTeam_Notify();
freezetag_Unfreeze(world);
freezetag_count_alive_players();
return 1;
{
freezetag_Add_Score(frag_attacker);
freezetag_count_alive_players();
+ freezetag_LastPlayerForTeam_Notify();
}
else
freezetag_Unfreeze(world); // remove ice
return 1;
freezetag_Freeze(frag_attacker);
+ freezetag_LastPlayerForTeam_Notify();
if(frag_attacker == frag_target || frag_attacker == world)
{