]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/mutators/mutator/gamemode_ca.qc
Merge branch 'martin-t/warns' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / mutator / gamemode_ca.qc
index ebfcd9540282d99f853c94cbb6c0f5d94ca75d04..919df49013dd5f53cc1c5c2f819cf11c2ee38d41 100644 (file)
@@ -6,7 +6,7 @@ bool autocvar_g_ca_spectate_enemies;
 void CA_count_alive_players()
 {
        total_players = redalive = bluealive = yellowalive = pinkalive = 0;
-       FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
+       FOREACH_CLIENT(IS_PLAYER(it), {
                switch(it.team)
                {
                        case NUM_TEAM_1: ++total_players; if(!IS_DEAD(it)) ++redalive; break;
@@ -14,13 +14,13 @@ void CA_count_alive_players()
                        case NUM_TEAM_3: ++total_players; if(!IS_DEAD(it)) ++yellowalive; break;
                        case NUM_TEAM_4: ++total_players; if(!IS_DEAD(it)) ++pinkalive; break;
                }
-       ));
-       FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(
+       });
+       FOREACH_CLIENT(IS_REAL_CLIENT(it), {
                it.redalive_stat = redalive;
                it.bluealive_stat = bluealive;
                it.yellowalive_stat = yellowalive;
                it.pinkalive_stat = pinkalive;
-       ));
+       });
 }
 
 float CA_GetWinnerTeam()
@@ -58,9 +58,11 @@ float CA_CheckWinner()
        {
                Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_ROUND_OVER);
                Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_ROUND_OVER);
+               FOREACH_CLIENT(IS_PLAYER(it), { nades_Clear(it); });
+
                allowed_to_spawn = false;
+               game_stopped = true;
                round_handler_Init(5, autocvar_g_ca_warmup, autocvar_g_ca_round_timelimit);
-               FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(nades_Clear(it)));
                return 1;
        }
 
@@ -82,9 +84,10 @@ float CA_CheckWinner()
        }
 
        allowed_to_spawn = false;
+       game_stopped = true;
        round_handler_Init(5, autocvar_g_ca_warmup, autocvar_g_ca_round_timelimit);
 
-       FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(nades_Clear(it)));
+       FOREACH_CLIENT(IS_PLAYER(it), { nades_Clear(it); });
 
        return 1;
 }
@@ -185,7 +188,7 @@ MUTATOR_HOOKFUNCTION(ca, PutClientInServer)
        if (!allowed_to_spawn && IS_PLAYER(player)) // this is true even when player is trying to join
        {
                TRANSMUTE(Observer, player);
-               if (player.jointime != time && !player.caplayer) // not when connecting
+               if (CS(player).jointime != time && !player.caplayer) // not when connecting
                {
                        player.caplayer = 0.5;
                        Send_Notification(NOTIF_ONE_ONLY, player, MSG_INFO, INFO_CA_JOIN_LATE);
@@ -196,7 +199,7 @@ MUTATOR_HOOKFUNCTION(ca, PutClientInServer)
 MUTATOR_HOOKFUNCTION(ca, reset_map_players)
 {
        FOREACH_CLIENT(true, {
-               it.killcount = 0;
+               CS(it).killcount = 0;
                if (!it.caplayer && IS_BOT_CLIENT(it))
                {
                        it.team = -1;
@@ -209,6 +212,7 @@ MUTATOR_HOOKFUNCTION(ca, reset_map_players)
                        PutClientInServer(it);
                }
        });
+       bot_relinkplayerlist();
        return true;
 }
 
@@ -262,9 +266,15 @@ MUTATOR_HOOKFUNCTION(ca, PlayerDies)
 
        ca_LastPlayerForTeam_Notify(frag_target);
        if (!allowed_to_spawn)
-               frag_target.respawn_flags =  RESPAWN_SILENT;
+       {
+               frag_target.respawn_flags = RESPAWN_SILENT;
+               // prevent unwanted sudden rejoin as spectator and move of spectator camera
+               frag_target.respawn_time = time + 2;
+       }
        if (!warmup_stage)
                eliminatedPlayers.SendFlags |= 1;
+       if(IS_BOT_CLIENT(frag_target))
+               bot_clear(frag_target);
        return true;
 }
 
@@ -318,7 +328,7 @@ MUTATOR_HOOKFUNCTION(ca, SetStartItems)
        start_ammo_fuel    = warmup_start_ammo_fuel    = cvar("g_lms_start_ammo_fuel");
 }
 
-MUTATOR_HOOKFUNCTION(ca, PlayerDamage_Calculate)
+MUTATOR_HOOKFUNCTION(ca, Damage_Calculate)
 {
        entity frag_attacker = M_ARGV(1, entity);
        entity frag_target = M_ARGV(2, entity);
@@ -360,7 +370,7 @@ MUTATOR_HOOKFUNCTION(ca, PlayerDamage_SplitHealthArmor)
        float excess = max(0, frag_damage - damage_take - damage_save);
 
        if (frag_target != frag_attacker && IS_PLAYER(frag_attacker))
-               PlayerTeamScore_Add(frag_attacker, SP_SCORE, ST_SCORE, (frag_damage - excess) * autocvar_g_ca_damage2score_multiplier);
+               GameRules_scoring_add_team(frag_attacker, SCORE, (frag_damage - excess) * autocvar_g_ca_damage2score_multiplier);
 }
 
 MUTATOR_HOOKFUNCTION(ca, PlayerRegen)
@@ -452,6 +462,11 @@ MUTATOR_HOOKFUNCTION(ca, WantWeapon)
        M_ARGV(2, bool) = true; // all weapons
 }
 
+MUTATOR_HOOKFUNCTION(ca, HideTeamNagger)
+{
+       return true; // doesn't work well with the whole spectator as player thing
+}
+
 MUTATOR_HOOKFUNCTION(ca, GetPlayerStatus)
 {
        entity player = M_ARGV(0, entity);