]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/scores_rules.qc
Merge branch 'terencehill/cl_forceplayercolors_3' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / scores_rules.qc
1 #include "scores_rules.qh"
2
3 #include <common/weapons/_all.qh>
4 #include <common/stats.qh>
5 #include <server/miscfunctions.qh>
6 #include "client.qh"
7 #include "scores.qh"
8 #include <common/gamemodes/rules.qh>
9 #include "teamplay.qh"
10
11 int ScoreRules_teams;
12
13 int NumTeams(int teams)
14 {
15         return boolean(teams & BIT(0)) + boolean(teams & BIT(1)) + boolean(teams & BIT(2)) + boolean(teams & BIT(3));
16 }
17
18 int AvailableTeams()
19 {
20         return NumTeams(ScoreRules_teams);
21 }
22
23 // NOTE: ST_constants may not be >= MAX_TEAMSCORE
24 // scores that should be in all modes:
25 void ScoreRules_basics(int teams, float sprio, float stprio, float score_enabled)
26 {
27         FOREACH(Scores, true, {
28                 ScoreInfo_SetLabel_PlayerScore(it, "", 0);
29     });
30         for(int i = 0; i < MAX_TEAMSCORE; ++i)
31                 ScoreInfo_SetLabel_TeamScore(i, "", 0);
32
33         ScoreRules_teams = teams;
34
35         if(score_enabled)
36                 ScoreInfo_SetLabel_TeamScore  (ST_SCORE,        "score",     stprio);
37
38         if (!INDEPENDENT_PLAYERS)
39                 ScoreInfo_SetLabel_PlayerScore(SP_KILLS,        "kills",     0);
40
41         ScoreInfo_SetLabel_PlayerScore(SP_DEATHS,       "deaths",    SFL_LOWER_IS_BETTER);
42
43         if (!INDEPENDENT_PLAYERS)
44         {
45                 ScoreInfo_SetLabel_PlayerScore(SP_SUICIDES,     "suicides",  SFL_LOWER_IS_BETTER);
46                 ScoreInfo_SetLabel_PlayerScore(SP_TEAMKILLS,     "teamkills", SFL_LOWER_IS_BETTER);
47         }
48
49         if(score_enabled)
50                 ScoreInfo_SetLabel_PlayerScore(SP_SCORE,        "score",     sprio);
51
52         ScoreInfo_SetLabel_PlayerScore(SP_DMG, "dmg", 0);
53         ScoreInfo_SetLabel_PlayerScore(SP_DMGTAKEN, "dmgtaken", SFL_LOWER_IS_BETTER);
54         ScoreInfo_SetLabel_PlayerScore(SP_ELO, "elo", 0);
55
56         if(STAT(SHOWFPS))
57                 ScoreInfo_SetLabel_PlayerScore(SP_FPS, "fps", 0);
58 }
59 void ScoreRules_basics_end()
60 {
61         ScoreInfo_Init(ScoreRules_teams);
62 }
63 void ScoreRules_generic()
64 {
65     int teams = 0;
66         if (teamplay)
67         {
68                 entity balance = TeamBalance_CheckAllowedTeams(NULL);
69                 teams = TeamBalance_GetAllowedTeams(balance);
70                 TeamBalance_Destroy(balance);
71         }
72         GameRules_scoring(teams, SFL_SORT_PRIO_PRIMARY, SFL_SORT_PRIO_PRIMARY, {});
73 }