7 #include "../common/constants.qh"
8 #include "../common/triggers/subs.qh"
9 #include "../common/util.qh"
10 #include "../dpdefs/dpextensions.qh"
11 #include "../dpdefs/progsdefs.qh"
12 #include "../server/command/common.qh"
13 #include "../server/constants.qh"
14 #include "../server/defs.qh"
17 #ifdef WARPZONELIB_KEEPDEBUG
18 #define WARPZONELIB_REMOVEHACK
22 .vector warpzone_save_origin;
23 .vector warpzone_save_angles;
24 .vector warpzone_save_eorigin;
25 .vector warpzone_save_eangles;
28 .vector warpzone_oldorigin, warpzone_oldvelocity, warpzone_oldangles;
29 .float warpzone_teleport_time;
30 .float warpzone_teleport_finishtime;
31 .entity warpzone_teleport_zone;
33 void WarpZone_StoreProjectileData(entity e)
35 e.warpzone_oldorigin = e.origin;
36 e.warpzone_oldvelocity = e.velocity;
37 e.warpzone_oldangles = e.angles;
40 void WarpZone_TeleportPlayer(entity teleporter, entity player, vector to, vector to_angles, vector to_velocity)
42 setorigin (player, to); // NOTE: this also aborts the move, when this is called by touch
43 player.oldorigin = to; // for DP's unsticking
44 player.angles = to_angles;
45 player.fixangle = true;
46 player.velocity = to_velocity;
48 BITXOR_ASSIGN(player.effects, EF_TELEPORT_BIT);
51 BITCLR_ASSIGN(player.flags, FL_ONGROUND);
53 WarpZone_PostTeleportPlayer_Callback(player);
56 bool WarpZone_Teleported_Send(entity to, int sf)
58 WriteByte(MSG_ENTITY, ENT_CLIENT_WARPZONE_TELEPORTED);
59 WriteCoord(MSG_ENTITY, self.angles.x);
60 WriteCoord(MSG_ENTITY, self.angles.y);
61 WriteCoord(MSG_ENTITY, self.angles.z);
65 float WarpZone_Teleport(entity wz, entity player, float f0, float f1)
67 vector o0, a0, v0, o1, a1, v1, o10;
69 o0 = player.origin + player.view_ofs;
73 o10 = o1 = WarpZone_TransformOrigin(wz, o0);
74 v1 = WarpZone_TransformVelocity(wz, v0);
75 if (!IS_NOT_A_CLIENT(player))
76 a1 = WarpZone_TransformVAngles(wz, player.v_angle);
78 a1 = WarpZone_TransformAngles(wz, a0);
80 if(f0 != 0 || f1 != 0)
82 // retry last move but behind the warpzone!
83 // we must first go back as far as we can, then forward again, to not cause double touch events!
85 tracebox(o1 - player.view_ofs + v1 * frametime * f1, player.mins, player.maxs, o1 - player.view_ofs + v1 * frametime * f0, MOVE_WORLDONLY, player);
90 tracebox(trace_endpos, player.mins, player.maxs, o1 - player.view_ofs + v1 * frametime * f1, MOVE_NORMAL, player); // this should get us through the warpzone
93 o1 = trace_endpos + player.view_ofs;
96 md = max(vlen(player.mins), vlen(player.maxs));
97 d = WarpZone_TargetPlaneDist(wz, o1);
98 dv = WarpZone_TargetPlaneDist(wz, v1);
100 o1 = o1 - v1 * (d / dv);
103 // put him out of solid
104 tracebox(o1 - player.view_ofs, player.mins, player.maxs, o1 - player.view_ofs, MOVE_NOMONSTERS, player);
107 setorigin(player, o1 - player.view_ofs);
108 if(WarpZoneLib_MoveOutOfSolid(player))
110 o1 = player.origin + player.view_ofs;
111 setorigin(player, o0 - player.view_ofs);
115 print("would have to put player in solid, won't do that\n");
116 setorigin(player, o0 - player.view_ofs);
122 WarpZone_RefSys_Add(player, wz);
123 WarpZone_TeleportPlayer(wz, player, o1 - player.view_ofs, a1, v1);
124 WarpZone_StoreProjectileData(player);
125 player.warpzone_teleport_time = time;
126 player.warpzone_teleport_finishtime = time;
127 player.warpzone_teleport_zone = wz;
129 // prevent further teleports back
130 float dt = (o1 - o10) * v1 * (1 / (v1 * v1));
131 if(dt < sys_frametime)
132 player.warpzone_teleport_finishtime += sys_frametime - dt;
134 #ifndef WARPZONE_USE_FIXANGLE
135 if(IS_PLAYER(player))
137 // instead of fixangle, send the transform to the client for smoother operation
138 player.fixangle = false;
141 setmodel(ts, "null");
142 ts.SendEntity = WarpZone_Teleported_Send;
143 ts.SendFlags = 0xFFFFFF;
144 ts.drawonlytoclient = player;
145 ts.think = SUB_Remove;
146 ts.nextthink = time + 1;
149 ts.effects = EF_NODEPTHTEST;
150 ts.classname = "warpzone_teleported";
151 ts.angles = wz.warpzone_transform;
158 void WarpZone_Touch (void)
162 if(other.classname == "trigger_warpzone")
165 if(time <= other.warpzone_teleport_finishtime) // already teleported this frame
168 // FIXME needs a better check to know what is safe to teleport and what not
169 if(other.movetype == MOVETYPE_NONE || other.movetype == MOVETYPE_FOLLOW || other.tag_entity)
172 if(WarpZoneLib_ExactTrigger_Touch())
175 if(WarpZone_PlaneDist(self, other.origin + other.view_ofs) >= 0) // wrong side of the trigger_warpzone (don't teleport yet)
179 // number of frames we need to go back:
180 // dist = 16*sqrt(2) qu
183 // 24 qu = v*frametime*n
184 // n = 24 qu/(v*frametime)
185 // for clients go only one frame though, may be too irritating otherwise
186 // but max 0.25 sec = 0.25/frametime frames
187 // 24/(0.25/frametime)
190 d = 24 + max(vlen(other.mins), vlen(other.maxs));
191 if(IS_NOT_A_CLIENT(other))
192 f = -d / bound(frametime * d * 1, frametime * vlen(other.velocity), d);
195 if(WarpZone_Teleport(self, other, f, 0))
200 save1 = self.target; self.target = string_null;
201 save2 = self.target3; self.target3 = string_null;
203 if (!self.target) self.target = save1;
204 if (!self.target3) self.target3 = save2;
208 save1 = self.target; self.target = string_null;
209 save2 = self.target2; self.target2 = string_null;
211 if (!self.target) self.target = save1;
212 if (!self.target2) self.target2 = save2;
217 dprint("WARPZONE FAIL AHAHAHAHAH))\n");
221 bool WarpZone_Send(entity to, int sendflags)
223 WriteByte(MSG_ENTITY, ENT_CLIENT_WARPZONE);
225 // we must send this flag for clientside to match properly too
227 if(self.warpzone_isboxy)
229 if(self.warpzone_fadestart)
231 if(self.origin != '0 0 0')
233 WriteByte(MSG_ENTITY, f);
235 // we need THESE to render the warpzone (and cull properly)...
238 WriteCoord(MSG_ENTITY, self.origin.x);
239 WriteCoord(MSG_ENTITY, self.origin.y);
240 WriteCoord(MSG_ENTITY, self.origin.z);
243 WriteShort(MSG_ENTITY, self.modelindex);
244 WriteCoord(MSG_ENTITY, self.mins.x);
245 WriteCoord(MSG_ENTITY, self.mins.y);
246 WriteCoord(MSG_ENTITY, self.mins.z);
247 WriteCoord(MSG_ENTITY, self.maxs.x);
248 WriteCoord(MSG_ENTITY, self.maxs.y);
249 WriteCoord(MSG_ENTITY, self.maxs.z);
250 WriteByte(MSG_ENTITY, bound(1, self.scale * 16, 255));
252 // we need THESE to calculate the proper transform
253 WriteCoord(MSG_ENTITY, self.warpzone_origin.x);
254 WriteCoord(MSG_ENTITY, self.warpzone_origin.y);
255 WriteCoord(MSG_ENTITY, self.warpzone_origin.z);
256 WriteCoord(MSG_ENTITY, self.warpzone_angles.x);
257 WriteCoord(MSG_ENTITY, self.warpzone_angles.y);
258 WriteCoord(MSG_ENTITY, self.warpzone_angles.z);
259 WriteCoord(MSG_ENTITY, self.warpzone_targetorigin.x);
260 WriteCoord(MSG_ENTITY, self.warpzone_targetorigin.y);
261 WriteCoord(MSG_ENTITY, self.warpzone_targetorigin.z);
262 WriteCoord(MSG_ENTITY, self.warpzone_targetangles.x);
263 WriteCoord(MSG_ENTITY, self.warpzone_targetangles.y);
264 WriteCoord(MSG_ENTITY, self.warpzone_targetangles.z);
268 WriteShort(MSG_ENTITY, self.warpzone_fadestart);
269 WriteShort(MSG_ENTITY, self.warpzone_fadeend);
275 bool WarpZone_Camera_Send(entity to, int sendflags)
278 WriteByte(MSG_ENTITY, ENT_CLIENT_WARPZONE_CAMERA);
280 if(self.warpzone_fadestart)
282 if(self.origin != '0 0 0')
284 WriteByte(MSG_ENTITY, f);
286 // we need THESE to render the warpzone (and cull properly)...
289 WriteCoord(MSG_ENTITY, self.origin.x);
290 WriteCoord(MSG_ENTITY, self.origin.y);
291 WriteCoord(MSG_ENTITY, self.origin.z);
294 WriteShort(MSG_ENTITY, self.modelindex);
295 WriteCoord(MSG_ENTITY, self.mins.x);
296 WriteCoord(MSG_ENTITY, self.mins.y);
297 WriteCoord(MSG_ENTITY, self.mins.z);
298 WriteCoord(MSG_ENTITY, self.maxs.x);
299 WriteCoord(MSG_ENTITY, self.maxs.y);
300 WriteCoord(MSG_ENTITY, self.maxs.z);
301 WriteByte(MSG_ENTITY, bound(1, self.scale * 16, 255));
303 // we need THESE to calculate the proper transform
304 WriteCoord(MSG_ENTITY, self.enemy.origin.x);
305 WriteCoord(MSG_ENTITY, self.enemy.origin.y);
306 WriteCoord(MSG_ENTITY, self.enemy.origin.z);
307 WriteCoord(MSG_ENTITY, self.enemy.angles.x);
308 WriteCoord(MSG_ENTITY, self.enemy.angles.y);
309 WriteCoord(MSG_ENTITY, self.enemy.angles.z);
313 WriteShort(MSG_ENTITY, self.warpzone_fadestart);
314 WriteShort(MSG_ENTITY, self.warpzone_fadeend);
320 #ifdef WARPZONELIB_KEEPDEBUG
321 float WarpZone_CheckProjectileImpact(entity player)
325 o0 = player.origin + player.view_ofs;
326 v0 = player.velocity;
328 // if we teleported shortly before, abort
329 if(time <= player.warpzone_teleport_finishtime + 0.1)
332 // if player hit a warpzone, abort
334 wz = WarpZone_Find(o0 + player.mins, o0 + player.maxs);
338 #ifdef WARPZONELIB_REMOVEHACK
339 print("impactfilter found something - and it no longer gets handled correctly - please tell divVerent whether anything behaves broken now\n");
341 print("impactfilter found something - and it even gets handled correctly - please tell divVerent that this code apparently gets triggered again\n");
343 print("Entity type: ", player.classname, "\n");
344 print("Origin: ", vtos(player.origin), "\n");
345 print("Velocity: ", vtos(player.velocity), "\n");
347 #ifdef WARPZONELIB_REMOVEHACK
350 // retry previous move
351 setorigin(player, player.warpzone_oldorigin);
352 player.velocity = player.warpzone_oldvelocity;
353 if(WarpZone_Teleport(wz, player, 0, 1))
363 save1 = self.target; self.target = string_null;
364 save2 = self.target3; self.target3 = string_null;
366 if (!self.target) self.target = save1;
367 if (!self.target3) self.target3 = save2;
370 save1 = self.target; self.target = string_null;
371 save2 = self.target2; self.target2 = string_null;
373 if (!self.target) self.target = save1;
374 if (!self.target2) self.target2 = save2;
379 setorigin(player, o0 - player.view_ofs);
380 player.velocity = v0;
388 float WarpZone_Projectile_Touch()
390 if(other.classname == "trigger_warpzone")
393 // no further impacts if we teleported this frame!
394 // this is because even if we did teleport, the engine still may raise
395 // touch events for the previous location
396 // engine now aborts moves on teleport, so this SHOULD not happen any more
397 // but if this is called from TouchAreaGrid of the projectile moving,
398 // then this won't do
399 if(time == self.warpzone_teleport_time)
402 #ifdef WARPZONELIB_KEEPDEBUG
403 // this SEEMS to not happen at the moment, but if it did, it would be more reliable
405 float save_dpstartcontents;
406 float save_dphitcontents;
407 float save_dphitq3surfaceflags;
408 string save_dphittexturename;
410 float save_startsolid;
413 vector save_plane_normal;
414 float save_plane_dist;
418 save_dpstartcontents = trace_dpstartcontents;
419 save_dphitcontents = trace_dphitcontents;
420 save_dphitq3surfaceflags = trace_dphitq3surfaceflags;
421 save_dphittexturename = trace_dphittexturename;
422 save_allsolid = trace_allsolid;
423 save_startsolid = trace_startsolid;
424 save_fraction = trace_fraction;
425 save_endpos = trace_endpos;
426 save_plane_normal = trace_plane_normal;
427 save_plane_dist = trace_plane_dist;
428 save_ent = trace_ent;
429 save_inopen = trace_inopen;
430 save_inwater = trace_inwater;
432 if((f = WarpZone_CheckProjectileImpact(self)) != 0)
434 trace_dpstartcontents = save_dpstartcontents;
435 trace_dphitcontents = save_dphitcontents;
436 trace_dphitq3surfaceflags = save_dphitq3surfaceflags;
437 trace_dphittexturename = save_dphittexturename;
438 trace_allsolid = save_allsolid;
439 trace_startsolid = save_startsolid;
440 trace_fraction = save_fraction;
441 trace_endpos = save_endpos;
442 trace_plane_normal = save_plane_normal;
443 trace_plane_dist = save_plane_dist;
444 trace_ent = save_ent;
445 trace_inopen = save_inopen;
446 trace_inwater = save_inwater;
450 if(WarpZone_Projectile_Touch_ImpactFilter_Callback())
456 void WarpZone_InitStep_FindOriginTarget()
458 if(self.killtarget != "")
460 self.aiment = find(world, targetname, self.killtarget);
461 if(self.aiment == world)
463 error("Warp zone with nonexisting killtarget");
466 self.killtarget = string_null;
470 void WarpZonePosition_InitStep_FindTarget()
472 if(self.target == "")
474 error("Warp zone position with no target");
477 self.enemy = find(world, targetname, self.target);
478 if(self.enemy == world)
480 error("Warp zone position with nonexisting target");
483 if(self.enemy.aiment)
485 // already is positioned
486 error("Warp zone position targeting already oriented warpzone");
489 self.enemy.aiment = self;
492 void WarpZoneCamera_Think(void)
494 if(self.warpzone_save_origin != self.origin
495 || self.warpzone_save_angles != self.angles
496 || self.warpzone_save_eorigin != self.enemy.origin
497 || self.warpzone_save_eangles != self.enemy.angles)
499 WarpZone_Camera_SetUp(self, self.enemy.origin, self.enemy.angles);
500 self.warpzone_save_origin = self.origin;
501 self.warpzone_save_angles = self.angles;
502 self.warpzone_save_eorigin = self.enemy.origin;
503 self.warpzone_save_eangles = self.enemy.angles;
505 self.nextthink = time;
508 void WarpZoneCamera_InitStep_FindTarget()
512 if(self.target == "")
514 error("Camera with no target");
518 for(e = world, i = 0; (e = find(e, targetname, self.target)); )
519 if(random() * ++i < 1)
521 if(self.enemy == world)
523 error("Camera with nonexisting target");
526 warpzone_cameras_exist = 1;
527 WarpZone_Camera_SetUp(self, self.enemy.origin, self.enemy.angles);
528 self.SendFlags = 0xFFFFFF;
529 if(self.spawnflags & 1)
531 self.think = WarpZoneCamera_Think;
532 self.nextthink = time;
538 void WarpZone_InitStep_UpdateTransform()
540 vector org, ang, norm, point;
542 vector tri, a, b, c, n;
548 org = 0.5 * (self.mins + self.maxs);
550 norm = point = '0 0 0';
552 for(i_s = 0; ; ++i_s)
554 tex = getsurfacetexture(self, i_s);
556 break; // this is beyond the last one
557 if(tex == "textures/common/trigger" || tex == "trigger")
559 n_t = getsurfacenumtriangles(self, i_s);
560 for(i_t = 0; i_t < n_t; ++i_t)
562 tri = getsurfacetriangle(self, i_s, i_t);
563 a = getsurfacepoint(self, i_s, tri.x);
564 b = getsurfacepoint(self, i_s, tri.y);
565 c = getsurfacepoint(self, i_s, tri.z);
566 n = cross(c - a, b - a);
567 area = area + vlen(n);
569 point = point + vlen(n) * (a + b + c);
574 norm = norm * (1 / area);
575 point = point * (1 / (3 * area));
576 if(vlen(norm) < 0.99)
578 print("trigger_warpzone near ", vtos(self.aiment.origin), " is nonplanar. BEWARE.\n");
579 area = 0; // no autofixing in this case
581 norm = normalize(norm);
587 org = self.aiment.origin;
588 ang = self.aiment.angles;
591 org = org - ((org - point) * norm) * norm; // project to plane
593 if(norm * v_forward < 0)
595 print("Position target of trigger_warpzone near ", vtos(self.aiment.origin), " points into trigger_warpzone. BEWARE.\n");
598 ang = vectoangles2(norm, v_up); // keep rotation, but turn exactly against plane
600 if(norm * v_forward < 0.99)
601 print("trigger_warpzone near ", vtos(self.aiment.origin), " has been turned to match plane orientation (", vtos(self.aiment.angles), " -> ", vtos(ang), "\n");
602 if(vlen(org - self.aiment.origin) > 0.5)
603 print("trigger_warpzone near ", vtos(self.aiment.origin), " has been moved to match the plane (", vtos(self.aiment.origin), " -> ", vtos(org), ").\n");
609 ang = vectoangles(norm);
613 error("cannot infer origin/angles for this warpzone, please use a killtarget or a trigger_warpzone_position");
615 self.warpzone_origin = org;
616 self.warpzone_angles = ang;
619 void WarpZone_InitStep_ClearTarget()
622 self.enemy.enemy = world;
626 entity warpzone_first; .entity warpzone_next;
627 void WarpZone_InitStep_FindTarget()
635 // this way only one of the two ents needs to target
636 if(self.target != "")
638 self.enemy = self; // so the if(!e.enemy) check also skips self, saves one IF
641 for(e = world, i = 0; (e = find(e, targetname, self.target)); )
643 if(e.classname == self.classname) // possibly non-warpzones may use the same targetname!
644 if(random() * ++i < 1)
649 error("Warpzone with non-existing target");
657 void WarpZone_Think();
658 void WarpZone_InitStep_FinalizeTransform()
660 if(!self.enemy || self.enemy.enemy != self)
662 error("Invalid warp zone detected. Killed.");
666 warpzone_warpzones_exist = 1;
667 WarpZone_SetUp(self, self.warpzone_origin, self.warpzone_angles, self.enemy.warpzone_origin, self.enemy.warpzone_angles);
668 self.touch = WarpZone_Touch;
669 self.SendFlags = 0xFFFFFF;
670 if(self.spawnflags & 1)
672 self.think = WarpZone_Think;
673 self.nextthink = time;
679 float warpzone_initialized;
680 //entity warpzone_first;
681 entity warpzone_position_first;
682 entity warpzone_camera_first;
683 .entity warpzone_next;
684 void spawnfunc_misc_warpzone_position(void)
686 // "target", "angles", "origin"
687 self.warpzone_next = warpzone_position_first;
688 warpzone_position_first = self;
690 void spawnfunc_trigger_warpzone_position(void)
692 spawnfunc_misc_warpzone_position();
694 void spawnfunc_trigger_warpzone(void)
696 // warp zone entities must have:
697 // "killtarget" pointing to a target_position with a direction arrow
698 // that points AWAY from the warp zone, and that is inside
699 // the warp zone trigger
700 // "target" pointing to an identical warp zone at another place in
701 // the map, with another killtarget to designate its
704 #ifndef WARPZONE_USE_FIXANGLE
705 // used when teleporting
706 precache_model("null");
710 self.scale = self.modelscale;
715 WarpZoneLib_ExactTrigger_Init();
719 setmodel(self, m); // no precision needed
721 setorigin(self, self.origin);
723 setsize(self, self.mins * self.scale, self.maxs * self.scale);
725 setsize(self, self.mins, self.maxs);
726 self.SendEntity = WarpZone_Send;
727 self.SendFlags = 0xFFFFFF;
728 BITSET_ASSIGN(self.effects, EF_NODEPTHTEST);
729 self.warpzone_next = warpzone_first;
730 warpzone_first = self;
732 void spawnfunc_func_camera(void)
735 self.scale = self.modelscale;
740 precache_model(self.model);
741 setmodel(self, self.model); // no precision needed
743 setorigin(self, self.origin);
745 setsize(self, self.mins * self.scale, self.maxs * self.scale);
747 setsize(self, self.mins, self.maxs);
749 self.solid = SOLID_BSP;
750 else if(self.solid < 0)
751 self.solid = SOLID_NOT;
752 self.SendEntity = WarpZone_Camera_Send;
753 self.SendFlags = 0xFFFFFF;
754 self.warpzone_next = warpzone_camera_first;
755 warpzone_camera_first = self;
757 void WarpZones_Reconnect()
761 for(self = warpzone_first; self; self = self.warpzone_next)
762 WarpZone_InitStep_ClearTarget();
763 for(self = warpzone_first; self; self = self.warpzone_next)
764 WarpZone_InitStep_FindTarget();
765 for(self = warpzone_camera_first; self; self = self.warpzone_next)
766 WarpZoneCamera_InitStep_FindTarget();
767 for(self = warpzone_first; self; self = self.warpzone_next)
768 WarpZone_InitStep_FinalizeTransform();
772 void WarpZone_Think()
774 if(self.warpzone_save_origin != self.origin
775 || self.warpzone_save_angles != self.angles
776 || self.warpzone_save_eorigin != self.enemy.origin
777 || self.warpzone_save_eangles != self.enemy.angles)
781 WarpZone_InitStep_UpdateTransform();
783 WarpZone_InitStep_UpdateTransform();
785 WarpZone_InitStep_FinalizeTransform();
787 WarpZone_InitStep_FinalizeTransform();
789 self.warpzone_save_origin = self.origin;
790 self.warpzone_save_angles = self.angles;
791 self.warpzone_save_eorigin = self.enemy.origin;
792 self.warpzone_save_eangles = self.enemy.angles;
794 self.nextthink = time;
797 void WarpZone_StartFrame()
800 if(warpzone_initialized == 0)
802 warpzone_initialized = 1;
804 for(self = warpzone_first; self; self = self.warpzone_next)
805 WarpZone_InitStep_FindOriginTarget();
806 for(self = warpzone_position_first; self; self = self.warpzone_next)
807 WarpZonePosition_InitStep_FindTarget();
808 for(self = warpzone_first; self; self = self.warpzone_next)
809 WarpZone_InitStep_UpdateTransform();
811 WarpZones_Reconnect();
812 WarpZone_PostInitialize_Callback();
815 entity oldself, oldother;
818 for(e = world; (e = nextent(e)); )
820 if(warpzone_warpzones_exist) { WarpZone_StoreProjectileData(e); }
822 if(IS_REAL_CLIENT(e))
824 if(e.solid == SOLID_NOT) // not spectating?
825 if(e.movetype == MOVETYPE_NOCLIP || e.movetype == MOVETYPE_FLY || e.movetype == MOVETYPE_FLY_WORLDONLY) // not spectating? (this is to catch observers)
830 if(warpzone_warpzones_exist) {
831 self = WarpZone_Find(e.origin + e.mins, e.origin + e.maxs);
833 if(!WarpZoneLib_ExactTrigger_Touch())
834 if(WarpZone_PlaneDist(self, e.origin + e.view_ofs) <= 0)
835 WarpZone_Teleport(self, e, -1, 0); } // NOT triggering targets by this!
838 self = Teleport_Find(e.origin + e.mins, e.origin + e.maxs);
840 if(!WarpZoneLib_ExactTrigger_Touch())
841 Simple_TeleportPlayer(self, other); // NOT triggering targets by this!
845 if(IS_NOT_A_CLIENT(e))
847 if(warpzone_warpzones_exist)
848 for (; (e = nextent(e)); )
849 WarpZone_StoreProjectileData(e);
857 .float warpzone_reconnecting;
858 float visible_to_some_client(entity ent)
861 for(e = nextent(world); !IS_NOT_A_CLIENT(e); e = nextent(e))
862 if(IS_PLAYER(e) && IS_REAL_CLIENT(e))
863 if(checkpvs(e.origin + e.view_ofs, ent))
867 void trigger_warpzone_reconnect_use()
871 // NOTE: this matches for target, not targetname, but of course
872 // targetname must be set too on the other entities
873 for(self = warpzone_first; self; self = self.warpzone_next)
874 self.warpzone_reconnecting = ((e.target == "" || self.target == e.target) && !((e.spawnflags & 1) && (visible_to_some_client(self) || visible_to_some_client(self.enemy))));
875 for(self = warpzone_camera_first; self; self = self.warpzone_next)
876 self.warpzone_reconnecting = ((e.target == "" || self.target == e.target) && !((e.spawnflags & 1) && visible_to_some_client(self)));
877 for(self = warpzone_first; self; self = self.warpzone_next)
878 if(self.warpzone_reconnecting)
879 WarpZone_InitStep_ClearTarget();
880 for(self = warpzone_first; self; self = self.warpzone_next)
881 if(self.warpzone_reconnecting)
882 WarpZone_InitStep_FindTarget();
883 for(self = warpzone_camera_first; self; self = self.warpzone_next)
884 if(self.warpzone_reconnecting)
885 WarpZoneCamera_InitStep_FindTarget();
886 for(self = warpzone_first; self; self = self.warpzone_next)
887 if(self.warpzone_reconnecting || self.enemy.warpzone_reconnecting)
888 WarpZone_InitStep_FinalizeTransform();
892 void spawnfunc_trigger_warpzone_reconnect()
894 self.use = trigger_warpzone_reconnect_use;
897 void spawnfunc_target_warpzone_reconnect()
899 spawnfunc_trigger_warpzone_reconnect(); // both names make sense here :(
902 void WarpZone_PlayerPhysics_FixVAngle(void)
904 #ifndef WARPZONE_DONT_FIX_VANGLE
905 if(IS_REAL_CLIENT(self))
906 if(self.v_angle.z <= 360) // if not already adjusted
907 if(time - self.ping * 0.001 < self.warpzone_teleport_time)
909 self.v_angle = WarpZone_TransformVAngles(self.warpzone_teleport_zone, self.v_angle);
910 self.v_angle_z += 720; // mark as adjusted