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