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 */
17 /** 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);
47 void entcs_update_players(entity player);
49 bool radar_showenemies;
58 AL_NEW(_entcs, 255, NULL, e); // 255 is the engine limit on maxclients
64 #define entcs_receiver(...) EVAL_entcs_receiver(OVERLOAD(entcs_receiver, __VA_ARGS__))
65 #define EVAL_entcs_receiver(...) __VA_ARGS__
66 #define entcs_receiver_1(i) AL_gete(_entcs, i)
67 #define entcs_receiver_2(i, v) AL_sete(_entcs, i, v)
68 #define entcs_is_self(e) ((e).sv_entnum == player_localentnum - 1)
71 * @param i zero indexed player
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))
78 int entcs_GetSpecState(int i)
80 bool unconnected = !playerslots[i].gotscores;
81 entity e = entcs_receiver(i);
82 int fr = ((e) ? e.frags : stof(getplayerkeyvalue(i, "frags")));
83 if (unconnected || fr == FRAGS_SPECTATOR)
84 return ENTCS_SPEC_PURE;
85 int sol = ((e) ? e.sv_solid : SOLID_NOT);
86 if (fr == FRAGS_PLAYER_OUT_OF_GAME && sol == SOLID_NOT)
87 return ENTCS_SPEC_IN_SCOREBOARD;
92 * @param i zero indexed player
94 int entcs_GetClientColors(int i)
96 entity e = entcs_receiver(i);
97 return e ? e.colormap : stof(getplayerkeyvalue(i, "colors"));
101 * @param i zero indexed player
102 * @returns 0 if not teamplay
104 int entcs_GetTeamColor(int i)
106 return (!teamplay) ? 0 : entcs_GetClientColors(i) & 15;
110 * @param i zero indexed player
112 int entcs_GetTeam(int i)
114 return (entcs_GetSpecState(i) == ENTCS_SPEC_PURE) ? NUM_SPECTATOR : entcs_GetTeamColor(i);
118 * Same as `entcs_GetTeam`, but returns -1 for no team in teamplay
120 int entcs_GetScoreTeam(int i)
122 int t = entcs_GetTeam(i);
123 if (teamplay && !t) t = -1;
128 * @param i zero indexed player
130 string entcs_GetName(int i)
132 entity e = entcs_receiver(i);
133 return ColorTranslateRGB(e ? e.netname : getplayerkeyvalue(i, "name"));
137 * @param i zero indexed player
139 entity CSQCModel_server2csqc(int i);
144 * @param i zero indexed player
146 float entcs_GetAlpha(int i)
148 entity e = CSQCModel_server2csqc(i);
149 return e ? e.alpha : 1;
153 * @param i zero indexed player
155 vector entcs_GetColor(int i)
157 entity e = CSQCModel_server2csqc(i);
158 return (!e || e.colormap <= 0)
160 : colormapPaletteColor(((e.colormap >= 1024)
162 : entcs_GetClientColors(e.colormap - 1)) & 15, true)
167 * @param i zero indexed player
169 bool entcs_IsDead(int i)
171 entity e = CSQCModel_server2csqc(i);
172 return e ? e.csqcmodel_isdead : false;