X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fteamplay.qc;h=c5f8988b94387f795231865cf18464cc8fb38c66;hb=5bad3c7afd764ecf5957604854c83cc5ee5a6f30;hp=fa02ea24b5e6c51e1dcbeef568ce8f9d41303d8c;hpb=14800edad1a4c4e2e08ec6a2257184ea2f396d23;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/teamplay.qc b/qcsrc/server/teamplay.qc index fa02ea24b..c5f8988b9 100644 --- a/qcsrc/server/teamplay.qc +++ b/qcsrc/server/teamplay.qc @@ -12,7 +12,7 @@ float IsTeamBalanceForced() { if(intermission_running) return 0; // no rebalancing whatsoever please - if(!teams_matter) + if(!teamplay) return 0; if(autocvar_g_campaign) return 0; @@ -149,7 +149,8 @@ void ReadGameCvars() g_tdm = 1; } - teams_matter = 0; + teamplay = 0; + serverflags &~= SERVERFLAG_TEAMPLAY; } void default_delayedinit() @@ -161,7 +162,7 @@ void default_delayedinit() void ActivateTeamplay() { serverflags |= SERVERFLAG_TEAMPLAY; - teams_matter = 1; + teamplay = 1; } void InitGameplayMode() @@ -172,8 +173,6 @@ void InitGameplayMode() VoteReset(); - teams_matter = 0; - // make sure only ONE type is selected ReadGameCvars(); WriteGameCvars(); @@ -239,7 +238,6 @@ void InitGameplayMode() game = GAME_CTF; gamemode_name = "Capture the Flag"; ActivateTeamplay(); - g_ctf_win_mode = autocvar_g_ctf_win_mode; g_ctf_ignore_frags = autocvar_g_ctf_ignore_frags; if(g_ctf_win_mode == 2) { @@ -384,7 +382,7 @@ void InitGameplayMode() MUTATOR_ADD(gamemode_keepaway); } - if(teams_matter) + if(teamplay) entcs_init(); // save it (for the next startup) @@ -452,56 +450,10 @@ string GetClientVersionMessage() { return versionmsg; } - -void PrintWelcomeMessage(entity pl) +string getwelcomemessage(void) { string s, modifications, motd; - if(self.cvar_scr_centertime == 0) return; - - if(autocvar_g_campaign) - { - if(self.classname == "player" && !self.BUTTON_INFO) - return; - } - else - { - if((time - self.jointime) > autocvar_welcome_message_time && !self.BUTTON_INFO) - return; - } - - if( !(timeoutStatus >= 1) ) { //really print the WelcomeMessage to the player every frame when timeout-seconds are shown or the game is restarted, to make sure that the shown number is accurate - if(self.welcomemessage_time > time) return; - self.welcomemessage_time = time + max(0.5, self.cvar_scr_centertime * 0.6); - } - - if(autocvar_g_campaign) - { - centerprint(pl, campaign_message); - return; - } - -//TODO GreEn`mArine: make the timeout-messages clientside as well (just like the ready restart countdown)! - if(!self.BUTTON_INFO) - { - // TODO get rid of this too - local string specString; - specString = NEWLINES; - //if(time < game_starttime) //also show the countdown when being a spectator - // specString = strcat(specString, "\n\n^1Game starts in ", ftos(ceil(game_starttime - time)), " seconds^7"); - //else - if (timeoutStatus != 0) - specString = strcat(specString, "\n\n", getTimeoutText(1)); - else - { - if(self.classname == "player") - return; - goto normal; - } - return centerprint_atprio(self, CENTERPRIO_SPAM, specString); - } - -:normal ret_string = ""; MUTATOR_CALLHOOK(BuildMutatorsPrettyString); modifications = ret_string; @@ -519,18 +471,18 @@ void PrintWelcomeMessage(entity pl) modifications = strcat(modifications, ", No start weapons"); if(autocvar_sv_gravity < 800) modifications = strcat(modifications, ", Low gravity"); - if(g_cloaked) + if(g_cloaked && !g_cts) modifications = strcat(modifications, ", Cloaked"); if(g_grappling_hook) modifications = strcat(modifications, ", Hook"); if(g_midair) modifications = strcat(modifications, ", Midair"); if(g_pinata) - modifications = strcat(modifications, ", Pinata"); - if(g_weapon_stay) + modifications = strcat(modifications, ", Piñata"); + if(g_weapon_stay && !g_cts) modifications = strcat(modifications, ", Weapons stay"); if(g_bloodloss > 0) - modifications = strcat(modifications, ", Bloodloss"); + modifications = strcat(modifications, ", Blood loss"); if(g_jetpack) modifications = strcat(modifications, ", Jet pack"); modifications = substring(modifications, 2, strlen(modifications) - 2); @@ -538,15 +490,12 @@ void PrintWelcomeMessage(entity pl) local string versionmessage; versionmessage = GetClientVersionMessage(); - s = strcat(s, NEWLINES, "This is Xonotic ", autocvar_g_xonoticversion, "\n", versionmessage); + s = strcat("This is Xonotic ", autocvar_g_xonoticversion, "\n", versionmessage); s = strcat(s, "^8\n\nmatch type is ^1", gamemode_name, "^8\n"); if(modifications != "") s = strcat(s, "^8\nactive modifications: ^3", modifications, "^8\n"); - if(timeoutStatus != 0) - s = strcat(s, "\n\n", getTimeoutText(1)); - if (g_grappling_hook) s = strcat(s, "\n\n^3grappling hook^8 is enabled, press 'e' to use it\n"); @@ -568,12 +517,9 @@ void PrintWelcomeMessage(entity pl) if (motd != "") { s = strcat(s, "\n\n^8MOTD: ^7", strreplace("\\n", "\n", motd)); } - s = strcat(s, "\n"); - - centerprint(pl, s); + return s; } - void SetPlayerColors(entity pl, float _color) { /*string s; @@ -588,7 +534,7 @@ void SetPlayerColors(entity pl, float _color) shirt = _color & 0xF0; - if(teams_matter) { + if(teamplay) { setcolor(pl, 16*pants + pants); } else { setcolor(pl, shirt + pants); @@ -629,11 +575,7 @@ void CheckAllowedTeams (entity for_whom) c1 = c2 = c3 = c4 = -1; cb1 = cb2 = cb3 = cb4 = 0; - if(autocvar_g_campaign && for_whom && clienttype(for_whom) == CLIENTTYPE_REAL) - { - c1 = 0; // only allow RED team for player joining - } - else if(g_onslaught) + if(g_onslaught) { // onslaught is special head = findchain(classname, "onslaught_generator"); @@ -749,8 +691,15 @@ void GetTeamCounts(entity ignore) // FIXME: also find and memorize the lowest-scoring bot on each team (in case players must be shuffled around) // also remember the lowest-scoring player - FOR_EACH_PLAYER(head) + FOR_EACH_CLIENT(head) { + float t; + if(head.classname == "player") + t = head.team; + else if(head.team_forced > 0) + t = head.team_forced; // reserve the spot + else + continue; if(head != ignore)// && head.netname != "") { value = PlayerValue(head); @@ -758,7 +707,7 @@ void GetTeamCounts(entity ignore) bvalue = value; else bvalue = 0; - if(head.team == COLOR_TEAM1) + if(t == COLOR_TEAM1) { if(c1 >= 0) { @@ -766,7 +715,7 @@ void GetTeamCounts(entity ignore) cb1 = cb1 + bvalue; } } - if(head.team == COLOR_TEAM2) + if(t == COLOR_TEAM2) { if(c2 >= 0) { @@ -774,7 +723,7 @@ void GetTeamCounts(entity ignore) cb2 = cb2 + bvalue; } } - if(head.team == COLOR_TEAM3) + if(t == COLOR_TEAM3) { if(c3 >= 0) { @@ -782,7 +731,7 @@ void GetTeamCounts(entity ignore) cb3 = cb3 + bvalue; } } - if(head.team == COLOR_TEAM4) + if(t == COLOR_TEAM4) { if(c4 >= 0) { @@ -792,6 +741,18 @@ void GetTeamCounts(entity ignore) } } } + + // if the player who has a forced team has not joined yet, reserve the spot + if(autocvar_g_campaign) + { + switch(autocvar_g_campaign_forceteam) + { + case 1: if(c1 == cb1) ++c1; break; + case 2: if(c2 == cb2) ++c2; break; + case 3: if(c3 == cb3) ++c3; break; + case 4: if(c4 == cb4) ++c4; break; + } + } } // returns # of smallest team (1, 2, 3, 4) @@ -842,13 +803,6 @@ float FindSmallestTeam(entity pl, float ignore_pl) // c1...c4 now have counts of each team // figure out which is smallest, giving priority to the team the player is already on as a tie-breaker - if(autocvar_g_campaign) - { - entity e; - FOR_EACH_REALCLIENT(e) - if(e.team != COLOR_TEAM1) // player is forced to the red team in campaign - ++c1; // player will join the red team, join bots accordingly - } // 2 gives priority to what team you're already on, 1 goes in order // 2 doesn't seem to work though... balance_type = 1; @@ -897,39 +851,12 @@ float JoinBestTeam(entity pl, float only_return_best, float forcebestteam) float smallest, selectedteam; // don't join a team if we're not playing a team game - if(!teams_matter) + if(!teamplay) return 0; // find out what teams are available CheckAllowedTeams(pl); - // if we want the player in a certain team for campaign, force him there - if(autocvar_g_campaign) - if(clienttype(pl) == CLIENTTYPE_REAL) // only players, not bots - { - switch(autocvar_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) @@ -1001,7 +928,7 @@ void SV_ChangeTeam(float _color) float scolor, dcolor, steam, dteam, dbotcount, scount, dcount; // in normal deathmatch we can just apply the color and we're done - if(!teams_matter) { + if(!teamplay) { SetPlayerColors(self, _color); return; }