4 #include <client/defs.qh>
7 REGISTER_NET_LINKED(ENT_CLIENT_ENTCS)
8 REGISTER_NET_TEMP(CLIENT_ENTCS)
10 /** True when private information such as origin is available */
11 .bool m_entcs_private;
13 /** True when origin is available */
14 // FIXME: it seems sometimes this is false when observing even though observers should be able to know about all players
15 // easily reproducible on heart_v2 or The_Yard with bots - might be because they lack waypoints and bots stand still
16 // it has happened in matches with players and no bots but much more rarely
19 /** True when a recent server sent origin has been received */
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 ;)
35 bool entcs_send(entity this, entity to, int sf);
37 void entcs_think(entity this);
39 void entcs_attach(entity e);
41 void entcs_detach(entity e);
45 /** Force an origin update, for player sounds */
46 #define entcs_force_origin(e) ((e).entcs.m_forceupdate = BIT(2))
55 AL_NEW(_entcs, 255, NULL, e); // 255 is the engine limit on maxclients
61 #define entcs_receiver(...) EVAL_entcs_receiver(OVERLOAD(entcs_receiver, __VA_ARGS__))
62 #define EVAL_entcs_receiver(...) __VA_ARGS__
63 #define entcs_receiver_1(i) AL_gete(_entcs, i)
64 #define entcs_receiver_2(i, v) AL_sete(_entcs, i, v)
65 #define entcs_is_self(e) ((e).sv_entnum == player_localentnum - 1)
68 * @param i zero indexed player
71 bool entcs_IsSpectating(int i)
73 bool unconnected = !playerslots[i].gotscores;
74 entity e = entcs_receiver(i);
75 return unconnected || ((e) ? e.frags : stof(getplayerkeyvalue(i, "frags"))) == FRAGS_SPECTATOR;
79 * @param i zero indexed player
81 int entcs_GetClientColors(int i)
83 entity e = entcs_receiver(i);
84 return e ? e.colormap : stof(getplayerkeyvalue(i, "colors"));
88 * @param i zero indexed player
89 * @returns 0 if not teamplay
91 int entcs_GetTeamColor(int i)
93 return (!teamplay) ? 0 : entcs_GetClientColors(i) & 15;
97 * @param i zero indexed player
98 * @returns 0 if not teamplay | NUM_TEAM_##N | NUM_SPECTATOR
100 int entcs_GetTeam(int i)
102 return entcs_IsSpectating(i) ? NUM_SPECTATOR : entcs_GetTeamColor(i);
106 * Same as `entcs_GetTeam`, but returns -1 for no team in teamplay
108 int entcs_GetScoreTeam(int i)
110 int t = entcs_GetTeam(i);
111 if (teamplay && !t) t = -1;
116 * @param i zero indexed player
118 string entcs_GetName(int i)
120 entity e = entcs_receiver(i);
121 return ColorTranslateRGB(e ? e.netname : getplayerkeyvalue(i, "name"));
125 * @param i zero indexed player
127 entity CSQCModel_server2csqc(int i);
132 * @param i zero indexed player
134 float entcs_GetAlpha(int i)
136 entity e = CSQCModel_server2csqc(i);
137 return e ? e.alpha : 1;
141 * @param i zero indexed player
143 vector entcs_GetColor(int i)
145 entity e = CSQCModel_server2csqc(i);
146 return (!e || e.colormap <= 0)
148 : colormapPaletteColor(((e.colormap >= 1024)
150 : entcs_GetClientColors(e.colormap - 1)) & 15, true)
155 * @param i zero indexed player
157 bool entcs_IsDead(int i)
159 entity e = CSQCModel_server2csqc(i);
160 return e ? e.csqcmodel_isdead : false;