1 ..entity owned_by_field;
7 .float(entity) waypointsprite_visible_for_player;
9 void WaypointSprite_UpdateSprites(entity e, string m1, string m2, string m3)
28 void WaypointSprite_UpdateOrigin(entity e, vector o)
37 void WaypointSprite_UpdateRule(entity e, float t, float r)
39 // no check, as this is never called without doing an actual change (usually only once)
45 void WaypointSprite_UpdateTeamRadar(entity e, float icon, vector col)
47 // no check, as this is never called without doing an actual change (usually only once)
48 e.cnt = (icon & 0x7F) | (e.cnt & 0x80);
53 void WaypointSprite_Ping(entity e)
55 // ALWAYS sends (this causes a radar circle), thus no check
60 void WaypointSprite_FadeOutIn(entity e, float t)
65 e.teleport_time = time + t;
67 else if(t < (e.teleport_time - time))
69 // accelerate the waypoint's dying
71 // (e.teleport_time - time) / wp.health stays
72 // e.teleport_time = time + fadetime
73 float current_fadetime;
74 current_fadetime = e.teleport_time - time;
75 e.teleport_time = time + t;
76 e.health = e.health * t / current_fadetime;
82 float waypointsprite_limitedrange, waypointsprite_deployed_lifetime, waypointsprite_deadlifetime;
83 void WaypointSprite_Init()
85 waypointsprite_limitedrange = cvar("g_waypointsprite_limitedrange");
86 waypointsprite_deployed_lifetime = cvar("g_waypointsprite_deployed_lifetime");
87 waypointsprite_deadlifetime = cvar("g_waypointsprite_deadlifetime");
89 void WaypointSprite_InitClient(entity e)
93 void WaypointSprite_Kill(entity wp)
98 wp.owner.(wp.owned_by_field) = world;
102 void WaypointSprite_Disown(entity wp, float fadetime)
108 if(wp.exteriormodeltoclient == wp.owner)
109 wp.exteriormodeltoclient = world;
110 wp.owner.(wp.owned_by_field) = world;
113 WaypointSprite_FadeOutIn(wp, fadetime);
117 void WaypointSprite_Think()
125 if(time >= self.teleport_time)
129 if(self.exteriormodeltoclient)
130 WaypointSprite_UpdateOrigin(self, self.exteriormodeltoclient.origin + self.view_ofs);
133 WaypointSprite_Kill(self);
135 self.nextthink = time; // WHY?!?
138 float WaypointSprite_visible_for_player(entity e)
140 // personal waypoints
142 if(self.enemy != other)
146 if(self.team && self.rule == SPRITERULE_DEFAULT)
148 if(self.team != other.team)
150 if(other.classname != "player")
157 float WaypointSprite_Customize()
159 // this is not in SendEntity because it shall run every frame, not just every update
161 return self.waypointsprite_visible_for_player(other);
164 float WaypointSprite_SendEntity(entity to, float sendflags)
166 WriteByte(MSG_ENTITY, ENT_CLIENT_WAYPOINT);
167 WriteByte(MSG_ENTITY, sendflags);
171 WriteCoord(MSG_ENTITY, self.origin_x);
172 WriteCoord(MSG_ENTITY, self.origin_y);
173 WriteCoord(MSG_ENTITY, self.origin_z);
178 WriteByte(MSG_ENTITY, self.team);
179 WriteByte(MSG_ENTITY, self.rule);
183 WriteString(MSG_ENTITY, self.model1);
186 WriteString(MSG_ENTITY, self.model2);
189 WriteString(MSG_ENTITY, self.model3);
193 WriteCoord(MSG_ENTITY, self.health);
194 WriteCoord(MSG_ENTITY, self.teleport_time);
195 WriteShort(MSG_ENTITY, self.max_health); // maxdist
200 if(self.exteriormodeltoclient == to)
202 WriteByte(MSG_ENTITY, f);
207 WriteByte(MSG_ENTITY, self.cnt); // icon on radar
208 WriteByte(MSG_ENTITY, self.colormod_x * 255.0);
209 WriteByte(MSG_ENTITY, self.colormod_y * 255.0);
210 WriteByte(MSG_ENTITY, self.colormod_z * 255.0);
216 entity WaypointSprite_Spawn(
217 string spr, // sprite
218 float lifetime, float maxdistance, // lifetime, max distance
219 entity ref, vector ofs, // position
220 entity showto, float t, // show to whom? Use a flag to indicate a team
221 entity own, .entity ownfield, // remove when own gets killed
222 float hideable // true when it should be controlled by cl_hidewaypoints
227 wp.classname = "sprite_waypoint";
228 wp.teleport_time = time + lifetime;
229 wp.health = lifetime;
230 wp.exteriormodeltoclient = ref;
238 wp.currentammo = hideable;
242 remove(own.ownfield);
244 wp.owned_by_field = ownfield;
246 wp.max_health = maxdistance;
247 wp.think = WaypointSprite_Think;
249 wp.effects = EF_NODEPTHTEST | EF_LOWPRECISION;
251 setmodel(wp, "null");
252 wp.SendEntity = WaypointSprite_SendEntity;
253 wp.customizeentityforclient = WaypointSprite_Customize;
254 wp.waypointsprite_visible_for_player = WaypointSprite_visible_for_player;
258 entity WaypointSprite_SpawnFixed(
265 return WaypointSprite_Spawn(spr, 0, 0, world, ofs, world, 0, own, ownfield, TRUE);
268 .entity waypointsprite_deployed_fixed;
269 entity WaypointSprite_DeployFixed(
275 float t, maxdistance;
281 maxdistance = waypointsprite_limitedrange;
284 return WaypointSprite_Spawn(spr, waypointsprite_deployed_lifetime, maxdistance, world, ofs, world, t, self, waypointsprite_deployed_fixed, FALSE);
287 .entity waypointsprite_deployed_personal;
288 entity WaypointSprite_DeployPersonal(
293 return WaypointSprite_Spawn(spr, 0, 0, world, ofs, world, 0, self, waypointsprite_deployed_personal, FALSE);
296 .entity waypointsprite_attached;
297 .entity waypointsprite_attachedforcarrier;
298 entity WaypointSprite_Attach(
303 float t, maxdistance;
304 if(self.waypointsprite_attachedforcarrier)
305 return world; // can't attach to FC
311 maxdistance = waypointsprite_limitedrange;
314 return WaypointSprite_Spawn(spr, waypointsprite_deployed_lifetime, maxdistance, self, '0 0 64', world, t, self, waypointsprite_attached, FALSE);
317 entity WaypointSprite_AttachCarrier(
322 WaypointSprite_Kill(carrier.waypointsprite_attached); // FC overrides attached
323 return WaypointSprite_Spawn(spr, 0, 0, carrier, '0 0 64', world, carrier.team, carrier, waypointsprite_attachedforcarrier, FALSE);
326 void WaypointSprite_DetachCarrier(entity carrier)
328 WaypointSprite_Disown(carrier.waypointsprite_attachedforcarrier, waypointsprite_deadlifetime);
331 void WaypointSprite_ClearPersonal()
333 WaypointSprite_Kill(self.waypointsprite_deployed_personal);
336 void WaypointSprite_ClearOwned()
338 WaypointSprite_Kill(self.waypointsprite_deployed_fixed);
339 WaypointSprite_Kill(self.waypointsprite_deployed_personal);
340 WaypointSprite_Kill(self.waypointsprite_attached);
343 void WaypointSprite_PlayerDead()
345 WaypointSprite_Disown(self.waypointsprite_attached, waypointsprite_deadlifetime);
346 WaypointSprite_DetachCarrier(self);
349 void WaypointSprite_PlayerGone()
351 WaypointSprite_Disown(self.waypointsprite_deployed_fixed, waypointsprite_deadlifetime);
352 WaypointSprite_Kill(self.waypointsprite_deployed_personal);
353 WaypointSprite_Disown(self.waypointsprite_attached, waypointsprite_deadlifetime);
354 WaypointSprite_DetachCarrier(self);