]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/gamemodes/sv_rules.qh
Merge branch 'master' into develop
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / gamemodes / sv_rules.qh
1 #pragma once
2
3 //int autocvar_leadlimit;
4 int autocvar_leadlimit_and_fraglimit;
5 int autocvar_leadlimit_override;
6
7 // TODO: find a better location for these?
8 int total_players;
9
10 .int ingame;
11 #define INGAME_STATUS_NONE 0
12 #define INGAME_STATUS_JOINING 0.5
13 #define INGAME_STATUS_JOINED 1
14
15 // typically used by game modes that temporarily turn players into spectators/observers
16 // when they are eliminated but keeping them "in game", i.e. listed among players
17 #define INGAME_STATUS_SET(it, s) (it).ingame = s
18 #define INGAME_STATUS_CLEAR(it) INGAME_STATUS_SET(it, INGAME_STATUS_NONE)
19
20 #define INGAME(it) ((it).ingame)
21 #define INGAME_JOINED(it) ((it).ingame == INGAME_STATUS_JOINED)
22 #define INGAME_JOINING(it) ((it).ingame == INGAME_STATUS_JOINING)
23
24
25 // todo: accept the number of teams as a parameter
26 void GameRules_teams(bool value);
27
28 /**
29  * Used to disable team spawns in team modes
30  */
31 void GameRules_spawning_teams(bool value);
32
33 /**
34  * Disabling score disables the "score" column on the scoreboard
35  */
36 void GameRules_score_enabled(bool value);
37
38 void GameRules_limit_score(int limit);
39 void GameRules_limit_lead(int limit);
40 void GameRules_limit_time(int limit);
41 void GameRules_limit_time_qualifying(int limit);
42
43 /**
44  * Set any unspecified rules to their defaults
45  */
46 void GameRules_limit_fallbacks();
47
48 /**
49  * @param teams a bitmask of active teams
50  * @param spprio player score priority (if frags aren't enabled)
51  * @param stprio team score priority (if frags aren't enabled)
52  */
53 #define GameRules_scoring(teams, spprio, stprio, fields) MACRO_BEGIN \
54     _GameRules_scoring_begin((teams), (spprio), (stprio)); \
55     noref void(entity, string, float) field = _GameRules_scoring_field; \
56     /* todo: just have the one `field` function */ \
57     noref void(int, string, float) field_team = _GameRules_scoring_field_team; \
58     LAMBDA(fields); \
59     _GameRules_scoring_end(); \
60 MACRO_END
61
62 void _GameRules_scoring_begin(int teams, float spprio, float stprio);
63 void _GameRules_scoring_field(entity i, string label, int scoreflags);
64 void _GameRules_scoring_field_team(float i, string label, int scoreflags);
65 void _GameRules_scoring_end();
66
67 /**
68  * Mark a player as being 'important' (flag carrier, ball carrier, etc)
69  * @param player the entity to mark
70  * @param value VIP status
71  */
72 void GameRules_scoring_vip(entity player, bool value);
73 bool GameRules_scoring_is_vip(entity player);
74
75 #define GameRules_scoring_add_float2int(client, fld, value, float_field, score_factor) \
76         _GameRules_scoring_add_float2int(client, SP_##fld, value, float_field, score_factor)
77 float _GameRules_scoring_add_float2int(entity client, entity sp, float value, .float field, float score_factor);
78 #define GameRules_scoring_add(client, fld, value) _GameRules_scoring_add(client, SP_##fld, value)
79 float _GameRules_scoring_add(entity client, entity sp, float value);
80 #define GameRules_scoring_add_team(client, fld, value) _GameRules_scoring_add_team(client, SP_##fld, ST_##fld, value)
81 float _GameRules_scoring_add_team(entity client, entity sp, int st, float value);