]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/gamemodes/gamemode/invasion/sv_invasion.qc
Remove teamplay support from invasion and fix mage only ever teleporting once
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / gamemodes / gamemode / invasion / sv_invasion.qc
index 5039eb10059c606202d40f14de8e693c14a24290..5b61762784070e68fa395bb2b94be3e43a82572a 100644 (file)
@@ -4,8 +4,6 @@
 #include <common/monsters/sv_spawner.qh>
 #include <common/monsters/sv_monsters.qh>
 
-#include <server/teamplay.qh>
-
 IntrusiveList g_invasion_roundends;
 IntrusiveList g_invasion_waves;
 IntrusiveList g_invasion_spawns;
@@ -97,7 +95,7 @@ int WinningCondition_Invasion()
                        if(it.winning)
                        {
                                bprint("Invasion: round completed.\n");
-                               // winners already set (TODO: teamplay support)
+                               // winners already set
 
                                status = WINNING_YES;
                                break;
@@ -232,32 +230,6 @@ void invasion_SpawnChosenMonster(Monster mon)
                monster.target2 = spawn_point.target2;
        }
 
-       if(teamplay)
-       {
-               if(spawn_point && spawn_point.team && inv_monsters_perteam[spawn_point.team] > 0)
-                       monster.team = spawn_point.team;
-               else
-               {
-                       RandomSelection_Init();
-                       if(inv_monsters_perteam[NUM_TEAM_1] > 0) RandomSelection_AddFloat(NUM_TEAM_1, 1, 1);
-                       if(inv_monsters_perteam[NUM_TEAM_2] > 0) RandomSelection_AddFloat(NUM_TEAM_2, 1, 1);
-                       if(invasion_teams >= 3) if(inv_monsters_perteam[NUM_TEAM_3] > 0) { RandomSelection_AddFloat(NUM_TEAM_3, 1, 1); }
-                       if(invasion_teams >= 4) if(inv_monsters_perteam[NUM_TEAM_4] > 0) { RandomSelection_AddFloat(NUM_TEAM_4, 1, 1); }
-
-                       monster.team = RandomSelection_chosen_float;
-               }
-
-               monster_setupcolors(monster);
-
-               if(monster.sprite)
-               {
-                       WaypointSprite_UpdateTeamRadar(monster.sprite, RADARICON_DANGER, ((monster.team) ? Team_ColorRGB(monster.team) : '1 0 0'));
-
-                       monster.sprite.team = 0;
-                       monster.sprite.SendFlags |= 1;
-               }
-       }
-
        if(monster.monster_attack)
                IL_REMOVE(g_monster_targets, monster);
        monster.monster_attack = false; // it's the player's job to kill all the monsters
@@ -289,22 +261,13 @@ bool Invasion_CheckWinner()
                return 1;
        }
 
-       float total_alive_monsters = 0, supermonster_count = 0, red_alive = 0, blue_alive = 0, yellow_alive = 0, pink_alive = 0;
+       float total_alive_monsters = 0, supermonster_count = 0;
 
        IL_EACH(g_monsters, GetResourceAmount(it, RESOURCE_HEALTH) > 0,
        {
                if((get_monsterinfo(it.monsterid)).spawnflags & MON_FLAG_SUPERMONSTER)
                        ++supermonster_count;
                ++total_alive_monsters;
-
-               if(teamplay)
-               switch(it.team)
-               {
-                       case NUM_TEAM_1: ++red_alive; break;
-                       case NUM_TEAM_2: ++blue_alive; break;
-                       case NUM_TEAM_3: ++yellow_alive; break;
-                       case NUM_TEAM_4: ++pink_alive; break;
-               }
        });
 
        if((total_alive_monsters + inv_numkilled) < inv_maxspawned && inv_maxcurrent < inv_maxspawned)
@@ -321,42 +284,20 @@ bool Invasion_CheckWinner()
        if(inv_numspawned < 1)
                return 0; // nothing has spawned yet
 
-       if(teamplay)
-       {
-               if(((red_alive > 0) + (blue_alive > 0) + (yellow_alive > 0) + (pink_alive > 0)) > 1)
-                       return 0;
-       }
-       else if(inv_numkilled < inv_maxspawned)
+       if(inv_numkilled < inv_maxspawned)
                return 0;
 
        entity winner = NULL;
-       float winning_score = 0, winner_team = 0;
+       float winning_score = 0;
 
-
-       if(teamplay)
-       {
-               if(red_alive > 0) { winner_team = NUM_TEAM_1; }
-               if(blue_alive > 0)
-               if(winner_team) { winner_team = 0; }
-               else { winner_team = NUM_TEAM_2; }
-               if(yellow_alive > 0)
-               if(winner_team) { winner_team = 0; }
-               else { winner_team = NUM_TEAM_3; }
-               if(pink_alive > 0)
-               if(winner_team) { winner_team = 0; }
-               else { winner_team = NUM_TEAM_4; }
-       }
-       else
-       {
-               FOREACH_CLIENT(IS_PLAYER(it), {
-                       float cs = GameRules_scoring_add(it, KILLS, 0);
-                       if(cs > winning_score)
-                       {
-                               winning_score = cs;
-                               winner = it;
-                       }
-               });
-       }
+       FOREACH_CLIENT(IS_PLAYER(it), {
+               float cs = GameRules_scoring_add(it, KILLS, 0);
+               if(cs > winning_score)
+               {
+                       winning_score = cs;
+                       winner = it;
+               }
+       });
 
        IL_EACH(g_monsters, true,
        {
@@ -364,15 +305,7 @@ bool Invasion_CheckWinner()
        });
        IL_CLEAR(g_monsters);
 
-       if(teamplay)
-       {
-               if(winner_team)
-               {
-                       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));
-               }
-       }
-       else if(winner)
+       if(winner)
        {
                Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_ROUND_PLAYER_WIN, winner.netname);
                Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_ROUND_PLAYER_WIN, winner.netname);
@@ -406,15 +339,6 @@ void Invasion_RoundStart()
        inv_numkilled = 0;
 
        inv_maxspawned = rint(max(autocvar_g_invasion_monster_count, autocvar_g_invasion_monster_count * (inv_roundcnt * 0.5)));
-
-       if(teamplay)
-       {
-               DistributeEvenly_Init(inv_maxspawned, invasion_teams);
-               inv_monsters_perteam[NUM_TEAM_1] = DistributeEvenly_Get(1);
-               inv_monsters_perteam[NUM_TEAM_2] = DistributeEvenly_Get(1);
-               if(invasion_teams >= 3) inv_monsters_perteam[NUM_TEAM_3] = DistributeEvenly_Get(1);
-               if(invasion_teams >= 4) inv_monsters_perteam[NUM_TEAM_4] = DistributeEvenly_Get(1);
-       }
 }
 
 MUTATOR_HOOKFUNCTION(inv, MonsterDies)
@@ -429,16 +353,13 @@ MUTATOR_HOOKFUNCTION(inv, MonsterDies)
                        inv_numkilled += 1;
                        inv_maxcurrent -= 1;
                }
-               if(teamplay) { inv_monsters_perteam[frag_target.team] -= 1; }
 
                if(IS_PLAYER(frag_attacker))
-               if(SAME_TEAM(frag_attacker, frag_target)) // in non-teamplay modes, same team = same player, so this works
-                       GameRules_scoring_add(frag_attacker, KILLS, -1);
-               else
                {
-                       GameRules_scoring_add(frag_attacker, KILLS, +1);
-                       if(teamplay)
-                               TeamScore_AddToTeam(frag_attacker.team, ST_INV_KILLS, +1);
+                       if(SAME_TEAM(frag_attacker, frag_target))
+                               GameRules_scoring_add(frag_attacker, KILLS, -1);
+                       else
+                               GameRules_scoring_add(frag_attacker, KILLS, +1);
                }
        }
 }
@@ -549,44 +470,28 @@ MUTATOR_HOOKFUNCTION(inv, CheckRules_World)
        return true;
 }
 
-MUTATOR_HOOKFUNCTION(inv, TeamBalance_CheckAllowedTeams, CBC_ORDER_EXCLUSIVE)
-{
-       M_ARGV(0, float) = invasion_teams;
-       return true;
-}
-
 MUTATOR_HOOKFUNCTION(inv, AllowMobButcher)
 {
        M_ARGV(0, string) = "This command does not work during an invasion!";
        return true;
 }
 
-void invasion_ScoreRules(int inv_teams)
+void invasion_ScoreRules()
 {
        GameRules_score_enabled(false);
-       GameRules_scoring(inv_teams, 0, 0, {
-           if (inv_teams) {
-            field_team(ST_INV_KILLS, "frags", SFL_SORT_PRIO_PRIMARY);
-           }
-           field(SP_KILLS, "frags", ((inv_teams) ? SFL_SORT_PRIO_SECONDARY : SFL_SORT_PRIO_PRIMARY));
+       GameRules_scoring(0, 0, 0, {
+           field(SP_KILLS, "frags", SFL_SORT_PRIO_PRIMARY);
        });
 }
 
-void invasion_DelayedInit(entity this) // Do this check with a delay so we can wait for teams to be set up.
+void invasion_DelayedInit(entity this)
 {
        if(autocvar_g_invasion_type == INV_TYPE_HUNT || autocvar_g_invasion_type == INV_TYPE_STAGE)
                cvar_set("fraglimit", "0");
 
-       if(autocvar_g_invasion_teams)
-       {
-               invasion_teams = BITS(bound(2, autocvar_g_invasion_teams, 4));
-       }
-       else
-               invasion_teams = 0;
-
        independent_players = 1; // to disable extra useless scores
 
-       invasion_ScoreRules(invasion_teams);
+       invasion_ScoreRules();
 
        independent_players = 0;