X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fserver%2Fteamplay.qc;h=262b5e98bae1a6ca4fae3df2d29a0b93f3663cf1;hp=02e4467a1dad6837465576337060fc61f6cb973f;hb=162a91bc68d7b8e58c92cb0af873871129e386a9;hpb=76cb7ad665ac05ce9fbf1fcc28d03e2b8904db8f diff --git a/qcsrc/server/teamplay.qc b/qcsrc/server/teamplay.qc index 02e4467a1..262b5e98b 100644 --- a/qcsrc/server/teamplay.qc +++ b/qcsrc/server/teamplay.qc @@ -16,6 +16,8 @@ float IsTeamBalanceForced() return 0; if(cvar("g_campaign")) return 0; + if(cvar("bot_vs_human") && (c3==-1 && c4==-1)) + return 0; if(!cvar("g_balance_teams_force")) return -1; return 1; @@ -99,6 +101,8 @@ void WriteGameCvars() cvar_set("g_race", ftos(g_race)); cvar_set("g_nexball", ftos(g_nexball)); cvar_set("g_cts", ftos(g_cts)); + cvar_set("g_freezetag", ftos(g_freezetag)); + cvar_set("g_keepaway", ftos(g_keepaway)); } void ReadGameCvars() @@ -111,6 +115,7 @@ void ReadGameCvars() prev = cvar("gamecfg"); for(i = 0; i < 2; ++i) { +//#NO AUTOCVARS START found += (g_dm = (!found && (prev != GAME_DEATHMATCH) && cvar("g_dm"))); found += (g_tdm = (!found && (prev != GAME_TEAM_DEATHMATCH) && cvar("g_tdm"))); found += (g_domination = (!found && (prev != GAME_DOMINATION) && cvar("g_domination"))); @@ -125,6 +130,9 @@ void ReadGameCvars() found += (g_race = (!found && (prev != GAME_RACE) && cvar("g_race"))); found += (g_nexball = (!found && (prev != GAME_NEXBALL) && cvar("g_nexball"))); found += (g_cts = (!found && (prev != GAME_CTS) && cvar("g_cts"))); + found += (g_freezetag = (!found && (prev != GAME_FREEZETAG) && cvar("g_freezetag"))); + found += (g_keepaway = (!found && (prev != GAME_KEEPAWAY) && cvar("g_keepaway"))); +//#NO AUTOCVARS END if(found) break; @@ -315,6 +323,16 @@ void InitGameplayMode() MUTATOR_ADD(gamemode_keyhunt); } + if(g_freezetag) + { + game = GAME_FREEZETAG; + gamemode_name = "Freeze Tag"; + ActivateTeamplay(); + fraglimit_override = cvar("g_freezetag_point_limit"); + leadlimit_override = cvar("g_freezetag_point_leadlimit"); + MUTATOR_ADD(gamemode_freezetag); + } + if(g_assault) { game = GAME_ASSAULT; @@ -371,6 +389,13 @@ void InitGameplayMode() have_team_spawns = -1; // request team spawns } + if(g_keepaway) + { + game = GAME_KEEPAWAY; + gamemode_name = "Keepaway"; + MUTATOR_ADD(gamemode_keepaway); + } + if(teams_matter) entcs_init(); @@ -408,7 +433,7 @@ void InitGameplayMode() race_timelimit = cvar("timelimit"); cvar_set("fraglimit", "0"); cvar_set("leadlimit", "0"); - cvar_set("timelimit", cvar_string("g_race_qualifying_timelimit")); + cvar_set("timelimit", ftos(cvar("g_race_qualifying_timelimit"))); } else g_race_qualifying = 0; @@ -489,11 +514,12 @@ void PrintWelcomeMessage(entity pl) } :normal - modifications = ""; + ret_string = ""; + MUTATOR_CALLHOOK(BuildMutatorsPrettyString); + modifications = ret_string; + if(g_minstagib) modifications = strcat(modifications, ", MinstaGib"); - if(g_nixnex) - modifications = strcat(modifications, ", NixNex"); if(g_weaponarena) { if(g_weaponarena_random) @@ -507,16 +533,10 @@ void PrintWelcomeMessage(entity pl) modifications = strcat(modifications, ", Low gravity"); if(g_cloaked) modifications = strcat(modifications, ", Cloaked"); - if(g_footsteps) - modifications = strcat(modifications, ", Steps"); if(g_grappling_hook) modifications = strcat(modifications, ", Hook"); - if(g_laserguided_missile) - modifications = strcat(modifications, ", LG missiles"); if(g_midair) modifications = strcat(modifications, ", Midair"); - if(g_vampire) - modifications = strcat(modifications, ", Vampire"); if(g_pinata) modifications = strcat(modifications, ", Pinata"); if(g_weapon_stay) @@ -621,7 +641,11 @@ void CheckAllowedTeams (entity for_whom) c1 = c2 = c3 = c4 = -1; cb1 = cb2 = cb3 = cb4 = 0; - if(g_onslaught) + if(cvar("g_campaign") && for_whom && clienttype(for_whom) == CLIENTTYPE_REAL) + { + c1 = 0; // only allow RED team for player joining + } + else if(g_onslaught) { // onslaught is special head = findchain(classname, "onslaught_generator"); @@ -686,7 +710,7 @@ void CheckAllowedTeams (entity for_whom) } // TODO: Balance quantity of bots across > 2 teams when bot_vs_human is set (and remove next line) - if(c3==-1&&c4==-1) + if(c3==-1 && c4==-1) if(cvar("bot_vs_human") && for_whom) { if(cvar("bot_vs_human") > 0) @@ -706,6 +730,16 @@ void CheckAllowedTeams (entity for_whom) c1 = -1; } } + + // if player has a forced team, ONLY allow that one + if(self.team_forced == COLOR_TEAM1 && c1 >= 0) + c2 = c3 = c4 = -1; + else if(self.team_forced == COLOR_TEAM2 && c2 >= 0) + c1 = c3 = c4 = -1; + else if(self.team_forced == COLOR_TEAM3 && c3 >= 0) + c1 = c2 = c4 = -1; + else if(self.team_forced == COLOR_TEAM4 && c4 >= 0) + c1 = c2 = c3 = -1; } float PlayerValue(entity p) @@ -713,6 +747,7 @@ float PlayerValue(entity p) if(IsTeamBalanceForced() == 1) return 1; return 1; + // FIXME: it always returns 1... } // c1...c4 should be set to -1 (not allowed) or 0 (allowed). @@ -791,17 +826,21 @@ float FindSmallestTeam(entity pl, float ignore_pl) if(c4 >= 0) totalteams = totalteams + 1; - if(cvar("bot_vs_human")) + if((cvar("bot_vs_human") || pl.team_forced > 0) && totalteams == 1) totalteams += 1; if(totalteams <= 1) { - if(g_domination) + if(cvar("g_campaign") && pl && clienttype(pl) == CLIENTTYPE_REAL) + return 1; // special case for campaign and player joining + else if(g_domination) error("Too few teams available for domination\n"); else if(g_ctf) error("Too few teams available for ctf\n"); else if(g_keyhunt) error("Too few teams available for key hunt\n"); + else if(g_freezetag) + error("Too few teams available for freeze tag\n"); else error("Too few teams available for team deathmatch\n"); } @@ -843,9 +882,9 @@ float FindSmallestTeam(entity pl, float ignore_pl) { // 1: use team count, if equal prefer own team if(c1 >= 0) RandomSelection_Add(world, 1, string_null, 1, (maxc - c1) + (self.team == COLOR_TEAM1) / 512.0); - if(c2 >= 0) RandomSelection_Add(world, 1, string_null, 1, (maxc - c1) + (self.team == COLOR_TEAM2) / 512.0); - if(c3 >= 0) RandomSelection_Add(world, 1, string_null, 1, (maxc - c1) + (self.team == COLOR_TEAM3) / 512.0); - if(c4 >= 0) RandomSelection_Add(world, 1, string_null, 1, (maxc - c1) + (self.team == COLOR_TEAM4) / 512.0); + if(c2 >= 0) RandomSelection_Add(world, 2, string_null, 1, (maxc - c1) + (self.team == COLOR_TEAM2) / 512.0); + if(c3 >= 0) RandomSelection_Add(world, 3, string_null, 1, (maxc - c1) + (self.team == COLOR_TEAM3) / 512.0); + if(c4 >= 0) RandomSelection_Add(world, 4, string_null, 1, (maxc - c1) + (self.team == COLOR_TEAM4) / 512.0); } else if(balance_type == 3) { @@ -869,6 +908,33 @@ float JoinBestTeam(entity pl, float only_return_best, float forcebestteam) // find out what teams are available CheckAllowedTeams(pl); + // if we want the player in a certain team for campaign, force him there + if(cvar("g_campaign")) + if(clienttype(pl) == CLIENTTYPE_REAL) // only players, not bots + { + switch(cvar("g_campaign_forceteam")) + { + case 1: + SetPlayerColors(pl, COLOR_TEAM1 - 1); + LogTeamchange(pl.playerid, pl.team, 2); + return COLOR_TEAM1; + case 2: + SetPlayerColors(pl, COLOR_TEAM2 - 1); + LogTeamchange(pl.playerid, pl.team, 2); + return COLOR_TEAM2; + case 3: + SetPlayerColors(pl, COLOR_TEAM3 - 1); + LogTeamchange(pl.playerid, pl.team, 2); + return COLOR_TEAM3; + case 4: + SetPlayerColors(pl, COLOR_TEAM4 - 1); + LogTeamchange(pl.playerid, pl.team, 2); + return COLOR_TEAM4; + default: + break; + } + } + // if we don't care what team he ends up on, put him on whatever team he entered as. // if he's not on a valid team, then let other code put him on the smallest team if(!forcebestteam) @@ -901,7 +967,7 @@ float JoinBestTeam(entity pl, float only_return_best, float forcebestteam) smallest = FindSmallestTeam(pl, TRUE); - if(!only_return_best) + if(!only_return_best && !pl.bot_forced_team) { TeamchangeFrags(self); if(smallest == 1)