Xonotic
sv_race.qc File Reference
#include "sv_race.qh"
#include <server/client.qh>
#include <server/world.qh>
#include <server/gamelog.qh>
#include <server/intermission.qh>
#include <server/race.qh>
#include <common/ent_cs.qh>
#include <common/mapobjects/triggers.qh>
+ Include dependency graph for sv_race.qc:

Go to the source code of this file.

Macros

#define autocvar_g_race_laps_limit   cvar("g_race_laps_limit")
 

Functions

void havocbot_role_race (entity this)
 
 MUTATOR_HOOKFUNCTION (rc, ClientKill)
 
 MUTATOR_HOOKFUNCTION (rc, AbortSpeedrun)
 
 MUTATOR_HOOKFUNCTION (rc, PlayerPhysics)
 
 MUTATOR_HOOKFUNCTION (rc, reset_map_global)
 
 MUTATOR_HOOKFUNCTION (rc, ClientConnect)
 
 MUTATOR_HOOKFUNCTION (rc, MakePlayerObserver)
 
 MUTATOR_HOOKFUNCTION (rc, PlayerSpawn)
 
 MUTATOR_HOOKFUNCTION (rc, PutClientInServer)
 
 MUTATOR_HOOKFUNCTION (rc, PlayerDamaged)
 
 MUTATOR_HOOKFUNCTION (rc, PlayerDies)
 
 MUTATOR_HOOKFUNCTION (rc, HavocBot_ChooseRole)
 
 MUTATOR_HOOKFUNCTION (rc, GetPressedKeys)
 
 MUTATOR_HOOKFUNCTION (rc, ForbidPlayerScore_Clear)
 
 MUTATOR_HOOKFUNCTION (rc, TeamBalance_CheckAllowedTeams, CBC_ORDER_EXCLUSIVE)
 
 MUTATOR_HOOKFUNCTION (rc, Scores_CountFragsRemaining)
 
 MUTATOR_HOOKFUNCTION (rc, GetRecords)
 
 MUTATOR_HOOKFUNCTION (rc, HideTeamNagger)
 
 MUTATOR_HOOKFUNCTION (rc, FixClientCvars)
 
 MUTATOR_HOOKFUNCTION (rc, CheckRules_World)
 
 MUTATOR_HOOKFUNCTION (rc, ReadLevelCvars)
 
void race_EventLog (string mode, entity actor)
 
void race_Initialize ()
 
void race_ScoreRules ()
 
void rc_SetLimits ()
 
float WinningCondition_QualifyingThenRace (float limit)
 
float WinningCondition_Race (float fraglimit)
 

Variables

float autocvar_g_race_qualifying_timelimit
 
float autocvar_g_race_qualifying_timelimit_override
 
int autocvar_g_race_teams
 
float race_checkpoint
 

Macro Definition Documentation

◆ autocvar_g_race_laps_limit

#define autocvar_g_race_laps_limit   cvar("g_race_laps_limit")

Definition at line 11 of file sv_race.qc.

Referenced by rc_SetLimits().

Function Documentation

◆ havocbot_role_race()

void havocbot_role_race ( entity  this)

Definition at line 18 of file sv_race.qc.

References g_racecheckpoints, IL_EACH, IS_DEAD, LABEL, navigation_goalrating_end(), navigation_goalrating_start(), navigation_goalrating_timeout(), navigation_goalrating_timeout_set(), navigation_routerating(), and race_checkpoint.

Referenced by MUTATOR_HOOKFUNCTION().

19 {
20  if(IS_DEAD(this))
21  return;
22 
24  {
26 
27  bool raw_touch_check = true;
28  int cp = this.race_checkpoint;
29 
30  LABEL(search_racecheckpoints)
32  {
33  if(it.cnt == cp || cp == -1)
34  {
35  // redirect bot to next goal if it touched the waypoint of an untouchable checkpoint
36  // e.g. checkpoint in front of Stormkeep's warpzone
37  // the same workaround is applied in CTS game mode
38  if (raw_touch_check && vdist(this.origin - it.nearestwaypoint.origin, <, 30))
39  {
40  cp = race_NextCheckpoint(cp);
41  raw_touch_check = false;
42  goto search_racecheckpoints;
43  }
44  navigation_routerating(this, it, 1000000, 5000);
45  }
46  });
47 
49 
51  }
52 }
#define IL_EACH(this, cond, body)
void navigation_goalrating_start(entity this)
Definition: navigation.qc:1830
void navigation_goalrating_end(entity this)
Definition: navigation.qc:1845
void navigation_routerating(entity this, entity e, float f, float rangebias)
Definition: navigation.qc:1220
bool navigation_goalrating_timeout(entity this)
Definition: navigation.qc:43
IntrusiveList g_racecheckpoints
Definition: race.qc:69
#define IS_DEAD(s)
Definition: utils.qh:26
void navigation_goalrating_timeout_set(entity this)
Definition: navigation.qc:19
float race_checkpoint
Definition: sv_race.qc:17
#define LABEL(id)
Definition: compiler.qh:36
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MUTATOR_HOOKFUNCTION() [1/20]

MUTATOR_HOOKFUNCTION ( rc  ,
ClientKill   
)

Definition at line 115 of file sv_race.qc.

References g_race_qualifying, and M_ARGV.

116 {
118  M_ARGV(1, float) = 0; // killtime
119 }
bool g_race_qualifying
Definition: race.qh:12
#define M_ARGV(x, type)
Definition: events.qh:17

◆ MUTATOR_HOOKFUNCTION() [2/20]

MUTATOR_HOOKFUNCTION ( rc  ,
AbortSpeedrun   
)

Definition at line 121 of file sv_race.qc.

References autocvar_g_allow_checkpoints, entity(), M_ARGV, and race_PreparePlayer().

122 {
123  entity player = M_ARGV(0, entity);
124 
126  race_PreparePlayer(player); // nice try
127 }
entity() spawn
bool autocvar_g_allow_checkpoints
Definition: race.qh:3
void race_PreparePlayer(entity this)
Definition: race.qc:1180
#define M_ARGV(x, type)
Definition: events.qh:17
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [3/20]

MUTATOR_HOOKFUNCTION ( rc  ,
PlayerPhysics   
)

Definition at line 129 of file sv_race.qc.

References CS(), entity(), fabs(), floor(), IS_PLAYER, M_ARGV, M_SQRT1_2, movement, MOVETYPE_NONE, set_movetype(), time, vector(), and vlen().

130 {
131  entity player = M_ARGV(0, entity);
132  float dt = M_ARGV(1, float);
133 
134  player.race_movetime_frac += dt;
135  float f = floor(player.race_movetime_frac);
136  player.race_movetime_frac -= f;
137  player.race_movetime_count += f;
138  player.race_movetime = player.race_movetime_frac + player.race_movetime_count;
139 
140  if(IS_PLAYER(player))
141  {
142  if (player.race_penalty)
143  if (time > player.race_penalty)
144  player.race_penalty = 0;
145  if(player.race_penalty)
146  {
147  player.velocity = '0 0 0';
148  set_movetype(player, MOVETYPE_NONE);
149  player.disableclientprediction = 2;
150  }
151  }
152 
153  // force kbd movement for fairness
154  float wishspeed;
155  vector wishvel;
156 
157  // if record times matter
158  // ensure nothing EVIL is being done (i.e. div0_evade)
159  // this hinders joystick users though
160  // but it still gives SOME analog control
161  wishvel.x = fabs(CS(player).movement.x);
162  wishvel.y = fabs(CS(player).movement.y);
163  if(wishvel.x != 0 && wishvel.y != 0 && wishvel.x != wishvel.y)
164  {
165  wishvel.z = 0;
166  wishspeed = vlen(wishvel);
167  if(wishvel.x >= 2 * wishvel.y)
168  {
169  // pure X motion
170  if(CS(player).movement.x > 0)
171  CS(player).movement_x = wishspeed;
172  else
173  CS(player).movement_x = -wishspeed;
174  CS(player).movement_y = 0;
175  }
176  else if(wishvel.y >= 2 * wishvel.x)
177  {
178  // pure Y motion
179  CS(player).movement_x = 0;
180  if(CS(player).movement.y > 0)
181  CS(player).movement_y = wishspeed;
182  else
183  CS(player).movement_y = -wishspeed;
184  }
185  else
186  {
187  // diagonal
188  if(CS(player).movement.x > 0)
189  CS(player).movement_x = M_SQRT1_2 * wishspeed;
190  else
191  CS(player).movement_x = -M_SQRT1_2 * wishspeed;
192  if(CS(player).movement.y > 0)
193  CS(player).movement_y = M_SQRT1_2 * wishspeed;
194  else
195  CS(player).movement_y = -M_SQRT1_2 * wishspeed;
196  }
197  }
198 }
float MOVETYPE_NONE
Definition: progsdefs.qc:246
entity() spawn
ClientState CS(Client this)
Definition: state.qh:47
const float M_SQRT1_2
Definition: mathlib.qh:115
#define M_ARGV(x, type)
Definition: events.qh:17
vector movement
vector(float skel, float bonenum) _skel_get_boneabs_hidden
float time
Definition: csprogsdefs.qc:16
void set_movetype(entity this, int mt)
#define IS_PLAYER(v)
Definition: utils.qh:9
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [4/20]

MUTATOR_HOOKFUNCTION ( rc  ,
reset_map_global   
)

Definition at line 200 of file sv_race.qc.

References cvar_set(), FOREACH_CLIENT, ftos(), g_race_qualifying, independent_players, NULL, PlayerScore_Sort(), race_ClearRecords(), race_EventLog(), race_fraglimit, race_leadlimit, race_place, race_ScoreRules(), race_timelimit, and Score_NicePrint().

201 {
202  float s;
203 
205 
207  PlayerScore_Sort(race_place, 0, true, false);
208 
209  FOREACH_CLIENT(true, {
210  if(it.race_place)
211  {
212  s = GameRules_scoring_add(it, RACE_FASTEST, 0);
213  if(!s)
214  it.race_place = 0;
215  }
216  race_EventLog(ftos(it.race_place), it);
217  });
218 
219  if(g_race_qualifying == 2)
220  {
221  g_race_qualifying = 0;
223  cvar_set("fraglimit", ftos(race_fraglimit));
224  cvar_set("leadlimit", ftos(race_leadlimit));
225  cvar_set("timelimit", ftos(race_timelimit));
226  race_ScoreRules();
227  }
228 }
float race_place
Definition: race.qh:23
void race_ClearRecords()
Definition: race.qc:1210
void Score_NicePrint(entity to)
Prints the scores to the console of a player.
Definition: scores.qc:903
#define FOREACH_CLIENT(cond, body)
Definition: utils.qh:49
bool g_race_qualifying
Definition: race.qh:12
void race_ScoreRules()
Definition: sv_race.qc:54
#define NULL
Definition: post.qh:17
void race_EventLog(string mode, entity actor)
Definition: sv_race.qc:71
entity PlayerScore_Sort(.float field, int teams, bool strict, bool nospectators)
Sorts the players and stores their place in the given field, starting with.
Definition: scores.qc:724
bool independent_players
Definition: client.qh:312
float race_fraglimit
Definition: race.qh:20
float race_leadlimit
Definition: race.qh:21
float race_timelimit
Definition: race.qh:22
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [5/20]

MUTATOR_HOOKFUNCTION ( rc  ,
ClientConnect   
)

Definition at line 230 of file sv_race.qc.

References entity(), M_ARGV, race_PreparePlayer(), and race_SendAll().

231 {
232  entity player = M_ARGV(0, entity);
233 
234  race_PreparePlayer(player);
235  player.race_checkpoint = -1;
236 
237  race_SendAll(player, false);
238 }
void race_SendAll(entity player, bool only_rankings)
Definition: race.qc:324
entity() spawn
void race_PreparePlayer(entity this)
Definition: race.qc:1180
#define M_ARGV(x, type)
Definition: events.qh:17
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [6/20]

MUTATOR_HOOKFUNCTION ( rc  ,
MakePlayerObserver   
)

Definition at line 240 of file sv_race.qc.

References entity(), FRAGS_PLAYER_OUT_OF_GAME, FRAGS_SPECTATOR, g_race_qualifying, GameRules_scoring_add, M_ARGV, and race_PreparePlayer().

241 {
242  entity player = M_ARGV(0, entity);
243 
245  {
246  if(GameRules_scoring_add(player, RACE_FASTEST, 0))
247  player.frags = FRAGS_PLAYER_OUT_OF_GAME;
248  else
249  player.frags = FRAGS_SPECTATOR;
250  }
251 
252  race_PreparePlayer(player);
253  player.race_checkpoint = -1;
254 }
entity() spawn
#define GameRules_scoring_add(client, fld, value)
Definition: sv_rules.qh:78
bool g_race_qualifying
Definition: race.qh:12
void race_PreparePlayer(entity this)
Definition: race.qc:1180
#define M_ARGV(x, type)
Definition: events.qh:17
const int FRAGS_PLAYER_OUT_OF_GAME
Definition: constants.qh:5
const int FRAGS_SPECTATOR
Definition: constants.qh:4
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [7/20]

MUTATOR_HOOKFUNCTION ( rc  ,
PlayerSpawn   
)

Definition at line 256 of file sv_race.qc.

References entity(), M_ARGV, and race_PreparePlayer().

257 {
258  entity player = M_ARGV(0, entity);
259  entity spawn_spot = M_ARGV(1, entity);
260 
261  if(spawn_spot.target == "")
262  // Emergency: this wasn't a real spawnpoint. Can this ever happen?
263  race_PreparePlayer(player);
264 
265  // if we need to respawn, do it right
266  player.race_respawn_checkpoint = player.race_checkpoint;
267  player.race_respawn_spotref = spawn_spot;
268 
269  player.race_place = 0;
270 }
entity() spawn
void race_PreparePlayer(entity this)
Definition: race.qc:1180
#define M_ARGV(x, type)
Definition: events.qh:17
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [8/20]

MUTATOR_HOOKFUNCTION ( rc  ,
PutClientInServer   
)

Definition at line 272 of file sv_race.qc.

References CS(), entity(), FRAGS_SPECTATOR, g_race_qualifying, IS_PLAYER, killcount, M_ARGV, race_AbandonRaceCheck(), race_PreparePlayer(), and race_RetractPlayer().

273 {
274  entity player = M_ARGV(0, entity);
275 
276  if(IS_PLAYER(player))
277  if(!game_stopped)
278  {
279  if(CS(player).killcount == FRAGS_SPECTATOR /* initial spawn */ || g_race_qualifying) // spawn
280  race_PreparePlayer(player);
281  else // respawn
282  race_RetractPlayer(player);
283 
284  race_AbandonRaceCheck(player);
285  }
286 }
entity() spawn
ClientState CS(Client this)
Definition: state.qh:47
int killcount
Definition: client.qh:317
bool g_race_qualifying
Definition: race.qh:12
void race_PreparePlayer(entity this)
Definition: race.qc:1180
#define M_ARGV(x, type)
Definition: events.qh:17
const int FRAGS_SPECTATOR
Definition: constants.qh:4
void race_RetractPlayer(entity this)
Definition: race.qc:1189
#define IS_PLAYER(v)
Definition: utils.qh:9
void race_AbandonRaceCheck(entity p)
Definition: race.qc:1163
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [9/20]

MUTATOR_HOOKFUNCTION ( rc  ,
PlayerDamaged   
)

Definition at line 288 of file sv_race.qc.

References M_ARGV.

289 {
290  int frag_deathtype = M_ARGV(5, int);
291  if (frag_deathtype == DEATH_KILL.m_id)
292  return true; // forbid logging damage
293 }
#define M_ARGV(x, type)
Definition: events.qh:17

◆ MUTATOR_HOOKFUNCTION() [10/20]

MUTATOR_HOOKFUNCTION ( rc  ,
PlayerDies   
)

Definition at line 295 of file sv_race.qc.

References entity(), M_ARGV, race_AbandonRaceCheck(), and RESPAWN_FORCE.

296 {
297  entity frag_target = M_ARGV(2, entity);
298 
299  frag_target.respawn_flags |= RESPAWN_FORCE;
300  race_AbandonRaceCheck(frag_target);
301 }
const int RESPAWN_FORCE
Definition: client.qh:330
entity() spawn
#define M_ARGV(x, type)
Definition: events.qh:17
void race_AbandonRaceCheck(entity p)
Definition: race.qc:1163
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [11/20]

MUTATOR_HOOKFUNCTION ( rc  ,
HavocBot_ChooseRole   
)

Definition at line 303 of file sv_race.qc.

References entity(), havocbot_role_race(), and M_ARGV.

304 {
305  entity bot = M_ARGV(0, entity);
306 
307  bot.havocbot_role = havocbot_role_race;
308  return true;
309 }
entity() spawn
#define M_ARGV(x, type)
Definition: events.qh:17
void havocbot_role_race(entity this)
Definition: sv_race.qc:18
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [12/20]

MUTATOR_HOOKFUNCTION ( rc  ,
GetPressedKeys   
)

Definition at line 311 of file sv_race.qc.

References entity(), M_ARGV, race_checkAndWriteName(), and race_SpeedAwardFrame().

312 {
313  entity player = M_ARGV(0, entity);
314 
315  race_checkAndWriteName(player);
316  race_SpeedAwardFrame(player);
317 }
entity() spawn
void race_checkAndWriteName(entity player)
Definition: race.qc:143
void race_SpeedAwardFrame(entity player)
Definition: race.qc:296
#define M_ARGV(x, type)
Definition: events.qh:17
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [13/20]

MUTATOR_HOOKFUNCTION ( rc  ,
ForbidPlayerScore_Clear   
)

Definition at line 319 of file sv_race.qc.

References g_race_qualifying.

320 {
322  return true; // in qualifying, you don't lose score by observing
323 }
bool g_race_qualifying
Definition: race.qh:12

◆ MUTATOR_HOOKFUNCTION() [14/20]

MUTATOR_HOOKFUNCTION ( rc  ,
TeamBalance_CheckAllowedTeams  ,
CBC_ORDER_EXCLUSIVE   
)

Definition at line 325 of file sv_race.qc.

References M_ARGV, and race_teams.

326 {
327  M_ARGV(0, float) = race_teams;
328  return true;
329 }
#define M_ARGV(x, type)
Definition: events.qh:17
float race_teams
Definition: race.qh:5

◆ MUTATOR_HOOKFUNCTION() [15/20]

MUTATOR_HOOKFUNCTION ( rc  ,
Scores_CountFragsRemaining   
)

Definition at line 331 of file sv_race.qc.

References g_race_qualifying.

332 {
333  // announce remaining frags if not in qualifying mode
334  if(!g_race_qualifying)
335  return true;
336 }
bool g_race_qualifying
Definition: race.qh:12

◆ MUTATOR_HOOKFUNCTION() [16/20]

MUTATOR_HOOKFUNCTION ( rc  ,
GetRecords   
)

Definition at line 338 of file sv_race.qc.

References M_ARGV, MapInfo_count, MapInfo_Get_ByID(), MapInfo_Map_bspname, race_readName(), race_readTime(), strcat(), and TIME_ENCODED_TOSTRING.

339 {
340  int record_page = M_ARGV(0, int);
341  string ret_string = M_ARGV(1, string);
342 
343  for(int i = record_page * 200; i < MapInfo_count && i < record_page * 200 + 200; ++i)
344  {
345  if(MapInfo_Get_ByID(i))
346  {
347  float r = race_readTime(MapInfo_Map_bspname, 1);
348 
349  if(!r)
350  continue;
351 
352  string h = race_readName(MapInfo_Map_bspname, 1);
353  ret_string = strcat(ret_string, strpad(32, MapInfo_Map_bspname), " ", strpad(-8, TIME_ENCODED_TOSTRING(r)), " ", h, "\n");
354  }
355  }
356 
357  M_ARGV(1, string) = ret_string;
358 }
bool MapInfo_Get_ByID(int i)
Definition: mapinfo.qc:256
#define TIME_ENCODED_TOSTRING(n)
Definition: util.qh:57
float MapInfo_count
Definition: mapinfo.qh:144
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
float race_readTime(string map, float pos)
Definition: race.qc:78
#define M_ARGV(x, type)
Definition: events.qh:17
string race_readName(string map, float pos)
Definition: race.qc:138
string MapInfo_Map_bspname
Definition: mapinfo.qh:6
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [17/20]

MUTATOR_HOOKFUNCTION ( rc  ,
HideTeamNagger   
)

Definition at line 360 of file sv_race.qc.

361 {
362  return true; // doesn't work so well
363 }

◆ MUTATOR_HOOKFUNCTION() [18/20]

MUTATOR_HOOKFUNCTION ( rc  ,
FixClientCvars   
)

Definition at line 365 of file sv_race.qc.

References entity(), M_ARGV, and stuffcmd.

366 {
367  entity player = M_ARGV(0, entity);
368 
369  stuffcmd(player, "cl_cmd settemp cl_movecliptokeyboard 2\n");
370 }
entity() spawn
#define M_ARGV(x, type)
Definition: events.qh:17
#define stuffcmd(cl,...)
Definition: progsdefs.qh:23
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [19/20]

MUTATOR_HOOKFUNCTION ( rc  ,
CheckRules_World   
)

Definition at line 372 of file sv_race.qc.

References g_race_qualifying, M_ARGV, WinningCondition_QualifyingThenRace(), and WinningCondition_Race().

373 {
374  float checkrules_timelimit = M_ARGV(1, float);
375  float checkrules_fraglimit = M_ARGV(2, float);
376 
377  if(checkrules_timelimit >= 0)
378  {
379  if(!g_race_qualifying)
380  {
381  M_ARGV(0, float) = WinningCondition_Race(checkrules_fraglimit);
382  return true;
383  }
384  else if(g_race_qualifying == 2)
385  {
386  M_ARGV(0, float) = WinningCondition_QualifyingThenRace(checkrules_fraglimit);
387  return true;
388  }
389  }
390 }
bool g_race_qualifying
Definition: race.qh:12
float WinningCondition_QualifyingThenRace(float limit)
Definition: sv_race.qc:101
#define M_ARGV(x, type)
Definition: events.qh:17
float WinningCondition_Race(float fraglimit)
Definition: sv_race.qc:77
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [20/20]

MUTATOR_HOOKFUNCTION ( rc  ,
ReadLevelCvars   
)

Definition at line 392 of file sv_race.qc.

References g_race_qualifying, and warmup_stage.

393 {
394  if(g_race_qualifying == 2)
395  warmup_stage = 0;
396 }
bool warmup_stage
Definition: main.qh:103
bool g_race_qualifying
Definition: race.qh:12

◆ race_EventLog()

void race_EventLog ( string  mode,
entity  actor 
)

Definition at line 71 of file sv_race.qc.

References autocvar_sv_eventlog, ftos(), GameLogEcho(), NULL, and strcat().

Referenced by MUTATOR_HOOKFUNCTION().

72 {
74  GameLogEcho(strcat(":race:", mode, ":", ((actor != NULL) ? (strcat(":", ftos(actor.playerid))) : "")));
75 }
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
#define NULL
Definition: post.qh:17
void GameLogEcho(string s)
Definition: gamelog.qc:12
bool autocvar_sv_eventlog
Definition: gamelog.qh:3
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ race_Initialize()

void race_Initialize ( )

Definition at line 398 of file sv_race.qc.

References g_race_qualifying, race_ScoreRules(), and warmup_stage.

Referenced by REGISTER_MUTATOR().

399 {
400  race_ScoreRules();
401  if(g_race_qualifying == 2)
402  warmup_stage = 0;
403  radar_showenemies = true;
404 }
bool warmup_stage
Definition: main.qh:103
bool g_race_qualifying
Definition: race.qh:12
void race_ScoreRules()
Definition: sv_race.qc:54
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ race_ScoreRules()

void race_ScoreRules ( )

Definition at line 54 of file sv_race.qc.

References g_race_qualifying, GameRules_score_enabled(), GameRules_scoring, race_teams, SFL_LOWER_IS_BETTER, SFL_SORT_PRIO_PRIMARY, SFL_SORT_PRIO_SECONDARY, SFL_TIME, and ST_RACE_LAPS.

Referenced by MUTATOR_HOOKFUNCTION(), and race_Initialize().

55 {
58  if (race_teams)
59  field_team(ST_RACE_LAPS, "laps", SFL_SORT_PRIO_PRIMARY);
60  else if (g_race_qualifying)
61  field(SP_RACE_FASTEST, "fastest", SFL_SORT_PRIO_PRIMARY | SFL_LOWER_IS_BETTER | SFL_TIME);
63  {
64  field(SP_RACE_LAPS, "laps", SFL_SORT_PRIO_PRIMARY);
65  field(SP_RACE_TIME, "time", SFL_SORT_PRIO_SECONDARY | SFL_LOWER_IS_BETTER | SFL_TIME);
66  field(SP_RACE_FASTEST, "fastest", SFL_LOWER_IS_BETTER | SFL_TIME);
67  }
68  });
69 }
#define GameRules_scoring(teams, spprio, stprio, fields)
Definition: sv_rules.qh:53
const int SFL_SORT_PRIO_SECONDARY
Scoring priority (NOTE: PRIMARY is used for fraglimit)
Definition: scores.qh:126
const int SFL_SORT_PRIO_PRIMARY
Definition: scores.qh:127
void GameRules_score_enabled(bool value)
Disabling score disables the "score" column on the scoreboard.
Definition: sv_rules.qc:28
bool g_race_qualifying
Definition: race.qh:12
const int SFL_LOWER_IS_BETTER
Lower scores are better (e.g.
Definition: scores.qh:98
const float ST_RACE_LAPS
Definition: race.qh:8
const int SFL_TIME
Display as mm:ss.s, value is stored as 10ths of a second (AND 0 is the worst possible value!) ...
Definition: scores.qh:118
float race_teams
Definition: race.qh:5
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ rc_SetLimits()

void rc_SetLimits ( )

Definition at line 406 of file sv_race.qc.

References autocvar_g_campaign, autocvar_g_race_laps_limit, autocvar_g_race_qualifying_timelimit, autocvar_g_race_qualifying_timelimit_override, autocvar_g_race_teams, BITS, bound(), g_race_qualifying, GameRules_limit_lead(), GameRules_limit_score(), GameRules_limit_time(), GameRules_limit_time_qualifying(), GameRules_teams(), independent_players, race_fraglimit, race_leadlimit, RACE_RECORD, race_teams, race_timelimit, and record_type.

Referenced by REGISTER_MUTATOR().

407 {
408  int fraglimit_override, leadlimit_override;
409  float timelimit_override, qualifying_override;
410 
412  {
413  GameRules_teams(true);
415  }
416  else
417  race_teams = 0;
418 
419  qualifying_override = autocvar_g_race_qualifying_timelimit_override;
420  fraglimit_override = autocvar_g_race_laps_limit;
421  leadlimit_override = 0; // currently not supported by race
422  timelimit_override = autocvar_timelimit_override;
423 
424  float want_qualifying = ((qualifying_override >= 0) ? qualifying_override : autocvar_g_race_qualifying_timelimit) > 0;
425 
427 
429  {
430  g_race_qualifying = 1;
432  }
433  else if(want_qualifying)
434  {
435  g_race_qualifying = 2;
437  race_fraglimit = (fraglimit_override >= 0) ? fraglimit_override : autocvar_fraglimit;
438  race_leadlimit = (leadlimit_override >= 0) ? leadlimit_override : autocvar_leadlimit;
439  race_timelimit = (timelimit_override >= 0) ? timelimit_override : autocvar_timelimit;
440  qualifying_override = (qualifying_override >= 0) ? qualifying_override : autocvar_g_race_qualifying_timelimit;
441  fraglimit_override = 0;
442  leadlimit_override = 0;
443  timelimit_override = qualifying_override;
444  }
445  else
446  g_race_qualifying = 0;
447  GameRules_limit_score(fraglimit_override);
448  GameRules_limit_lead(leadlimit_override);
449  GameRules_limit_time(timelimit_override);
450  GameRules_limit_time_qualifying(qualifying_override);
451 }
float autocvar_g_race_qualifying_timelimit_override
Definition: sv_race.qc:13
#define autocvar_g_race_laps_limit
Definition: sv_race.qc:11
void GameRules_limit_score(int limit)
Definition: sv_rules.qc:34
#define RACE_RECORD
Definition: util.qh:58
bool g_race_qualifying
Definition: race.qh:12
void GameRules_limit_time_qualifying(int limit)
Definition: sv_rules.qc:64
void GameRules_limit_time(int limit)
Definition: sv_rules.qc:54
void GameRules_teams(bool value)
Definition: sv_rules.qc:6
string record_type
Definition: world.qh:49
int autocvar_g_race_teams
Definition: sv_race.qc:14
bool independent_players
Definition: client.qh:312
float race_fraglimit
Definition: race.qh:20
float autocvar_g_race_qualifying_timelimit
Definition: sv_race.qc:12
void GameRules_limit_lead(int limit)
Definition: sv_rules.qc:44
bool autocvar_g_campaign
Definition: campaign.qh:6
float race_leadlimit
Definition: race.qh:21
#define BITS(n)
Definition: bits.qh:9
float race_timelimit
Definition: race.qh:22
float race_teams
Definition: race.qh:5
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ WinningCondition_QualifyingThenRace()

float WinningCondition_QualifyingThenRace ( float  limit)

Definition at line 101 of file sv_race.qc.

References WINNING_STARTSUDDENDEATHOVERTIME, WINNING_YES, and WinningCondition_Scores().

Referenced by MUTATOR_HOOKFUNCTION().

102 {
103  float wc;
104  wc = WinningCondition_Scores(limit, 0);
105 
106  // NEVER initiate overtime
108  {
109  return WINNING_YES;
110  }
111 
112  return wc;
113 }
const int WINNING_STARTSUDDENDEATHOVERTIME
Definition: world.qh:138
const int WINNING_YES
Definition: world.qh:136
float WinningCondition_Scores(float limit, float leadlimit)
Definition: world.qc:1428
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ WinningCondition_Race()

float WinningCondition_Race ( float  fraglimit)

Definition at line 77 of file sv_race.qc.

References CS(), FOREACH_CLIENT, IS_PLAYER, race_completed, WINNING_NEVER, WINNING_STARTSUDDENDEATHOVERTIME, WINNING_YES, and WinningCondition_Scores().

Referenced by MUTATOR_HOOKFUNCTION().

78 {
79  float wc;
80  float n, c;
81 
82  n = 0;
83  c = 0;
85  ++n;
86  if(CS(it).race_completed)
87  ++c;
88  });
89  if(n && (n == c))
90  return WINNING_YES;
91  wc = WinningCondition_Scores(fraglimit, 0);
92 
93  // ALWAYS initiate overtime, unless EVERYONE has finished the race!
95  // do NOT support equality when the laps are all raced!
97  else
98  return WINNING_NEVER;
99 }
ClientState CS(Client this)
Definition: state.qh:47
#define FOREACH_CLIENT(cond, body)
Definition: utils.qh:49
const int WINNING_STARTSUDDENDEATHOVERTIME
Definition: world.qh:138
const int WINNING_YES
Definition: world.qh:136
const int WINNING_NEVER
Definition: world.qh:137
float race_completed
Definition: race.qh:25
float WinningCondition_Scores(float limit, float leadlimit)
Definition: world.qc:1428
#define IS_PLAYER(v)
Definition: utils.qh:9
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ autocvar_g_race_qualifying_timelimit

float autocvar_g_race_qualifying_timelimit

Definition at line 12 of file sv_race.qc.

Referenced by rc_SetLimits().

◆ autocvar_g_race_qualifying_timelimit_override

float autocvar_g_race_qualifying_timelimit_override

Definition at line 13 of file sv_race.qc.

Referenced by rc_SetLimits().

◆ autocvar_g_race_teams

int autocvar_g_race_teams

Definition at line 14 of file sv_race.qc.

Referenced by rc_SetLimits().

◆ race_checkpoint

float race_checkpoint

Definition at line 17 of file sv_race.qc.

Referenced by havocbot_role_race().