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 player);
41 void entcs_detach(entity player);
45 void entcs_force_origin(entity player);
54 AL_NEW(_entcs, 255, NULL, e); // 255 is the engine limit on maxclients
60 #define entcs_receiver(...) EVAL_entcs_receiver(OVERLOAD(entcs_receiver, __VA_ARGS__))
61 #define EVAL_entcs_receiver(...) __VA_ARGS__
62 #define entcs_receiver_1(i) AL_gete(_entcs, i)
63 #define entcs_receiver_2(i, v) AL_sete(_entcs, i, v)
64 #define entcs_is_self(e) ((e).sv_entnum == player_localentnum - 1)
67 * @param i zero indexed player
70 bool entcs_IsSpectating(int i)
72 bool unconnected = !playerslots[i].gotscores;
73 entity e = entcs_receiver(i);
74 return unconnected || ((e) ? e.frags : stof(getplayerkeyvalue(i, "frags"))) == FRAGS_SPECTATOR;
78 * @param i zero indexed player
80 int entcs_GetClientColors(int i)
82 entity e = entcs_receiver(i);
83 return e ? e.colormap : stof(getplayerkeyvalue(i, "colors"));
87 * @param i zero indexed player
88 * @returns 0 if not teamplay
90 int entcs_GetTeamColor(int i)
92 return (!teamplay) ? 0 : entcs_GetClientColors(i) & 15;
96 * @param i zero indexed player
97 * @returns 0 if not teamplay | NUM_TEAM_##N | NUM_SPECTATOR
99 int entcs_GetTeam(int i)
101 return entcs_IsSpectating(i) ? NUM_SPECTATOR : entcs_GetTeamColor(i);
105 * Same as `entcs_GetTeam`, but returns -1 for no team in teamplay
107 int entcs_GetScoreTeam(int i)
109 int t = entcs_GetTeam(i);
110 if (teamplay && !t) t = -1;
115 * @param i zero indexed player
117 string entcs_GetName(int i)
119 entity e = entcs_receiver(i);
120 return ColorTranslateRGB(e ? e.netname : getplayerkeyvalue(i, "name"));
124 * @param i zero indexed player
126 entity CSQCModel_server2csqc(int i);
131 * @param i zero indexed player
133 float entcs_GetAlpha(int i)
135 entity e = CSQCModel_server2csqc(i);
136 return e ? e.alpha : 1;
140 * @param i zero indexed player
142 vector entcs_GetColor(int i)
144 entity e = CSQCModel_server2csqc(i);
145 return (!e || e.colormap <= 0)
147 : colormapPaletteColor(((e.colormap >= 1024)
149 : entcs_GetClientColors(e.colormap - 1)) & 15, true)
154 * @param i zero indexed player
156 bool entcs_IsDead(int i)
158 entity e = CSQCModel_server2csqc(i);
159 return e ? e.csqcmodel_isdead : false;