]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/mutators/gamemode_freezetag.qc
Reapply some changes that got lost in the previous merge commit and update code to...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / gamemode_freezetag.qc
index 3853d49f27d96114bb181d9d19f4230d9487f112..5cfd1b9f5d70145bab03ead3c3c97e0edff6eb25 100644 (file)
@@ -11,22 +11,22 @@ void freezetag_count_alive_players()
        entity e;
        total_players = redalive = bluealive = yellowalive = pinkalive = 0;
        FOR_EACH_PLAYER(e) {
-               if(e.team == COLOR_TEAM1 && e.health >= 1)
+               if(e.team == NUM_TEAM_1 && e.health >= 1)
                {
                        ++total_players;
                        if (!e.freezetag_frozen) ++redalive;
                }
-               else if(e.team == COLOR_TEAM2 && e.health >= 1)
+               else if(e.team == NUM_TEAM_2 && e.health >= 1)
                {
                        ++total_players;
                        if (!e.freezetag_frozen) ++bluealive;
                }
-               else if(e.team == COLOR_TEAM3 && e.health >= 1)
+               else if(e.team == NUM_TEAM_3 && e.health >= 1)
                {
                        ++total_players;
                        if (!e.freezetag_frozen) ++yellowalive;
                }
-               else if(e.team == COLOR_TEAM4 && e.health >= 1)
+               else if(e.team == NUM_TEAM_4 && e.health >= 1)
                {
                        ++total_players;
                        if (!e.freezetag_frozen) ++pinkalive;
@@ -45,30 +45,22 @@ void freezetag_count_alive_players()
 float prev_total_players;
 float freezetag_CheckTeams()
 {
-       entity e;
        if(FREEZETAG_ALIVE_TEAMS_OK())
        {
-               if(prev_total_players != -1)
-               {
-                       FOR_EACH_REALCLIENT(e)
-                               Send_CSQC_Centerprint_Generic_Expire(e, CPID_WAITING_PLAYERS);
-               }
+               Kill_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_MISSING_TEAMS);
                prev_total_players = -1;
                return 1;
        }
        if(prev_total_players != total_players)
        {
-               string teams_missing = "";
-               if(!redalive)   teams_missing = strcat(teams_missing, ColoredTeamName(COLOR_TEAM1), ", ");
-               if(!bluealive)  teams_missing = strcat(teams_missing, ColoredTeamName(COLOR_TEAM2), ", ");
+               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)        teams_missing = strcat(teams_missing, ColoredTeamName(COLOR_TEAM3), ", ");
-               if(freezetag_teams == 4)
-               if(!pinkalive)  teams_missing = strcat(teams_missing, ColoredTeamName(COLOR_TEAM4), ", ");
-               teams_missing = substring(teams_missing, 0, strlen(teams_missing)-2);
-
-               FOR_EACH_REALCLIENT(e)
-                       Send_CSQC_Centerprint_Generic(e, CPID_WAITING_PLAYERS, strcat("Waiting for players to join...\n\nNeed active players for: ", teams_missing), -1, 0);
+               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;
        }
        return 0;
@@ -78,21 +70,21 @@ float freezetag_getWinnerTeam()
 {
        float winner_team = 0;
        if(redalive >= 1)
-               winner_team = COLOR_TEAM1;
+               winner_team = NUM_TEAM_1;
        if(bluealive >= 1)
        {
                if(winner_team) return 0;
-               winner_team = COLOR_TEAM2;
+               winner_team = NUM_TEAM_2;
        }
        if(yellowalive >= 1)
        {
                if(winner_team) return 0;
-               winner_team = COLOR_TEAM3;
+               winner_team = NUM_TEAM_3;
        }
        if(pinkalive >= 1)
        {
                if(winner_team) return 0;
-               winner_team = COLOR_TEAM4;
+               winner_team = NUM_TEAM_4;
        }
        if(winner_team)
                return winner_team;
@@ -104,9 +96,8 @@ float freezetag_CheckWinner()
        entity e;
        if(round_handler_GetTimeLeft() <= 0)
        {
-               FOR_EACH_REALCLIENT(e)
-                       centerprint(e, "Round over, there's no winner");
-               bprint("Round over, there's no winner.\n");
+               Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_ROUND_OVER);
+               Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_ROUND_OVER);
                FOR_EACH_PLAYER(e)
                        e.freezetag_frozen_timeout = 0;
                round_handler_Init(5, autocvar_g_freezetag_warmup, autocvar_g_freezetag_round_timelimit);
@@ -117,19 +108,17 @@ float freezetag_CheckWinner()
                return 0;
 
        float winner_team;
-       string teamname;
        winner_team = freezetag_getWinnerTeam();
        if(winner_team > 0)
        {
-               Send_Notification(NOTIF_ALL, world, MSG_CENTER, APP_TEAM_NUM_4(winner.team, CENTER_FREEZETAG_ROUND_WIN_));
-               Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_NUM_4(winner.team, INFO_FREEZETAG_ROUND_WIN_));
+               Send_Notification(NOTIF_ALL, world, MSG_CENTER, APP_TEAM_NUM_4(winner_team, CENTER_ROUND_TEAM_WIN_));
+               Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_NUM_4(winner_team, INFO_ROUND_TEAM_WIN_));
                TeamScore_AddToTeam(winner_team, ST_SCORE, +1);
        }
        else if(winner_team == -1)
        {
-               FOR_EACH_REALCLIENT(e)
-                       centerprint(e, "^5Round tied! All teams were frozen.");
-               bprint("^5Round tied! All teams were frozen.\n");
+               Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_ROUND_TIED);
+               Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_ROUND_TIED);
        }
 
        FOR_EACH_PLAYER(e)
@@ -186,7 +175,7 @@ void freezetag_Freeze(entity attacker)
        ice.nextthink = time;
        ice.frame = floor(random() * 21); // ice model has 20 different looking frames
        ice.alpha = ICE_MAX_ALPHA;
-       ice.colormod = TeamColor(self.team);
+       ice.colormod = Team_ColorRGB(self.team);
        ice.glowmod = ice.colormod;
        setmodel(ice, "models/ice/ice.md3");
 
@@ -487,9 +476,8 @@ MUTATOR_HOOKFUNCTION(freezetag_PlayerPreThink)
 
                        if(n == -1)
                        {
-                               string s = ftos(autocvar_g_freezetag_frozen_maxtime);
-                               centerprint(self, strcat("^5You were automatically revived after ", s, " seconds^5.\n"));
-                               bprint("^7", self.netname, "^5 were automatically revived after ", s, " seconds^5.\n");
+                               Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_FREEZETAG_AUTO_REVIVED, autocvar_g_freezetag_frozen_maxtime);
+                               Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_FREEZETAG_AUTO_REVIVED, self.netname, autocvar_g_freezetag_frozen_maxtime);
                                return 1;
                        }
 
@@ -505,7 +493,7 @@ MUTATOR_HOOKFUNCTION(freezetag_PlayerPreThink)
 
                        Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_FREEZETAG_REVIVED, o.netname);
                        Send_Notification(NOTIF_ONE, o, MSG_CENTER, CENTER_FREEZETAG_REVIVE, self.netname);
-                       Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_FREEZETAG_REVIVE, self.netname, o.netname);
+                       Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_FREEZETAG_REVIVED, self.netname, o.netname);
                }
 
                FOR_EACH_PLAYER(other)