Xonotic
ent_cs.qh
Go to the documentation of this file.
1 #pragma once
2 
3 #ifdef CSQC
5 #endif
6 
7 REGISTER_NET_LINKED(ENT_CLIENT_ENTCS)
8 REGISTER_NET_TEMP(CLIENT_ENTCS)
9 
10 #ifdef CSQC
11 
12 .bool m_entcs_private;
13 
15 .bool has_origin;
16 
18 .bool has_sv_origin;
19 #endif
20 .int sv_solid;
21 
22 #ifdef SVQC
23 /*
24  * The point of these entities is to avoid the problems
25  * with clientprediction.
26  * If you add SendEntity to players, the engine will not
27  * do any prediction anymore, and you'd have to write the whole
28  * prediction code in CSQC, you want that? :P
29  * Data can depend on gamemode. For now, it serves as GPS entities
30  * in onslaught... YAY ;)
31  */
32 
33  .entity entcs;
34 
35  bool entcs_send(entity this, entity to, int sf);
36 
37  void entcs_think(entity this);
38 
39  void entcs_attach(entity player);
40 
41  void entcs_detach(entity player);
42 
43  .int m_forceupdate;
44 
45  void entcs_force_origin(entity player);
46 
47  void entcs_update_players(entity player);
48 
49  bool radar_showenemies;
50 
51 #endif
52 
53 #ifdef CSQC
54 
55  ArrayList _entcs;
56  STATIC_INIT(_entcs)
57  {
58  AL_NEW(_entcs, 255, NULL, e); // 255 is the engine limit on maxclients
59  }
60  SHUTDOWN(_entcs)
61  {
62  AL_DELETE(_entcs);
63  }
64  #define entcs_receiver(...) EVAL_entcs_receiver(OVERLOAD(entcs_receiver, __VA_ARGS__))
65  #define EVAL_entcs_receiver(...) __VA_ARGS__
66  #define entcs_receiver_1(i) AL_gete(_entcs, i)
67  #define entcs_receiver_2(i, v) AL_sete(_entcs, i, v)
68  #define entcs_is_self(e) ((e).sv_entnum == player_localentnum - 1)
69 
73  .int frags;
74  const int ENTCS_SPEC_PURE = 1; // real spectator
75  const int ENTCS_SPEC_IN_SCOREBOARD = 2; // spectator but still in game (can be in a team)
76  #define entcs_IsSpectating(i) boolean(entcs_GetSpecState(i))
77 
78  int entcs_GetSpecState(int i)
79  {
80  bool unconnected = !playerslots[i].gotscores;
81  entity e = entcs_receiver(i);
82  int fr = ((e) ? e.frags : stof(getplayerkeyvalue(i, "frags")));
83  if (unconnected || fr == FRAGS_SPECTATOR)
84  return ENTCS_SPEC_PURE;
85  int sol = ((e) ? e.sv_solid : SOLID_NOT);
86  if (fr == FRAGS_PLAYER_OUT_OF_GAME && sol == SOLID_NOT)
87  return ENTCS_SPEC_IN_SCOREBOARD;
88  return 0;
89  }
90 
94  int entcs_GetClientColors(int i)
95  {
96  entity e = entcs_receiver(i);
97  return e ? e.colormap : stof(getplayerkeyvalue(i, "colors"));
98  }
99 
104  int entcs_GetTeamColor(int i)
105  {
106  return (!teamplay) ? 0 : entcs_GetClientColors(i) & 15;
107  }
108 
112  int entcs_GetTeam(int i)
113  {
114  return (entcs_GetSpecState(i) == ENTCS_SPEC_PURE) ? NUM_SPECTATOR : entcs_GetTeamColor(i);
115  }
116 
120  int entcs_GetScoreTeam(int i)
121  {
122  int t = entcs_GetTeam(i);
123  if (teamplay && !t) t = -1;
124  return t;
125  }
126 
130  string entcs_GetName(int i)
131  {
132  entity e = entcs_receiver(i);
133  return ColorTranslateRGB(e ? e.netname : getplayerkeyvalue(i, "name"));
134  }
135 
140 
141  .float alpha;
142 
146  float entcs_GetAlpha(int i)
147  {
149  return e ? e.alpha : 1;
150  }
151 
155  vector entcs_GetColor(int i)
156  {
158  return (!e || e.colormap <= 0)
159  ? '1 1 1'
160  : colormapPaletteColor(((e.colormap >= 1024)
161  ? e.colormap
162  : entcs_GetClientColors(e.colormap - 1)) & 15, true)
163  ;
164  }
165 
169  bool entcs_IsDead(int i)
170  {
172  return e ? e.csqcmodel_isdead : false;
173  }
174 
175 #endif
#define AL_NEW(this, n, default, T)
Definition: arraylist.qh:7
const float SOLID_NOT
Definition: csprogsdefs.qc:244
void entcs_detach(entity this)
float alpha
Definition: items.qc:14
const int NUM_SPECTATOR
Definition: teams.qh:23
#define REGISTER_NET_LINKED(id)
Definition: net.qh:67
entity ArrayList
Definition: arraylist.qh:3
entity CSQCModel_server2csqc(int i)
Definition: cl_model.qc:314
void entcs_attach(entity this)
entity() spawn
#define STATIC_INIT(func)
during worldspawn
Definition: static.qh:32
entity to
Definition: self.qh:96
entity playerslots[255]
Definition: main.qh:70
int sv_solid
Definition: ent_cs.qh:20
ERASEABLE string ColorTranslateRGB(string s)
Definition: string.qh:177
#define NULL
Definition: post.qh:17
frags
Definition: ent_cs.qc:151
#define SHUTDOWN(func)
before shutdown
Definition: static.qh:49
float teamplay
Definition: progsdefs.qc:31
vector(float skel, float bonenum) _skel_get_boneabs_hidden
const int FRAGS_PLAYER_OUT_OF_GAME
Definition: constants.qh:5
const int FRAGS_SPECTATOR
Definition: constants.qh:4
#define REGISTER_NET_TEMP(id)
Definition: net.qh:33
#define AL_DELETE(this)
Definition: arraylist.qh:18
#define colormapPaletteColor(c, isPants)
Definition: color.qh:5