X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fmutators%2Fgamemode_freezetag.qc;h=5280e559bbceab46554144dadbace4d92f41b63e;hb=49e5f5d2c7423c3c4536a57e6740d79d9b8eec94;hp=26e19910ad0f3f571a19f779bec902872b9de8e7;hpb=14f88293289444c9a39357a88c1980c019733eff;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/mutators/gamemode_freezetag.qc b/qcsrc/server/mutators/gamemode_freezetag.qc index 26e19910a..5280e559b 100644 --- a/qcsrc/server/mutators/gamemode_freezetag.qc +++ b/qcsrc/server/mutators/gamemode_freezetag.qc @@ -42,27 +42,30 @@ void freezetag_count_alive_players() #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; } @@ -134,6 +137,34 @@ float freezetag_CheckWinner() 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 @@ -322,6 +353,8 @@ void havocbot_role_ft_freeing() 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; @@ -348,6 +381,7 @@ MUTATOR_HOOKFUNCTION(freezetag_PlayerDies) { freezetag_Add_Score(frag_attacker); freezetag_count_alive_players(); + freezetag_LastPlayerForTeam_Notify(); } else freezetag_Unfreeze(world); // remove ice @@ -359,6 +393,7 @@ MUTATOR_HOOKFUNCTION(freezetag_PlayerDies) return 1; freezetag_Freeze(frag_attacker); + freezetag_LastPlayerForTeam_Notify(); if(frag_attacker == frag_target || frag_attacker == world) {