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_VEHICLE(player) && player.owner)
136 player = player.owner; // hax
137 if(IS_PLAYER(player))
139 // instead of fixangle, send the transform to the client for smoother operation
140 player.fixangle = false;
143 setmodel(ts, "null");
144 ts.SendEntity = WarpZone_Teleported_Send;
145 ts.SendFlags = 0xFFFFFF;
146 ts.drawonlytoclient = player;
147 ts.think = SUB_Remove;
148 ts.nextthink = time + 1;
151 ts.effects = EF_NODEPTHTEST;
152 ts.classname = "warpzone_teleported";
153 ts.angles = wz.warpzone_transform;
160 void WarpZone_Touch (void)
164 if(other.classname == "trigger_warpzone")
167 if(time <= other.warpzone_teleport_finishtime) // already teleported this frame
170 // FIXME needs a better check to know what is safe to teleport and what not
171 if(other.movetype == MOVETYPE_NONE || other.movetype == MOVETYPE_FOLLOW || other.tag_entity)
174 if(WarpZoneLib_ExactTrigger_Touch())
177 if(WarpZone_PlaneDist(self, other.origin + other.view_ofs) >= 0) // wrong side of the trigger_warpzone (don't teleport yet)
181 // number of frames we need to go back:
182 // dist = 16*sqrt(2) qu
185 // 24 qu = v*frametime*n
186 // n = 24 qu/(v*frametime)
187 // for clients go only one frame though, may be too irritating otherwise
188 // but max 0.25 sec = 0.25/frametime frames
189 // 24/(0.25/frametime)
192 d = 24 + max(vlen(other.mins), vlen(other.maxs));
193 if(IS_NOT_A_CLIENT(other))
194 f = -d / bound(frametime * d * 1, frametime * vlen(other.velocity), d);
197 if(WarpZone_Teleport(self, other, f, 0))
202 save1 = self.target; self.target = string_null;
203 save2 = self.target3; self.target3 = string_null;
205 if (!self.target) self.target = save1;
206 if (!self.target3) self.target3 = save2;
210 save1 = self.target; self.target = string_null;
211 save2 = self.target2; self.target2 = string_null;
213 if (!self.target) self.target = save1;
214 if (!self.target2) self.target2 = save2;
219 dprint("WARPZONE FAIL AHAHAHAHAH))\n");
223 bool WarpZone_Send(entity to, int sendflags)
225 WriteByte(MSG_ENTITY, ENT_CLIENT_WARPZONE);
227 // we must send this flag for clientside to match properly too
229 if(self.warpzone_isboxy)
231 if(self.warpzone_fadestart)
233 if(self.origin != '0 0 0')
235 WriteByte(MSG_ENTITY, f);
237 // we need THESE to render the warpzone (and cull properly)...
240 WriteCoord(MSG_ENTITY, self.origin.x);
241 WriteCoord(MSG_ENTITY, self.origin.y);
242 WriteCoord(MSG_ENTITY, self.origin.z);
245 WriteShort(MSG_ENTITY, self.modelindex);
246 WriteCoord(MSG_ENTITY, self.mins.x);
247 WriteCoord(MSG_ENTITY, self.mins.y);
248 WriteCoord(MSG_ENTITY, self.mins.z);
249 WriteCoord(MSG_ENTITY, self.maxs.x);
250 WriteCoord(MSG_ENTITY, self.maxs.y);
251 WriteCoord(MSG_ENTITY, self.maxs.z);
252 WriteByte(MSG_ENTITY, bound(1, self.scale * 16, 255));
254 // we need THESE to calculate the proper transform
255 WriteCoord(MSG_ENTITY, self.warpzone_origin.x);
256 WriteCoord(MSG_ENTITY, self.warpzone_origin.y);
257 WriteCoord(MSG_ENTITY, self.warpzone_origin.z);
258 WriteCoord(MSG_ENTITY, self.warpzone_angles.x);
259 WriteCoord(MSG_ENTITY, self.warpzone_angles.y);
260 WriteCoord(MSG_ENTITY, self.warpzone_angles.z);
261 WriteCoord(MSG_ENTITY, self.warpzone_targetorigin.x);
262 WriteCoord(MSG_ENTITY, self.warpzone_targetorigin.y);
263 WriteCoord(MSG_ENTITY, self.warpzone_targetorigin.z);
264 WriteCoord(MSG_ENTITY, self.warpzone_targetangles.x);
265 WriteCoord(MSG_ENTITY, self.warpzone_targetangles.y);
266 WriteCoord(MSG_ENTITY, self.warpzone_targetangles.z);
270 WriteShort(MSG_ENTITY, self.warpzone_fadestart);
271 WriteShort(MSG_ENTITY, self.warpzone_fadeend);
277 bool WarpZone_Camera_Send(entity to, int sendflags)
280 WriteByte(MSG_ENTITY, ENT_CLIENT_WARPZONE_CAMERA);
282 if(self.warpzone_fadestart)
284 if(self.origin != '0 0 0')
286 WriteByte(MSG_ENTITY, f);
288 // we need THESE to render the warpzone (and cull properly)...
291 WriteCoord(MSG_ENTITY, self.origin.x);
292 WriteCoord(MSG_ENTITY, self.origin.y);
293 WriteCoord(MSG_ENTITY, self.origin.z);
296 WriteShort(MSG_ENTITY, self.modelindex);
297 WriteCoord(MSG_ENTITY, self.mins.x);
298 WriteCoord(MSG_ENTITY, self.mins.y);
299 WriteCoord(MSG_ENTITY, self.mins.z);
300 WriteCoord(MSG_ENTITY, self.maxs.x);
301 WriteCoord(MSG_ENTITY, self.maxs.y);
302 WriteCoord(MSG_ENTITY, self.maxs.z);
303 WriteByte(MSG_ENTITY, bound(1, self.scale * 16, 255));
305 // we need THESE to calculate the proper transform
306 WriteCoord(MSG_ENTITY, self.enemy.origin.x);
307 WriteCoord(MSG_ENTITY, self.enemy.origin.y);
308 WriteCoord(MSG_ENTITY, self.enemy.origin.z);
309 WriteCoord(MSG_ENTITY, self.enemy.angles.x);
310 WriteCoord(MSG_ENTITY, self.enemy.angles.y);
311 WriteCoord(MSG_ENTITY, self.enemy.angles.z);
315 WriteShort(MSG_ENTITY, self.warpzone_fadestart);
316 WriteShort(MSG_ENTITY, self.warpzone_fadeend);
322 #ifdef WARPZONELIB_KEEPDEBUG
323 float WarpZone_CheckProjectileImpact(entity player)
327 o0 = player.origin + player.view_ofs;
328 v0 = player.velocity;
330 // if we teleported shortly before, abort
331 if(time <= player.warpzone_teleport_finishtime + 0.1)
334 // if player hit a warpzone, abort
336 wz = WarpZone_Find(o0 + player.mins, o0 + player.maxs);
340 #ifdef WARPZONELIB_REMOVEHACK
341 print("impactfilter found something - and it no longer gets handled correctly - please tell divVerent whether anything behaves broken now\n");
343 print("impactfilter found something - and it even gets handled correctly - please tell divVerent that this code apparently gets triggered again\n");
345 print("Entity type: ", player.classname, "\n");
346 print("Origin: ", vtos(player.origin), "\n");
347 print("Velocity: ", vtos(player.velocity), "\n");
349 #ifdef WARPZONELIB_REMOVEHACK
352 // retry previous move
353 setorigin(player, player.warpzone_oldorigin);
354 player.velocity = player.warpzone_oldvelocity;
355 if(WarpZone_Teleport(wz, player, 0, 1))
365 save1 = self.target; self.target = string_null;
366 save2 = self.target3; self.target3 = string_null;
368 if (!self.target) self.target = save1;
369 if (!self.target3) self.target3 = save2;
372 save1 = self.target; self.target = string_null;
373 save2 = self.target2; self.target2 = string_null;
375 if (!self.target) self.target = save1;
376 if (!self.target2) self.target2 = save2;
381 setorigin(player, o0 - player.view_ofs);
382 player.velocity = v0;
390 float WarpZone_Projectile_Touch()
392 if(other.classname == "trigger_warpzone")
395 // no further impacts if we teleported this frame!
396 // this is because even if we did teleport, the engine still may raise
397 // touch events for the previous location
398 // engine now aborts moves on teleport, so this SHOULD not happen any more
399 // but if this is called from TouchAreaGrid of the projectile moving,
400 // then this won't do
401 if(time == self.warpzone_teleport_time)
404 #ifdef WARPZONELIB_KEEPDEBUG
405 // this SEEMS to not happen at the moment, but if it did, it would be more reliable
407 float save_dpstartcontents;
408 float save_dphitcontents;
409 float save_dphitq3surfaceflags;
410 string save_dphittexturename;
412 float save_startsolid;
415 vector save_plane_normal;
416 float save_plane_dist;
420 save_dpstartcontents = trace_dpstartcontents;
421 save_dphitcontents = trace_dphitcontents;
422 save_dphitq3surfaceflags = trace_dphitq3surfaceflags;
423 save_dphittexturename = trace_dphittexturename;
424 save_allsolid = trace_allsolid;
425 save_startsolid = trace_startsolid;
426 save_fraction = trace_fraction;
427 save_endpos = trace_endpos;
428 save_plane_normal = trace_plane_normal;
429 save_plane_dist = trace_plane_dist;
430 save_ent = trace_ent;
431 save_inopen = trace_inopen;
432 save_inwater = trace_inwater;
434 if((f = WarpZone_CheckProjectileImpact(self)) != 0)
436 trace_dpstartcontents = save_dpstartcontents;
437 trace_dphitcontents = save_dphitcontents;
438 trace_dphitq3surfaceflags = save_dphitq3surfaceflags;
439 trace_dphittexturename = save_dphittexturename;
440 trace_allsolid = save_allsolid;
441 trace_startsolid = save_startsolid;
442 trace_fraction = save_fraction;
443 trace_endpos = save_endpos;
444 trace_plane_normal = save_plane_normal;
445 trace_plane_dist = save_plane_dist;
446 trace_ent = save_ent;
447 trace_inopen = save_inopen;
448 trace_inwater = save_inwater;
452 if(WarpZone_Projectile_Touch_ImpactFilter_Callback())
458 void WarpZone_InitStep_FindOriginTarget()
460 if(self.killtarget != "")
462 self.aiment = find(world, targetname, self.killtarget);
463 if(self.aiment == world)
465 error("Warp zone with nonexisting killtarget");
468 self.killtarget = string_null;
472 void WarpZonePosition_InitStep_FindTarget()
474 if(self.target == "")
476 error("Warp zone position with no target");
479 self.enemy = find(world, targetname, self.target);
480 if(self.enemy == world)
482 error("Warp zone position with nonexisting target");
485 if(self.enemy.aiment)
487 // already is positioned
488 error("Warp zone position targeting already oriented warpzone");
491 self.enemy.aiment = self;
494 void WarpZoneCamera_Think(void)
496 if(self.warpzone_save_origin != self.origin
497 || self.warpzone_save_angles != self.angles
498 || self.warpzone_save_eorigin != self.enemy.origin
499 || self.warpzone_save_eangles != self.enemy.angles)
501 WarpZone_Camera_SetUp(self, self.enemy.origin, self.enemy.angles);
502 self.warpzone_save_origin = self.origin;
503 self.warpzone_save_angles = self.angles;
504 self.warpzone_save_eorigin = self.enemy.origin;
505 self.warpzone_save_eangles = self.enemy.angles;
507 self.nextthink = time;
510 void WarpZoneCamera_InitStep_FindTarget()
514 if(self.target == "")
516 error("Camera with no target");
520 for(e = world, i = 0; (e = find(e, targetname, self.target)); )
521 if(random() * ++i < 1)
523 if(self.enemy == world)
525 error("Camera with nonexisting target");
528 warpzone_cameras_exist = 1;
529 WarpZone_Camera_SetUp(self, self.enemy.origin, self.enemy.angles);
530 self.SendFlags = 0xFFFFFF;
531 if(self.spawnflags & 1)
533 self.think = WarpZoneCamera_Think;
534 self.nextthink = time;
540 void WarpZone_InitStep_UpdateTransform()
542 vector org, ang, norm, point;
544 vector tri, a, b, c, n;
550 org = 0.5 * (self.mins + self.maxs);
552 norm = point = '0 0 0';
554 for(i_s = 0; ; ++i_s)
556 tex = getsurfacetexture(self, i_s);
558 break; // this is beyond the last one
559 if(tex == "textures/common/trigger" || tex == "trigger")
561 n_t = getsurfacenumtriangles(self, i_s);
562 for(i_t = 0; i_t < n_t; ++i_t)
564 tri = getsurfacetriangle(self, i_s, i_t);
565 a = getsurfacepoint(self, i_s, tri.x);
566 b = getsurfacepoint(self, i_s, tri.y);
567 c = getsurfacepoint(self, i_s, tri.z);
568 n = cross(c - a, b - a);
569 area = area + vlen(n);
571 point = point + vlen(n) * (a + b + c);
576 norm = norm * (1 / area);
577 point = point * (1 / (3 * area));
578 if(vlen(norm) < 0.99)
580 print("trigger_warpzone near ", vtos(self.aiment.origin), " is nonplanar. BEWARE.\n");
581 area = 0; // no autofixing in this case
583 norm = normalize(norm);
589 org = self.aiment.origin;
590 ang = self.aiment.angles;
593 org = org - ((org - point) * norm) * norm; // project to plane
595 if(norm * v_forward < 0)
597 print("Position target of trigger_warpzone near ", vtos(self.aiment.origin), " points into trigger_warpzone. BEWARE.\n");
600 ang = vectoangles2(norm, v_up); // keep rotation, but turn exactly against plane
602 if(norm * v_forward < 0.99)
603 print("trigger_warpzone near ", vtos(self.aiment.origin), " has been turned to match plane orientation (", vtos(self.aiment.angles), " -> ", vtos(ang), "\n");
604 if(vlen(org - self.aiment.origin) > 0.5)
605 print("trigger_warpzone near ", vtos(self.aiment.origin), " has been moved to match the plane (", vtos(self.aiment.origin), " -> ", vtos(org), ").\n");
611 ang = vectoangles(norm);
615 error("cannot infer origin/angles for this warpzone, please use a killtarget or a trigger_warpzone_position");
617 self.warpzone_origin = org;
618 self.warpzone_angles = ang;
621 void WarpZone_InitStep_ClearTarget()
624 self.enemy.enemy = world;
628 entity warpzone_first; .entity warpzone_next;
629 void WarpZone_InitStep_FindTarget()
637 // this way only one of the two ents needs to target
638 if(self.target != "")
640 self.enemy = self; // so the if(!e.enemy) check also skips self, saves one IF
643 for(e = world, i = 0; (e = find(e, targetname, self.target)); )
645 if(e.classname == self.classname) // possibly non-warpzones may use the same targetname!
646 if(random() * ++i < 1)
651 error("Warpzone with non-existing target");
659 void WarpZone_Think();
660 void WarpZone_InitStep_FinalizeTransform()
662 if(!self.enemy || self.enemy.enemy != self)
664 error("Invalid warp zone detected. Killed.");
668 warpzone_warpzones_exist = 1;
669 WarpZone_SetUp(self, self.warpzone_origin, self.warpzone_angles, self.enemy.warpzone_origin, self.enemy.warpzone_angles);
670 self.touch = WarpZone_Touch;
671 self.SendFlags = 0xFFFFFF;
672 if(self.spawnflags & 1)
674 self.think = WarpZone_Think;
675 self.nextthink = time;
681 float warpzone_initialized;
682 //entity warpzone_first;
683 entity warpzone_position_first;
684 entity warpzone_camera_first;
685 .entity warpzone_next;
686 void spawnfunc_misc_warpzone_position(void)
688 // "target", "angles", "origin"
689 self.warpzone_next = warpzone_position_first;
690 warpzone_position_first = self;
692 void spawnfunc_trigger_warpzone_position(void)
694 spawnfunc_misc_warpzone_position();
696 void spawnfunc_trigger_warpzone(void)
698 // warp zone entities must have:
699 // "killtarget" pointing to a target_position with a direction arrow
700 // that points AWAY from the warp zone, and that is inside
701 // the warp zone trigger
702 // "target" pointing to an identical warp zone at another place in
703 // the map, with another killtarget to designate its
706 #ifndef WARPZONE_USE_FIXANGLE
707 // used when teleporting
708 precache_model("null");
712 self.scale = self.modelscale;
717 WarpZoneLib_ExactTrigger_Init();
721 setmodel(self, m); // no precision needed
723 setorigin(self, self.origin);
725 setsize(self, self.mins * self.scale, self.maxs * self.scale);
727 setsize(self, self.mins, self.maxs);
728 self.SendEntity = WarpZone_Send;
729 self.SendFlags = 0xFFFFFF;
730 BITSET_ASSIGN(self.effects, EF_NODEPTHTEST);
731 self.warpzone_next = warpzone_first;
732 warpzone_first = self;
734 void spawnfunc_func_camera(void)
737 self.scale = self.modelscale;
742 precache_model(self.model);
743 setmodel(self, self.model); // no precision needed
745 setorigin(self, self.origin);
747 setsize(self, self.mins * self.scale, self.maxs * self.scale);
749 setsize(self, self.mins, self.maxs);
751 self.solid = SOLID_BSP;
752 else if(self.solid < 0)
753 self.solid = SOLID_NOT;
754 self.SendEntity = WarpZone_Camera_Send;
755 self.SendFlags = 0xFFFFFF;
756 self.warpzone_next = warpzone_camera_first;
757 warpzone_camera_first = self;
759 void WarpZones_Reconnect()
763 for(self = warpzone_first; self; self = self.warpzone_next)
764 WarpZone_InitStep_ClearTarget();
765 for(self = warpzone_first; self; self = self.warpzone_next)
766 WarpZone_InitStep_FindTarget();
767 for(self = warpzone_camera_first; self; self = self.warpzone_next)
768 WarpZoneCamera_InitStep_FindTarget();
769 for(self = warpzone_first; self; self = self.warpzone_next)
770 WarpZone_InitStep_FinalizeTransform();
774 void WarpZone_Think()
776 if(self.warpzone_save_origin != self.origin
777 || self.warpzone_save_angles != self.angles
778 || self.warpzone_save_eorigin != self.enemy.origin
779 || self.warpzone_save_eangles != self.enemy.angles)
783 WarpZone_InitStep_UpdateTransform();
785 WarpZone_InitStep_UpdateTransform();
787 WarpZone_InitStep_FinalizeTransform();
789 WarpZone_InitStep_FinalizeTransform();
791 self.warpzone_save_origin = self.origin;
792 self.warpzone_save_angles = self.angles;
793 self.warpzone_save_eorigin = self.enemy.origin;
794 self.warpzone_save_eangles = self.enemy.angles;
796 self.nextthink = time;
799 void WarpZone_StartFrame()
802 if(warpzone_initialized == 0)
804 warpzone_initialized = 1;
806 for(self = warpzone_first; self; self = self.warpzone_next)
807 WarpZone_InitStep_FindOriginTarget();
808 for(self = warpzone_position_first; self; self = self.warpzone_next)
809 WarpZonePosition_InitStep_FindTarget();
810 for(self = warpzone_first; self; self = self.warpzone_next)
811 WarpZone_InitStep_UpdateTransform();
813 WarpZones_Reconnect();
814 WarpZone_PostInitialize_Callback();
817 entity oldself, oldother;
820 for(e = world; (e = nextent(e)); )
822 if(warpzone_warpzones_exist) { WarpZone_StoreProjectileData(e); }
824 if(IS_REAL_CLIENT(e))
826 if(e.solid == SOLID_NOT) // not spectating?
827 if(e.movetype == MOVETYPE_NOCLIP || e.movetype == MOVETYPE_FLY || e.movetype == MOVETYPE_FLY_WORLDONLY) // not spectating? (this is to catch observers)
832 if(warpzone_warpzones_exist) {
833 self = WarpZone_Find(e.origin + e.mins, e.origin + e.maxs);
835 if(!WarpZoneLib_ExactTrigger_Touch())
836 if(WarpZone_PlaneDist(self, e.origin + e.view_ofs) <= 0)
837 WarpZone_Teleport(self, e, -1, 0); } // NOT triggering targets by this!
840 self = Teleport_Find(e.origin + e.mins, e.origin + e.maxs);
842 if(!WarpZoneLib_ExactTrigger_Touch())
843 Simple_TeleportPlayer(self, other); // NOT triggering targets by this!
847 if(IS_NOT_A_CLIENT(e))
849 if(warpzone_warpzones_exist)
850 for (; (e = nextent(e)); )
851 WarpZone_StoreProjectileData(e);
859 .float warpzone_reconnecting;
860 float visible_to_some_client(entity ent)
863 for(e = nextent(world); !IS_NOT_A_CLIENT(e); e = nextent(e))
864 if(IS_PLAYER(e) && IS_REAL_CLIENT(e))
865 if(checkpvs(e.origin + e.view_ofs, ent))
869 void trigger_warpzone_reconnect_use()
873 // NOTE: this matches for target, not targetname, but of course
874 // targetname must be set too on the other entities
875 for(self = warpzone_first; self; self = self.warpzone_next)
876 self.warpzone_reconnecting = ((e.target == "" || self.target == e.target) && !((e.spawnflags & 1) && (visible_to_some_client(self) || visible_to_some_client(self.enemy))));
877 for(self = warpzone_camera_first; self; self = self.warpzone_next)
878 self.warpzone_reconnecting = ((e.target == "" || self.target == e.target) && !((e.spawnflags & 1) && visible_to_some_client(self)));
879 for(self = warpzone_first; self; self = self.warpzone_next)
880 if(self.warpzone_reconnecting)
881 WarpZone_InitStep_ClearTarget();
882 for(self = warpzone_first; self; self = self.warpzone_next)
883 if(self.warpzone_reconnecting)
884 WarpZone_InitStep_FindTarget();
885 for(self = warpzone_camera_first; self; self = self.warpzone_next)
886 if(self.warpzone_reconnecting)
887 WarpZoneCamera_InitStep_FindTarget();
888 for(self = warpzone_first; self; self = self.warpzone_next)
889 if(self.warpzone_reconnecting || self.enemy.warpzone_reconnecting)
890 WarpZone_InitStep_FinalizeTransform();
894 void spawnfunc_trigger_warpzone_reconnect()
896 self.use = trigger_warpzone_reconnect_use;
899 void spawnfunc_target_warpzone_reconnect()
901 spawnfunc_trigger_warpzone_reconnect(); // both names make sense here :(
904 void WarpZone_PlayerPhysics_FixVAngle(void)
906 #ifndef WARPZONE_DONT_FIX_VANGLE
907 if(IS_REAL_CLIENT(self))
908 if(self.v_angle.z <= 360) // if not already adjusted
909 if(time - self.ping * 0.001 < self.warpzone_teleport_time)
911 self.v_angle = WarpZone_TransformVAngles(self.warpzone_teleport_zone, self.v_angle);
912 self.v_angle_z += 720; // mark as adjusted