1 ..entity owned_by_field;
6 .float(entity) waypointsprite_visible_for_player;
8 void WaypointSprite_UpdateSprites(entity e, string m1, string m2, string m3)
27 void WaypointSprite_UpdateOrigin(entity e, vector o)
36 void WaypointSprite_UpdateRule(entity e, float t, float r)
38 // no check, as this is never called without doing an actual change (usually only once)
44 void WaypointSprite_UpdateTeamRadar(entity e, float icon, vector col)
46 // no check, as this is never called without doing an actual change (usually only once)
47 e.cnt = (icon & 0x7F) | (e.cnt & 0x80);
52 void WaypointSprite_Ping(entity e)
54 // ALWAYS sends (this causes a radar circle), thus no check
59 void WaypointSprite_FadeOutIn(entity e, float t)
64 e.teleport_time = time + t;
66 else if(t < (e.teleport_time - time))
68 // accelerate the waypoint's dying
70 // (e.teleport_time - time) / wp.health stays
71 // e.teleport_time = time + fadetime
72 float current_fadetime;
73 current_fadetime = e.teleport_time - time;
74 e.teleport_time = time + t;
75 e.health = e.health * t / current_fadetime;
81 float waypointsprite_limitedrange, waypointsprite_deployed_lifetime, waypointsprite_deadlifetime;
82 void WaypointSprite_Init()
84 waypointsprite_limitedrange = cvar("g_waypointsprite_limitedrange");
85 waypointsprite_deployed_lifetime = cvar("g_waypointsprite_deployed_lifetime");
86 waypointsprite_deadlifetime = cvar("g_waypointsprite_deadlifetime");
88 void WaypointSprite_InitClient(entity e)
92 void WaypointSprite_Kill(entity wp)
97 wp.owner.(wp.owned_by_field) = world;
101 void WaypointSprite_Disown(entity wp, float fadetime)
107 if(wp.exteriormodeltoclient == wp.owner)
108 wp.exteriormodeltoclient = world;
109 wp.owner.(wp.owned_by_field) = world;
112 WaypointSprite_FadeOutIn(wp, fadetime);
116 void WaypointSprite_Think()
124 if(time >= self.teleport_time)
128 if(self.exteriormodeltoclient)
129 WaypointSprite_UpdateOrigin(self, self.exteriormodeltoclient.origin + self.view_ofs);
132 WaypointSprite_Kill(self);
134 self.nextthink = time; // WHY?!?
137 float WaypointSprite_visible_for_player(entity e)
139 // personal waypoints
141 if(self.enemy != other)
145 if(self.team && self.rule == SPRITERULE_DEFAULT)
147 if(self.team != other.team)
149 if(other.classname != "player")
156 float WaypointSprite_Customize()
158 // this is not in SendEntity because it shall run every frame, not just every update
160 return self.waypointsprite_visible_for_player(other);
163 float WaypointSprite_SendEntity(entity to, float sendflags)
165 WriteByte(MSG_ENTITY, ENT_CLIENT_WAYPOINT);
166 WriteByte(MSG_ENTITY, sendflags);
167 WriteCoord(MSG_ENTITY, self.origin_x);
168 WriteCoord(MSG_ENTITY, self.origin_y);
169 WriteCoord(MSG_ENTITY, self.origin_z);
171 if(self.model == "key-dropped")
172 print("flags: ", ftos(sendflags), "\n");
176 WriteByte(MSG_ENTITY, self.team);
177 WriteByte(MSG_ENTITY, self.rule);
181 WriteString(MSG_ENTITY, self.model);
184 WriteString(MSG_ENTITY, self.model2);
187 WriteString(MSG_ENTITY, self.model3);
191 WriteCoord(MSG_ENTITY, self.health);
192 WriteCoord(MSG_ENTITY, self.teleport_time);
193 WriteShort(MSG_ENTITY, self.max_health); // maxdist
198 if(self.exteriormodeltoclient == to)
200 WriteByte(MSG_ENTITY, f);
205 WriteByte(MSG_ENTITY, self.cnt); // icon on radar
206 WriteByte(MSG_ENTITY, self.colormod_x * 255.0);
207 WriteByte(MSG_ENTITY, self.colormod_y * 255.0);
208 WriteByte(MSG_ENTITY, self.colormod_z * 255.0);
214 entity WaypointSprite_Spawn(
215 string spr, // sprite
216 float lifetime, float maxdistance, // lifetime, max distance
217 entity ref, vector ofs, // position
218 entity showto, float t, // show to whom? Use a flag to indicate a team
219 entity own, .entity ownfield, // remove when own gets killed
220 float hideable // true when it should be controlled by cl_hidewaypoints
225 wp.classname = "sprite_waypoint";
226 wp.teleport_time = time + lifetime;
227 wp.health = lifetime;
228 wp.exteriormodeltoclient = ref;
236 wp.currentammo = hideable;
240 remove(own.ownfield);
242 wp.owned_by_field = ownfield;
244 wp.max_health = maxdistance;
245 wp.think = WaypointSprite_Think;
247 wp.effects = EF_NODEPTHTEST | EF_LOWPRECISION;
250 wp.SendEntity = WaypointSprite_SendEntity;
251 wp.customizeentityforclient = WaypointSprite_Customize;
252 wp.waypointsprite_visible_for_player = WaypointSprite_visible_for_player;
256 entity WaypointSprite_SpawnFixed(
263 return WaypointSprite_Spawn(spr, 0, 0, world, ofs, world, 0, own, ownfield, TRUE);
266 .entity waypointsprite_deployed_fixed;
267 entity WaypointSprite_DeployFixed(
273 float t, maxdistance;
279 maxdistance = waypointsprite_limitedrange;
282 return WaypointSprite_Spawn(spr, waypointsprite_deployed_lifetime, maxdistance, world, ofs, world, t, self, waypointsprite_deployed_fixed, FALSE);
285 .entity waypointsprite_deployed_personal;
286 entity WaypointSprite_DeployPersonal(
291 return WaypointSprite_Spawn(spr, 0, 0, world, ofs, self, 0, self, waypointsprite_deployed_personal, FALSE);
294 .entity waypointsprite_attached;
295 .entity waypointsprite_attachedforcarrier;
296 entity WaypointSprite_Attach(
301 float t, maxdistance;
302 if(self.waypointsprite_attachedforcarrier)
303 return world; // can't attach to FC
309 maxdistance = waypointsprite_limitedrange;
312 return WaypointSprite_Spawn(spr, waypointsprite_deployed_lifetime, maxdistance, self, '0 0 64', world, t, self, waypointsprite_attached, FALSE);
315 entity WaypointSprite_AttachCarrier(
320 WaypointSprite_Kill(carrier.waypointsprite_attached); // FC overrides attached
321 return WaypointSprite_Spawn(spr, 0, 0, carrier, '0 0 64', world, carrier.team, carrier, waypointsprite_attachedforcarrier, FALSE);
324 void WaypointSprite_DetachCarrier(entity carrier)
326 WaypointSprite_Disown(carrier.waypointsprite_attachedforcarrier, waypointsprite_deadlifetime);
329 void WaypointSprite_ClearPersonal()
331 WaypointSprite_Kill(self.waypointsprite_deployed_personal);
334 void WaypointSprite_ClearOwned()
336 WaypointSprite_Kill(self.waypointsprite_deployed_fixed);
337 WaypointSprite_Kill(self.waypointsprite_deployed_personal);
338 WaypointSprite_Kill(self.waypointsprite_attached);
341 void WaypointSprite_PlayerDead()
343 WaypointSprite_Disown(self.waypointsprite_attached, waypointsprite_deadlifetime);
344 WaypointSprite_DetachCarrier(self);
347 void WaypointSprite_PlayerGone()
349 WaypointSprite_Disown(self.waypointsprite_deployed_fixed, waypointsprite_deadlifetime);
350 WaypointSprite_Kill(self.waypointsprite_deployed_personal);
351 WaypointSprite_Disown(self.waypointsprite_attached, waypointsprite_deadlifetime);
352 WaypointSprite_DetachCarrier(self);