]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qc
Merge branch 'master' into z411/bai-server
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / gamemodes / gamemode / freezetag / sv_freezetag.qc
index ea00927abd908ae3856092f51b8d81d4ab80301b..fee45755df403349017ef28d1163f86059885f72 100644 (file)
@@ -106,18 +106,36 @@ int freezetag_getWinnerTeam()
 void nades_Clear(entity);
 void nades_GiveBonus(entity player, float score);
 
+entity freezetag_LastPlayer(float tm)
+{
+       entity last_pl = NULL;
+       FOREACH_CLIENT(IS_PLAYER(it) && it.team == tm, {
+               if (STAT(FROZEN, it) != FROZEN_NORMAL && GetResource(it, RES_HEALTH) >= 1)
+               {
+                       if (!last_pl)
+                               last_pl = it;
+                       else
+                               return NULL;
+               }
+       });
+       return last_pl;
+}
+
 bool freezetag_CheckWinner()
 {
        if(round_handler_GetEndTime() > 0 && round_handler_GetEndTime() - time <= 0)
        {
                Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_ROUND_OVER);
                Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_ROUND_OVER);
+               Send_Notification(NOTIF_ALL, NULL, MSG_ANNCE, ANNCE_ROUND_OVER);
+               
                FOREACH_CLIENT(IS_PLAYER(it), {
                        it.freezetag_frozen_timeout = 0;
                        it.freezetag_revive_time = 0;
                        nades_Clear(it);
                });
-               game_stopped = true;
+               if(autocvar_g_freezetag_round_stop)
+                       game_stopped = true;
                round_handler_Init(5, autocvar_g_freezetag_warmup, autocvar_g_freezetag_round_timelimit);
                return true;
        }
@@ -130,14 +148,21 @@ bool freezetag_CheckWinner()
        int winner_team = freezetag_getWinnerTeam();
        if(winner_team > 0)
        {
-               Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, APP_TEAM_NUM(winner_team, CENTER_ROUND_TEAM_WIN));
-               Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(winner_team, INFO_ROUND_TEAM_WIN));
+               entity last_pl = freezetag_LastPlayer(winner_team);
+               if(last_pl) {
+                       Give_Medal(last_pl, DEFENSE);
+               }
+       
+               Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, APP_TEAM_NUM(winner_team, CENTER_ROUND_TEAM_SCORES));
+               Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(winner_team, INFO_ROUND_TEAM_SCORES));
+               if(fragsleft > 1) Send_Notification(NOTIF_ALL, NULL, MSG_ANNCE, APP_TEAM_NUM(winner_team, ANNCE_ROUND_TEAM_WIN));
                TeamScore_AddToTeam(winner_team, ST_FT_ROUNDS, +1);
        }
        else if(winner_team == -1)
        {
                Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_ROUND_TIED);
                Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_ROUND_TIED);
+               Send_Notification(NOTIF_ALL, NULL, MSG_ANNCE, ANNCE_ROUND_TIED);
        }
 
        FOREACH_CLIENT(IS_PLAYER(it), {
@@ -146,7 +171,8 @@ bool freezetag_CheckWinner()
                nades_Clear(it);
        });
 
-       game_stopped = true;
+       if(autocvar_g_freezetag_round_stop)
+               game_stopped = true;
        round_handler_Init(5, autocvar_g_freezetag_warmup, autocvar_g_freezetag_round_timelimit);
        return true;
 }
@@ -172,8 +198,10 @@ void freezetag_LastPlayerForTeam_Notify(entity this)
        if(round_handler_IsRoundStarted())
        {
                entity pl = freezetag_LastPlayerForTeam(this);
-               if(pl)
+               if(pl) {
                        Send_Notification(NOTIF_ONE, pl, MSG_CENTER, CENTER_ALONE);
+                       Send_Notification(NOTIF_ONE, pl, MSG_ANNCE, ANNCE_ALONE);
+               }
        }
 }
 
@@ -440,9 +468,14 @@ MUTATOR_HOOKFUNCTION(ft, reset_map_players)
 {
        FOREACH_CLIENT(IS_PLAYER(it), {
                CS(it).killcount = 0;
-               it.freezetag_revive_time = 0;
-               it.freezetag_frozen_timeout = -1;
-               PutClientInServer(it);
+               
+               if(autocvar_g_freezetag_round_respawn) {
+                       it.freezetag_frozen_timeout = -1;
+                       PutClientInServer(it);
+               } else {
+                       ResetPlayerResources(it);
+               }
+               
                it.freezetag_frozen_timeout = 0;
        });
        freezetag_count_alive_players();
@@ -459,6 +492,12 @@ MUTATOR_HOOKFUNCTION(ft, Unfreeze)
 {
        entity targ = M_ARGV(0, entity);
        targ.freezetag_frozen_time = 0;
+       
+       if(autocvar_g_freezetag_revive_respawn) {
+               targ.freezetag_frozen_timeout = -1;
+               PutClientInServer(targ);
+       }
+       
        targ.freezetag_frozen_timeout = 0;
 }
 
@@ -590,6 +629,7 @@ MUTATOR_HOOKFUNCTION(ft, PlayerPreThink, CBC_ORDER_FIRST)
                        Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_FREEZETAG_REVIVED, first.netname);
                        Send_Notification(NOTIF_ONE, first, MSG_CENTER, CENTER_FREEZETAG_REVIVE, player.netname);
                        Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_FREEZETAG_REVIVED, player.netname, first.netname);
+                       Give_Medal(first, ASSIST);
                }
 
                for(entity it = reviving_players_first; it; it = it.chain)