Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
ent_cs.qh
Go to the documentation of this file.
1#pragma once
2
3#ifdef CSQC
5 #include <client/main.qh> // for playerslots
6#endif
7
8REGISTER_NET_LINKED(ENT_CLIENT_ENTCS)
9REGISTER_NET_TEMP(CLIENT_ENTCS)
10
11#ifdef CSQC
14
17
20#endif
22
23#ifdef SVQC
24/*
25 * The point of these entities is to avoid the problems
26 * with clientprediction.
27 * If you add SendEntity to players, the engine will not
28 * do any prediction anymore, and you'd have to write the whole
29 * prediction code in CSQC, you want that? :P
30 * Data can depend on gametype. For now, it serves as GPS entities
31 * in onslaught... YAY ;)
32 */
33
34 .entity entcs;
35
36 bool entcs_send(entity this, entity to, int sf);
37
38 void entcs_think(entity this);
39
40 void entcs_attach(entity player);
41
42 void entcs_detach(entity player);
43
45
46 void entcs_force_origin(entity player);
47
48 void entcs_update_players(entity player);
49
51
52#endif
53
54#ifdef CSQC
55
58 {
59 AL_NEW(_entcs, 255, NULL, e); // 255 is the engine limit on maxclients
60 }
65 #define entcs_receiver(...) EVAL_entcs_receiver(OVERLOAD(entcs_receiver, __VA_ARGS__))
66 #define EVAL_entcs_receiver(...) __VA_ARGS__
67 #define entcs_receiver_1(i) AL_gete(_entcs, i)
68 #define entcs_receiver_2(i, v) AL_sete(_entcs, i, v)
69 #define entcs_is_self(e) ((e).sv_entnum == player_localentnum - 1)
70
71 .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
82 {
83 bool unconnected = !playerslots[i].gotscores;
85 int fr = ((e) ? e.frags : 0);
86 if (unconnected || fr == FRAGS_SPECTATOR)
87 return ENTCS_SPEC_PURE;
88 int sol = ((e) ? e.sv_solid : SOLID_NOT);
89 if (fr == FRAGS_PLAYER_OUT_OF_GAME && sol == SOLID_NOT)
91 return 0;
92 }
93
98 {
100 return e.handicap_level;
101 }
102
107 {
108 entity e = entcs_receiver(i);
109 return e.wants_join;
110 }
111
116 {
117 entity e = entcs_receiver(i);
118 return e ? e.colormap : 0;
119 }
120
126 {
127 return (!teamplay) ? 0 : entcs_GetClientColors(i) & 15;
128 }
129
133 int entcs_GetTeam(int i)
134 {
136 }
137
142 {
143 int t = entcs_GetTeam(i);
144 if (teamplay && !t) t = -1;
145 return t;
146 }
147
151 string entcs_GetName(int i)
152 {
153 entity e = entcs_receiver(i);
154 return e ? ColorTranslateRGB(e.netname) : "";
155 }
156
161
162 .float alpha;
163
167 float entcs_GetAlpha(int i)
168 {
170 return e ? e.alpha : 1;
171 }
172
177 {
179 return (!e || e.colormap <= 0)
180 ? '1 1 1'
181 : colormapPaletteColor(((e.colormap >= 1024)
182 ? e.colormap
183 : entcs_GetClientColors(e.colormap - 1)) & 15, true)
184 ;
185 }
186
190 bool entcs_IsDead(int i)
191 {
193 return e ? e.csqcmodel_isdead : false;
194 }
195
196#endif
#define AL_DELETE(this)
Definition arraylist.qh:18
#define AL_NEW(this, n, default, T)
Definition arraylist.qh:7
entity ArrayList
Definition arraylist.qh:3
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
float alpha
Definition items.qc:13
entity playerslots[255]
Definition main.qh:84
#define colormapPaletteColor(c, isPants)
Definition color.qh:5
const int FRAGS_PLAYER_OUT_OF_GAME
Definition constants.qh:5
const int FRAGS_SPECTATOR
Definition constants.qh:4
const float SOLID_NOT
handicap_level
Definition ent_cs.qc:155
sv_solid
Definition ent_cs.qc:165
int entcs_GetHandicapLevel(int i)
Definition ent_cs.qh:97
bool radar_showenemies
Definition ent_cs.qh:50
bool entcs_IsDead(int i)
Definition ent_cs.qh:190
bool has_sv_origin
True when a recent server sent origin has been received.
Definition ent_cs.qh:19
int frags
Definition ent_cs.qh:71
float entcs_GetAlpha(int i)
Definition ent_cs.qh:167
string entcs_GetName(int i)
Definition ent_cs.qh:151
const int ENTCS_SPEC_PURE
Definition ent_cs.qh:74
#define entcs_receiver(...)
Definition ent_cs.qh:65
vector entcs_GetColor(int i)
Definition ent_cs.qh:176
ArrayList _entcs
Definition ent_cs.qh:56
int wants_join
Definition ent_cs.qh:73
void entcs_detach(entity player)
Definition ent_cs.qc:268
int entcs_GetTeam(int i)
Definition ent_cs.qh:133
int entcs_GetScoreTeam(int i)
Same as entcs_GetTeam, but returns -1 for no team in teamplay.
Definition ent_cs.qh:141
int entcs_GetTeamColor(int i)
Definition ent_cs.qh:125
entity CSQCModel_server2csqc(int i)
Definition cl_model.qc:314
int entcs_GetWantsJoin(int i)
Definition ent_cs.qh:106
int m_forceupdate
Definition ent_cs.qh:44
bool entcs_send(entity this, entity to, int sf)
Definition ent_cs.qc:220
void entcs_attach(entity player)
Definition ent_cs.qc:251
int entcs_GetClientColors(int i)
Definition ent_cs.qh:115
entity entcs
Definition ent_cs.qh:34
bool m_entcs_private
True when private information such as origin is available.
Definition ent_cs.qh:13
int entcs_GetSpecState(int i)
Definition ent_cs.qh:81
bool has_origin
True when origin is available.
Definition ent_cs.qh:16
void entcs_think(entity this)
Definition ent_cs.qc:225
void entcs_update_players(entity player)
Definition ent_cs.qc:183
void entcs_force_origin(entity player)
Definition ent_cs.qc:36
const int ENTCS_SPEC_IN_SCOREBOARD
Definition ent_cs.qh:75
#define REGISTER_NET_LINKED(id)
Definition net.qh:55
#define REGISTER_NET_TEMP(id)
Definition net.qh:28
#define NULL
Definition post.qh:14
vector
Definition self.qh:92
#define SHUTDOWN(func)
before shutdown
Definition static.qh:49
#define STATIC_INIT(func)
during worldspawn
Definition static.qh:32
ERASEABLE string ColorTranslateRGB(string s)
Definition string.qh:196
const int NUM_SPECTATOR
Definition teams.qh:23
bool teamplay
Definition teams.qh:59