4 #include "../dpdefs/progsdefs.qh"
5 #include "../dpdefs/dpextensions.qh"
8 #include "../common/constants.qh"
9 #include "../common/util.qh"
10 #include "../server/constants.qh"
11 #include "../server/defs.qh"
12 #include "../server/command/common.qh"
15 #ifdef WARPZONELIB_KEEPDEBUG
16 #define WARPZONELIB_REMOVEHACK
20 .vector warpzone_save_origin;
21 .vector warpzone_save_angles;
22 .vector warpzone_save_eorigin;
23 .vector warpzone_save_eangles;
26 .vector warpzone_oldorigin, warpzone_oldvelocity, warpzone_oldangles;
27 .float warpzone_teleport_time;
28 .float warpzone_teleport_finishtime;
29 .entity warpzone_teleport_zone;
31 void WarpZone_StoreProjectileData(entity e)
33 e.warpzone_oldorigin = e.origin;
34 e.warpzone_oldvelocity = e.velocity;
35 e.warpzone_oldangles = e.angles;
38 void WarpZone_TeleportPlayer(entity teleporter, entity player, vector to, vector to_angles, vector to_velocity)
40 setorigin (player, to); // NOTE: this also aborts the move, when this is called by touch
41 player.oldorigin = to; // for DP's unsticking
42 player.angles = to_angles;
43 player.fixangle = true;
44 player.velocity = to_velocity;
46 BITXOR_ASSIGN(player.effects, EF_TELEPORT_BIT);
49 BITCLR_ASSIGN(player.flags, FL_ONGROUND);
51 WarpZone_PostTeleportPlayer_Callback(player);
54 bool WarpZone_Teleported_Send(entity to, int sf)
56 WriteByte(MSG_ENTITY, ENT_CLIENT_WARPZONE_TELEPORTED);
57 WriteCoord(MSG_ENTITY, self.angles.x);
58 WriteCoord(MSG_ENTITY, self.angles.y);
59 WriteCoord(MSG_ENTITY, self.angles.z);
63 float WarpZone_Teleport(entity wz, entity player, float f0, float f1)
65 vector o0, a0, v0, o1, a1, v1, o10;
67 o0 = player.origin + player.view_ofs;
71 o10 = o1 = WarpZone_TransformOrigin(wz, o0);
72 v1 = WarpZone_TransformVelocity(wz, v0);
73 if (!IS_NOT_A_CLIENT(player))
74 a1 = WarpZone_TransformVAngles(wz, player.v_angle);
76 a1 = WarpZone_TransformAngles(wz, a0);
78 if(f0 != 0 || f1 != 0)
80 // retry last move but behind the warpzone!
81 // we must first go back as far as we can, then forward again, to not cause double touch events!
83 tracebox(o1 - player.view_ofs + v1 * frametime * f1, player.mins, player.maxs, o1 - player.view_ofs + v1 * frametime * f0, MOVE_WORLDONLY, player);
88 tracebox(trace_endpos, player.mins, player.maxs, o1 - player.view_ofs + v1 * frametime * f1, MOVE_NORMAL, player); // this should get us through the warpzone
91 o1 = trace_endpos + player.view_ofs;
94 md = max(vlen(player.mins), vlen(player.maxs));
95 d = WarpZone_TargetPlaneDist(wz, o1);
96 dv = WarpZone_TargetPlaneDist(wz, v1);
98 o1 = o1 - v1 * (d / dv);
101 // put him out of solid
102 tracebox(o1 - player.view_ofs, player.mins, player.maxs, o1 - player.view_ofs, MOVE_NOMONSTERS, player);
105 setorigin(player, o1 - player.view_ofs);
106 if(WarpZoneLib_MoveOutOfSolid(player))
108 o1 = player.origin + player.view_ofs;
109 setorigin(player, o0 - player.view_ofs);
113 print("would have to put player in solid, won't do that\n");
114 setorigin(player, o0 - player.view_ofs);
120 WarpZone_RefSys_Add(player, wz);
121 WarpZone_TeleportPlayer(wz, player, o1 - player.view_ofs, a1, v1);
122 WarpZone_StoreProjectileData(player);
123 player.warpzone_teleport_time = time;
124 player.warpzone_teleport_finishtime = time;
125 player.warpzone_teleport_zone = wz;
127 // prevent further teleports back
128 float dt = (o1 - o10) * v1 * (1 / (v1 * v1));
129 if(dt < sys_frametime)
130 player.warpzone_teleport_finishtime += sys_frametime - dt;
132 #ifndef WARPZONE_USE_FIXANGLE
133 if(IS_PLAYER(player))
135 // instead of fixangle, send the transform to the client for smoother operation
136 player.fixangle = false;
139 setmodel(ts, "null");
140 ts.SendEntity = WarpZone_Teleported_Send;
141 ts.SendFlags = 0xFFFFFF;
142 ts.drawonlytoclient = player;
143 ts.think = SUB_Remove;
144 ts.nextthink = time + 1;
147 ts.effects = EF_NODEPTHTEST;
148 ts.classname = "warpzone_teleported";
149 ts.angles = wz.warpzone_transform;
156 void WarpZone_Touch (void)
160 if(other.classname == "trigger_warpzone")
163 if(time <= other.warpzone_teleport_finishtime) // already teleported this frame
166 // FIXME needs a better check to know what is safe to teleport and what not
167 if(other.movetype == MOVETYPE_NONE || other.movetype == MOVETYPE_FOLLOW || other.tag_entity)
170 if(WarpZoneLib_ExactTrigger_Touch())
173 if(WarpZone_PlaneDist(self, other.origin + other.view_ofs) >= 0) // wrong side of the trigger_warpzone (don't teleport yet)
177 // number of frames we need to go back:
178 // dist = 16*sqrt(2) qu
181 // 24 qu = v*frametime*n
182 // n = 24 qu/(v*frametime)
183 // for clients go only one frame though, may be too irritating otherwise
184 // but max 0.25 sec = 0.25/frametime frames
185 // 24/(0.25/frametime)
188 d = 24 + max(vlen(other.mins), vlen(other.maxs));
189 if(IS_NOT_A_CLIENT(other))
190 f = -d / bound(frametime * d * 1, frametime * vlen(other.velocity), d);
193 if(WarpZone_Teleport(self, other, f, 0))
198 save1 = self.target; self.target = string_null;
199 save2 = self.target3; self.target3 = string_null;
201 if (!self.target) self.target = save1;
202 if (!self.target3) self.target3 = save2;
206 save1 = self.target; self.target = string_null;
207 save2 = self.target2; self.target2 = string_null;
209 if (!self.target) self.target = save1;
210 if (!self.target2) self.target2 = save2;
215 dprint("WARPZONE FAIL AHAHAHAHAH))\n");
219 bool WarpZone_Send(entity to, int sendflags)
221 WriteByte(MSG_ENTITY, ENT_CLIENT_WARPZONE);
223 // we must send this flag for clientside to match properly too
225 if(self.warpzone_isboxy)
227 if(self.warpzone_fadestart)
229 if(self.origin != '0 0 0')
231 WriteByte(MSG_ENTITY, f);
233 // we need THESE to render the warpzone (and cull properly)...
236 WriteCoord(MSG_ENTITY, self.origin.x);
237 WriteCoord(MSG_ENTITY, self.origin.y);
238 WriteCoord(MSG_ENTITY, self.origin.z);
241 WriteShort(MSG_ENTITY, self.modelindex);
242 WriteCoord(MSG_ENTITY, self.mins.x);
243 WriteCoord(MSG_ENTITY, self.mins.y);
244 WriteCoord(MSG_ENTITY, self.mins.z);
245 WriteCoord(MSG_ENTITY, self.maxs.x);
246 WriteCoord(MSG_ENTITY, self.maxs.y);
247 WriteCoord(MSG_ENTITY, self.maxs.z);
248 WriteByte(MSG_ENTITY, bound(1, self.scale * 16, 255));
250 // we need THESE to calculate the proper transform
251 WriteCoord(MSG_ENTITY, self.warpzone_origin.x);
252 WriteCoord(MSG_ENTITY, self.warpzone_origin.y);
253 WriteCoord(MSG_ENTITY, self.warpzone_origin.z);
254 WriteCoord(MSG_ENTITY, self.warpzone_angles.x);
255 WriteCoord(MSG_ENTITY, self.warpzone_angles.y);
256 WriteCoord(MSG_ENTITY, self.warpzone_angles.z);
257 WriteCoord(MSG_ENTITY, self.warpzone_targetorigin.x);
258 WriteCoord(MSG_ENTITY, self.warpzone_targetorigin.y);
259 WriteCoord(MSG_ENTITY, self.warpzone_targetorigin.z);
260 WriteCoord(MSG_ENTITY, self.warpzone_targetangles.x);
261 WriteCoord(MSG_ENTITY, self.warpzone_targetangles.y);
262 WriteCoord(MSG_ENTITY, self.warpzone_targetangles.z);
266 WriteShort(MSG_ENTITY, self.warpzone_fadestart);
267 WriteShort(MSG_ENTITY, self.warpzone_fadeend);
273 bool WarpZone_Camera_Send(entity to, int sendflags)
276 WriteByte(MSG_ENTITY, ENT_CLIENT_WARPZONE_CAMERA);
278 if(self.warpzone_fadestart)
280 if(self.origin != '0 0 0')
282 WriteByte(MSG_ENTITY, f);
284 // we need THESE to render the warpzone (and cull properly)...
287 WriteCoord(MSG_ENTITY, self.origin.x);
288 WriteCoord(MSG_ENTITY, self.origin.y);
289 WriteCoord(MSG_ENTITY, self.origin.z);
292 WriteShort(MSG_ENTITY, self.modelindex);
293 WriteCoord(MSG_ENTITY, self.mins.x);
294 WriteCoord(MSG_ENTITY, self.mins.y);
295 WriteCoord(MSG_ENTITY, self.mins.z);
296 WriteCoord(MSG_ENTITY, self.maxs.x);
297 WriteCoord(MSG_ENTITY, self.maxs.y);
298 WriteCoord(MSG_ENTITY, self.maxs.z);
299 WriteByte(MSG_ENTITY, bound(1, self.scale * 16, 255));
301 // we need THESE to calculate the proper transform
302 WriteCoord(MSG_ENTITY, self.enemy.origin.x);
303 WriteCoord(MSG_ENTITY, self.enemy.origin.y);
304 WriteCoord(MSG_ENTITY, self.enemy.origin.z);
305 WriteCoord(MSG_ENTITY, self.enemy.angles.x);
306 WriteCoord(MSG_ENTITY, self.enemy.angles.y);
307 WriteCoord(MSG_ENTITY, self.enemy.angles.z);
311 WriteShort(MSG_ENTITY, self.warpzone_fadestart);
312 WriteShort(MSG_ENTITY, self.warpzone_fadeend);
318 #ifdef WARPZONELIB_KEEPDEBUG
319 float WarpZone_CheckProjectileImpact(entity player)
323 o0 = player.origin + player.view_ofs;
324 v0 = player.velocity;
326 // if we teleported shortly before, abort
327 if(time <= player.warpzone_teleport_finishtime + 0.1)
330 // if player hit a warpzone, abort
332 wz = WarpZone_Find(o0 + player.mins, o0 + player.maxs);
336 #ifdef WARPZONELIB_REMOVEHACK
337 print("impactfilter found something - and it no longer gets handled correctly - please tell divVerent whether anything behaves broken now\n");
339 print("impactfilter found something - and it even gets handled correctly - please tell divVerent that this code apparently gets triggered again\n");
341 print("Entity type: ", player.classname, "\n");
342 print("Origin: ", vtos(player.origin), "\n");
343 print("Velocity: ", vtos(player.velocity), "\n");
345 #ifdef WARPZONELIB_REMOVEHACK
348 // retry previous move
349 setorigin(player, player.warpzone_oldorigin);
350 player.velocity = player.warpzone_oldvelocity;
351 if(WarpZone_Teleport(wz, player, 0, 1))
361 save1 = self.target; self.target = string_null;
362 save2 = self.target3; self.target3 = string_null;
364 if (!self.target) self.target = save1;
365 if (!self.target3) self.target3 = save2;
368 save1 = self.target; self.target = string_null;
369 save2 = self.target2; self.target2 = string_null;
371 if (!self.target) self.target = save1;
372 if (!self.target2) self.target2 = save2;
377 setorigin(player, o0 - player.view_ofs);
378 player.velocity = v0;
386 float WarpZone_Projectile_Touch()
388 if(other.classname == "trigger_warpzone")
391 // no further impacts if we teleported this frame!
392 // this is because even if we did teleport, the engine still may raise
393 // touch events for the previous location
394 // engine now aborts moves on teleport, so this SHOULD not happen any more
395 // but if this is called from TouchAreaGrid of the projectile moving,
396 // then this won't do
397 if(time == self.warpzone_teleport_time)
400 #ifdef WARPZONELIB_KEEPDEBUG
401 // this SEEMS to not happen at the moment, but if it did, it would be more reliable
403 float save_dpstartcontents;
404 float save_dphitcontents;
405 float save_dphitq3surfaceflags;
406 string save_dphittexturename;
408 float save_startsolid;
411 vector save_plane_normal;
412 float save_plane_dist;
416 save_dpstartcontents = trace_dpstartcontents;
417 save_dphitcontents = trace_dphitcontents;
418 save_dphitq3surfaceflags = trace_dphitq3surfaceflags;
419 save_dphittexturename = trace_dphittexturename;
420 save_allsolid = trace_allsolid;
421 save_startsolid = trace_startsolid;
422 save_fraction = trace_fraction;
423 save_endpos = trace_endpos;
424 save_plane_normal = trace_plane_normal;
425 save_plane_dist = trace_plane_dist;
426 save_ent = trace_ent;
427 save_inopen = trace_inopen;
428 save_inwater = trace_inwater;
430 if((f = WarpZone_CheckProjectileImpact(self)) != 0)
432 trace_dpstartcontents = save_dpstartcontents;
433 trace_dphitcontents = save_dphitcontents;
434 trace_dphitq3surfaceflags = save_dphitq3surfaceflags;
435 trace_dphittexturename = save_dphittexturename;
436 trace_allsolid = save_allsolid;
437 trace_startsolid = save_startsolid;
438 trace_fraction = save_fraction;
439 trace_endpos = save_endpos;
440 trace_plane_normal = save_plane_normal;
441 trace_plane_dist = save_plane_dist;
442 trace_ent = save_ent;
443 trace_inopen = save_inopen;
444 trace_inwater = save_inwater;
448 if(WarpZone_Projectile_Touch_ImpactFilter_Callback())
454 void WarpZone_InitStep_FindOriginTarget()
456 if(self.killtarget != "")
458 self.aiment = find(world, targetname, self.killtarget);
459 if(self.aiment == world)
461 error("Warp zone with nonexisting killtarget");
464 self.killtarget = string_null;
468 void WarpZonePosition_InitStep_FindTarget()
470 if(self.target == "")
472 error("Warp zone position with no target");
475 self.enemy = find(world, targetname, self.target);
476 if(self.enemy == world)
478 error("Warp zone position with nonexisting target");
481 if(self.enemy.aiment)
483 // already is positioned
484 error("Warp zone position targeting already oriented warpzone");
487 self.enemy.aiment = self;
490 void WarpZoneCamera_Think(void)
492 if(self.warpzone_save_origin != self.origin
493 || self.warpzone_save_angles != self.angles
494 || self.warpzone_save_eorigin != self.enemy.origin
495 || self.warpzone_save_eangles != self.enemy.angles)
497 WarpZone_Camera_SetUp(self, self.enemy.origin, self.enemy.angles);
498 self.warpzone_save_origin = self.origin;
499 self.warpzone_save_angles = self.angles;
500 self.warpzone_save_eorigin = self.enemy.origin;
501 self.warpzone_save_eangles = self.enemy.angles;
503 self.nextthink = time;
506 void WarpZoneCamera_InitStep_FindTarget()
510 if(self.target == "")
512 error("Camera with no target");
516 for(e = world, i = 0; (e = find(e, targetname, self.target)); )
517 if(random() * ++i < 1)
519 if(self.enemy == world)
521 error("Camera with nonexisting target");
524 warpzone_cameras_exist = 1;
525 WarpZone_Camera_SetUp(self, self.enemy.origin, self.enemy.angles);
526 self.SendFlags = 0xFFFFFF;
527 if(self.spawnflags & 1)
529 self.think = WarpZoneCamera_Think;
530 self.nextthink = time;
536 void WarpZone_InitStep_UpdateTransform()
538 vector org, ang, norm, point;
540 vector tri, a, b, c, n;
546 org = 0.5 * (self.mins + self.maxs);
548 norm = point = '0 0 0';
550 for(i_s = 0; ; ++i_s)
552 tex = getsurfacetexture(self, i_s);
554 break; // this is beyond the last one
555 if(tex == "textures/common/trigger" || tex == "trigger")
557 n_t = getsurfacenumtriangles(self, i_s);
558 for(i_t = 0; i_t < n_t; ++i_t)
560 tri = getsurfacetriangle(self, i_s, i_t);
561 a = getsurfacepoint(self, i_s, tri.x);
562 b = getsurfacepoint(self, i_s, tri.y);
563 c = getsurfacepoint(self, i_s, tri.z);
564 n = cross(c - a, b - a);
565 area = area + vlen(n);
567 point = point + vlen(n) * (a + b + c);
572 norm = norm * (1 / area);
573 point = point * (1 / (3 * area));
574 if(vlen(norm) < 0.99)
576 print("trigger_warpzone near ", vtos(self.aiment.origin), " is nonplanar. BEWARE.\n");
577 area = 0; // no autofixing in this case
579 norm = normalize(norm);
585 org = self.aiment.origin;
586 ang = self.aiment.angles;
589 org = org - ((org - point) * norm) * norm; // project to plane
591 if(norm * v_forward < 0)
593 print("Position target of trigger_warpzone near ", vtos(self.aiment.origin), " points into trigger_warpzone. BEWARE.\n");
596 ang = vectoangles2(norm, v_up); // keep rotation, but turn exactly against plane
598 if(norm * v_forward < 0.99)
599 print("trigger_warpzone near ", vtos(self.aiment.origin), " has been turned to match plane orientation (", vtos(self.aiment.angles), " -> ", vtos(ang), "\n");
600 if(vlen(org - self.aiment.origin) > 0.5)
601 print("trigger_warpzone near ", vtos(self.aiment.origin), " has been moved to match the plane (", vtos(self.aiment.origin), " -> ", vtos(org), ").\n");
607 ang = vectoangles(norm);
611 error("cannot infer origin/angles for this warpzone, please use a killtarget or a trigger_warpzone_position");
613 self.warpzone_origin = org;
614 self.warpzone_angles = ang;
617 void WarpZone_InitStep_ClearTarget()
620 self.enemy.enemy = world;
624 entity warpzone_first; .entity warpzone_next;
625 void WarpZone_InitStep_FindTarget()
633 // this way only one of the two ents needs to target
634 if(self.target != "")
636 self.enemy = self; // so the if(!e.enemy) check also skips self, saves one IF
639 for(e = world, i = 0; (e = find(e, targetname, self.target)); )
641 if(e.classname == self.classname) // possibly non-warpzones may use the same targetname!
642 if(random() * ++i < 1)
647 error("Warpzone with non-existing target");
655 void WarpZone_Think();
656 void WarpZone_InitStep_FinalizeTransform()
658 if(!self.enemy || self.enemy.enemy != self)
660 error("Invalid warp zone detected. Killed.");
664 warpzone_warpzones_exist = 1;
665 WarpZone_SetUp(self, self.warpzone_origin, self.warpzone_angles, self.enemy.warpzone_origin, self.enemy.warpzone_angles);
666 self.touch = WarpZone_Touch;
667 self.SendFlags = 0xFFFFFF;
668 if(self.spawnflags & 1)
670 self.think = WarpZone_Think;
671 self.nextthink = time;
677 float warpzone_initialized;
678 //entity warpzone_first;
679 entity warpzone_position_first;
680 entity warpzone_camera_first;
681 .entity warpzone_next;
682 void spawnfunc_misc_warpzone_position(void)
684 // "target", "angles", "origin"
685 self.warpzone_next = warpzone_position_first;
686 warpzone_position_first = self;
688 void spawnfunc_trigger_warpzone_position(void)
690 spawnfunc_misc_warpzone_position();
692 void spawnfunc_trigger_warpzone(void)
694 // warp zone entities must have:
695 // "killtarget" pointing to a target_position with a direction arrow
696 // that points AWAY from the warp zone, and that is inside
697 // the warp zone trigger
698 // "target" pointing to an identical warp zone at another place in
699 // the map, with another killtarget to designate its
702 #ifndef WARPZONE_USE_FIXANGLE
703 // used when teleporting
704 precache_model("null");
708 self.scale = self.modelscale;
713 WarpZoneLib_ExactTrigger_Init();
717 setmodel(self, m); // no precision needed
719 setorigin(self, self.origin);
721 setsize(self, self.mins * self.scale, self.maxs * self.scale);
723 setsize(self, self.mins, self.maxs);
724 self.SendEntity = WarpZone_Send;
725 self.SendFlags = 0xFFFFFF;
726 BITSET_ASSIGN(self.effects, EF_NODEPTHTEST);
727 self.warpzone_next = warpzone_first;
728 warpzone_first = self;
730 void spawnfunc_func_camera(void)
733 self.scale = self.modelscale;
738 precache_model(self.model);
739 setmodel(self, self.model); // no precision needed
741 setorigin(self, self.origin);
743 setsize(self, self.mins * self.scale, self.maxs * self.scale);
745 setsize(self, self.mins, self.maxs);
747 self.solid = SOLID_BSP;
748 else if(self.solid < 0)
749 self.solid = SOLID_NOT;
750 self.SendEntity = WarpZone_Camera_Send;
751 self.SendFlags = 0xFFFFFF;
752 self.warpzone_next = warpzone_camera_first;
753 warpzone_camera_first = self;
755 void WarpZones_Reconnect()
759 for(self = warpzone_first; self; self = self.warpzone_next)
760 WarpZone_InitStep_ClearTarget();
761 for(self = warpzone_first; self; self = self.warpzone_next)
762 WarpZone_InitStep_FindTarget();
763 for(self = warpzone_camera_first; self; self = self.warpzone_next)
764 WarpZoneCamera_InitStep_FindTarget();
765 for(self = warpzone_first; self; self = self.warpzone_next)
766 WarpZone_InitStep_FinalizeTransform();
770 void WarpZone_Think()
772 if(self.warpzone_save_origin != self.origin
773 || self.warpzone_save_angles != self.angles
774 || self.warpzone_save_eorigin != self.enemy.origin
775 || self.warpzone_save_eangles != self.enemy.angles)
779 WarpZone_InitStep_UpdateTransform();
781 WarpZone_InitStep_UpdateTransform();
783 WarpZone_InitStep_FinalizeTransform();
785 WarpZone_InitStep_FinalizeTransform();
787 self.warpzone_save_origin = self.origin;
788 self.warpzone_save_angles = self.angles;
789 self.warpzone_save_eorigin = self.enemy.origin;
790 self.warpzone_save_eangles = self.enemy.angles;
792 self.nextthink = time;
795 void WarpZone_StartFrame()
798 if(warpzone_initialized == 0)
800 warpzone_initialized = 1;
802 for(self = warpzone_first; self; self = self.warpzone_next)
803 WarpZone_InitStep_FindOriginTarget();
804 for(self = warpzone_position_first; self; self = self.warpzone_next)
805 WarpZonePosition_InitStep_FindTarget();
806 for(self = warpzone_first; self; self = self.warpzone_next)
807 WarpZone_InitStep_UpdateTransform();
809 WarpZones_Reconnect();
810 WarpZone_PostInitialize_Callback();
813 entity oldself, oldother;
816 for(e = world; (e = nextent(e)); )
818 if(warpzone_warpzones_exist) { WarpZone_StoreProjectileData(e); }
820 if(IS_REAL_CLIENT(e))
822 if(e.solid == SOLID_NOT) // not spectating?
823 if(e.movetype == MOVETYPE_NOCLIP || e.movetype == MOVETYPE_FLY || e.movetype == MOVETYPE_FLY_WORLDONLY) // not spectating? (this is to catch observers)
828 if(warpzone_warpzones_exist) {
829 self = WarpZone_Find(e.origin + e.mins, e.origin + e.maxs);
831 if(!WarpZoneLib_ExactTrigger_Touch())
832 if(WarpZone_PlaneDist(self, e.origin + e.view_ofs) <= 0)
833 WarpZone_Teleport(self, e, -1, 0); } // NOT triggering targets by this!
836 self = Teleport_Find(e.origin + e.mins, e.origin + e.maxs);
838 if(!WarpZoneLib_ExactTrigger_Touch())
839 Simple_TeleportPlayer(self, other); // NOT triggering targets by this!
843 if(IS_NOT_A_CLIENT(e))
845 if(warpzone_warpzones_exist)
846 for (; (e = nextent(e)); )
847 WarpZone_StoreProjectileData(e);
855 .float warpzone_reconnecting;
856 float visible_to_some_client(entity ent)
859 for(e = nextent(world); !IS_NOT_A_CLIENT(e); e = nextent(e))
860 if(IS_PLAYER(e) && IS_REAL_CLIENT(e))
861 if(checkpvs(e.origin + e.view_ofs, ent))
865 void trigger_warpzone_reconnect_use()
869 // NOTE: this matches for target, not targetname, but of course
870 // targetname must be set too on the other entities
871 for(self = warpzone_first; self; self = self.warpzone_next)
872 self.warpzone_reconnecting = ((e.target == "" || self.target == e.target) && !((e.spawnflags & 1) && (visible_to_some_client(self) || visible_to_some_client(self.enemy))));
873 for(self = warpzone_camera_first; self; self = self.warpzone_next)
874 self.warpzone_reconnecting = ((e.target == "" || self.target == e.target) && !((e.spawnflags & 1) && visible_to_some_client(self)));
875 for(self = warpzone_first; self; self = self.warpzone_next)
876 if(self.warpzone_reconnecting)
877 WarpZone_InitStep_ClearTarget();
878 for(self = warpzone_first; self; self = self.warpzone_next)
879 if(self.warpzone_reconnecting)
880 WarpZone_InitStep_FindTarget();
881 for(self = warpzone_camera_first; self; self = self.warpzone_next)
882 if(self.warpzone_reconnecting)
883 WarpZoneCamera_InitStep_FindTarget();
884 for(self = warpzone_first; self; self = self.warpzone_next)
885 if(self.warpzone_reconnecting || self.enemy.warpzone_reconnecting)
886 WarpZone_InitStep_FinalizeTransform();
890 void spawnfunc_trigger_warpzone_reconnect()
892 self.use = trigger_warpzone_reconnect_use;
895 void spawnfunc_target_warpzone_reconnect()
897 spawnfunc_trigger_warpzone_reconnect(); // both names make sense here :(
900 void WarpZone_PlayerPhysics_FixVAngle(void)
902 #ifndef WARPZONE_DONT_FIX_VANGLE
903 if(IS_REAL_CLIENT(self))
904 if(self.v_angle.z <= 360) // if not already adjusted
905 if(time - self.ping * 0.001 < self.warpzone_teleport_time)
907 self.v_angle = WarpZone_TransformVAngles(self.warpzone_teleport_zone, self.v_angle);
908 self.v_angle_z += 720; // mark as adjusted