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);
168 WriteCoord(MSG_ENTITY, self.origin_x);
169 WriteCoord(MSG_ENTITY, self.origin_y);
170 WriteCoord(MSG_ENTITY, self.origin_z);
174 WriteByte(MSG_ENTITY, self.team);
175 WriteByte(MSG_ENTITY, self.rule);
179 WriteString(MSG_ENTITY, self.model1);
182 WriteString(MSG_ENTITY, self.model2);
185 WriteString(MSG_ENTITY, self.model3);
189 WriteCoord(MSG_ENTITY, self.health);
190 WriteCoord(MSG_ENTITY, self.teleport_time);
191 WriteShort(MSG_ENTITY, self.max_health); // maxdist
196 if(self.exteriormodeltoclient == to)
198 WriteByte(MSG_ENTITY, f);
203 WriteByte(MSG_ENTITY, self.cnt); // icon on radar
204 WriteByte(MSG_ENTITY, self.colormod_x * 255.0);
205 WriteByte(MSG_ENTITY, self.colormod_y * 255.0);
206 WriteByte(MSG_ENTITY, self.colormod_z * 255.0);
212 entity WaypointSprite_Spawn(
213 string spr, // sprite
214 float lifetime, float maxdistance, // lifetime, max distance
215 entity ref, vector ofs, // position
216 entity showto, float t, // show to whom? Use a flag to indicate a team
217 entity own, .entity ownfield, // remove when own gets killed
218 float hideable // true when it should be controlled by cl_hidewaypoints
223 wp.classname = "sprite_waypoint";
224 wp.teleport_time = time + lifetime;
225 wp.health = lifetime;
226 wp.exteriormodeltoclient = ref;
234 wp.currentammo = hideable;
238 remove(own.ownfield);
240 wp.owned_by_field = ownfield;
242 wp.max_health = maxdistance;
243 wp.think = WaypointSprite_Think;
245 wp.effects = EF_NODEPTHTEST | EF_LOWPRECISION;
247 wp.model = "net_entity";
249 wp.SendEntity = WaypointSprite_SendEntity;
250 wp.customizeentityforclient = WaypointSprite_Customize;
251 wp.waypointsprite_visible_for_player = WaypointSprite_visible_for_player;
255 entity WaypointSprite_SpawnFixed(
262 return WaypointSprite_Spawn(spr, 0, 0, world, ofs, world, 0, own, ownfield, TRUE);
265 .entity waypointsprite_deployed_fixed;
266 entity WaypointSprite_DeployFixed(
272 float t, maxdistance;
278 maxdistance = waypointsprite_limitedrange;
281 return WaypointSprite_Spawn(spr, waypointsprite_deployed_lifetime, maxdistance, world, ofs, world, t, self, waypointsprite_deployed_fixed, FALSE);
284 .entity waypointsprite_deployed_personal;
285 entity WaypointSprite_DeployPersonal(
290 return WaypointSprite_Spawn(spr, 0, 0, world, ofs, self, 0, self, waypointsprite_deployed_personal, FALSE);
293 .entity waypointsprite_attached;
294 .entity waypointsprite_attachedforcarrier;
295 entity WaypointSprite_Attach(
300 float t, maxdistance;
301 if(self.waypointsprite_attachedforcarrier)
302 return world; // can't attach to FC
308 maxdistance = waypointsprite_limitedrange;
311 return WaypointSprite_Spawn(spr, waypointsprite_deployed_lifetime, maxdistance, self, '0 0 64', world, t, self, waypointsprite_attached, FALSE);
314 entity WaypointSprite_AttachCarrier(
319 WaypointSprite_Kill(carrier.waypointsprite_attached); // FC overrides attached
320 return WaypointSprite_Spawn(spr, 0, 0, carrier, '0 0 64', world, carrier.team, carrier, waypointsprite_attachedforcarrier, FALSE);
323 void WaypointSprite_DetachCarrier(entity carrier)
325 WaypointSprite_Disown(carrier.waypointsprite_attachedforcarrier, waypointsprite_deadlifetime);
328 void WaypointSprite_ClearPersonal()
330 WaypointSprite_Kill(self.waypointsprite_deployed_personal);
333 void WaypointSprite_ClearOwned()
335 WaypointSprite_Kill(self.waypointsprite_deployed_fixed);
336 WaypointSprite_Kill(self.waypointsprite_deployed_personal);
337 WaypointSprite_Kill(self.waypointsprite_attached);
340 void WaypointSprite_PlayerDead()
342 WaypointSprite_Disown(self.waypointsprite_attached, waypointsprite_deadlifetime);
343 WaypointSprite_DetachCarrier(self);
346 void WaypointSprite_PlayerGone()
348 WaypointSprite_Disown(self.waypointsprite_deployed_fixed, waypointsprite_deadlifetime);
349 WaypointSprite_Kill(self.waypointsprite_deployed_personal);
350 WaypointSprite_Disown(self.waypointsprite_attached, waypointsprite_deadlifetime);
351 WaypointSprite_DetachCarrier(self);