add score rules for domination (maybe add more stuff later)
[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 void ScoreRules_basics(float teams, float sprio)
7 {
8         ScoreInfo_Init(teams);
9         if(sprio)
10                 ScoreInfo_SetLabel_TeamScore  (ST_SCORE,        "score",     sprio);
11         ScoreInfo_SetLabel_PlayerScore(SP_KILLS,        "kills",     0);
12         ScoreInfo_SetLabel_PlayerScore(SP_DEATHS,       "deaths",    SFL_LOWER_IS_BETTER);
13         ScoreInfo_SetLabel_PlayerScore(SP_SUICIDES,     "suicides",  SFL_LOWER_IS_BETTER);
14         if(sprio)
15                 ScoreInfo_SetLabel_PlayerScore(SP_SCORE,        "score",     sprio);
16 }
17 void ScoreRules_generic()
18 {
19         CheckAllowedTeams(world);
20         if(teamplay)
21         {
22                 CheckAllowedTeams(world);
23                 ScoreRules_basics(((c4>=0) ? 4 : (c3>=0) ? 3 : 2), SFL_SORT_PRIO_PRIMARY);
24         }
25         else
26                 ScoreRules_basics(0, SFL_SORT_PRIO_PRIMARY);
27 }
28
29 // g_ctf
30 #define ST_CTF_CAPS 1
31 #define SP_CTF_CAPS 4
32 #define SP_CTF_PICKUPS 5
33 #define SP_CTF_FCKILLS 6
34 #define SP_CTF_RETURNS 7
35 void ScoreRules_ctf()
36 {
37         float sp_score, sp_caps;
38         sp_score = sp_caps = 0;
39         switch(cvar("g_ctf_win_mode"))
40         {
41                 case 0: // caps only
42                         sp_caps = SFL_SORT_PRIO_PRIMARY;
43                         break;
44                 case 1: // caps, then score
45                         sp_caps = SFL_SORT_PRIO_PRIMARY;
46                         sp_score = SFL_SORT_PRIO_SECONDARY;
47                         break;
48                 case 2: // score only
49                 default:
50                         sp_score = SFL_SORT_PRIO_PRIMARY;
51                         sp_caps = SFL_SORT_PRIO_SECONDARY; // looks better ;)
52                         break;
53         }
54
55         CheckAllowedTeams(world);
56         ScoreRules_basics(2 + (c3>=0), sp_score); // NOTE this assumes that the rogue team is team 3
57         ScoreInfo_SetLabel_TeamScore  (ST_CTF_CAPS,     "caps",      sp_caps);
58         ScoreInfo_SetLabel_PlayerScore(SP_CTF_CAPS,     "caps",      sp_caps);
59         ScoreInfo_SetLabel_PlayerScore(SP_CTF_PICKUPS,  "pickups",   0);
60         ScoreInfo_SetLabel_PlayerScore(SP_CTF_FCKILLS,  "fckills",   0);
61         ScoreInfo_SetLabel_PlayerScore(SP_CTF_RETURNS,  "returns",   0);
62 }
63
64 // g_domination
65 #define ST_DOM_DOMTICKS 1
66 #define SP_DOM_DOMTICKS 4
67 void ScoreRules_dom()
68 {
69         float sp_domticks, sp_score;
70         sp_score = sp_domticks = 0;
71         if(cvar("g_domination_disable_frags"))
72                 sp_domticks = SFL_SORT_PRIO_PRIMARY;
73         else
74                 sp_score = SFL_SORT_PRIO_PRIMARY;
75         CheckAllowedTeams(world);
76         ScoreRules_basics(((c4>=0) ? 4 : (c3>=0) ? 3 : 2), sp_score);
77         ScoreInfo_SetLabel_TeamScore  (ST_DOM_DOMTICKS, "domticks",  sp_domticks);
78         ScoreInfo_SetLabel_PlayerScore(SP_DOM_DOMTICKS, "domticks",  sp_domticks);
79 }
80
81 // LMS stuff
82 #define SP_LMS_LIVES 4
83 #define SP_LMS_RANK 5
84 void ScoreRules_lms()
85 {
86         ScoreRules_basics(0, 0);
87         ScoreInfo_SetLabel_PlayerScore(SP_LMS_LIVES,    "lives",     SFL_SORT_PRIO_SECONDARY);
88         ScoreInfo_SetLabel_PlayerScore(SP_LMS_RANK,     "rank",      SFL_LOWER_IS_BETTER | SFL_HIDE_ZERO | SFL_SORT_PRIO_PRIMARY | SFL_ALLOW_HIDE);
89 }
90
91 // Key hunt stuff
92 #define ST_KH_CAPS 1
93 #define SP_KH_CAPS 4
94 #define SP_KH_PUSHES 5
95 #define SP_KH_DESTROYS 6
96 #define SP_KH_PICKUPS 7
97 #define SP_KH_KCKILLS 8
98 #define SP_KH_LOSSES 9
99 void ScoreRules_kh(float teams)
100 {
101         ScoreRules_basics(teams, SFL_SORT_PRIO_PRIMARY);
102         ScoreInfo_SetLabel_TeamScore  (ST_KH_CAPS,      "caps",      SFL_SORT_PRIO_SECONDARY);
103         ScoreInfo_SetLabel_PlayerScore(SP_KH_CAPS,      "caps",      SFL_SORT_PRIO_SECONDARY);
104         ScoreInfo_SetLabel_PlayerScore(SP_KH_PUSHES,    "pushes",    0);
105         ScoreInfo_SetLabel_PlayerScore(SP_KH_DESTROYS,  "destroyed", SFL_LOWER_IS_BETTER);
106         ScoreInfo_SetLabel_PlayerScore(SP_KH_PICKUPS,   "pickups",   0);
107         ScoreInfo_SetLabel_PlayerScore(SP_KH_KCKILLS,   "kckills",   0);
108         ScoreInfo_SetLabel_PlayerScore(SP_KH_LOSSES,    "losses",    SFL_LOWER_IS_BETTER);
109 }