Xonotic
client.qh File Reference
#include "utils.qh"
#include <server/intermission.qh>
#include <common/replicate.qh>
#include <common/sounds/all.qh>
+ Include dependency graph for client.qh:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Client
 
class  Observer
 
class  Player
 
class  Spectator
 

Macros

#define GAMETYPE_DEFAULTED_SETTING(str)
 
#define INDEPENDENT_PLAYERS   (autocvar__independent_players ? (autocvar__independent_players > 0) : independent_players)
 
#define IS_INDEPENDENT_PLAYER(e)   ((e).solid == SOLID_TRIGGER)
 
#define MAKE_INDEPENDENT_PLAYER(e)   (((e).solid = SOLID_TRIGGER), ((e).frags = FRAGS_PLAYER_OUT_OF_GAME))
 
#define SPECTATE_COPY()   ACCUMULATE void SpectateCopy(entity this, entity spectatee)
 
#define SPECTATE_COPYFIELD(fld)   SPECTATE_COPY() { this.(fld) = spectatee.(fld); }
 
#define UNWIND(class)   MACRO_BEGIN if (this.instanceOf##class) { METHOD_REFERENCE(class, dtorimpl)(this); } MACRO_END
 

Functions

void calculate_player_respawn_time (entity this)
 
void ClientData_Touch (entity e)
 
void ClientInit_misc (entity this)
 
void ClientInit_Spawn ()
 
void ClientState_attach (entity this)
 
void FixClientCvars (entity e)
 
void FixPlayermodel (entity player)
 
int GetPlayerLimit ()
 
void Join (entity this)
 
bool joinAllowed (entity this)
 
int nJoinAllowed (entity this, entity ignore)
 Determines whether the player is allowed to join. More...
 
void play_countdown (entity this, float finished, Sound samp)
 
void player_powerups_remove_all (entity this)
 
bool PlayerInList (entity player, string list)
 
void PlayerUseKey (entity this)
 
void PutObserverInServer (entity this, bool is_forced, bool use_spawnpoint)
 putting a client as observer in the server More...
 
void RotRegen (entity this, entity current, float limit_mod, float regenstable, float regenfactor, float regenlinear, float regenframetime, float rotstable, float rotfactor, float rotlinear, float rotframetime)
 
void SetSpectatee (entity this, entity spectatee)
 
void SetSpectatee_status (entity this, int spectatee_num)
 
bool Spectate (entity this, entity pl)
 
 STATIC_INIT (g_players)
 
 STATIC_INIT (g_initforplayer)
 
 void (entity this, entity player) init_for_player
 

Variables

float alivetime
 
int autocvar__independent_players
 
bool autocvar__notarget
 
int autocvar_g_balance_armor_start
 
float autocvar_g_balance_pause_armor_rot_spawn
 
float autocvar_g_balance_pause_fuel_rot_spawn
 
float autocvar_g_balance_pause_health_regen_spawn
 
float autocvar_g_balance_pause_health_rot_spawn
 
bool autocvar_g_botclip_collisions
 
bool autocvar_g_forced_respawn
 
bool autocvar_g_fullbrightplayers
 
int autocvar_g_maxplayers
 
float autocvar_g_maxplayers_spectator_blocktime
 
string autocvar_g_mutatormsg
 
bool autocvar_g_nodepthtestplayers
 
float autocvar_g_player_alpha
 
float autocvar_g_player_brightness
 
float autocvar_g_player_damageforcescale = 2
 
bool autocvar_g_playerclip_collisions
 
bool autocvar_g_respawn_delay_forced
 
float autocvar_g_respawn_delay_large
 
int autocvar_g_respawn_delay_large_count
 
float autocvar_g_respawn_delay_max
 
float autocvar_g_respawn_delay_small
 
int autocvar_g_respawn_delay_small_count
 
bool autocvar_g_respawn_ghosts
 
float autocvar_g_respawn_ghosts_alpha = 1
 
float autocvar_g_respawn_ghosts_fadetime = 1.5
 
float autocvar_g_respawn_ghosts_speed
 
float autocvar_g_respawn_ghosts_time = 4.5
 
int autocvar_g_respawn_waves
 
string autocvar_g_xonoticversion
 
float autocvar_gameversion
 
float autocvar_gameversion_max
 
float autocvar_gameversion_min
 
string autocvar_hostname
 
int autocvar_spawn_debug
 
float autocvar_sv_foginterval
 
float autocvar_sv_maxidle
 
bool autocvar_sv_maxidle_alsokickspectators
 
int autocvar_sv_maxidle_minplayers = 2
 
float autocvar_sv_maxidle_playertospectator = 60
 
int autocvar_sv_maxidle_slots
 
bool autocvar_sv_maxidle_slots_countbots
 
string autocvar_sv_motd
 
int autocvar_sv_name_maxlength = 64
 
float autocvar_sv_player_scale
 
bool autocvar_sv_servermodelsonly
 
bool autocvar_sv_showspectators
 
int autocvar_sv_spectate
 
bool autocvar_sv_teamnagger
 
float blockSpectators
 
entity clientdata
 
IntrusiveList g_initforplayer
 
IntrusiveList g_players
 
bool independent_players
 
float jointime
 
bool just_joined
 
int killcount
 
const int MAX_SPECTATORS = 7
 
const int MIN_SPEC_TIME = 1
 
float motd_actived_time
 
float nickspamcount
 
float nickspamtime
 
float pauseregen_finished
 
float pauserotarmor_finished
 
float pauserotfuel_finished
 
float pauserothealth_finished
 
bool player_blocked
 
int playerid
 
string playermodel
 
string playerskin
 
int pressedkeys
 
float respawn_countdown
 
const int RESPAWN_DENY = BIT(2)
 
int respawn_flags
 
const int RESPAWN_FORCE = BIT(0)
 
const int RESPAWN_SILENT = BIT(1)
 
float respawn_time
 
float respawn_time_max
 
int spectatee_status
 
float spectatortime
 
float startplaytime
 
const int SVC_SETVIEW = 5
 
bool wasplayer
 
string weaponorder_byimpulse
 
bool zoomstate
 

Macro Definition Documentation

◆ GAMETYPE_DEFAULTED_SETTING

#define GAMETYPE_DEFAULTED_SETTING (   str)
Value:
((gametype_setting_tmp = cvar(strcat("g_", GetGametype(), "_" #str))), \
(gametype_setting_tmp < 0) ? 0 \
: (gametype_setting_tmp == 0 || autocvar_g_respawn_delay_forced) ? max(0, autocvar_g_##str) \
: gametype_setting_tmp)
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"))
string GetGametype()
Definition: intermission.qc:13
bool autocvar_g_respawn_delay_forced
Definition: client.qh:26

Definition at line 352 of file client.qh.

Referenced by calculate_player_respawn_time().

◆ INDEPENDENT_PLAYERS

Definition at line 313 of file client.qh.

Referenced by PutPlayerInServer(), and ScoreRules_basics().

◆ IS_INDEPENDENT_PLAYER

◆ MAKE_INDEPENDENT_PLAYER

#define MAKE_INDEPENDENT_PLAYER (   e)    (((e).solid = SOLID_TRIGGER), ((e).frags = FRAGS_PLAYER_OUT_OF_GAME))

Definition at line 315 of file client.qh.

Referenced by PutPlayerInServer(), race_AbandonRaceCheck(), and race_SendTime().

◆ SPECTATE_COPY

#define SPECTATE_COPY ( )    ACCUMULATE void SpectateCopy(entity this, entity spectatee)

Definition at line 403 of file client.qh.

◆ SPECTATE_COPYFIELD

#define SPECTATE_COPYFIELD (   fld)    SPECTATE_COPY() { this.(fld) = spectatee.(fld); }

Definition at line 404 of file client.qh.

◆ UNWIND

#define UNWIND (   class)    MACRO_BEGIN if (this.instanceOf##class) { METHOD_REFERENCE(class, dtorimpl)(this); } MACRO_END

Function Documentation

◆ calculate_player_respawn_time()

void calculate_player_respawn_time ( entity  this)

Definition at line 1315 of file client.qc.

References autocvar_g_forced_respawn, ceil(), FOREACH_CLIENT, GAMETYPE_DEFAULTED_SETTING, IS_INDEPENDENT_PLAYER, IS_PLAYER, MUTATOR_CALLHOOK, respawn_countdown, respawn_flags, RESPAWN_FORCE, respawn_time, respawn_time_max, teamplay, and time.

Referenced by PlayerDamage().

1316 {
1317  if(MUTATOR_CALLHOOK(CalculateRespawnTime, this))
1318  return;
1319 
1320  float gametype_setting_tmp;
1321  float sdelay_max = GAMETYPE_DEFAULTED_SETTING(respawn_delay_max);
1322  float sdelay_small = GAMETYPE_DEFAULTED_SETTING(respawn_delay_small);
1323  float sdelay_large = GAMETYPE_DEFAULTED_SETTING(respawn_delay_large);
1324  float sdelay_small_count = GAMETYPE_DEFAULTED_SETTING(respawn_delay_small_count);
1325  float sdelay_large_count = GAMETYPE_DEFAULTED_SETTING(respawn_delay_large_count);
1326  float waves = GAMETYPE_DEFAULTED_SETTING(respawn_waves);
1327 
1328  float pcount = 1; // Include myself whether or not team is already set right and I'm a "player".
1329  if (teamplay)
1330  {
1331  FOREACH_CLIENT(IS_PLAYER(it) && it != this, {
1332  if(it.team == this.team)
1333  ++pcount;
1334  });
1335  if (sdelay_small_count == 0)
1336  sdelay_small_count = 1;
1337  if (sdelay_large_count == 0)
1338  sdelay_large_count = 1;
1339  }
1340  else
1341  {
1342  FOREACH_CLIENT(IS_PLAYER(it) && it != this, {
1343  ++pcount;
1344  });
1345  if (sdelay_small_count == 0)
1346  {
1347  if (IS_INDEPENDENT_PLAYER(this))
1348  {
1349  // Players play independently. No point in requiring enemies.
1350  sdelay_small_count = 1;
1351  }
1352  else
1353  {
1354  // Players play AGAINST each other. Enemies required.
1355  sdelay_small_count = 2;
1356  }
1357  }
1358  if (sdelay_large_count == 0)
1359  {
1360  if (IS_INDEPENDENT_PLAYER(this))
1361  {
1362  // Players play independently. No point in requiring enemies.
1363  sdelay_large_count = 1;
1364  }
1365  else
1366  {
1367  // Players play AGAINST each other. Enemies required.
1368  sdelay_large_count = 2;
1369  }
1370  }
1371  }
1372 
1373  float sdelay;
1374 
1375  if (pcount <= sdelay_small_count)
1376  sdelay = sdelay_small;
1377  else if (pcount >= sdelay_large_count)
1378  sdelay = sdelay_large;
1379  else // NOTE: this case implies sdelay_large_count > sdelay_small_count.
1380  sdelay = sdelay_small + (sdelay_large - sdelay_small) * (pcount - sdelay_small_count) / (sdelay_large_count - sdelay_small_count);
1381 
1382  if(waves)
1383  this.respawn_time = ceil((time + sdelay) / waves) * waves;
1384  else
1385  this.respawn_time = time + sdelay;
1386 
1387  if(sdelay < sdelay_max)
1388  this.respawn_time_max = time + sdelay_max;
1389  else
1390  this.respawn_time_max = this.respawn_time;
1391 
1392  if((sdelay + waves >= 5.0) && (this.respawn_time - time > 1.75))
1393  this.respawn_countdown = 10; // first number to count down from is 10
1394  else
1395  this.respawn_countdown = -1; // do not count down
1396 
1399 }
const int RESPAWN_FORCE
Definition: client.qh:330
float respawn_countdown
Definition: client.qh:328
int respawn_flags
Definition: client.qh:324
float respawn_time
Definition: client.qh:325
#define IS_INDEPENDENT_PLAYER(e)
Definition: client.qh:314
#define FOREACH_CLIENT(cond, body)
Definition: utils.qh:49
bool autocvar_g_forced_respawn
Definition: client.qh:42
float respawn_time_max
Definition: client.qh:326
float teamplay
Definition: progsdefs.qc:31
#define MUTATOR_CALLHOOK(id,...)
Definition: base.qh:140
#define GAMETYPE_DEFAULTED_SETTING(str)
Definition: client.qh:352
float time
Definition: csprogsdefs.qc:16
#define IS_PLAYER(v)
Definition: utils.qh:9
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ClientData_Touch()

void ClientData_Touch ( entity  e)

Definition at line 171 of file client.qc.

References CS(), entity(), FOREACH_CLIENT, IS_REAL_CLIENT, and IS_SPEC.

Referenced by race_AbandonRaceCheck(), race_SendTime(), SetSpectatee(), SetSpectatee_status(), SetZoomState(), and SpectateSet().

172 {
173  entity cd = CS(e).clientdata;
174  if (cd) { cd.SendFlags = 1; }
175 
176  // make it spectatable
177  FOREACH_CLIENT(IS_REAL_CLIENT(it) && it != e && IS_SPEC(it) && it.enemy == e,
178  {
179  entity cd = CS(it).clientdata;
180  if (cd) { cd.SendFlags = 1; }
181  });
182 }
entity() spawn
ClientState CS(Client this)
Definition: state.qh:47
#define FOREACH_CLIENT(cond, body)
Definition: utils.qh:49
#define IS_REAL_CLIENT(v)
Definition: utils.qh:17
#define IS_SPEC(v)
Definition: utils.qh:10
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ClientInit_misc()

void ClientInit_misc ( entity  this)

Definition at line 855 of file client.qc.

References autocvar_g_trueaim_minrange, autocvar_sv_foginterval, cnt, compressShotOrigin(), count, g_nexball_meter_period, hook_shotorigin, MSG_ONE, serverflags, world, WriteByte(), WriteCoord(), and WriteString().

Referenced by ClientInit_SendEntity(), and STATIC_INIT().

856 {
857  int channel = MSG_ONE;
858  WriteHeader(channel, ENT_CLIENT_INIT);
859  WriteByte(channel, g_nexball_meter_period * 32);
860  WriteInt24_t(channel, compressShotOrigin(hook_shotorigin[0]));
861  WriteInt24_t(channel, compressShotOrigin(hook_shotorigin[1]));
862  WriteInt24_t(channel, compressShotOrigin(hook_shotorigin[2]));
863  WriteInt24_t(channel, compressShotOrigin(hook_shotorigin[3]));
864  WriteInt24_t(channel, compressShotOrigin(arc_shotorigin[0]));
865  WriteInt24_t(channel, compressShotOrigin(arc_shotorigin[1]));
866  WriteInt24_t(channel, compressShotOrigin(arc_shotorigin[2]));
867  WriteInt24_t(channel, compressShotOrigin(arc_shotorigin[3]));
868 
869  if(autocvar_sv_foginterval && world.fog != "")
870  WriteString(channel, world.fog);
871  else
872  WriteString(channel, "");
873  WriteByte(channel, this.count * 255.0); // g_balance_armor_blockpercent
874  WriteByte(channel, this.cnt * 255.0); // g_balance_damagepush_speedfactor
875  WriteByte(channel, serverflags);
877 }
int serverflags
Definition: main.qh:184
entity world
Definition: csprogsdefs.qc:15
float g_nexball_meter_period
Definition: sv_nexball.qh:54
vector hook_shotorigin[4]
Definition: main.qh:177
float compressShotOrigin(vector v)
Definition: util.qc:1121
float autocvar_g_trueaim_minrange
Definition: tracing.qh:16
float cnt
Definition: powerups.qc:24
float autocvar_sv_foginterval
Definition: client.qh:35
float count
Definition: powerups.qc:22
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ClientInit_Spawn()

void ClientInit_Spawn ( )

Definition at line 894 of file client.qc.

References ClientInit_CheckUpdate(), ClientInit_SendEntity(), entity(), new_pure, and setthink.

Referenced by spawnfunc(), and STATIC_INIT().

895 {
896  entity e = new_pure(clientinit);
898  Net_LinkEntity(e, false, 0, ClientInit_SendEntity);
899 
901 }
void ClientInit_CheckUpdate(entity this)
Definition: client.qc:879
entity() spawn
#define new_pure(class)
purely logical entities (.origin doesn&#39;t work)
Definition: oo.qh:62
#define setthink(e, f)
bool ClientInit_SendEntity(entity this, entity to, int sf)
Definition: client.qc:843
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ClientState_attach()

void ClientState_attach ( entity  this)

Definition at line 46 of file state.qc.

References _cs, accuracy_free(), accuracy_init(), anticheat_init(), anticheat_report_to_eventlog(), bot_clientdisconnect(), ClientData_Attach(), ClientData_Detach(), DecodeLevelParms(), entcs_attach(), entcs_detach(), entity(), InventoryStorage_attach(), NEW, PlayerScore_Attach(), PlayerScore_Detach(), W_HitPlotClose(), and W_HitPlotOpen().

Referenced by Client::Client ::Client().

47 {
48  this._cs = NEW(ClientState, this);
49 
50  // TODO: fold all of these into ClientState
51 
52  DecodeLevelParms(this);
53 
54  PlayerScore_Attach(this);
55  PlayerStats_PlayerBasic_CheckUpdate(this);
56  ClientData_Attach(this);
57  accuracy_init(this);
58  entcs_attach(this);
59  anticheat_init(this);
60  W_HitPlotOpen(this);
62  StatusEffectsStorage_attach(this);
63 }
#define NEW(cname,...)
Definition: oo.qh:105
void DecodeLevelParms(entity this)
Definition: client.qc:934
void entcs_attach(entity this)
void accuracy_init(entity this)
Definition: accuracy.qc:45
void ClientData_Attach(entity this)
Definition: client.qc:158
void anticheat_init(entity this)
Definition: anticheat.qc:240
ClientState _cs
Definition: state.qh:42
void PlayerScore_Attach(entity this)
Definition: scores.qc:318
void InventoryStorage_attach(PlayerState this)
void W_HitPlotOpen(entity this)
Definition: hitplot.qc:82
Purpose: common client state, usable on client and server Client: singleton representing the viewed p...
Definition: state.qh:29
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FixClientCvars()

void FixClientCvars ( entity  e)

Definition at line 947 of file client.qc.

References autocvar_g_antilag, FixClientCvars(), MUTATOR_CALLHOOK, and stuffcmd.

Referenced by ClientConnect(), FixClientCvars(), and MapVote_Finished().

948 {
949  // send prediction settings to the client
950  if(autocvar_g_antilag == 3) // client side hitscan
951  stuffcmd(e, "cl_cmd settemp cl_prydoncursor_notrace 0\n");
952  if(autocvar_sv_gentle)
953  stuffcmd(e, "cl_cmd settemp cl_gentle 1\n");
954 
955  stuffcmd(e, sprintf("\ncl_jumpspeedcap_min \"%s\"\n", autocvar_sv_jumpspeedcap_min));
956  stuffcmd(e, sprintf("\ncl_jumpspeedcap_max \"%s\"\n", autocvar_sv_jumpspeedcap_max));
957 
958  stuffcmd(e, sprintf("\ncl_shootfromfixedorigin \"%s\"\n", autocvar_g_shootfromfixedorigin));
959 
961 }
int autocvar_g_antilag
Definition: antilag.qh:3
#define stuffcmd(cl,...)
Definition: progsdefs.qh:23
#define MUTATOR_CALLHOOK(id,...)
Definition: base.qh:140
void FixClientCvars(entity e)
Definition: client.qc:947
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FixPlayermodel()

void FixPlayermodel ( entity  player)

Definition at line 423 of file client.qc.

References argv(), autocvar_sv_defaultcharacter, autocvar_sv_defaultcharacterskin, autocvar_sv_defaultplayercolors, autocvar_sv_defaultplayermodel, autocvar_sv_defaultplayermodel_blue, autocvar_sv_defaultplayermodel_pink, autocvar_sv_defaultplayermodel_red, autocvar_sv_defaultplayermodel_yellow, autocvar_sv_defaultplayerskin, autocvar_sv_defaultplayerskin_blue, autocvar_sv_defaultplayerskin_pink, autocvar_sv_defaultplayerskin_red, autocvar_sv_defaultplayerskin_yellow, CheckPlayerModel(), CS(), FixPlayermodel(), floor(), M_ARGV, model_randomizer, MUTATOR_CALLHOOK, NUM_TEAM_1, NUM_TEAM_2, NUM_TEAM_3, NUM_TEAM_4, oldskin, player_getspecies(), setcolor, setplayermodel(), stof(), strcat(), strlen(), strstrofs, substring(), teamplay, tokenize_console, UpdatePlayerSounds(), and vector().

Referenced by FixPlayermodel(), PlayerThink(), PutObserverInServer(), PutPlayerInServer(), and STATIC_INIT().

424 {
425  string defaultmodel = "";
426  int defaultskin = 0;
428  {
429  if(teamplay)
430  {
431  switch(player.team)
432  {
433  case NUM_TEAM_1: defaultmodel = autocvar_sv_defaultplayermodel_red; defaultskin = autocvar_sv_defaultplayerskin_red; break;
434  case NUM_TEAM_2: defaultmodel = autocvar_sv_defaultplayermodel_blue; defaultskin = autocvar_sv_defaultplayerskin_blue; break;
436  case NUM_TEAM_4: defaultmodel = autocvar_sv_defaultplayermodel_pink; defaultskin = autocvar_sv_defaultplayerskin_pink; break;
437  }
438  }
439 
440  if(defaultmodel == "")
441  {
442  defaultmodel = autocvar_sv_defaultplayermodel;
443  defaultskin = autocvar_sv_defaultplayerskin;
444  }
445 
446  int n = tokenize_console(defaultmodel);
447  if(n > 0)
448  {
449  defaultmodel = argv(floor(n * CS(player).model_randomizer));
450  // However, do NOT randomize if the player-selected model is in the list.
451  for (int i = 0; i < n; ++i)
452  if ((argv(i) == player.playermodel && defaultskin == stof(player.playerskin)) || argv(i) == strcat(player.playermodel, ":", player.playerskin))
453  defaultmodel = argv(i);
454  }
455 
456  int i = strstrofs(defaultmodel, ":", 0);
457  if(i >= 0)
458  {
459  defaultskin = stof(substring(defaultmodel, i+1, -1));
460  defaultmodel = substring(defaultmodel, 0, i);
461  }
462  }
463  if(autocvar_sv_defaultcharacterskin && !defaultskin)
464  {
465  if(teamplay)
466  {
467  switch(player.team)
468  {
469  case NUM_TEAM_1: defaultskin = autocvar_sv_defaultplayerskin_red; break;
470  case NUM_TEAM_2: defaultskin = autocvar_sv_defaultplayerskin_blue; break;
471  case NUM_TEAM_3: defaultskin = autocvar_sv_defaultplayerskin_yellow; break;
472  case NUM_TEAM_4: defaultskin = autocvar_sv_defaultplayerskin_pink; break;
473  }
474  }
475 
476  if(!defaultskin)
477  defaultskin = autocvar_sv_defaultplayerskin;
478  }
479 
480  MUTATOR_CALLHOOK(FixPlayermodel, defaultmodel, defaultskin, player);
481  defaultmodel = M_ARGV(0, string);
482  defaultskin = M_ARGV(1, int);
483 
484  bool chmdl = false;
485  int oldskin;
486  if(defaultmodel != "")
487  {
488  if (defaultmodel != player.model)
489  {
490  vector m1 = player.mins;
491  vector m2 = player.maxs;
492  setplayermodel (player, defaultmodel);
493  setsize (player, m1, m2);
494  chmdl = true;
495  }
496 
497  oldskin = player.skin;
498  player.skin = defaultskin;
499  } else {
500  if (player.playermodel != player.model || player.playermodel == "")
501  {
502  player.playermodel = CheckPlayerModel(player.playermodel); // this is never "", so no endless loop
503  vector m1 = player.mins;
504  vector m2 = player.maxs;
505  setplayermodel (player, player.playermodel);
506  setsize (player, m1, m2);
507  chmdl = true;
508  }
509 
511  {
512  oldskin = player.skin;
513  player.skin = stof(player.playerskin);
514  }
515  else
516  {
517  oldskin = player.skin;
518  player.skin = defaultskin;
519  }
520  }
521 
522  if(chmdl || oldskin != player.skin) // model or skin has changed
523  {
524  player.species = player_getspecies(player); // update species
525  if(!autocvar_g_debug_globalsounds)
526  UpdatePlayerSounds(player); // update skin sounds
527  }
528 
529  if(!teamplay)
531  if(player.clientcolors != stof(autocvar_sv_defaultplayercolors))
533 }
float model_randomizer
Definition: client.qc:422
int autocvar_sv_defaultplayerskin_pink
Definition: player.qh:9
const int NUM_TEAM_2
Definition: teams.qh:19
int autocvar_sv_defaultplayerskin_blue
Definition: player.qh:8
int autocvar_sv_defaultplayerskin_red
Definition: player.qh:10
ClientState CS(Client this)
Definition: state.qh:47
bool autocvar_sv_defaultcharacterskin
Definition: player.qh:7
string autocvar_sv_defaultplayermodel
Definition: player.qh:13
void UpdatePlayerSounds(entity this)
Definition: globalsound.qc:300
string autocvar_sv_defaultplayermodel_blue
Definition: player.qh:14
int autocvar_sv_defaultplayerskin
Definition: player.qh:18
string autocvar_sv_defaultplayercolors
Definition: player.qh:12
string autocvar_sv_defaultplayermodel_yellow
Definition: player.qh:17
string CheckPlayerModel(string plyermodel)
Definition: client.qc:194
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"))
int autocvar_sv_defaultplayerskin_yellow
Definition: player.qh:11
int player_getspecies(entity this)
Definition: client.qc:413
#define strstrofs
Definition: dpextensions.qh:42
bool autocvar_sv_defaultcharacter
Definition: player.qh:6
#define setcolor
Definition: pre.qh:11
float teamplay
Definition: progsdefs.qc:31
#define M_ARGV(x, type)
Definition: events.qh:17
vector(float skel, float bonenum) _skel_get_boneabs_hidden
#define tokenize_console
Definition: dpextensions.qh:24
const int NUM_TEAM_4
Definition: teams.qh:21
string autocvar_sv_defaultplayermodel_red
Definition: player.qh:16
#define MUTATOR_CALLHOOK(id,...)
Definition: base.qh:140
void FixPlayermodel(entity player)
Definition: client.qc:423
void setplayermodel(entity e, string modelname)
Definition: client.qc:228
const int NUM_TEAM_1
Definition: teams.qh:18
int oldskin
Definition: sv_monsters.qh:56
string autocvar_sv_defaultplayermodel_pink
Definition: player.qh:15
const int NUM_TEAM_3
Definition: teams.qh:20
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetPlayerLimit()

int GetPlayerLimit ( )

Definition at line 1990 of file client.qc.

References autocvar_g_maxplayers, g_duel, GetPlayerLimit(), M_ARGV, and MUTATOR_CALLHOOK.

Referenced by bot_fixcount(), GetPlayerLimit(), MapHasRightSize(), nJoinAllowed(), and STATIC_INIT().

1991 {
1992  if(g_duel)
1993  return 2; // TODO: this workaround is needed since the mutator hook from duel can't be activated before the gametype is loaded (e.g. switching modes via gametype vote screen)
1994  int player_limit = autocvar_g_maxplayers;
1995  MUTATOR_CALLHOOK(GetPlayerLimit, player_limit);
1996  player_limit = M_ARGV(0, int);
1997  return player_limit;
1998 }
int GetPlayerLimit()
Definition: client.qc:1990
#define M_ARGV(x, type)
Definition: events.qh:17
#define MUTATOR_CALLHOOK(id,...)
Definition: base.qh:140
int autocvar_g_maxplayers
Definition: client.qh:43
#define g_duel
Definition: duel.qh:28
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Join()

void Join ( entity  this)

Definition at line 1966 of file client.qc.

References autocvar_g_balance_teams, autocvar_g_campaign, campaign_bots_may_start, IS_PLAYER, netname, NULL, PutClientInServer(), team, team_selected, TeamBalance_JoinBestTeam(), teamplay, and TRANSMUTE().

Referenced by ClientCommand_join(), ObserverOrSpectatorThink(), and PlayerPreThink().

1967 {
1968  TRANSMUTE(Player, this);
1969 
1970  if(!this.team_selected)
1973 
1975  campaign_bots_may_start = true;
1976 
1977  Kill_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CPID_PREVENT_JOIN);
1978 
1979  PutClientInServer(this);
1980 
1981  if(IS_PLAYER(this))
1982  if(teamplay && this.team != -1)
1983  {
1984  }
1985  else
1986  Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_JOIN_PLAY, this.netname);
1987  this.team_selected = false;
1988 }
TRANSMUTE(Player, this)
string netname
Definition: powerups.qc:20
bool team_selected
Definition: client.qc:1958
void TeamBalance_JoinBestTeam(entity player)
Assigns the given player to a team that will make the game most balanced.
Definition: teamplay.qc:451
this team
Definition: client.qc:86
#define NULL
Definition: post.qh:17
float teamplay
Definition: progsdefs.qc:31
bool campaign_bots_may_start
campaign mode: bots shall spawn but wait for the player to spawn before they do anything in other gam...
Definition: campaign.qh:27
bool autocvar_g_balance_teams
Definition: teamplay.qh:8
PutClientInServer(this)
bool autocvar_g_campaign
Definition: campaign.qh:6
#define IS_PLAYER(v)
Definition: utils.qh:9
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ joinAllowed()

bool joinAllowed ( entity  this)

Definition at line 2108 of file client.qc.

References CS(), jointime, lockteams, MIN_SPEC_TIME, MUTATOR_CALLHOOK, nJoinAllowed(), ShowTeamSelection(), teamplay, and time.

Referenced by ClientCommand_join(), ObserverOrSpectatorThink(), and PlayerPreThink().

2109 {
2110  if (CS(this).version_mismatch) return false;
2111  if (time < CS(this).jointime + MIN_SPEC_TIME) return false;
2112  if (!nJoinAllowed(this, this)) return false;
2113  if (teamplay && lockteams) return false;
2114  if (MUTATOR_CALLHOOK(ForbidSpawn, this)) return false;
2115  if (ShowTeamSelection(this)) return false;
2116  return true;
2117 }
ClientState CS(Client this)
Definition: state.qh:47
bool ShowTeamSelection(entity this)
Definition: client.qc:1959
float jointime
Definition: client.qh:64
float teamplay
Definition: progsdefs.qc:31
bool lockteams
Definition: teamplay.qh:13
#define MUTATOR_CALLHOOK(id,...)
Definition: base.qh:140
int nJoinAllowed(entity this, entity ignore)
Determines whether the player is allowed to join.
Definition: client.qc:2006
const int MIN_SPEC_TIME
Definition: client.qh:399
float time
Definition: csprogsdefs.qc:16
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nJoinAllowed()

int nJoinAllowed ( entity  this,
entity  ignore 
)

Determines whether the player is allowed to join.

This depends on cvar g_maxplayers, if it isn't used this function always return true, otherwise it checks whether the number of currently playing players exceeds g_maxplayers.

Returns
int number of free slots for players, 0 if none

Definition at line 2006 of file client.qc.

References autocvar_g_forced_team_otherwise, FOREACH_CLIENT, GetPlayerLimit(), INGAME, IS_PLAYER, IS_REAL_CLIENT, maxclients, min(), Player_GetForcedTeamIndex(), TEAM_FORCE_SPECTATOR, and time.

Referenced by joinAllowed(), and WinningConditionHelper().

2007 {
2008  if(!ignore)
2009  // this is called that way when checking if anyone may be able to join (to build qcstatus)
2010  // so report 0 free slots if restricted
2011  {
2012  if(autocvar_g_forced_team_otherwise == "spectate")
2013  return 0;
2014  if(autocvar_g_forced_team_otherwise == "spectator")
2015  return 0;
2016  }
2017 
2018  if(this && (Player_GetForcedTeamIndex(this) == TEAM_FORCE_SPECTATOR))
2019  return 0; // forced spectators can never join
2020 
2021  // TODO simplify this
2022  int totalClients = 0;
2023  int currentlyPlaying = 0;
2024  FOREACH_CLIENT(true, {
2025  if(it != ignore)
2026  ++totalClients;
2027  if(IS_REAL_CLIENT(it) && (IS_PLAYER(it) || INGAME(it)))
2028  ++currentlyPlaying;
2029  });
2030 
2031  int player_limit = GetPlayerLimit();
2032 
2033  int free_slots = 0;
2034  if (!player_limit)
2035  free_slots = maxclients - totalClients;
2036  else if(player_limit > 0 && currentlyPlaying < player_limit)
2037  free_slots = min(maxclients - totalClients, player_limit - currentlyPlaying);
2038 
2039  static float msg_time = 0;
2040  if(this && !INGAME(this) && ignore && !free_slots && time > msg_time)
2041  {
2042  Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_JOIN_PREVENT);
2043  msg_time = time + 0.5;
2044  }
2045 
2046  return free_slots;
2047 }
#define INGAME(it)
Definition: sv_rules.qh:20
string autocvar_g_forced_team_otherwise
Definition: teamplay.qh:11
#define FOREACH_CLIENT(cond, body)
Definition: utils.qh:49
int GetPlayerLimit()
Definition: client.qc:1990
float maxclients
Definition: csprogsdefs.qc:21
#define IS_REAL_CLIENT(v)
Definition: utils.qh:17
Force the player to spectator team.
Definition: teamplay.qh:137
int Player_GetForcedTeamIndex(entity player)
Returns the index of the forced team of the given player.
Definition: teamplay.qc:346
float time
Definition: csprogsdefs.qc:16
#define IS_PLAYER(v)
Definition: utils.qh:9
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ play_countdown()

void play_countdown ( entity  this,
float  finished,
Sound  samp 
)

Definition at line 1447 of file client.qc.

References ATTEN_NORM, CH_INFO, floor(), frametime, IS_REAL_CLIENT, sound, TC, time, and VOL_BASE.

Referenced by player_powerups(), and STATIC_INIT().

1448 {
1449  TC(Sound, samp);
1450  if(IS_REAL_CLIENT(this))
1451  if(floor(finished - time - frametime) != floor(finished - time))
1452  if(finished - time < 6)
1453  sound (this, CH_INFO, samp, VOL_BASE, ATTEN_NORM);
1454 }
const int CH_INFO
Definition: sound.qh:6
#define IS_REAL_CLIENT(v)
Definition: utils.qh:17
float frametime
Definition: csprogsdefs.qc:17
const float VOL_BASE
Definition: sound.qh:36
#define TC(T, sym)
Definition: _all.inc:82
Definition: sound.qh:119
const float ATTEN_NORM
Definition: sound.qh:30
#define sound(e, c, s, v, a)
Definition: sound.qh:52
float time
Definition: csprogsdefs.qc:16
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ player_powerups_remove_all()

void player_powerups_remove_all ( entity  this)

Definition at line 1457 of file client.qc.

References ATTEN_NORM, CH_INFO, CH_TRIGGER_SINGLE, IS_CLIENT, items, sound, time, and VOL_BASE.

Referenced by ClientDisconnect(), player_powerups(), PutObserverInServer(), reset_map(), and STATIC_INIT().

1458 {
1459  if (this.items & (IT_SUPERWEAPON | IT_UNLIMITED_AMMO | IT_UNLIMITED_SUPERWEAPONS))
1460  {
1461  // don't play the poweroff sound when the game restarts or the player disconnects
1462  if (time > game_starttime + 1 && IS_CLIENT(this))
1463  sound(this, CH_INFO, SND_POWEROFF, VOL_BASE, ATTEN_NORM);
1464  if (this.items & (IT_UNLIMITED_AMMO | IT_UNLIMITED_SUPERWEAPONS))
1465  stopsound(this, CH_TRIGGER_SINGLE); // get rid of the pickup sound
1466  this.items -= (this.items & (IT_SUPERWEAPON | IT_UNLIMITED_AMMO | IT_UNLIMITED_SUPERWEAPONS));
1467  }
1468 }
#define IS_CLIENT(v)
Definition: utils.qh:13
const int CH_INFO
Definition: sound.qh:6
const float VOL_BASE
Definition: sound.qh:36
const float ATTEN_NORM
Definition: sound.qh:30
const int CH_TRIGGER_SINGLE
Definition: sound.qh:13
float items
Definition: progsdefs.qc:145
#define sound(e, c, s, v, a)
Definition: sound.qh:52
float time
Definition: csprogsdefs.qc:16
+ Here is the caller graph for this function:

◆ PlayerInList()

bool PlayerInList ( entity  player,
string  list 
)

Definition at line 995 of file client.qc.

References autocvar_sv_eventlog, boolean, entity(), etof(), GameLogEcho(), IS_REAL_CLIENT, netaddress, playerid, PlayerInIDList(), and PlayerInIPList().

Referenced by Player_DetermineForcedTeam().

996 {
997  return boolean(PlayerInIDList(player, list) || PlayerInIPList(player, list));
998 }
bool PlayerInIPList(entity p, string iplist)
Definition: client.qc:977
#define boolean(value)
Definition: bool.qh:9
bool PlayerInIDList(entity p, string idlist)
Definition: client.qc:986
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ PlayerUseKey()

void PlayerUseKey ( entity  this)

Definition at line 2349 of file client.qc.

References DAMAGE_NO, entity(), IS_DEAD, IS_INDEPENDENT_PLAYER, IS_PLAYER, IS_VEHICLE, MUTATOR_CALLHOOK, NULL, origin, PlayerUseKey(), SAME_TEAM, vehicle, vehicles_enter(), vehicles_exit(), VHF_MULTISLOT, vlen2, and WarpZone_FindRadius().

Referenced by IMPULSE(), PlayerPreThink(), and PlayerUseKey().

2350 {
2351  if (!IS_PLAYER(this))
2352  return;
2353 
2354  if(this.vehicle)
2355  {
2356  if(!game_stopped)
2357  {
2358  vehicles_exit(this.vehicle, VHEF_NORMAL);
2359  return;
2360  }
2361  }
2362  else if(autocvar_g_vehicles_enter)
2363  {
2364  if(!game_stopped && !STAT(FROZEN, this) && !IS_DEAD(this) && !IS_INDEPENDENT_PLAYER(this))
2365  {
2366  entity head, closest_target = NULL;
2367  head = WarpZone_FindRadius(this.origin, autocvar_g_vehicles_enter_radius, true);
2368 
2369  while(head) // find the closest acceptable target to enter
2370  {
2371  if(IS_VEHICLE(head) && !IS_DEAD(head) && head.takedamage != DAMAGE_NO)
2372  if(!head.owner || ((head.vehicle_flags & VHF_MULTISLOT) && SAME_TEAM(head.owner, this)))
2373  {
2374  if(closest_target)
2375  {
2376  if(vlen2(this.origin - head.origin) < vlen2(this.origin - closest_target.origin))
2377  { closest_target = head; }
2378  }
2379  else { closest_target = head; }
2380  }
2381 
2382  head = head.chain;
2383  }
2384 
2385  if(closest_target) { vehicles_enter(this, closest_target); return; }
2386  }
2387  }
2388 
2389  // a use key was pressed; call handlers
2391 }
#define IS_INDEPENDENT_PLAYER(e)
Definition: client.qh:314
entity() spawn
origin
Definition: ent_cs.qc:114
void vehicles_enter(entity pl, entity veh)
Definition: sv_vehicles.qc:939
#define vlen2(v)
Definition: vector.qh:4
void PlayerUseKey(entity this)
Definition: client.qc:2349
#define NULL
Definition: post.qh:17
#define SAME_TEAM(a, b)
Definition: teams.qh:239
#define IS_DEAD(s)
Definition: utils.qh:26
entity WarpZone_FindRadius(vector org, float rad, bool needlineofsight)
Definition: common.qc:669
#define IS_VEHICLE(v)
Definition: utils.qh:22
const int VHF_MULTISLOT
Add random head angles each frame if health < 50%.
Definition: vehicle.qh:75
#define MUTATOR_CALLHOOK(id,...)
Definition: base.qh:140
void vehicles_exit(entity vehic, bool eject)
Definition: sv_vehicles.qc:788
entity vehicle
Definition: impulse.qc:21
float DAMAGE_NO
Definition: progsdefs.qc:282
#define IS_PLAYER(v)
Definition: utils.qh:9
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ PutObserverInServer()

void PutObserverInServer ( entity  this,
bool  is_forced,
bool  use_spawnpoint 
)

putting a client as observer in the server

Definition at line 238 of file client.qc.

References accuracy_resend(), alivetime, alpha, angles, autocvar_g_balance_armor_start, autocvar_g_playerclip_collisions, AuxiliaryXhair, avelocity, bot_attack, bot_relinkplayerlist(), CHAT_NOSPECTATORS, CS(), DAMAGE_NO, damagedbycontents, damageforcescale, DEAD_NO, deadflag, death_time, DPCONTENTS_PLAYERCLIP, DPCONTENTS_SOLID, dphitcontentsmask, drag_undraggable(), drawonlytoclient, effects, entity(), etof(), fade_time, fixangle, FixPlayermodel(), FL_CLIENT, FL_NOTARGET, flags, frags, FRAGS_SPECTATOR, func_null(), g_bot_targets, g_damagedbycontents, g_monster_targets, GetResource(), IL_REMOVE(), IS_PLAYER, IS_REAL_CLIENT, iscreature, istypefrag, items, just_joined, killcount, LOG_FATAL, MAX_AXH, MAX_WEAPONSLOTS, model, monster_attack, MOVETYPE_FLY_WORLDONLY, msg_entity, MSG_ONE, MUTATOR_CALLHOOK, nextthink, NULL, oldvelocity, origin, pain_finished, pauseregen_finished, pauserotarmor_finished, pauserothealth_finished, player_powerups_remove_all(), PlayerState_detach(), Portal_ClearAll(), punchangle, punchvector, pushltime, ready, ReadyCount(), RemoveGrapplingHooks(), RES_HEALTH, respawn_flags, respawn_time, revival_time, scale, SelectSpawnPoint(), set_movetype(), setmodel, setorigin(), SetPlayerTeam(), SetResourceExplicit(), SetSpectatee(), SetSpectatee_status(), setthink, solid, SOLID_NOT, SVC_SETVIEW, takedamage, TEAM_CHANGE_SPECTATOR, TELEPORT_SIMPLE, teleportable, time, TRANSMUTE(), Unfreeze(), UNSET_DUCKED, vec2, vehicle, vehicles_exit(), velocity, view_ofs, viewloc, vote_called, VoteCount(), warmup_stage, weaponentities, weaponmodel, WriteByte(), and WriteEntity().

Referenced by ClientKill_Now_TeamChange(), GameCommand_allspec(), GameCommand_moveplayer(), minigame_addplayer(), ObserverOrSpectatorThink(), PlayerPostThink(), PutClientInServer(), SpectateSet(), and STATIC_INIT().

239 {
240  bool mutator_returnvalue = MUTATOR_CALLHOOK(MakePlayerObserver, this, is_forced);
241  bool recount_ready = false;
242  PlayerState_detach(this);
243 
244  if (IS_PLAYER(this))
245  {
246  if(GetResource(this, RES_HEALTH) >= 1)
247  {
248  // despawn effect
249  Send_Effect(EFFECT_SPAWN_NEUTRAL, this.origin, '0 0 0', 1);
250  }
251 
252  // was a player, recount votes and ready status
253  if(IS_REAL_CLIENT(this))
254  {
255  if (vote_called) { VoteCount(false); }
256  this.ready = false;
257  recount_ready = true;
258  }
259  entcs_update_players(this);
260  }
261 
262  if (use_spawnpoint)
263  {
264  entity spot = SelectSpawnPoint(this, true);
265  if (!spot) LOG_FATAL("No spawnpoints for observers?!?");
266  this.angles = vec2(spot.angles);
267  // offset it so that the spectator spawns higher off the ground, looks better this way
268  setorigin(this, spot.origin + STAT(PL_VIEW_OFS, this));
269  }
270  else // change origin to restore previous view origin
271  setorigin(this, this.origin + STAT(PL_VIEW_OFS, this) - STAT(PL_CROUCH_VIEW_OFS, this));
272  this.fixangle = true;
273 
274  if (IS_REAL_CLIENT(this))
275  {
276  msg_entity = this;
278  WriteEntity(MSG_ONE, this);
279  }
280  // give the spectator some space between walls for MOVETYPE_FLY_WORLDONLY
281  // so that your view doesn't go into the ceiling with MOVETYPE_FLY_WORLDONLY, previously "PL_VIEW_OFS"
282  if(!autocvar_g_debug_globalsounds)
283  {
284  // needed for player sounds
285  this.model = "";
286  FixPlayermodel(this);
287  }
288  setmodel(this, MDL_Null);
289  setsize(this, STAT(PL_CROUCH_MIN, this), STAT(PL_CROUCH_MAX, this));
290  this.view_ofs = '0 0 0';
291 
292  RemoveGrapplingHooks(this);
293  Portal_ClearAll(this);
294  Unfreeze(this, false);
295  SetSpectatee(this, NULL);
296 
297  if (this.alivetime)
298  {
299  if (!warmup_stage)
300  PlayerStats_GameReport_Event_Player(this, PLAYERSTATS_ALIVETIME, time - this.alivetime);
301  this.alivetime = 0;
302  }
303 
304  if (this.vehicle) vehicles_exit(this.vehicle, VHEF_RELEASE);
305 
306  TRANSMUTE(Observer, this);
307 
308  if(recount_ready) ReadyCount();
309 
310  WaypointSprite_PlayerDead(this);
311  accuracy_resend(this);
312 
313  if (CS(this).killcount != FRAGS_SPECTATOR && !game_stopped && CHAT_NOSPECTATORS())
314  Send_Notification(NOTIF_ONE_ONLY, this, MSG_INFO, INFO_CHAT_NOSPECTATORS);
315 
316  CS(this).spectatortime = time;
317  if(this.bot_attack)
318  IL_REMOVE(g_bot_targets, this);
319  this.bot_attack = false;
320  if(this.monster_attack)
322  this.monster_attack = false;
323  STAT(HUD, this) = HUD_NORMAL;
324  this.iscreature = false;
326  if(this.damagedbycontents)
328  this.damagedbycontents = false;
330  SetSpectatee_status(this, etof(this));
331  this.takedamage = DAMAGE_NO;
332  this.solid = SOLID_NOT;
333  set_movetype(this, MOVETYPE_FLY_WORLDONLY); // user preference is controlled by playerprethink
334  this.flags = FL_CLIENT | FL_NOTARGET;
335  this.effects = 0;
336  SetResourceExplicit(this, RES_ARMOR, autocvar_g_balance_armor_start); // was 666?!
337  this.pauserotarmor_finished = 0;
338  this.pauserothealth_finished = 0;
339  this.pauseregen_finished = 0;
340  this.damageforcescale = 0;
341  this.death_time = 0;
342  this.respawn_flags = 0;
343  this.respawn_time = 0;
344  STAT(RESPAWN_TIME, this) = 0;
345  this.alpha = 0;
346  this.scale = 0;
347  this.fade_time = 0;
348  this.pain_finished = 0;
349  STAT(AIR_FINISHED, this) = 0;
350  //this.dphitcontentsmask = 0;
354  this.pushltime = 0;
355  this.istypefrag = 0;
356  setthink(this, func_null);
357  this.nextthink = 0;
358  this.deadflag = DEAD_NO;
359  UNSET_DUCKED(this);
360  STAT(REVIVE_PROGRESS, this) = 0;
361  this.revival_time = 0;
362  this.draggable = drag_undraggable;
363 
365  this.items = 0;
366  STAT(WEAPONS, this) = '0 0 0';
367  this.drawonlytoclient = this;
368 
369  this.viewloc = NULL;
370 
371  //this.spawnpoint_targ = NULL; // keep it so they can return to where they were?
372 
373  this.weaponmodel = "";
374  for (int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
375  {
376  this.weaponentities[slot] = NULL;
377  }
378  this.exteriorweaponentity = NULL;
379  CS(this).killcount = FRAGS_SPECTATOR;
380  this.velocity = '0 0 0';
381  this.avelocity = '0 0 0';
382  this.punchangle = '0 0 0';
383  this.punchvector = '0 0 0';
384  this.oldvelocity = this.velocity;
385  this.event_damage = func_null;
386  this.event_heal = func_null;
387 
388  for(int slot = 0; slot < MAX_AXH; ++slot)
389  {
390  entity axh = this.(AuxiliaryXhair[slot]);
391  this.(AuxiliaryXhair[slot]) = NULL;
392 
393  if(axh.owner == this && axh != NULL && !wasfreed(axh))
394  delete(axh);
395  }
396 
397  if (mutator_returnvalue)
398  {
399  // mutator prevents resetting teams+score
400  }
401  else
402  {
404  this.frags = FRAGS_SPECTATOR;
405  }
406 
408 
409  if (CS(this).just_joined)
410  CS(this).just_joined = false;
411 }
const float SOLID_NOT
Definition: csprogsdefs.qc:244
ERASEABLE void IL_REMOVE(IntrusiveList this, entity it)
Remove any element, anywhere in the list.
entity SelectSpawnPoint(entity this, bool anypoint)
Definition: spawnpoints.qc:329
void ReadyCount()
Definition: vote.qc:498
float alpha
Definition: items.qc:14
bool monster_attack
Definition: sv_monsters.qh:62
IntrusiveList g_monster_targets
Definition: sv_monsters.qh:147
bool SetPlayerTeam(entity player, int team_index, int type)
Sets the team of the player.
Definition: teamplay.qc:237
TRANSMUTE(Player, this)
vector view_ofs
Definition: progsdefs.qc:151
bool SetResourceExplicit(entity e, Resource res_type, float amount)
Sets the resource amount of an entity without calling any hooks.
Definition: cl_resources.qc:15
int respawn_flags
Definition: client.qh:324
const int TELEPORT_SIMPLE
Definition: teleporters.qh:27
bool iscreature
Definition: main.qh:42
void bot_relinkplayerlist()
Definition: bot.qc:381
float respawn_time
Definition: client.qh:325
float damageforcescale
Definition: damage.qh:137
IntrusiveList g_damagedbycontents
Definition: damage.qh:155
entity() spawn
float bot_attack
Definition: api.qh:38
ClientState CS(Client this)
Definition: state.qh:47
int autocvar_g_balance_armor_start
Definition: client.qh:10
bool warmup_stage
Definition: main.qh:103
bool ready
Definition: main.qh:74
float pushltime
Definition: jumppads.qh:10
float DPCONTENTS_PLAYERCLIP
float vote_called
Definition: vote.qh:43
origin
Definition: ent_cs.qc:114
#define UNSET_DUCKED(s)
Definition: player.qh:208
vector punchangle
vector oldvelocity
Definition: main.qh:38
vector avelocity
Definition: csprogsdefs.qc:105
int killcount
Definition: client.qh:317
const int MAX_AXH
Definition: cl_vehicles.qh:23
float effects
Definition: csprogsdefs.qc:111
string model
Definition: csprogsdefs.qc:108
IntrusiveList g_bot_targets
Definition: api.qh:149
#define IS_REAL_CLIENT(v)
Definition: utils.qh:17
#define setmodel(this, m)
Definition: model.qh:26
RES_HEALTH
Definition: ent_cs.qc:126
#define CHAT_NOSPECTATORS()
Definition: chat.qh:27
void Unfreeze(entity targ, bool reset_health)
Definition: damage.qc:546
string weaponmodel
Definition: progsdefs.qc:140
Player is joining spectators. //TODO: Remove?
Definition: teamplay.qh:113
entity msg_entity
Definition: progsdefs.qc:63
vector punchvector
entity AuxiliaryXhair[MAX_AXH]
Definition: cl_vehicles.qh:24
void Portal_ClearAll(entity own)
Definition: portals.qc:587
float damagedbycontents
Definition: damage.qh:48
const int MAX_WEAPONSLOTS
Definition: weapon.qh:13
bool just_joined
Definition: client.qh:74
float pauserothealth_finished
Definition: client.qh:343
float fixangle
Definition: progsdefs.qc:160
float MOVETYPE_FLY_WORLDONLY
#define NULL
Definition: post.qh:17
float DPCONTENTS_SOLID
float pauserotarmor_finished
Definition: client.qh:344
frags
Definition: ent_cs.qc:151
float takedamage
Definition: progsdefs.qc:147
void SetSpectatee(entity this, entity spectatee)
Definition: client.qc:1836
float alivetime
Definition: client.qh:66
float nextthink
Definition: csprogsdefs.qc:121
float scale
Definition: projectile.qc:14
void RemoveGrapplingHooks(entity pl)
Definition: hook.qc:78
void SetSpectatee_status(entity this, int spectatee_num)
Definition: client.qc:1819
entity viewloc
Definition: viewloc.qh:13
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
Definition: cl_resources.qc:10
float deadflag
Definition: progsdefs.qc:149
float pain_finished
float flags
Definition: csprogsdefs.qc:129
entity drawonlytoclient
bool istypefrag
Definition: jumppads.qh:11
float fade_time
Definition: common.qh:22
const int SVC_SETVIEW
Definition: client.qh:339
float items
Definition: progsdefs.qc:145
const int FRAGS_SPECTATOR
Definition: constants.qh:4
#define MUTATOR_CALLHOOK(id,...)
Definition: base.qh:140
bool drag_undraggable(entity draggee, entity dragger)
Definition: cheats.qc:897
void FixPlayermodel(entity player)
Definition: client.qc:423
#define vec2(...)
Definition: vector.qh:90
entity weaponentities[MAX_WEAPONSLOTS]
Definition: weapon.qh:14
float teleportable
Definition: teleporters.qh:24
setorigin(ent, v)
float dphitcontentsmask
float DEAD_NO
Definition: progsdefs.qc:274
float pauseregen_finished
Definition: client.qh:342
#define setthink(e, f)
vector angles
Definition: csprogsdefs.qc:104
void vehicles_exit(entity vehic, bool eject)
Definition: sv_vehicles.qc:788
float FL_NOTARGET
Definition: progsdefs.qc:238
void PlayerState_detach(entity this)
Definition: state.qc:22
void VoteCount(float first_count)
Definition: vote.qc:207
entity vehicle
Definition: impulse.qc:21
bool autocvar_g_playerclip_collisions
Definition: client.qh:17
float time
Definition: csprogsdefs.qc:16
vector velocity
Definition: csprogsdefs.qc:103
#define LOG_FATAL(...)
Definition: log.qh:58
float death_time
void accuracy_resend(entity e)
Definition: accuracy.qc:74
float DAMAGE_NO
Definition: progsdefs.qc:282
float revival_time
Definition: damage.qh:113
void set_movetype(entity this, int mt)
#define IS_PLAYER(v)
Definition: utils.qh:9
var void func_null()
void player_powerups_remove_all(entity this)
Definition: client.qc:1457
float FL_CLIENT
Definition: progsdefs.qc:234
float solid
Definition: csprogsdefs.qc:99
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RotRegen()

void RotRegen ( entity  this,
entity  current,
float  limit_mod,
float  regenstable,
float  regenfactor,
float  regenlinear,
float  regenframetime,
float  rotstable,
float  rotfactor,
float  rotlinear,
float  rotframetime 
)

Referenced by STATIC_INIT().

+ Here is the caller graph for this function:

◆ SetSpectatee()

void SetSpectatee ( entity  this,
entity  spectatee 
)

Definition at line 1836 of file client.qc.

References ClientData_Touch(), enemy, entity(), etof(), IS_BOT_CLIENT, MAX_WEAPONSLOTS, SetSpectatee_status(), and weaponentities.

Referenced by ClientDisconnect(), PutClientInServer(), PutObserverInServer(), Spectate(), SpectateNext(), SpectatePrev(), SpectateUpdate(), and STATIC_INIT().

1837 {
1838  if(IS_BOT_CLIENT(this))
1839  return; // bots abuse .enemy, this code is useless to them
1840 
1841  entity old_spectatee = this.enemy;
1842 
1843  this.enemy = spectatee;
1844 
1845  // WEAPONTODO
1846  // these are required to fix the spectator bug with arc
1847  if(old_spectatee)
1848  {
1849  for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
1850  {
1851  .entity weaponentity = weaponentities[slot];
1852  if(old_spectatee.(weaponentity).arc_beam)
1853  old_spectatee.(weaponentity).arc_beam.SendFlags |= ARC_SF_SETTINGS;
1854  }
1855  }
1856  if(spectatee)
1857  {
1858  for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
1859  {
1860  .entity weaponentity = weaponentities[slot];
1861  if(spectatee.(weaponentity).arc_beam)
1862  spectatee.(weaponentity).arc_beam.SendFlags |= ARC_SF_SETTINGS;
1863  }
1864  }
1865 
1866  if (spectatee)
1867  SetSpectatee_status(this, etof(spectatee));
1868 
1869  // needed to update spectator list
1870  if(old_spectatee) { ClientData_Touch(old_spectatee); }
1871 }
entity() spawn
entity enemy
Definition: sv_ctf.qh:143
const int MAX_WEAPONSLOTS
Definition: weapon.qh:13
void SetSpectatee_status(entity this, int spectatee_num)
Definition: client.qc:1819
void ClientData_Touch(entity e)
Definition: client.qc:171
#define IS_BOT_CLIENT(v)
want: (IS_CLIENT(v) && !IS_REAL_CLIENT(v))
Definition: utils.qh:15
entity weaponentities[MAX_WEAPONSLOTS]
Definition: weapon.qh:14
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetSpectatee_status()

void SetSpectatee_status ( entity  this,
int  spectatee_num 
)

Definition at line 1819 of file client.qc.

References ClientData_Touch(), CS(), g_cts, g_race, race_InitSpectator(), and spectatee_status.

Referenced by PutObserverInServer(), PutPlayerInServer(), SetSpectatee(), and STATIC_INIT().

1820 {
1821  int oldspectatee_status = CS(this).spectatee_status;
1822  CS(this).spectatee_status = spectatee_num;
1823 
1824  if (CS(this).spectatee_status != oldspectatee_status)
1825  {
1826  if (STAT(PRESSED_KEYS, this))
1827  {
1828  CS(this).pressedkeys = 0;
1829  STAT(PRESSED_KEYS, this) = 0;
1830  }
1831  ClientData_Touch(this);
1832  if (g_race || g_cts) race_InitSpectator();
1833  }
1834 }
ClientState CS(Client this)
Definition: state.qh:47
#define g_cts
Definition: cts.qh:36
#define g_race
Definition: race.qh:46
float spectatee_status
Definition: main.qh:166
void ClientData_Touch(entity e)
Definition: client.qc:171
void race_InitSpectator()
Definition: race.qc:71
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Spectate()

bool Spectate ( entity  this,
entity  pl 
)

Definition at line 1873 of file client.qc.

References entity(), M_ARGV, MUTATOR_CALLHOOK, SetSpectatee(), and SpectateSet().

Referenced by ClientCommand_spectate(), STATIC_INIT(), and superspec_Spectate().

1874 {
1875  if(MUTATOR_CALLHOOK(SpectateSet, this, pl))
1876  return false;
1877  pl = M_ARGV(1, entity);
1878 
1879  SetSpectatee(this, pl);
1880  return SpectateSet(this);
1881 }
entity() spawn
void SetSpectatee(entity this, entity spectatee)
Definition: client.qc:1836
#define M_ARGV(x, type)
Definition: events.qh:17
#define MUTATOR_CALLHOOK(id,...)
Definition: base.qh:140
bool SpectateSet(entity this)
Definition: client.qc:1800
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ STATIC_INIT() [1/2]

STATIC_INIT ( g_players  )

Definition at line 86 of file client.qh.

References IL_NEW.

86 { g_players = IL_NEW(); }
#define IL_NEW()
IntrusiveList g_players
Definition: client.qh:85

◆ STATIC_INIT() [2/2]

STATIC_INIT ( g_initforplayer  )

Definition at line 374 of file client.qh.

References ClientInit_misc(), ClientInit_Spawn(), FixPlayermodel(), GetPlayerLimit(), IL_NEW, play_countdown(), player_powerups_remove_all(), PutObserverInServer(), RotRegen(), SetSpectatee(), SetSpectatee_status(), and Spectate().

374 { g_initforplayer = IL_NEW(); }
#define IL_NEW()
IntrusiveList g_initforplayer
Definition: client.qh:373
+ Here is the call graph for this function:

◆ void()

void ( entity  this,
entity  player 
)

Variable Documentation

◆ alivetime

float alivetime

Definition at line 66 of file client.qh.

Referenced by PlayerDamage(), PutObserverInServer(), and PutPlayerInServer().

◆ autocvar__independent_players

int autocvar__independent_players

Definition at line 311 of file client.qh.

◆ autocvar__notarget

bool autocvar__notarget

Definition at line 9 of file client.qh.

Referenced by PutPlayerInServer().

◆ autocvar_g_balance_armor_start

int autocvar_g_balance_armor_start

Definition at line 10 of file client.qh.

Referenced by PutObserverInServer().

◆ autocvar_g_balance_pause_armor_rot_spawn

float autocvar_g_balance_pause_armor_rot_spawn

Definition at line 11 of file client.qh.

Referenced by PutPlayerInServer().

◆ autocvar_g_balance_pause_fuel_rot_spawn

float autocvar_g_balance_pause_fuel_rot_spawn

Definition at line 12 of file client.qh.

Referenced by PutPlayerInServer().

◆ autocvar_g_balance_pause_health_regen_spawn

float autocvar_g_balance_pause_health_regen_spawn

Definition at line 13 of file client.qh.

Referenced by PutPlayerInServer().

◆ autocvar_g_balance_pause_health_rot_spawn

float autocvar_g_balance_pause_health_rot_spawn

Definition at line 14 of file client.qh.

Referenced by PutPlayerInServer().

◆ autocvar_g_botclip_collisions

bool autocvar_g_botclip_collisions

Definition at line 15 of file client.qh.

Referenced by PutPlayerInServer().

◆ autocvar_g_forced_respawn

bool autocvar_g_forced_respawn

Definition at line 42 of file client.qh.

Referenced by calculate_player_respawn_time().

◆ autocvar_g_fullbrightplayers

bool autocvar_g_fullbrightplayers

◆ autocvar_g_maxplayers

int autocvar_g_maxplayers

Definition at line 43 of file client.qh.

Referenced by GetPlayerLimit().

◆ autocvar_g_maxplayers_spectator_blocktime

float autocvar_g_maxplayers_spectator_blocktime

◆ autocvar_g_mutatormsg

string autocvar_g_mutatormsg

Definition at line 34 of file client.qh.

Referenced by getwelcomemessage().

◆ autocvar_g_nodepthtestplayers

bool autocvar_g_nodepthtestplayers

◆ autocvar_g_player_alpha

float autocvar_g_player_alpha

Definition at line 18 of file client.qh.

Referenced by SetDefaultAlpha().

◆ autocvar_g_player_brightness

float autocvar_g_player_brightness

Definition at line 19 of file client.qh.

Referenced by PutPlayerInServer().

◆ autocvar_g_player_damageforcescale

float autocvar_g_player_damageforcescale = 2

Definition at line 20 of file client.qh.

Referenced by PutPlayerInServer().

◆ autocvar_g_playerclip_collisions

bool autocvar_g_playerclip_collisions

◆ autocvar_g_respawn_delay_forced

bool autocvar_g_respawn_delay_forced

Definition at line 26 of file client.qh.

◆ autocvar_g_respawn_delay_large

float autocvar_g_respawn_delay_large

Definition at line 23 of file client.qh.

◆ autocvar_g_respawn_delay_large_count

int autocvar_g_respawn_delay_large_count

Definition at line 24 of file client.qh.

◆ autocvar_g_respawn_delay_max

float autocvar_g_respawn_delay_max

Definition at line 25 of file client.qh.

◆ autocvar_g_respawn_delay_small

float autocvar_g_respawn_delay_small

Definition at line 21 of file client.qh.

◆ autocvar_g_respawn_delay_small_count

int autocvar_g_respawn_delay_small_count

Definition at line 22 of file client.qh.

◆ autocvar_g_respawn_ghosts

bool autocvar_g_respawn_ghosts

Definition at line 27 of file client.qh.

Referenced by respawn().

◆ autocvar_g_respawn_ghosts_alpha

float autocvar_g_respawn_ghosts_alpha = 1

Definition at line 28 of file client.qh.

Referenced by respawn().

◆ autocvar_g_respawn_ghosts_fadetime

float autocvar_g_respawn_ghosts_fadetime = 1.5

Definition at line 29 of file client.qh.

Referenced by respawn().

◆ autocvar_g_respawn_ghosts_speed

float autocvar_g_respawn_ghosts_speed

Definition at line 31 of file client.qh.

Referenced by respawn().

◆ autocvar_g_respawn_ghosts_time

float autocvar_g_respawn_ghosts_time = 4.5

Definition at line 30 of file client.qh.

Referenced by respawn().

◆ autocvar_g_respawn_waves

int autocvar_g_respawn_waves

Definition at line 32 of file client.qh.

◆ autocvar_g_xonoticversion

string autocvar_g_xonoticversion

Definition at line 45 of file client.qh.

Referenced by GetClientVersionMessage(), PlayerPreThink(), and WinningConditionHelper().

◆ autocvar_gameversion

float autocvar_gameversion

Definition at line 46 of file client.qh.

Referenced by GetClientVersionMessage().

◆ autocvar_gameversion_max

float autocvar_gameversion_max

Definition at line 48 of file client.qh.

Referenced by ClientCommand_clientversion().

◆ autocvar_gameversion_min

float autocvar_gameversion_min

Definition at line 47 of file client.qh.

Referenced by ClientCommand_clientversion().

◆ autocvar_hostname

◆ autocvar_spawn_debug

int autocvar_spawn_debug

Definition at line 50 of file client.qh.

Referenced by _StartItem(), PutPlayerInServer(), and SelectSpawnPoint().

◆ autocvar_sv_foginterval

float autocvar_sv_foginterval

Definition at line 35 of file client.qh.

Referenced by ClientConnect(), and ClientInit_misc().

◆ autocvar_sv_maxidle

float autocvar_sv_maxidle

Definition at line 36 of file client.qh.

Referenced by DecodeLevelParms(), PlayerPostThink(), and sys_phys_monitor().

◆ autocvar_sv_maxidle_alsokickspectators

bool autocvar_sv_maxidle_alsokickspectators

Definition at line 39 of file client.qh.

Referenced by PlayerPostThink().

◆ autocvar_sv_maxidle_minplayers

int autocvar_sv_maxidle_minplayers = 2

Definition at line 37 of file client.qh.

Referenced by PlayerPostThink().

◆ autocvar_sv_maxidle_playertospectator

float autocvar_sv_maxidle_playertospectator = 60

Definition at line 38 of file client.qh.

Referenced by PlayerPostThink(), SetPlayerTeam(), and sys_phys_monitor().

◆ autocvar_sv_maxidle_slots

int autocvar_sv_maxidle_slots

Definition at line 40 of file client.qh.

Referenced by PlayerPostThink().

◆ autocvar_sv_maxidle_slots_countbots

bool autocvar_sv_maxidle_slots_countbots

Definition at line 41 of file client.qh.

Referenced by PlayerPostThink().

◆ autocvar_sv_motd

string autocvar_sv_motd

Definition at line 51 of file client.qh.

Referenced by getwelcomemessage().

◆ autocvar_sv_name_maxlength

int autocvar_sv_name_maxlength = 64

Definition at line 52 of file client.qh.

Referenced by PlayerPreThink().

◆ autocvar_sv_player_scale

float autocvar_sv_player_scale

Definition at line 56 of file client.qh.

Referenced by PutPlayerInServer().

◆ autocvar_sv_servermodelsonly

bool autocvar_sv_servermodelsonly

Definition at line 53 of file client.qh.

Referenced by CheckPlayerModel().

◆ autocvar_sv_showspectators

bool autocvar_sv_showspectators

Definition at line 57 of file client.qh.

Referenced by ClientData_Send().

◆ autocvar_sv_spectate

int autocvar_sv_spectate

◆ autocvar_sv_teamnagger

bool autocvar_sv_teamnagger

Definition at line 55 of file client.qh.

Referenced by ClientConnect().

◆ blockSpectators

float blockSpectators

◆ clientdata

entity clientdata

Definition at line 62 of file client.qh.

Referenced by ClientData_Attach().

◆ g_initforplayer

IntrusiveList g_initforplayer

Definition at line 373 of file client.qh.

Referenced by ClientConnect().

◆ g_players

IntrusiveList g_players

Definition at line 85 of file client.qh.

Referenced by StartFrame().

◆ independent_players

bool independent_players

◆ jointime

◆ just_joined

bool just_joined

Definition at line 74 of file client.qh.

Referenced by PutObserverInServer(), and SetPlayerTeam().

◆ killcount

◆ MAX_SPECTATORS

const int MAX_SPECTATORS = 7

Definition at line 406 of file client.qh.

◆ MIN_SPEC_TIME

const int MIN_SPEC_TIME = 1

◆ motd_actived_time

float motd_actived_time

Definition at line 67 of file client.qh.

Referenced by PrintWelcomeMessage().

◆ nickspamcount

float nickspamcount

Definition at line 321 of file client.qh.

Referenced by PM_check_nickspam().

◆ nickspamtime

float nickspamtime

Definition at line 320 of file client.qh.

Referenced by PM_check_nickspam().

◆ pauseregen_finished

◆ pauserotarmor_finished

float pauserotarmor_finished

◆ pauserotfuel_finished

float pauserotfuel_finished

Definition at line 345 of file client.qh.

Referenced by CheatImpulse(), GiveItems(), player_regen(), and PutPlayerInServer().

◆ pauserothealth_finished

float pauserothealth_finished

◆ player_blocked

bool player_blocked

Definition at line 337 of file client.qh.

Referenced by ClientKill(), PlayerJump(), and PM_check_blocked().

◆ playerid

◆ playermodel

string playermodel

Definition at line 80 of file client.qh.

◆ playerskin

string playerskin

Definition at line 81 of file client.qh.

◆ pressedkeys

int pressedkeys

Definition at line 76 of file client.qh.

Referenced by HUD_PressedKeys(), and PM_dodging().

◆ respawn_countdown

float respawn_countdown

Definition at line 328 of file client.qh.

Referenced by calculate_player_respawn_time(), and ShowRespawnCountdown().

◆ RESPAWN_DENY

const int RESPAWN_DENY = BIT(2)

Definition at line 332 of file client.qh.

Referenced by PlayerThink().

◆ respawn_flags

int respawn_flags

◆ RESPAWN_FORCE

const int RESPAWN_FORCE = BIT(0)

Definition at line 330 of file client.qh.

Referenced by calculate_player_respawn_time(), MUTATOR_HOOKFUNCTION(), and PlayerThink().

◆ RESPAWN_SILENT

const int RESPAWN_SILENT = BIT(1)

Definition at line 331 of file client.qh.

Referenced by MUTATOR_HOOKFUNCTION(), and PlayerThink().

◆ respawn_time

◆ respawn_time_max

float respawn_time_max

Definition at line 326 of file client.qh.

Referenced by calculate_player_respawn_time(), and PlayerThink().

◆ spectatee_status

int spectatee_status

Definition at line 71 of file client.qh.

◆ spectatortime

float spectatortime

Definition at line 335 of file client.qh.

Referenced by PlayerPreThink().

◆ startplaytime

float startplaytime

Definition at line 65 of file client.qh.

◆ SVC_SETVIEW

const int SVC_SETVIEW = 5

Definition at line 339 of file client.qh.

Referenced by PutClientInServer(), PutObserverInServer(), and SpectateSet().

◆ wasplayer

bool wasplayer

◆ weaponorder_byimpulse

string weaponorder_byimpulse

Definition at line 60 of file client.qh.

Referenced by ClientDisconnect(), W_Model(), W_NextWeapon(), and W_PreviousWeapon().

◆ zoomstate

bool zoomstate

Definition at line 72 of file client.qh.

Referenced by ClientData_Send(), SetZoomState(), and SpectateCopy().