4 #include <client/csqcmodel_hooks.qh>
7 REGISTER_NET_LINKED(ENT_CLIENT_ENTCS)
8 REGISTER_NET_TEMP(CLIENT_ENTCS)
11 /** True when private information such as origin is available */
12 .bool m_entcs_private;
14 /** True when origin is available */
15 // FIXME: it seems sometimes this is false when observing even though observers should be able to know about all players
16 // easily reproducible on heart_v2 or The_Yard with bots - might be because they lack waypoints and bots stand still
17 // it has happened in matches with players and no bots but much more rarely
20 /** True when a recent server sent origin has been received */
27 * The point of these entities is to avoid the problems
28 * with clientprediction.
29 * If you add SendEntity to players, the engine will not
30 * do any prediction anymore, and you'd have to write the whole
31 * prediction code in CSQC, you want that? :P
32 * Data can depend on gamemode. For now, it serves as GPS entities
33 * in onslaught... YAY ;)
38 bool entcs_send(entity this, entity to, int sf);
40 void entcs_think(entity this);
42 void entcs_attach(entity player);
44 void entcs_detach(entity player);
48 void entcs_force_origin(entity player);
50 bool radar_showenemies;
59 AL_NEW(_entcs, 255, NULL, e); // 255 is the engine limit on maxclients
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)
72 * @param i zero indexed player
75 const int ENTCS_SPEC_PURE = 1; // real spectator
76 const int ENTCS_SPEC_IN_SCOREBOARD = 2; // spectator but still in game (can be in a team)
77 #define entcs_IsSpectating(i) boolean(entcs_GetSpecState(i))
79 int entcs_GetSpecState(int i)
81 bool unconnected = !playerslots[i].gotscores;
82 entity e = entcs_receiver(i);
83 int fr = ((e) ? e.frags : stof(getplayerkeyvalue(i, "frags")));
84 if (unconnected || fr == FRAGS_SPECTATOR)
85 return ENTCS_SPEC_PURE;
86 int sol = ((e) ? e.sv_solid : SOLID_NOT);
87 if (fr == FRAGS_PLAYER_OUT_OF_GAME && sol == SOLID_NOT)
88 return ENTCS_SPEC_IN_SCOREBOARD;
93 * @param i zero indexed player
95 int entcs_GetClientColors(int i)
97 entity e = entcs_receiver(i);
98 return e ? e.colormap : stof(getplayerkeyvalue(i, "colors"));
102 * @param i zero indexed player
103 * @returns 0 if not teamplay
105 int entcs_GetTeamColor(int i)
107 return (!teamplay) ? 0 : entcs_GetClientColors(i) & 15;
111 * @param i zero indexed player
113 int entcs_GetTeam(int i)
115 return (entcs_GetSpecState(i) == ENTCS_SPEC_PURE) ? NUM_SPECTATOR : entcs_GetTeamColor(i);
119 * Same as `entcs_GetTeam`, but returns -1 for no team in teamplay
121 int entcs_GetScoreTeam(int i)
123 int t = entcs_GetTeam(i);
124 if (teamplay && !t) t = -1;
129 * @param i zero indexed player
131 string entcs_GetName(int i)
133 entity e = entcs_receiver(i);
134 return ColorTranslateRGB(e ? e.netname : getplayerkeyvalue(i, "name"));
138 * @param i zero indexed player
140 entity CSQCModel_server2csqc(int i);
145 * @param i zero indexed player
147 float entcs_GetAlpha(int i)
149 entity e = CSQCModel_server2csqc(i);
150 return e ? e.alpha : 1;
154 * @param i zero indexed player
156 vector entcs_GetColor(int i)
158 entity e = CSQCModel_server2csqc(i);
159 return (!e || e.colormap <= 0)
161 : colormapPaletteColor(((e.colormap >= 1024)
163 : entcs_GetClientColors(e.colormap - 1)) & 15, true)
168 * @param i zero indexed player
170 bool entcs_IsDead(int i)
172 entity e = CSQCModel_server2csqc(i);
173 return e ? e.csqcmodel_isdead : false;