Merge remote-tracking branch 'origin/divVerent/allow-override-item-model'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / scores_rules.qc
1 float c1, c2, c3, c4;
2 void CheckAllowedTeams (entity for_whom);
3
4 // NOTE: SP_ constants may not be >= MAX_SCORE; ST_constants may not be >= MAX_TEAMSCORE
5 // scores that should be in all modes:
6 float ScoreRules_teams;
7 void ScoreRules_basics(float teams, float sprio, float stprio, float score_enabled)
8 {
9         float i;
10         for(i = 0; i < MAX_SCORE; ++i)
11                 ScoreInfo_SetLabel_PlayerScore(i, "", 0);
12         for(i = 0; i < MAX_TEAMSCORE; ++i)
13                 ScoreInfo_SetLabel_TeamScore(i, "", 0);
14
15         ScoreRules_teams = teams;
16
17         if(score_enabled)
18                 ScoreInfo_SetLabel_TeamScore  (ST_SCORE,        "score",     stprio);
19
20         if not(INDEPENDENT_PLAYERS)
21                 ScoreInfo_SetLabel_PlayerScore(SP_KILLS,        "kills",     0);
22
23         ScoreInfo_SetLabel_PlayerScore(SP_DEATHS,       "deaths",    SFL_LOWER_IS_BETTER);
24
25         if not(INDEPENDENT_PLAYERS)
26                 ScoreInfo_SetLabel_PlayerScore(SP_SUICIDES,     "suicides",  SFL_LOWER_IS_BETTER);
27
28         if(score_enabled)
29                 ScoreInfo_SetLabel_PlayerScore(SP_SCORE,        "score",     sprio);
30 }
31 void ScoreRules_basics_end()
32 {
33         ScoreInfo_Init(ScoreRules_teams);
34 }
35 void ScoreRules_generic()
36 {
37         if(teamplay)
38         {
39                 CheckAllowedTeams(world);
40                 ScoreRules_basics(((c4>=0) ? 4 : (c3>=0) ? 3 : 2), SFL_SORT_PRIO_PRIMARY, SFL_SORT_PRIO_PRIMARY, TRUE);
41         }
42         else
43                 ScoreRules_basics(0, SFL_SORT_PRIO_PRIMARY, SFL_SORT_PRIO_PRIMARY, TRUE);
44         ScoreRules_basics_end();
45 }
46
47 // g_ctf
48 #define ST_CTF_CAPS 1
49 #define SP_CTF_CAPS 4
50 #define SP_CTF_PICKUPS 5
51 #define SP_CTF_DROPS 6
52 #define SP_CTF_FCKILLS 7
53 #define SP_CTF_RETURNS 8
54 void ScoreRules_ctf()
55 {
56         CheckAllowedTeams(world);
57         ScoreRules_basics(2 + (c3>=0), SFL_SORT_PRIO_PRIMARY, 0, TRUE); // NOTE this assumes that the rogue team is team 3
58         ScoreInfo_SetLabel_TeamScore  (ST_CTF_CAPS,     "caps",      SFL_SORT_PRIO_PRIMARY);
59         ScoreInfo_SetLabel_PlayerScore(SP_CTF_CAPS,     "caps",      SFL_SORT_PRIO_SECONDARY);
60         ScoreInfo_SetLabel_PlayerScore(SP_CTF_PICKUPS,  "pickups",   0);
61         ScoreInfo_SetLabel_PlayerScore(SP_CTF_FCKILLS,  "fckills",   0);
62         ScoreInfo_SetLabel_PlayerScore(SP_CTF_RETURNS,  "returns",   0);
63         ScoreInfo_SetLabel_PlayerScore(SP_CTF_DROPS,    "drops",     SFL_LOWER_IS_BETTER);
64         ScoreRules_basics_end();
65 }
66
67 // g_domination
68 #define ST_DOM_TICKS 1
69 #define SP_DOM_TICKS 4
70 #define SP_DOM_TAKES 5
71 void ScoreRules_dom()
72 {
73         float sp_domticks, sp_score;
74         sp_score = sp_domticks = 0;
75         if(autocvar_g_domination_disable_frags)
76                 sp_domticks = SFL_SORT_PRIO_PRIMARY;
77         else
78                 sp_score = SFL_SORT_PRIO_PRIMARY;
79         CheckAllowedTeams(world);
80         ScoreRules_basics(((c4>=0) ? 4 : (c3>=0) ? 3 : 2), sp_score, sp_score, TRUE);
81         ScoreInfo_SetLabel_TeamScore  (ST_DOM_TICKS,    "ticks",     sp_domticks);
82         ScoreInfo_SetLabel_PlayerScore(SP_DOM_TICKS,    "ticks",     sp_domticks);
83         ScoreInfo_SetLabel_PlayerScore(SP_DOM_TAKES,    "takes",     0);
84         ScoreRules_basics_end();
85 }
86
87 // LMS stuff
88 #define SP_LMS_LIVES 4
89 #define SP_LMS_RANK 5
90 void ScoreRules_lms()
91 {
92         ScoreRules_basics(0, 0, 0, FALSE);
93         ScoreInfo_SetLabel_PlayerScore(SP_LMS_LIVES,    "lives",     SFL_SORT_PRIO_SECONDARY);
94         ScoreInfo_SetLabel_PlayerScore(SP_LMS_RANK,     "rank",      SFL_LOWER_IS_BETTER | SFL_RANK | SFL_SORT_PRIO_PRIMARY | SFL_ALLOW_HIDE);
95         ScoreRules_basics_end();
96 }
97
98 // Key hunt stuff
99 #define ST_KH_CAPS 1
100 #define SP_KH_CAPS 4
101 #define SP_KH_PUSHES 5
102 #define SP_KH_DESTROYS 6
103 #define SP_KH_PICKUPS 7
104 #define SP_KH_KCKILLS 8
105 #define SP_KH_LOSSES 9
106 void ScoreRules_kh(float teams)
107 {
108         ScoreRules_basics(teams, SFL_SORT_PRIO_PRIMARY, SFL_SORT_PRIO_PRIMARY, TRUE);
109         ScoreInfo_SetLabel_TeamScore  (ST_KH_CAPS,      "caps",      SFL_SORT_PRIO_SECONDARY);
110         ScoreInfo_SetLabel_PlayerScore(SP_KH_CAPS,      "caps",      SFL_SORT_PRIO_SECONDARY);
111         ScoreInfo_SetLabel_PlayerScore(SP_KH_PUSHES,    "pushes",    0);
112         ScoreInfo_SetLabel_PlayerScore(SP_KH_DESTROYS,  "destroyed", SFL_LOWER_IS_BETTER);
113         ScoreInfo_SetLabel_PlayerScore(SP_KH_PICKUPS,   "pickups",   0);
114         ScoreInfo_SetLabel_PlayerScore(SP_KH_KCKILLS,   "kckills",   0);
115         ScoreInfo_SetLabel_PlayerScore(SP_KH_LOSSES,    "losses",    SFL_LOWER_IS_BETTER);
116         ScoreRules_basics_end();
117 }
118
119 // Race stuff
120 #define ST_RACE_LAPS 1
121 #define SP_RACE_LAPS 4
122 #define SP_RACE_FASTEST 5
123 #define SP_RACE_TIME 5
124 //#define SP_RACE_RANK 6
125 void ScoreRules_race()
126 {
127         ScoreRules_basics(race_teams, 0, 0, FALSE);
128         if(race_teams)
129         {
130                 ScoreInfo_SetLabel_TeamScore(  ST_RACE_LAPS,    "laps",      SFL_SORT_PRIO_PRIMARY);
131                 ScoreInfo_SetLabel_PlayerScore(SP_RACE_LAPS,    "laps",      SFL_SORT_PRIO_PRIMARY);
132                 ScoreInfo_SetLabel_PlayerScore(SP_RACE_TIME,    "time",      SFL_SORT_PRIO_SECONDARY | SFL_LOWER_IS_BETTER | SFL_TIME);
133                 //ScoreInfo_SetLabel_PlayerScore(SP_RACE_RANK,    "rank",      SFL_LOWER_IS_BETTER | SFL_RANK | SFL_ALLOW_HIDE);
134         }
135         else if(g_race_qualifying)
136         {
137                 ScoreInfo_SetLabel_PlayerScore(SP_RACE_FASTEST, "fastest",   SFL_SORT_PRIO_PRIMARY | SFL_LOWER_IS_BETTER | SFL_TIME);
138         }
139         else
140         {
141                 //ScoreInfo_SetLabel_TeamScore(  ST_RACE_LAPS,    "laps",      0);
142                 ScoreInfo_SetLabel_PlayerScore(SP_RACE_LAPS,    "laps",      SFL_SORT_PRIO_PRIMARY);
143                 ScoreInfo_SetLabel_PlayerScore(SP_RACE_TIME,    "time",      SFL_SORT_PRIO_SECONDARY | SFL_LOWER_IS_BETTER | SFL_TIME);
144         }
145         ScoreRules_basics_end();
146 }
147
148 // Assault stuff
149 #define ST_ASSAULT_OBJECTIVES 1
150 #define SP_ASSAULT_OBJECTIVES 4
151 void ScoreRules_assault()
152 {
153         ScoreRules_basics(2, SFL_SORT_PRIO_SECONDARY, SFL_SORT_PRIO_SECONDARY, TRUE);
154         ScoreInfo_SetLabel_TeamScore(  ST_ASSAULT_OBJECTIVES,    "objectives",      SFL_SORT_PRIO_PRIMARY);
155         ScoreInfo_SetLabel_PlayerScore(SP_ASSAULT_OBJECTIVES,    "objectives",      SFL_SORT_PRIO_PRIMARY);
156         ScoreRules_basics_end();
157 }
158
159 // Nexball stuff
160 #define ST_NEXBALL_GOALS 1
161 #define SP_NEXBALL_GOALS 4
162 #define SP_NEXBALL_FAULTS 5
163 void ScoreRules_nexball(float teams)
164 {
165         ScoreRules_basics(teams, 0, 0, TRUE);
166         ScoreInfo_SetLabel_TeamScore(   ST_NEXBALL_GOALS,  "goals", SFL_SORT_PRIO_PRIMARY);
167         ScoreInfo_SetLabel_PlayerScore( SP_NEXBALL_GOALS,  "goals", SFL_SORT_PRIO_PRIMARY);
168         ScoreInfo_SetLabel_PlayerScore(SP_NEXBALL_FAULTS, "faults", SFL_SORT_PRIO_SECONDARY | SFL_LOWER_IS_BETTER);
169         ScoreRules_basics_end();
170 }
171
172 // Keep Away stuff
173 #define SP_KEEPAWAY_PICKUPS 4
174 #define SP_KEEPAWAY_CARRIERKILLS 5
175 #define SP_KEEPAWAY_BCTIME 6
176 void ScoreRules_keepaway()
177 {
178         ScoreRules_basics(0, SFL_SORT_PRIO_PRIMARY, 0, TRUE); // SFL_SORT_PRIO_PRIMARY
179         ScoreInfo_SetLabel_PlayerScore(SP_KEEPAWAY_PICKUPS,                     "pickups",              0);
180         ScoreInfo_SetLabel_PlayerScore(SP_KEEPAWAY_CARRIERKILLS,        "bckills",              0);
181         ScoreInfo_SetLabel_PlayerScore(SP_KEEPAWAY_BCTIME,                      "bctime",                       SFL_SORT_PRIO_SECONDARY);
182         ScoreRules_basics_end();
183 }
184
185 // FreezeTag stuff
186 #define SP_FREEZETAG_REVIVALS 4
187 void ScoreRules_freezetag()
188 {
189         CheckAllowedTeams(world);
190         ScoreRules_basics(((c4>=0) ? 4 : (c3>=0) ? 3 : 2), SFL_SORT_PRIO_PRIMARY, SFL_SORT_PRIO_PRIMARY, TRUE); // SFL_SORT_PRIO_PRIMARY
191         ScoreInfo_SetLabel_PlayerScore(SP_FREEZETAG_REVIVALS,           "revivals",             0);
192         ScoreRules_basics_end();
193 }