]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/scores_rules.qc
Merge branch 'master' into mario/domination_mutator
[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 // LMS stuff
48 #define SP_LMS_LIVES 4
49 #define SP_LMS_RANK 5
50 void ScoreRules_lms()
51 {
52         ScoreRules_basics(0, 0, 0, FALSE);
53         ScoreInfo_SetLabel_PlayerScore(SP_LMS_LIVES,    "lives",     SFL_SORT_PRIO_SECONDARY);
54         ScoreInfo_SetLabel_PlayerScore(SP_LMS_RANK,     "rank",      SFL_LOWER_IS_BETTER | SFL_RANK | SFL_SORT_PRIO_PRIMARY | SFL_ALLOW_HIDE);
55         ScoreRules_basics_end();
56 }
57
58 // Key hunt stuff
59 #define ST_KH_CAPS 1
60 #define SP_KH_CAPS 4
61 #define SP_KH_PUSHES 5
62 #define SP_KH_DESTROYS 6
63 #define SP_KH_PICKUPS 7
64 #define SP_KH_KCKILLS 8
65 #define SP_KH_LOSSES 9
66 void ScoreRules_kh(float teams)
67 {
68         ScoreRules_basics(teams, SFL_SORT_PRIO_PRIMARY, SFL_SORT_PRIO_PRIMARY, TRUE);
69         ScoreInfo_SetLabel_TeamScore  (ST_KH_CAPS,      "caps",      SFL_SORT_PRIO_SECONDARY);
70         ScoreInfo_SetLabel_PlayerScore(SP_KH_CAPS,      "caps",      SFL_SORT_PRIO_SECONDARY);
71         ScoreInfo_SetLabel_PlayerScore(SP_KH_PUSHES,    "pushes",    0);
72         ScoreInfo_SetLabel_PlayerScore(SP_KH_DESTROYS,  "destroyed", SFL_LOWER_IS_BETTER);
73         ScoreInfo_SetLabel_PlayerScore(SP_KH_PICKUPS,   "pickups",   0);
74         ScoreInfo_SetLabel_PlayerScore(SP_KH_KCKILLS,   "kckills",   0);
75         ScoreInfo_SetLabel_PlayerScore(SP_KH_LOSSES,    "losses",    SFL_LOWER_IS_BETTER);
76         ScoreRules_basics_end();
77 }
78
79 // Race stuff
80 #define ST_RACE_LAPS 1
81 #define SP_RACE_LAPS 4
82 #define SP_RACE_FASTEST 5
83 #define SP_RACE_TIME 5
84 //#define SP_RACE_RANK 6
85 void ScoreRules_race()
86 {
87         ScoreRules_basics(race_teams, 0, 0, FALSE);
88         if(race_teams)
89         {
90                 ScoreInfo_SetLabel_TeamScore(  ST_RACE_LAPS,    "laps",      SFL_SORT_PRIO_PRIMARY);
91                 ScoreInfo_SetLabel_PlayerScore(SP_RACE_LAPS,    "laps",      SFL_SORT_PRIO_PRIMARY);
92                 ScoreInfo_SetLabel_PlayerScore(SP_RACE_TIME,    "time",      SFL_SORT_PRIO_SECONDARY | SFL_LOWER_IS_BETTER | SFL_TIME);
93                 //ScoreInfo_SetLabel_PlayerScore(SP_RACE_RANK,    "rank",      SFL_LOWER_IS_BETTER | SFL_RANK | SFL_ALLOW_HIDE);
94         }
95         else if(g_race_qualifying)
96         {
97                 ScoreInfo_SetLabel_PlayerScore(SP_RACE_FASTEST, "fastest",   SFL_SORT_PRIO_PRIMARY | SFL_LOWER_IS_BETTER | SFL_TIME);
98         }
99         else
100         {
101                 //ScoreInfo_SetLabel_TeamScore(  ST_RACE_LAPS,    "laps",      0);
102                 ScoreInfo_SetLabel_PlayerScore(SP_RACE_LAPS,    "laps",      SFL_SORT_PRIO_PRIMARY);
103                 ScoreInfo_SetLabel_PlayerScore(SP_RACE_TIME,    "time",      SFL_SORT_PRIO_SECONDARY | SFL_LOWER_IS_BETTER | SFL_TIME);
104         }
105         ScoreRules_basics_end();
106 }
107
108 // Assault stuff
109 #define ST_ASSAULT_OBJECTIVES 1
110 #define SP_ASSAULT_OBJECTIVES 4
111 void ScoreRules_assault()
112 {
113         ScoreRules_basics(2, SFL_SORT_PRIO_SECONDARY, SFL_SORT_PRIO_SECONDARY, TRUE);
114         ScoreInfo_SetLabel_TeamScore(  ST_ASSAULT_OBJECTIVES,    "objectives",      SFL_SORT_PRIO_PRIMARY);
115         ScoreInfo_SetLabel_PlayerScore(SP_ASSAULT_OBJECTIVES,    "objectives",      SFL_SORT_PRIO_PRIMARY);
116         ScoreRules_basics_end();
117 }
118
119 // Nexball stuff
120 #define ST_NEXBALL_GOALS 1
121 #define SP_NEXBALL_GOALS 4
122 #define SP_NEXBALL_FAULTS 5
123 void ScoreRules_nexball(float teams)
124 {
125         ScoreRules_basics(teams, 0, 0, TRUE);
126         ScoreInfo_SetLabel_TeamScore(   ST_NEXBALL_GOALS,  "goals", SFL_SORT_PRIO_PRIMARY);
127         ScoreInfo_SetLabel_PlayerScore( SP_NEXBALL_GOALS,  "goals", SFL_SORT_PRIO_PRIMARY);
128         ScoreInfo_SetLabel_PlayerScore(SP_NEXBALL_FAULTS, "faults", SFL_SORT_PRIO_SECONDARY | SFL_LOWER_IS_BETTER);
129         ScoreRules_basics_end();
130 }
131
132 // FreezeTag stuff
133 #define SP_FREEZETAG_REVIVALS 4
134 void ScoreRules_freezetag()
135 {
136         CheckAllowedTeams(world);
137         ScoreRules_basics(((c4>=0) ? 4 : (c3>=0) ? 3 : 2), SFL_SORT_PRIO_PRIMARY, SFL_SORT_PRIO_PRIMARY, TRUE); // SFL_SORT_PRIO_PRIMARY
138         ScoreInfo_SetLabel_PlayerScore(SP_FREEZETAG_REVIVALS,           "revivals",             0);
139         ScoreRules_basics_end();
140 }