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;
12 /** True when origin is available */
14 /** True when a recent server sent origin has been received */
19 * The point of these entities is to avoid the problems
20 * with clientprediction.
21 * If you add SendEntity to players, the engine will not
22 * do any prediction anymore, and you'd have to write the whole
23 * prediction code in CSQC, you want that? :P
24 * Data can depend on gamemode. For now, it serves as GPS entities
25 * in onslaught... YAY ;)
30 bool entcs_send(entity this, entity to, int sf);
32 void entcs_think(entity this);
34 void entcs_attach(entity e);
36 void entcs_detach(entity e);
40 /** Force an origin update, for player sounds */
41 #define entcs_force_origin(e) ((e).entcs.m_forceupdate = BIT(2))
50 AL_NEW(_entcs, 255, NULL, e); // 255 is the engine limit on maxclients
56 #define entcs_receiver(...) EVAL_entcs_receiver(OVERLOAD(entcs_receiver, __VA_ARGS__))
57 #define EVAL_entcs_receiver(...) __VA_ARGS__
58 #define entcs_receiver_1(i) AL_gete(_entcs, i)
59 #define entcs_receiver_2(i, v) AL_sete(_entcs, i, v)
60 #define entcs_is_self(e) ((e).sv_entnum == player_localentnum - 1)
63 * @param i zero indexed player
66 bool entcs_IsSpectating(int i)
68 bool unconnected = !playerslots[i].gotscores;
69 entity e = entcs_receiver(i);
70 return unconnected || ((e) ? e.frags : stof(getplayerkeyvalue(i, "frags"))) == FRAGS_SPECTATOR;
74 * @param i zero indexed player
76 int entcs_GetClientColors(int i)
78 entity e = entcs_receiver(i);
79 return e ? e.colormap : stof(getplayerkeyvalue(i, "colors"));
83 * @param i zero indexed player
84 * @returns 0 if not teamplay
86 int entcs_GetTeamColor(int i)
88 return (!teamplay) ? 0 : entcs_GetClientColors(i) & 15;
92 * @param i zero indexed player
93 * @returns 0 if not teamplay | NUM_TEAM_##N | NUM_SPECTATOR
95 int entcs_GetTeam(int i)
97 return entcs_IsSpectating(i) ? NUM_SPECTATOR : entcs_GetTeamColor(i);
101 * Same as `entcs_GetTeam`, but returns -1 for no team in teamplay
103 int entcs_GetScoreTeam(int i)
105 int t = entcs_GetTeam(i);
106 if (teamplay && !t) t = -1;
111 * @param i zero indexed player
113 string entcs_GetName(int i)
115 entity e = entcs_receiver(i);
116 return ColorTranslateRGB(e ? e.netname : getplayerkeyvalue(i, "name"));
120 * @param i zero indexed player
122 entity CSQCModel_server2csqc(int i);
127 * @param i zero indexed player
129 float entcs_GetAlpha(int i)
131 entity e = CSQCModel_server2csqc(i);
132 return e ? e.alpha : 1;
136 * @param i zero indexed player
138 vector entcs_GetColor(int i)
140 entity e = CSQCModel_server2csqc(i);
141 return (!e || e.colormap <= 0)
143 : colormapPaletteColor(((e.colormap >= 1024)
145 : entcs_GetClientColors(e.colormap - 1)) & 15, true)
150 * @param i zero indexed player
152 bool entcs_IsDead(int i)
154 entity e = CSQCModel_server2csqc(i);
155 return e ? e.csqcmodel_isdead : false;