3 REGISTER_NET_LINKED(ENT_CLIENT_ENTCS)
4 REGISTER_NET_TEMP(CLIENT_ENTCS)
6 /** True when private information such as origin is available */
8 /** True when origin is available */
10 /** True when a recent server sent origin has been received */
15 * The point of these entities is to avoid the problems
16 * with clientprediction.
17 * If you add SendEntity to players, the engine will not
18 * do any prediction anymore, and you'd have to write the whole
19 * prediction code in CSQC, you want that? :P
20 * Data can depend on gamemode. For now, it serves as GPS entities
21 * in onslaught... YAY ;)
26 bool entcs_send(entity this, entity to, int sf);
28 void entcs_think(entity this);
30 void entcs_attach(entity e);
32 void entcs_detach(entity e);
36 /** Force an origin update, for player sounds */
37 #define entcs_force_origin(e) ((e).entcs.m_forceupdate = BIT(2))
46 AL_NEW(_entcs, 255, NULL, e); // 255 is the engine limit on maxclients
52 #define entcs_receiver(...) EVAL_entcs_receiver(OVERLOAD(entcs_receiver, __VA_ARGS__))
53 #define EVAL_entcs_receiver(...) __VA_ARGS__
54 #define entcs_receiver_1(i) AL_gete(_entcs, i)
55 #define entcs_receiver_2(i, v) AL_sete(_entcs, i, v)
56 #define entcs_is_self(e) ((e).sv_entnum == player_localentnum - 1)
59 * @param i zero indexed player
61 bool entcs_IsSpectating(int i)
63 bool unconnected = !playerslots[i].gotscores;
64 return unconnected || stof(getplayerkeyvalue(i, "frags")) == FRAGS_SPECTATOR;
68 * @param i zero indexed player
70 int entcs_GetClientColors(int i)
72 entity e = entcs_receiver(i);
73 return e ? e.colormap : stof(getplayerkeyvalue(i, "colors"));
77 * @param i zero indexed player
78 * @returns 0 if not teamplay
80 int entcs_GetTeamColor(int i)
82 return (!teamplay) ? 0 : entcs_GetClientColors(i) & 15;
86 * @param i zero indexed player
87 * @returns 0 if not teamplay | NUM_TEAM_##N | NUM_SPECTATOR
89 int entcs_GetTeam(int i)
91 return entcs_IsSpectating(i) ? NUM_SPECTATOR : entcs_GetTeamColor(i);
95 * Same as `entcs_GetTeam`, but returns -1 for no team in teamplay
97 int entcs_GetScoreTeam(int i)
99 int t = entcs_GetTeam(i);
100 if (teamplay && !t) t = -1;
105 * @param i zero indexed player
107 string entcs_GetName(int i)
109 entity e = entcs_receiver(i);
110 return e ? ColorTranslateRGB(e.netname) : ColorTranslateRGB(getplayerkeyvalue(i, "name"));
114 * @param i zero indexed player
116 entity CSQCModel_server2csqc(int i);
121 * @param i zero indexed player
123 float entcs_GetAlpha(int i)
125 entity e = CSQCModel_server2csqc(i);
126 return e ? e.alpha : 1;
130 * @param i zero indexed player
132 vector entcs_GetColor(int i)
134 entity e = CSQCModel_server2csqc(i);
135 return (!e || e.colormap <= 0)
137 : colormapPaletteColor(((e.colormap >= 1024)
139 : entcs_GetClientColors(e.colormap - 1)) & 15, true)
144 * @param i zero indexed player
146 bool entcs_IsDead(int i)
148 entity e = CSQCModel_server2csqc(i);
149 return e ? e.csqcmodel_isdead : false;