]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/scores_rules.qc
race: hide kills/suicides columns in qualifying
[divverent/nexuiz.git] / data / 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)
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(sprio)
18                 ScoreInfo_SetLabel_TeamScore  (ST_SCORE,        "score",     sprio);
19
20         if(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(independent_players)
26                 ScoreInfo_SetLabel_PlayerScore(SP_SUICIDES,     "suicides",  SFL_LOWER_IS_BETTER);
27
28         if(sprio)
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         CheckAllowedTeams(world);
38         if(teamplay)
39         {
40                 CheckAllowedTeams(world);
41                 ScoreRules_basics(((c4>=0) ? 4 : (c3>=0) ? 3 : 2), SFL_SORT_PRIO_PRIMARY);
42         }
43         else
44                 ScoreRules_basics(0, SFL_SORT_PRIO_PRIMARY);
45         ScoreRules_basics_end();
46 }
47
48 // g_ctf
49 #define ST_CTF_CAPS 1
50 #define SP_CTF_CAPS 4
51 #define SP_CTF_PICKUPS 5
52 #define SP_CTF_FCKILLS 6
53 #define SP_CTF_RETURNS 7
54 void ScoreRules_ctf()
55 {
56         float sp_score, sp_caps;
57         sp_score = sp_caps = 0;
58         switch(cvar("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_score = SFL_SORT_PRIO_PRIMARY;
70                         sp_caps = SFL_SORT_PRIO_SECONDARY; // looks better ;)
71                         break;
72         }
73
74         CheckAllowedTeams(world);
75         ScoreRules_basics(2 + (c3>=0), sp_score); // 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",      sp_caps);
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         ScoreRules_basics_end();
82 }
83
84 // g_domination
85 #define ST_DOM_TICKS 1
86 #define SP_DOM_TICKS 4
87 #define SP_DOM_TAKES 5
88 void ScoreRules_dom()
89 {
90         float sp_domticks, sp_score;
91         sp_score = sp_domticks = 0;
92         if(cvar("g_domination_disable_frags"))
93                 sp_domticks = SFL_SORT_PRIO_PRIMARY;
94         else
95                 sp_score = SFL_SORT_PRIO_PRIMARY;
96         CheckAllowedTeams(world);
97         ScoreRules_basics(((c4>=0) ? 4 : (c3>=0) ? 3 : 2), sp_score);
98         ScoreInfo_SetLabel_TeamScore  (ST_DOM_TICKS,    "ticks",     sp_domticks);
99         ScoreInfo_SetLabel_PlayerScore(SP_DOM_TICKS,    "ticks",     sp_domticks);
100         ScoreInfo_SetLabel_PlayerScore(SP_DOM_TAKES,    "takes",     0);
101         ScoreRules_basics_end();
102 }
103
104 // LMS stuff
105 #define SP_LMS_LIVES 4
106 #define SP_LMS_RANK 5
107 void ScoreRules_lms()
108 {
109         ScoreRules_basics(0, 0);
110         ScoreInfo_SetLabel_PlayerScore(SP_LMS_LIVES,    "lives",     SFL_SORT_PRIO_SECONDARY);
111         ScoreInfo_SetLabel_PlayerScore(SP_LMS_RANK,     "rank",      SFL_LOWER_IS_BETTER | SFL_RANK | SFL_SORT_PRIO_PRIMARY | SFL_ALLOW_HIDE);
112         ScoreRules_basics_end();
113 }
114
115 // Key hunt stuff
116 #define ST_KH_CAPS 1
117 #define SP_KH_CAPS 4
118 #define SP_KH_PUSHES 5
119 #define SP_KH_DESTROYS 6
120 #define SP_KH_PICKUPS 7
121 #define SP_KH_KCKILLS 8
122 #define SP_KH_LOSSES 9
123 void ScoreRules_kh(float teams)
124 {
125         ScoreRules_basics(teams, SFL_SORT_PRIO_PRIMARY);
126         ScoreInfo_SetLabel_TeamScore  (ST_KH_CAPS,      "caps",      SFL_SORT_PRIO_SECONDARY);
127         ScoreInfo_SetLabel_PlayerScore(SP_KH_CAPS,      "caps",      SFL_SORT_PRIO_SECONDARY);
128         ScoreInfo_SetLabel_PlayerScore(SP_KH_PUSHES,    "pushes",    0);
129         ScoreInfo_SetLabel_PlayerScore(SP_KH_DESTROYS,  "destroyed", SFL_LOWER_IS_BETTER);
130         ScoreInfo_SetLabel_PlayerScore(SP_KH_PICKUPS,   "pickups",   0);
131         ScoreInfo_SetLabel_PlayerScore(SP_KH_KCKILLS,   "kckills",   0);
132         ScoreInfo_SetLabel_PlayerScore(SP_KH_LOSSES,    "losses",    SFL_LOWER_IS_BETTER);
133         ScoreRules_basics_end();
134 }
135
136 // Race stuff
137 #define ST_RACE_LAPS 1
138 #define SP_RACE_LAPS 4
139 #define SP_RACE_FASTEST 5
140 #define SP_RACE_TIME 5
141 void ScoreRules_race()
142 {
143         ScoreRules_basics(race_teams, 0);
144         if(race_teams)
145         {
146                 ScoreInfo_SetLabel_TeamScore(  ST_RACE_LAPS,    "laps",      SFL_SORT_PRIO_PRIMARY);
147                 ScoreInfo_SetLabel_PlayerScore(SP_RACE_LAPS,    "laps",      SFL_SORT_PRIO_PRIMARY);
148                 ScoreInfo_SetLabel_PlayerScore(SP_RACE_TIME,    "time",      SFL_SORT_PRIO_SECONDARY | SFL_LOWER_IS_BETTER | SFL_TIME);
149         }
150         else if(g_race_qualifying)
151         {
152                 ScoreInfo_SetLabel_TeamScore(  ST_RACE_LAPS,    "laps",      0);
153                 ScoreInfo_SetLabel_PlayerScore(SP_RACE_LAPS,    "laps",      0);
154                 ScoreInfo_SetLabel_PlayerScore(SP_RACE_FASTEST, "fastest",   SFL_SORT_PRIO_PRIMARY | SFL_LOWER_IS_BETTER | SFL_TIME);
155         }
156         else
157         {
158                 ScoreInfo_SetLabel_TeamScore(  ST_RACE_LAPS,    "laps",      0);
159                 ScoreInfo_SetLabel_PlayerScore(SP_RACE_LAPS,    "laps",      SFL_SORT_PRIO_PRIMARY);
160                 ScoreInfo_SetLabel_PlayerScore(SP_RACE_TIME,    "time",      SFL_SORT_PRIO_SECONDARY | SFL_LOWER_IS_BETTER | SFL_TIME);
161         }
162         ScoreRules_basics_end();
163 }