]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/scores_rules.qc
Merge branch 'morphed/hpitems' of ssh://git.xonotic.org/xonotic-data.pk3dir into...
[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(teams_matter)
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         float sp_score, sp_caps;
57         sp_score = sp_caps = 0;
58         switch(g_ctf_win_mode)
59         {
60                 case 0: // caps only
61                         sp_caps = SFL_SORT_PRIO_PRIMARY;
62                         break;
63                 case 1: // caps, then score
64                         sp_caps = SFL_SORT_PRIO_PRIMARY;
65                         sp_score = SFL_SORT_PRIO_SECONDARY;
66                         break;
67                 case 2: // score only
68                 default:
69                         sp_caps = SFL_SORT_PRIO_SECONDARY; // looks better ;)
70                         sp_score = SFL_SORT_PRIO_PRIMARY;
71                         break;
72         }
73
74         CheckAllowedTeams(world);
75         ScoreRules_basics(2 + (c3>=0), SFL_SORT_PRIO_PRIMARY, sp_score, TRUE); // NOTE this assumes that the rogue team is team 3
76         ScoreInfo_SetLabel_TeamScore  (ST_CTF_CAPS,     "caps",      sp_caps);
77         ScoreInfo_SetLabel_PlayerScore(SP_CTF_CAPS,     "caps",      SFL_SORT_PRIO_SECONDARY);
78         ScoreInfo_SetLabel_PlayerScore(SP_CTF_PICKUPS,  "pickups",   0);
79         ScoreInfo_SetLabel_PlayerScore(SP_CTF_FCKILLS,  "fckills",   0);
80         ScoreInfo_SetLabel_PlayerScore(SP_CTF_RETURNS,  "returns",   0);
81         ScoreInfo_SetLabel_PlayerScore(SP_CTF_DROPS,    "drops",     SFL_LOWER_IS_BETTER);
82         ScoreRules_basics_end();
83 }
84
85 // g_domination
86 #define ST_DOM_TICKS 1
87 #define SP_DOM_TICKS 4
88 #define SP_DOM_TAKES 5
89 void ScoreRules_dom()
90 {
91         float sp_domticks, sp_score;
92         sp_score = sp_domticks = 0;
93         if(autocvar_g_domination_disable_frags)
94                 sp_domticks = SFL_SORT_PRIO_PRIMARY;
95         else
96                 sp_score = SFL_SORT_PRIO_PRIMARY;
97         CheckAllowedTeams(world);
98         ScoreRules_basics(((c4>=0) ? 4 : (c3>=0) ? 3 : 2), sp_score, sp_score, TRUE);
99         ScoreInfo_SetLabel_TeamScore  (ST_DOM_TICKS,    "ticks",     sp_domticks);
100         ScoreInfo_SetLabel_PlayerScore(SP_DOM_TICKS,    "ticks",     sp_domticks);
101         ScoreInfo_SetLabel_PlayerScore(SP_DOM_TAKES,    "takes",     0);
102         ScoreRules_basics_end();
103 }
104
105 // LMS stuff
106 #define SP_LMS_LIVES 4
107 #define SP_LMS_RANK 5
108 void ScoreRules_lms()
109 {
110         ScoreRules_basics(0, 0, 0, FALSE);
111         ScoreInfo_SetLabel_PlayerScore(SP_LMS_LIVES,    "lives",     SFL_SORT_PRIO_SECONDARY);
112         ScoreInfo_SetLabel_PlayerScore(SP_LMS_RANK,     "rank",      SFL_LOWER_IS_BETTER | SFL_RANK | SFL_SORT_PRIO_PRIMARY | SFL_ALLOW_HIDE);
113         ScoreRules_basics_end();
114 }
115
116 // Key hunt stuff
117 #define ST_KH_CAPS 1
118 #define SP_KH_CAPS 4
119 #define SP_KH_PUSHES 5
120 #define SP_KH_DESTROYS 6
121 #define SP_KH_PICKUPS 7
122 #define SP_KH_KCKILLS 8
123 #define SP_KH_LOSSES 9
124 void ScoreRules_kh(float teams)
125 {
126         ScoreRules_basics(teams, SFL_SORT_PRIO_PRIMARY, SFL_SORT_PRIO_PRIMARY, TRUE);
127         ScoreInfo_SetLabel_TeamScore  (ST_KH_CAPS,      "caps",      SFL_SORT_PRIO_SECONDARY);
128         ScoreInfo_SetLabel_PlayerScore(SP_KH_CAPS,      "caps",      SFL_SORT_PRIO_SECONDARY);
129         ScoreInfo_SetLabel_PlayerScore(SP_KH_PUSHES,    "pushes",    0);
130         ScoreInfo_SetLabel_PlayerScore(SP_KH_DESTROYS,  "destroyed", SFL_LOWER_IS_BETTER);
131         ScoreInfo_SetLabel_PlayerScore(SP_KH_PICKUPS,   "pickups",   0);
132         ScoreInfo_SetLabel_PlayerScore(SP_KH_KCKILLS,   "kckills",   0);
133         ScoreInfo_SetLabel_PlayerScore(SP_KH_LOSSES,    "losses",    SFL_LOWER_IS_BETTER);
134         ScoreRules_basics_end();
135 }
136
137 // Race stuff
138 #define ST_RACE_LAPS 1
139 #define SP_RACE_LAPS 4
140 #define SP_RACE_FASTEST 5
141 #define SP_RACE_TIME 5
142 //#define SP_RACE_RANK 6
143 void ScoreRules_race()
144 {
145         ScoreRules_basics(race_teams, 0, 0, FALSE);
146         if(race_teams)
147         {
148                 ScoreInfo_SetLabel_TeamScore(  ST_RACE_LAPS,    "laps",      SFL_SORT_PRIO_PRIMARY);
149                 ScoreInfo_SetLabel_PlayerScore(SP_RACE_LAPS,    "laps",      SFL_SORT_PRIO_PRIMARY);
150                 ScoreInfo_SetLabel_PlayerScore(SP_RACE_TIME,    "time",      SFL_SORT_PRIO_SECONDARY | SFL_LOWER_IS_BETTER | SFL_TIME);
151                 //ScoreInfo_SetLabel_PlayerScore(SP_RACE_RANK,    "rank",      SFL_LOWER_IS_BETTER | SFL_RANK | SFL_ALLOW_HIDE);
152         }
153         else if(g_race_qualifying)
154         {
155                 ScoreInfo_SetLabel_PlayerScore(SP_RACE_FASTEST, "fastest",   SFL_SORT_PRIO_PRIMARY | SFL_LOWER_IS_BETTER | SFL_TIME);
156         }
157         else
158         {
159                 //ScoreInfo_SetLabel_TeamScore(  ST_RACE_LAPS,    "laps",      0);
160                 ScoreInfo_SetLabel_PlayerScore(SP_RACE_LAPS,    "laps",      SFL_SORT_PRIO_PRIMARY);
161                 ScoreInfo_SetLabel_PlayerScore(SP_RACE_TIME,    "time",      SFL_SORT_PRIO_SECONDARY | SFL_LOWER_IS_BETTER | SFL_TIME);
162         }
163         ScoreRules_basics_end();
164 }
165
166 // Assault stuff
167 #define ST_ASSAULT_OBJECTIVES 1
168 #define SP_ASSAULT_OBJECTIVES 4
169 void ScoreRules_assault()
170 {
171         ScoreRules_basics(2, SFL_SORT_PRIO_SECONDARY, SFL_SORT_PRIO_SECONDARY, TRUE);
172         ScoreInfo_SetLabel_TeamScore(  ST_ASSAULT_OBJECTIVES,    "objectives",      SFL_SORT_PRIO_PRIMARY);
173         ScoreInfo_SetLabel_PlayerScore(SP_ASSAULT_OBJECTIVES,    "objectives",      SFL_SORT_PRIO_PRIMARY);
174         ScoreRules_basics_end();
175 }
176
177 // Nexball stuff
178 #define ST_NEXBALL_GOALS 1
179 #define SP_NEXBALL_GOALS 4
180 #define SP_NEXBALL_FAULTS 5
181 void ScoreRules_nexball(float teams)
182 {
183         ScoreRules_basics(teams, 0, 0, TRUE);
184         ScoreInfo_SetLabel_TeamScore(   ST_NEXBALL_GOALS,  "goals", SFL_SORT_PRIO_PRIMARY);
185         ScoreInfo_SetLabel_PlayerScore( SP_NEXBALL_GOALS,  "goals", SFL_SORT_PRIO_PRIMARY);
186         ScoreInfo_SetLabel_PlayerScore(SP_NEXBALL_FAULTS, "faults", SFL_SORT_PRIO_SECONDARY | SFL_LOWER_IS_BETTER);
187         ScoreRules_basics_end();
188 }
189
190 // Keep Away stuff
191 #define SP_KEEPAWAY_PICKUPS 4
192 #define SP_KEEPAWAY_CARRIERKILLS 5
193 #define SP_KEEPAWAY_BCTIME 6
194 void ScoreRules_keepaway()
195 {
196         ScoreRules_basics(0, SFL_SORT_PRIO_PRIMARY, 0, TRUE); // SFL_SORT_PRIO_PRIMARY
197         ScoreInfo_SetLabel_PlayerScore(SP_KEEPAWAY_PICKUPS,                     "pickups",              0);
198         ScoreInfo_SetLabel_PlayerScore(SP_KEEPAWAY_CARRIERKILLS,        "bckills",              0);
199         ScoreInfo_SetLabel_PlayerScore(SP_KEEPAWAY_BCTIME,                      "bctime",                       SFL_SORT_PRIO_SECONDARY);
200         ScoreRules_basics_end();
201 }
202
203 // FreezeTag stuff
204 #define SP_FREEZETAG_REVIVALS 4
205 void ScoreRules_freezetag()
206 {
207         CheckAllowedTeams(world);
208         ScoreRules_basics(((c4>=0) ? 4 : (c3>=0) ? 3 : 2), SFL_SORT_PRIO_PRIMARY, SFL_SORT_PRIO_PRIMARY, TRUE); // SFL_SORT_PRIO_PRIMARY
209         ScoreInfo_SetLabel_PlayerScore(SP_FREEZETAG_REVIVALS,           "revivals",             0);
210         ScoreRules_basics_end();
211 }