Xonotic
sv_rules.qc File Reference
#include "sv_rules.qh"
#include <server/spawnpoints.qh>
#include <server/teamplay.qh>
+ Include dependency graph for sv_rules.qc:

Go to the source code of this file.

Functions

float _GameRules_scoring_add (entity client, entity sp, float value)
 
float _GameRules_scoring_add_float2int (entity client, entity sp, float value,.float float_field, float score_factor)
 
float _GameRules_scoring_add_team (entity client, entity sp, int st, float value)
 
void _GameRules_scoring_begin (int teams, float spprio, float stprio)
 
void _GameRules_scoring_end ()
 
void _GameRules_scoring_field (entity i, string label, int scoreflags)
 
void _GameRules_scoring_field_team (float i, string label, int scoreflags)
 
void GameRules_limit_fallbacks ()
 Set any unspecified rules to their defaults. More...
 
void GameRules_limit_lead (int limit)
 
void GameRules_limit_score (int limit)
 
void GameRules_limit_time (int limit)
 
void GameRules_limit_time_qualifying (int limit)
 
void GameRules_score_enabled (bool value)
 Disabling score disables the "score" column on the scoreboard. More...
 
bool GameRules_scoring_is_vip (entity player)
 
void GameRules_scoring_vip (entity player, bool value)
 Mark a player as being 'important' (flag carrier, ball carrier, etc) More...
 
void GameRules_spawning_teams (bool value)
 Used to disable team spawns in team modes. More...
 
void GameRules_teams (bool value)
 

Variables

bool _GameRules_score_enabled = true
 
bool GameRules_limit_lead_initialized
 
bool GameRules_limit_score_initialized
 
bool GameRules_limit_time_initialized
 
bool GameRules_limit_time_qualifying_initialized
 
bool m_GameRules_scoring_vip
 

Function Documentation

◆ _GameRules_scoring_add()

float _GameRules_scoring_add ( entity  client,
entity  sp,
float  value 
)

Definition at line 126 of file sv_rules.qc.

References PlayerScore_Add().

127 {
128  return PlayerScore_Add(client, sp, value);
129 }
float PlayerScore_Add(entity player, PlayerScoreField scorefield, float score)
Adds a score to the player&#39;s scores.
Definition: scores.qc:336
+ Here is the call graph for this function:

◆ _GameRules_scoring_add_float2int()

float _GameRules_scoring_add_float2int ( entity  client,
entity  sp,
float  value,
.float  float_field,
float  score_factor 
)

Definition at line 111 of file sv_rules.qc.

References floor(), and PlayerScore_Add().

112 {
113  client.(float_field) += value;
114  float score_counter = client.(float_field) / score_factor;
115  if (score_counter >= -0.5 && score_counter < 0.5)
116  return 0;
117 
118  // NOTE: this code works for subtracting score too
119  int points = floor(score_counter + 0.5);
120  client.(float_field) -= points * score_factor;
121  if (!points)
122  return 0;
123  return PlayerScore_Add(client, sp, points);
124 }
float PlayerScore_Add(entity player, PlayerScoreField scorefield, float score)
Adds a score to the player&#39;s scores.
Definition: scores.qc:336
+ Here is the call graph for this function:

◆ _GameRules_scoring_add_team()

float _GameRules_scoring_add_team ( entity  client,
entity  sp,
int  st,
float  value 
)

Definition at line 130 of file sv_rules.qc.

References PlayerTeamScore_Add().

131 {
132  return PlayerTeamScore_Add(client, sp, st, value);
133 }
float PlayerTeamScore_Add(entity player, PlayerScoreField pscorefield, float tscorefield, float score)
Adds a score to both the player and the team.
Definition: scores.qc:390
+ Here is the call graph for this function:

◆ _GameRules_scoring_begin()

void _GameRules_scoring_begin ( int  teams,
float  spprio,
float  stprio 
)

Definition at line 80 of file sv_rules.qc.

References _GameRules_score_enabled, and ScoreRules_basics().

81 {
83 }
void ScoreRules_basics(int teams, float sprio, float stprio, float score_enabled)
Definition: scores_rules.qc:29
entity teams
Definition: main.qh:44
bool _GameRules_score_enabled
Definition: sv_rules.qc:27
+ Here is the call graph for this function:

◆ _GameRules_scoring_end()

void _GameRules_scoring_end ( )

Definition at line 92 of file sv_rules.qc.

References ScoreRules_basics_end().

93 {
95 }
void ScoreRules_basics_end()
Definition: scores_rules.qc:64
+ Here is the call graph for this function:

◆ _GameRules_scoring_field()

void _GameRules_scoring_field ( entity  i,
string  label,
int  scoreflags 
)

Definition at line 84 of file sv_rules.qc.

References ScoreInfo_SetLabel_PlayerScore().

85 {
86  ScoreInfo_SetLabel_PlayerScore(i, label, scoreflags);
87 }
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
+ Here is the call graph for this function:

◆ _GameRules_scoring_field_team()

void _GameRules_scoring_field_team ( float  i,
string  label,
int  scoreflags 
)

Definition at line 88 of file sv_rules.qc.

References ScoreInfo_SetLabel_TeamScore().

89 {
90  ScoreInfo_SetLabel_TeamScore(i, label, scoreflags);
91 }
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
+ Here is the call graph for this function:

◆ GameRules_limit_fallbacks()

void GameRules_limit_fallbacks ( )

Set any unspecified rules to their defaults.

Definition at line 73 of file sv_rules.qc.

References autocvar_leadlimit_override, GameRules_limit_lead(), GameRules_limit_score(), and GameRules_limit_time().

Referenced by spawnfunc().

74 {
75  GameRules_limit_score(autocvar_fraglimit_override);
77  GameRules_limit_time(autocvar_timelimit_override);
78 }
void GameRules_limit_score(int limit)
Definition: sv_rules.qc:34
int autocvar_leadlimit_override
Definition: sv_rules.qh:5
void GameRules_limit_time(int limit)
Definition: sv_rules.qc:54
void GameRules_limit_lead(int limit)
Definition: sv_rules.qc:44
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GameRules_limit_lead()

void GameRules_limit_lead ( int  limit)

Definition at line 44 of file sv_rules.qc.

References autocvar_g_campaign, cvar_set(), ftos(), and GameRules_limit_lead_initialized.

Referenced by GameRules_limit_fallbacks(), nb_Initialize(), rc_SetLimits(), REGISTER_MUTATOR(), and tdm_Initialize().

45 {
47  if (autocvar_g_campaign) return;
48  if (limit < 0) return;
49  cvar_set("leadlimit", ftos(limit));
51 }
bool GameRules_limit_lead_initialized
Definition: sv_rules.qc:43
bool autocvar_g_campaign
Definition: campaign.qh:6
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GameRules_limit_score()

void GameRules_limit_score ( int  limit)

Definition at line 34 of file sv_rules.qc.

References autocvar_g_campaign, cvar_set(), ftos(), and GameRules_limit_score_initialized.

Referenced by GameRules_limit_fallbacks(), nb_Initialize(), rc_SetLimits(), REGISTER_MUTATOR(), and tdm_Initialize().

35 {
37  if (autocvar_g_campaign) return;
38  if (limit < 0) return;
39  cvar_set("fraglimit", ftos(limit));
41 }
bool autocvar_g_campaign
Definition: campaign.qh:6
bool GameRules_limit_score_initialized
Definition: sv_rules.qc:33
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GameRules_limit_time()

void GameRules_limit_time ( int  limit)

Definition at line 54 of file sv_rules.qc.

References autocvar_g_campaign, cvar_set(), ftos(), and GameRules_limit_time_initialized.

Referenced by GameRules_limit_fallbacks(), and rc_SetLimits().

55 {
57  if (autocvar_g_campaign) return;
58  if (limit < 0) return;
59  cvar_set("timelimit", ftos(limit));
61 }
bool autocvar_g_campaign
Definition: campaign.qh:6
bool GameRules_limit_time_initialized
Definition: sv_rules.qc:53
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GameRules_limit_time_qualifying()

void GameRules_limit_time_qualifying ( int  limit)

Definition at line 64 of file sv_rules.qc.

References autocvar_g_campaign, cvar_set(), ftos(), and GameRules_limit_time_qualifying_initialized.

Referenced by rc_SetLimits().

65 {
67  if (autocvar_g_campaign) return;
68  if (limit < 0) return;
69  cvar_set("g_race_qualifying_timelimit", ftos(limit));
71 }
bool GameRules_limit_time_qualifying_initialized
Definition: sv_rules.qc:63
bool autocvar_g_campaign
Definition: campaign.qh:6
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GameRules_score_enabled()

void GameRules_score_enabled ( bool  value)

Disabling score disables the "score" column on the scoreboard.

Definition at line 28 of file sv_rules.qc.

References _GameRules_score_enabled.

Referenced by cts_ScoreRules(), invasion_ScoreRules(), race_ScoreRules(), and REGISTER_MUTATOR().

29 {
31 }
bool _GameRules_score_enabled
Definition: sv_rules.qc:27
+ Here is the caller graph for this function:

◆ GameRules_scoring_is_vip()

bool GameRules_scoring_is_vip ( entity  player)

Definition at line 102 of file sv_rules.qc.

103 {
104  return player.m_GameRules_scoring_vip;
105 }

◆ GameRules_scoring_vip()

void GameRules_scoring_vip ( entity  player,
bool  value 
)

Mark a player as being 'important' (flag carrier, ball carrier, etc)

Parameters
playerthe entity to mark
valueVIP status

Definition at line 98 of file sv_rules.qc.

Referenced by ctf_Handle_Pickup(), ctf_Handle_Retrieve(), ctf_Handle_Throw(), ctf_RespawnFlag(), DropBall(), GiveBall(), ka_PlayerReset(), and ka_TouchEvent().

99 {
100  player.m_GameRules_scoring_vip = value;
101 }
+ Here is the caller graph for this function:

◆ GameRules_spawning_teams()

void GameRules_spawning_teams ( bool  value)

Used to disable team spawns in team modes.

Definition at line 22 of file sv_rules.qc.

References have_team_spawns.

Referenced by GameRules_teams(), REGISTER_MUTATOR(), and tdm_Initialize().

23 {
24  have_team_spawns = value ? -1 : 0;
25 }
int have_team_spawns
Definition: spawnpoints.qh:16
+ Here is the caller graph for this function:

◆ GameRules_teams()

void GameRules_teams ( bool  value)

Definition at line 6 of file sv_rules.qc.

References cvar_set(), GameRules_spawning_teams(), SERVERFLAG_TEAMPLAY, serverflags, Team_InitTeams(), and teamplay.

Referenced by InitGameplayMode(), nb_Initialize(), rc_SetLimits(), REGISTER_MUTATOR(), and tdm_Initialize().

7 {
8  if (value) {
10  teamplay = 1;
11  cvar_set("teamplay", "2"); // DP needs this for sending proper getstatus replies.
14  } else {
16  teamplay = 0;
17  cvar_set("teamplay", "0"); // DP needs this for sending proper getstatus replies.
19  }
20 }
int serverflags
Definition: main.qh:184
void GameRules_spawning_teams(bool value)
Used to disable team spawns in team modes.
Definition: sv_rules.qc:22
const int SERVERFLAG_TEAMPLAY
Definition: constants.qh:16
float teamplay
Definition: progsdefs.qc:31
void Team_InitTeams()
Definition: teamplay.qc:47
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ _GameRules_score_enabled

bool _GameRules_score_enabled = true

Definition at line 27 of file sv_rules.qc.

Referenced by _GameRules_scoring_begin(), and GameRules_score_enabled().

◆ GameRules_limit_lead_initialized

bool GameRules_limit_lead_initialized

Definition at line 43 of file sv_rules.qc.

Referenced by GameRules_limit_lead().

◆ GameRules_limit_score_initialized

bool GameRules_limit_score_initialized

Definition at line 33 of file sv_rules.qc.

Referenced by GameRules_limit_score().

◆ GameRules_limit_time_initialized

bool GameRules_limit_time_initialized

Definition at line 53 of file sv_rules.qc.

Referenced by GameRules_limit_time().

◆ GameRules_limit_time_qualifying_initialized

bool GameRules_limit_time_qualifying_initialized

Definition at line 63 of file sv_rules.qc.

Referenced by GameRules_limit_time_qualifying().

◆ m_GameRules_scoring_vip

bool m_GameRules_scoring_vip

Definition at line 97 of file sv_rules.qc.