]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/scores_rules.qc
302938b267d67ba0261c574e67b9798b9aec539f
[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_domination
48 #define ST_DOM_TICKS 1
49 #define SP_DOM_TICKS 4
50 #define SP_DOM_TAKES 5
51 void ScoreRules_dom()
52 {
53         float sp_domticks, sp_score;
54         sp_score = sp_domticks = 0;
55         if(autocvar_g_domination_disable_frags)
56                 sp_domticks = SFL_SORT_PRIO_PRIMARY;
57         else
58                 sp_score = SFL_SORT_PRIO_PRIMARY;
59         CheckAllowedTeams(world);
60         ScoreRules_basics(((c4>=0) ? 4 : (c3>=0) ? 3 : 2), sp_score, sp_score, TRUE);
61         ScoreInfo_SetLabel_TeamScore  (ST_DOM_TICKS,    "ticks",     sp_domticks);
62         ScoreInfo_SetLabel_PlayerScore(SP_DOM_TICKS,    "ticks",     sp_domticks);
63         ScoreInfo_SetLabel_PlayerScore(SP_DOM_TAKES,    "takes",     0);
64         ScoreRules_basics_end();
65 }
66
67 // LMS stuff
68 #define SP_LMS_LIVES 4
69 #define SP_LMS_RANK 5
70 void ScoreRules_lms()
71 {
72         ScoreRules_basics(0, 0, 0, FALSE);
73         ScoreInfo_SetLabel_PlayerScore(SP_LMS_LIVES,    "lives",     SFL_SORT_PRIO_SECONDARY);
74         ScoreInfo_SetLabel_PlayerScore(SP_LMS_RANK,     "rank",      SFL_LOWER_IS_BETTER | SFL_RANK | SFL_SORT_PRIO_PRIMARY | SFL_ALLOW_HIDE);
75         ScoreRules_basics_end();
76 }
77
78 // Key hunt stuff
79 #define ST_KH_CAPS 1
80 #define SP_KH_CAPS 4
81 #define SP_KH_PUSHES 5
82 #define SP_KH_DESTROYS 6
83 #define SP_KH_PICKUPS 7
84 #define SP_KH_KCKILLS 8
85 #define SP_KH_LOSSES 9
86 void ScoreRules_kh(float teams)
87 {
88         ScoreRules_basics(teams, SFL_SORT_PRIO_PRIMARY, SFL_SORT_PRIO_PRIMARY, TRUE);
89         ScoreInfo_SetLabel_TeamScore  (ST_KH_CAPS,      "caps",      SFL_SORT_PRIO_SECONDARY);
90         ScoreInfo_SetLabel_PlayerScore(SP_KH_CAPS,      "caps",      SFL_SORT_PRIO_SECONDARY);
91         ScoreInfo_SetLabel_PlayerScore(SP_KH_PUSHES,    "pushes",    0);
92         ScoreInfo_SetLabel_PlayerScore(SP_KH_DESTROYS,  "destroyed", SFL_LOWER_IS_BETTER);
93         ScoreInfo_SetLabel_PlayerScore(SP_KH_PICKUPS,   "pickups",   0);
94         ScoreInfo_SetLabel_PlayerScore(SP_KH_KCKILLS,   "kckills",   0);
95         ScoreInfo_SetLabel_PlayerScore(SP_KH_LOSSES,    "losses",    SFL_LOWER_IS_BETTER);
96         ScoreRules_basics_end();
97 }
98
99 // Race stuff
100 #define ST_RACE_LAPS 1
101 #define SP_RACE_LAPS 4
102 #define SP_RACE_FASTEST 5
103 #define SP_RACE_TIME 5
104 //#define SP_RACE_RANK 6
105 void ScoreRules_race()
106 {
107         ScoreRules_basics(race_teams, 0, 0, FALSE);
108         if(race_teams)
109         {
110                 ScoreInfo_SetLabel_TeamScore(  ST_RACE_LAPS,    "laps",      SFL_SORT_PRIO_PRIMARY);
111                 ScoreInfo_SetLabel_PlayerScore(SP_RACE_LAPS,    "laps",      SFL_SORT_PRIO_PRIMARY);
112                 ScoreInfo_SetLabel_PlayerScore(SP_RACE_TIME,    "time",      SFL_SORT_PRIO_SECONDARY | SFL_LOWER_IS_BETTER | SFL_TIME);
113                 //ScoreInfo_SetLabel_PlayerScore(SP_RACE_RANK,    "rank",      SFL_LOWER_IS_BETTER | SFL_RANK | SFL_ALLOW_HIDE);
114         }
115         else if(g_race_qualifying)
116         {
117                 ScoreInfo_SetLabel_PlayerScore(SP_RACE_FASTEST, "fastest",   SFL_SORT_PRIO_PRIMARY | SFL_LOWER_IS_BETTER | SFL_TIME);
118         }
119         else
120         {
121                 //ScoreInfo_SetLabel_TeamScore(  ST_RACE_LAPS,    "laps",      0);
122                 ScoreInfo_SetLabel_PlayerScore(SP_RACE_LAPS,    "laps",      SFL_SORT_PRIO_PRIMARY);
123                 ScoreInfo_SetLabel_PlayerScore(SP_RACE_TIME,    "time",      SFL_SORT_PRIO_SECONDARY | SFL_LOWER_IS_BETTER | SFL_TIME);
124         }
125         ScoreRules_basics_end();
126 }
127
128 // Assault stuff
129 #define ST_ASSAULT_OBJECTIVES 1
130 #define SP_ASSAULT_OBJECTIVES 4
131 void ScoreRules_assault()
132 {
133         ScoreRules_basics(2, SFL_SORT_PRIO_SECONDARY, SFL_SORT_PRIO_SECONDARY, TRUE);
134         ScoreInfo_SetLabel_TeamScore(  ST_ASSAULT_OBJECTIVES,    "objectives",      SFL_SORT_PRIO_PRIMARY);
135         ScoreInfo_SetLabel_PlayerScore(SP_ASSAULT_OBJECTIVES,    "objectives",      SFL_SORT_PRIO_PRIMARY);
136         ScoreRules_basics_end();
137 }
138
139 // Nexball stuff
140 #define ST_NEXBALL_GOALS 1
141 #define SP_NEXBALL_GOALS 4
142 #define SP_NEXBALL_FAULTS 5
143 void ScoreRules_nexball(float teams)
144 {
145         ScoreRules_basics(teams, 0, 0, TRUE);
146         ScoreInfo_SetLabel_TeamScore(   ST_NEXBALL_GOALS,  "goals", SFL_SORT_PRIO_PRIMARY);
147         ScoreInfo_SetLabel_PlayerScore( SP_NEXBALL_GOALS,  "goals", SFL_SORT_PRIO_PRIMARY);
148         ScoreInfo_SetLabel_PlayerScore(SP_NEXBALL_FAULTS, "faults", SFL_SORT_PRIO_SECONDARY | SFL_LOWER_IS_BETTER);
149         ScoreRules_basics_end();
150 }
151
152 // Keep Away stuff
153 #define SP_KEEPAWAY_PICKUPS 4
154 #define SP_KEEPAWAY_CARRIERKILLS 5
155 #define SP_KEEPAWAY_BCTIME 6
156 void ScoreRules_keepaway()
157 {
158         ScoreRules_basics(0, SFL_SORT_PRIO_PRIMARY, 0, TRUE); // SFL_SORT_PRIO_PRIMARY
159         ScoreInfo_SetLabel_PlayerScore(SP_KEEPAWAY_PICKUPS,                     "pickups",              0);
160         ScoreInfo_SetLabel_PlayerScore(SP_KEEPAWAY_CARRIERKILLS,        "bckills",              0);
161         ScoreInfo_SetLabel_PlayerScore(SP_KEEPAWAY_BCTIME,                      "bctime",                       SFL_SORT_PRIO_SECONDARY);
162         ScoreRules_basics_end();
163 }
164
165 // FreezeTag stuff
166 #define SP_FREEZETAG_REVIVALS 4
167 void ScoreRules_freezetag()
168 {
169         CheckAllowedTeams(world);
170         ScoreRules_basics(((c4>=0) ? 4 : (c3>=0) ? 3 : 2), SFL_SORT_PRIO_PRIMARY, SFL_SORT_PRIO_PRIMARY, TRUE); // SFL_SORT_PRIO_PRIMARY
171         ScoreInfo_SetLabel_PlayerScore(SP_FREEZETAG_REVIVALS,           "revivals",             0);
172         ScoreRules_basics_end();
173 }