Xonotic
scores_rules.qc
Go to the documentation of this file.
1 #include "scores_rules.qh"
2 
4 #include <common/stats.qh>
5 #include <common/weapons/_all.qh>
6 #include <server/client.qh>
7 #include <server/scores.qh>
8 #include <server/teamplay.qh>
9 
11 
12 bool IsTeamAvailable(int team_num)
13 {
14  return boolean(ScoreRules_teams & Team_TeamToBit(team_num));
15 }
16 
17 int NumTeams(int teams)
18 {
19  return boolean(teams & BIT(0)) + boolean(teams & BIT(1)) + boolean(teams & BIT(2)) + boolean(teams & BIT(3));
20 }
21 
23 {
24  return NumTeams(ScoreRules_teams);
25 }
26 
27 // NOTE: ST_constants may not be >= MAX_TEAMSCORE
28 // scores that should be in all modes:
29 void ScoreRules_basics(int teams, float sprio, float stprio, float score_enabled)
30 {
31  FOREACH(Scores, true, {
33  });
34  for(int i = 0; i < MAX_TEAMSCORE; ++i)
36 
38 
39  if(score_enabled)
40  ScoreInfo_SetLabel_TeamScore(ST_SCORE, "score", stprio);
41 
43  ScoreInfo_SetLabel_PlayerScore(SP_KILLS, "kills", 0);
44 
46 
48  {
49  ScoreInfo_SetLabel_PlayerScore(SP_SUICIDES, "suicides", SFL_LOWER_IS_BETTER);
50  ScoreInfo_SetLabel_PlayerScore(SP_TEAMKILLS, "teamkills", SFL_LOWER_IS_BETTER);
51  }
52 
53  if(score_enabled)
54  ScoreInfo_SetLabel_PlayerScore(SP_SCORE, "score", sprio);
55 
56  ScoreInfo_SetLabel_PlayerScore(SP_DMG, "dmg", 0);
57  ScoreInfo_SetLabel_PlayerScore(SP_DMGTAKEN, "dmgtaken", SFL_LOWER_IS_BETTER);
58  ScoreInfo_SetLabel_PlayerScore(SP_ELO, "elo", 0);
59 
60  if(STAT(SHOWFPS))
61  ScoreInfo_SetLabel_PlayerScore(SP_FPS, "fps", 0);
62 }
63 
65 {
67 }
68 
70 {
71  int teams = 0;
72  if (teamplay)
73  {
75  teams = TeamBalance_GetAllowedTeams(balance);
76  TeamBalance_Destroy(balance);
77  }
79 }
#define GameRules_scoring(teams, spprio, stprio, fields)
Definition: sv_rules.qh:53
int NumTeams(int teams)
Definition: scores_rules.qc:17
const int ST_SCORE
Definition: scores.qh:151
void TeamBalance_Destroy(entity balance)
Destroy the team balance entity.
Definition: teamplay.qc:627
entity() spawn
void ScoreRules_basics(int teams, float sprio, float stprio, float score_enabled)
Definition: scores_rules.qc:29
const int SFL_SORT_PRIO_PRIMARY
Definition: scores.qh:127
void ScoreRules_basics_end()
Definition: scores_rules.qc:64
void ScoreInfo_SetLabel_PlayerScore(PlayerScoreField i, string label, float scoreflags)
Set the label of a player score item, as well as the scoring flags.
Definition: scores.qc:165
#define INDEPENDENT_PLAYERS
Definition: client.qh:313
const int SFL_LOWER_IS_BETTER
Lower scores are better (e.g.
Definition: scores.qh:98
entity teams
Definition: main.qh:44
void ScoreInfo_Init(int teams)
Definition: scores.qc:214
#define BIT(n)
Only ever assign into the first 24 bits in QC (so max is BIT(23)).
Definition: bits.qh:8
void ScoreRules_generic()
Definition: scores_rules.qc:69
int TeamBalance_GetAllowedTeams(entity balance)
Returns the bitmask of allowed teams.
Definition: teamplay.qc:640
bool IsTeamAvailable(int team_num)
Definition: scores_rules.qc:12
#define MAX_TEAMSCORE
Definition: scores.qh:142
#define NULL
Definition: post.qh:17
int AvailableTeams()
Definition: scores_rules.qc:22
float teamplay
Definition: progsdefs.qc:31
void ScoreInfo_SetLabel_TeamScore(float i, string label, float scoreflags)
Set the label of a team score item, as well as the scoring flags.
Definition: scores.qc:181
int ScoreRules_teams
Definition: scores_rules.qc:10
entity TeamBalance_CheckAllowedTeams(entity for_whom)
Checks whether the player can join teams according to global configuration and mutator settings...
Definition: teamplay.qc:487
#define FOREACH(list, cond, body)
Definition: iter.qh:19
#define boolean(value)
Definition: bool.qh:9
int Team_TeamToBit(int team_num)
Converts team value into bit value that is used in team bitmasks.
Definition: teams.qh:199