1 #ifdef WARPZONELIB_KEEPDEBUG
2 #define WARPZONELIB_REMOVEHACK
6 .vector warpzone_save_origin;
7 .vector warpzone_save_angles;
8 .vector warpzone_save_eorigin;
9 .vector warpzone_save_eangles;
12 .vector warpzone_oldorigin, warpzone_oldvelocity, warpzone_oldangles;
13 .float warpzone_teleport_time;
14 .float warpzone_teleport_finishtime;
15 .entity warpzone_teleport_zone;
17 void WarpZone_StoreProjectileData(entity e)
19 e.warpzone_oldorigin = e.origin;
20 e.warpzone_oldvelocity = e.velocity;
21 e.warpzone_oldangles = e.angles;
24 void WarpZone_TeleportPlayer(entity teleporter, entity player, vector to, vector to_angles, vector to_velocity)
26 setorigin (player, to); // NOTE: this also aborts the move, when this is called by touch
27 player.oldorigin = to; // for DP's unsticking
28 player.angles = to_angles;
29 player.fixangle = TRUE;
30 player.velocity = to_velocity;
32 BITXOR_ASSIGN(player.effects, EF_TELEPORT_BIT);
34 if(player.classname == "player")
35 BITCLR_ASSIGN(player.flags, FL_ONGROUND);
37 WarpZone_PostTeleportPlayer_Callback(player);
40 float WarpZone_Teleported_Send(entity to, float sf)
42 WriteByte(MSG_ENTITY, ENT_CLIENT_WARPZONE_TELEPORTED);
43 WriteCoord(MSG_ENTITY, self.angles_x);
44 WriteCoord(MSG_ENTITY, self.angles_y);
45 WriteCoord(MSG_ENTITY, self.angles_z);
49 float WarpZone_Teleport(entity wz, entity player, float f0, float f1)
51 vector o0, a0, v0, o1, a1, v1, o10;
53 o0 = player.origin + player.view_ofs;
57 o10 = o1 = WarpZone_TransformOrigin(wz, o0);
58 v1 = WarpZone_TransformVelocity(wz, v0);
59 if(clienttype(player) != CLIENTTYPE_NOTACLIENT)
60 a1 = WarpZone_TransformVAngles(wz, player.v_angle);
62 a1 = WarpZone_TransformAngles(wz, a0);
64 if(f0 != 0 || f1 != 0)
66 // retry last move but behind the warpzone!
67 // we must first go back as far as we can, then forward again, to not cause double touch events!
69 tracebox(o1 - player.view_ofs + v1 * frametime * f1, player.mins, player.maxs, o1 - player.view_ofs + v1 * frametime * f0, MOVE_WORLDONLY, player);
74 tracebox(trace_endpos, player.mins, player.maxs, o1 - player.view_ofs + v1 * frametime * f1, MOVE_NORMAL, player); // this should get us through the warpzone
77 o1 = trace_endpos + player.view_ofs;
80 md = max(vlen(player.mins), vlen(player.maxs));
81 d = WarpZone_TargetPlaneDist(wz, o1);
82 dv = WarpZone_TargetPlaneDist(wz, v1);
84 o1 = o1 - v1 * (d / dv);
87 // put him out of solid
88 tracebox(o1 - player.view_ofs, player.mins, player.maxs, o1 - player.view_ofs, MOVE_NOMONSTERS, player);
91 setorigin(player, o1 - player.view_ofs);
92 if(WarpZoneLib_MoveOutOfSolid(player))
94 o1 = player.origin + player.view_ofs;
95 setorigin(player, o0 - player.view_ofs);
99 print("would have to put player in solid, won't do that\n");
100 setorigin(player, o0 - player.view_ofs);
106 WarpZone_RefSys_Add(player, wz);
107 WarpZone_TeleportPlayer(wz, player, o1 - player.view_ofs, a1, v1);
108 WarpZone_StoreProjectileData(player);
109 player.warpzone_teleport_time = time;
110 player.warpzone_teleport_finishtime = time;
111 player.warpzone_teleport_zone = wz;
113 // prevent further teleports back
114 float dt = (o1 - o10) * v1 * (1 / (v1 * v1));
115 if(dt < sys_frametime)
116 player.warpzone_teleport_finishtime += sys_frametime - dt;
118 #ifndef WARPZONE_USE_FIXANGLE
119 if(player.classname == "player")
121 // instead of fixangle, send the transform to the client for smoother operation
122 player.fixangle = FALSE;
125 setmodel(ts, "null");
126 ts.SendEntity = WarpZone_Teleported_Send;
127 ts.SendFlags = 0xFFFFFF;
128 ts.drawonlytoclient = player;
129 ts.think = SUB_Remove;
130 ts.nextthink = time + 1;
133 ts.effects = EF_NODEPTHTEST;
134 ts.classname = "warpzone_teleported";
135 ts.angles = wz.warpzone_transform;
142 void WarpZone_Touch (void)
146 if(other.classname == "trigger_warpzone")
149 if(time <= other.warpzone_teleport_finishtime) // already teleported this frame
152 // FIXME needs a better check to know what is safe to teleport and what not
153 if(other.movetype == MOVETYPE_NONE || other.movetype == MOVETYPE_FOLLOW || other.tag_entity)
156 if(WarpZoneLib_ExactTrigger_Touch())
159 if(WarpZone_PlaneDist(self, other.origin + other.view_ofs) >= 0) // wrong side of the trigger_warpzone (don't teleport yet)
163 // number of frames we need to go back:
164 // dist = 16*sqrt(2) qu
167 // 24 qu = v*frametime*n
168 // n = 24 qu/(v*frametime)
169 // for clients go only one frame though, may be too irritating otherwise
170 // but max 0.25 sec = 0.25/frametime frames
171 // 24/(0.25/frametime)
174 d = 24 + max(vlen(other.mins), vlen(other.maxs));
175 if(clienttype(other) == CLIENTTYPE_NOTACLIENT)
176 f = -d / bound(frametime * d * 1, frametime * vlen(other.velocity), d);
179 if(WarpZone_Teleport(self, other, f, 0))
184 save1 = self.target; self.target = string_null;
185 save2 = self.target3; self.target3 = string_null;
187 if not(self.target) self.target = save1;
188 if not(self.target3) self.target3 = save2;
192 save1 = self.target; self.target = string_null;
193 save2 = self.target2; self.target2 = string_null;
195 if not(self.target) self.target = save1;
196 if not(self.target2) self.target2 = save2;
201 dprint("WARPZONE FAIL AHAHAHAHAH))\n");
205 float WarpZone_Send(entity to, float sendflags)
208 WriteByte(MSG_ENTITY, ENT_CLIENT_WARPZONE);
210 // we must send this flag for clientside to match properly too
212 if(self.warpzone_isboxy)
214 if(self.warpzone_fadestart)
216 if(self.origin != '0 0 0')
218 WriteByte(MSG_ENTITY, f);
220 // we need THESE to render the warpzone (and cull properly)...
223 WriteCoord(MSG_ENTITY, self.origin_x);
224 WriteCoord(MSG_ENTITY, self.origin_y);
225 WriteCoord(MSG_ENTITY, self.origin_z);
228 WriteShort(MSG_ENTITY, self.modelindex);
229 WriteCoord(MSG_ENTITY, self.mins_x);
230 WriteCoord(MSG_ENTITY, self.mins_y);
231 WriteCoord(MSG_ENTITY, self.mins_z);
232 WriteCoord(MSG_ENTITY, self.maxs_x);
233 WriteCoord(MSG_ENTITY, self.maxs_y);
234 WriteCoord(MSG_ENTITY, self.maxs_z);
235 WriteByte(MSG_ENTITY, bound(1, self.scale * 16, 255));
237 // we need THESE to calculate the proper transform
238 WriteCoord(MSG_ENTITY, self.warpzone_origin_x);
239 WriteCoord(MSG_ENTITY, self.warpzone_origin_y);
240 WriteCoord(MSG_ENTITY, self.warpzone_origin_z);
241 WriteCoord(MSG_ENTITY, self.warpzone_angles_x);
242 WriteCoord(MSG_ENTITY, self.warpzone_angles_y);
243 WriteCoord(MSG_ENTITY, self.warpzone_angles_z);
244 WriteCoord(MSG_ENTITY, self.warpzone_targetorigin_x);
245 WriteCoord(MSG_ENTITY, self.warpzone_targetorigin_y);
246 WriteCoord(MSG_ENTITY, self.warpzone_targetorigin_z);
247 WriteCoord(MSG_ENTITY, self.warpzone_targetangles_x);
248 WriteCoord(MSG_ENTITY, self.warpzone_targetangles_y);
249 WriteCoord(MSG_ENTITY, self.warpzone_targetangles_z);
253 WriteShort(MSG_ENTITY, self.warpzone_fadestart);
254 WriteShort(MSG_ENTITY, self.warpzone_fadeend);
260 float WarpZone_Camera_Send(entity to, float sendflags)
263 WriteByte(MSG_ENTITY, ENT_CLIENT_WARPZONE_CAMERA);
265 if(self.warpzone_fadestart)
267 if(self.origin != '0 0 0')
269 WriteByte(MSG_ENTITY, f);
271 // we need THESE to render the warpzone (and cull properly)...
274 WriteCoord(MSG_ENTITY, self.origin_x);
275 WriteCoord(MSG_ENTITY, self.origin_y);
276 WriteCoord(MSG_ENTITY, self.origin_z);
279 WriteShort(MSG_ENTITY, self.modelindex);
280 WriteCoord(MSG_ENTITY, self.mins_x);
281 WriteCoord(MSG_ENTITY, self.mins_y);
282 WriteCoord(MSG_ENTITY, self.mins_z);
283 WriteCoord(MSG_ENTITY, self.maxs_x);
284 WriteCoord(MSG_ENTITY, self.maxs_y);
285 WriteCoord(MSG_ENTITY, self.maxs_z);
286 WriteByte(MSG_ENTITY, bound(1, self.scale * 16, 255));
288 // we need THESE to calculate the proper transform
289 WriteCoord(MSG_ENTITY, self.enemy.origin_x);
290 WriteCoord(MSG_ENTITY, self.enemy.origin_y);
291 WriteCoord(MSG_ENTITY, self.enemy.origin_z);
292 WriteCoord(MSG_ENTITY, self.enemy.angles_x);
293 WriteCoord(MSG_ENTITY, self.enemy.angles_y);
294 WriteCoord(MSG_ENTITY, self.enemy.angles_z);
298 WriteShort(MSG_ENTITY, self.warpzone_fadestart);
299 WriteShort(MSG_ENTITY, self.warpzone_fadeend);
305 #ifndef WARPZONELIB_KEEPDEBUG
306 float WarpZone_CheckProjectileImpact(entity player)
310 o0 = player.origin + player.view_ofs;
311 v0 = player.velocity;
313 // if we teleported shortly before, abort
314 if(time <= player.warpzone_teleport_finishtime + 0.1)
317 // if player hit a warpzone, abort
319 wz = WarpZone_Find(o0 + player.mins, o0 + player.maxs);
323 #ifdef WARPZONELIB_REMOVEHACK
324 print("impactfilter found something - and it no longer gets handled correctly - please tell divVerent whether anything behaves broken now\n");
326 print("impactfilter found something - and it even gets handled correctly - please tell divVerent that this code apparently gets triggered again\n");
328 print("Entity type: ", player.classname, "\n");
329 print("Origin: ", vtos(player.origin), "\n");
330 print("Velocity: ", vtos(player.velocity), "\n");
332 #ifdef WARPZONELIB_REMOVEHACK
335 // retry previous move
336 setorigin(player, player.warpzone_oldorigin);
337 player.velocity = player.warpzone_oldvelocity;
338 if(WarpZone_Teleport(wz, player, 0, 1))
348 save1 = self.target; self.target = string_null;
349 save2 = self.target3; self.target3 = string_null;
351 if not(self.target) self.target = save1;
352 if not(self.target3) self.target3 = save2;
355 save1 = self.target; self.target = string_null;
356 save2 = self.target2; self.target2 = string_null;
358 if not(self.target) self.target = save1;
359 if not(self.target2) self.target2 = save2;
364 setorigin(player, o0 - player.view_ofs);
365 player.velocity = v0;
373 float WarpZone_Projectile_Touch()
376 if(other.classname == "trigger_warpzone")
379 // no further impacts if we teleported this frame!
380 // this is because even if we did teleport, the engine still may raise
381 // touch events for the previous location
382 // engine now aborts moves on teleport, so this SHOULD not happen any more
383 // but if this is called from TouchAreaGrid of the projectile moving,
384 // then this won't do
385 if(time == self.warpzone_teleport_time)
388 #ifndef WARPZONELIB_KEEPDEBUG
389 // this SEEMS to not happen at the moment, but if it did, it would be more reliable
391 float save_dpstartcontents;
392 float save_dphitcontents;
393 float save_dphitq3surfaceflags;
394 string save_dphittexturename;
396 float save_startsolid;
399 vector save_plane_normal;
400 float save_plane_dist;
404 save_dpstartcontents = trace_dpstartcontents;
405 save_dphitcontents = trace_dphitcontents;
406 save_dphitq3surfaceflags = trace_dphitq3surfaceflags;
407 save_dphittexturename = trace_dphittexturename;
408 save_allsolid = trace_allsolid;
409 save_startsolid = trace_startsolid;
410 save_fraction = trace_fraction;
411 save_endpos = trace_endpos;
412 save_plane_normal = trace_plane_normal;
413 save_plane_dist = trace_plane_dist;
414 save_ent = trace_ent;
415 save_inopen = trace_inopen;
416 save_inwater = trace_inwater;
417 if((f = WarpZone_CheckProjectileImpact(self)) != 0)
419 trace_dpstartcontents = save_dpstartcontents;
420 trace_dphitcontents = save_dphitcontents;
421 trace_dphitq3surfaceflags = save_dphitq3surfaceflags;
422 trace_dphittexturename = save_dphittexturename;
423 trace_allsolid = save_allsolid;
424 trace_startsolid = save_startsolid;
425 trace_fraction = save_fraction;
426 trace_endpos = save_endpos;
427 trace_plane_normal = save_plane_normal;
428 trace_plane_dist = save_plane_dist;
429 trace_ent = save_ent;
430 trace_inopen = save_inopen;
431 trace_inwater = save_inwater;
435 if(WarpZone_Projectile_Touch_ImpactFilter_Callback())
441 void WarpZone_InitStep_FindOriginTarget()
443 if(self.killtarget != "")
445 self.aiment = find(world, targetname, self.killtarget);
446 if(self.aiment == world)
448 error("Warp zone with nonexisting killtarget");
451 self.killtarget = string_null;
455 void WarpZonePosition_InitStep_FindTarget()
457 if(self.target == "")
459 error("Warp zone position with no target");
462 self.enemy = find(world, targetname, self.target);
463 if(self.enemy == world)
465 error("Warp zone position with nonexisting target");
468 if(self.enemy.aiment)
470 // already is positioned
471 error("Warp zone position targeting already oriented warpzone");
474 self.enemy.aiment = self;
477 void WarpZoneCamera_Think(void)
479 if(self.warpzone_save_origin != self.origin
480 || self.warpzone_save_angles != self.angles
481 || self.warpzone_save_eorigin != self.enemy.origin
482 || self.warpzone_save_eangles != self.enemy.angles)
484 WarpZone_Camera_SetUp(self, self.enemy.origin, self.enemy.angles);
485 self.warpzone_save_origin = self.origin;
486 self.warpzone_save_angles = self.angles;
487 self.warpzone_save_eorigin = self.enemy.origin;
488 self.warpzone_save_eangles = self.enemy.angles;
490 self.nextthink = time;
493 void WarpZoneCamera_InitStep_FindTarget()
497 if(self.target == "")
499 error("Camera with no target");
503 for(e = world, i = 0; (e = find(e, targetname, self.target)); )
504 if(random() * ++i < 1)
506 if(self.enemy == world)
508 error("Camera with nonexisting target");
511 warpzone_cameras_exist = 1;
512 WarpZone_Camera_SetUp(self, self.enemy.origin, self.enemy.angles);
513 self.SendFlags = 0xFFFFFF;
514 if(self.spawnflags & 1)
516 self.think = WarpZoneCamera_Think;
517 self.nextthink = time;
523 void WarpZone_InitStep_UpdateTransform()
525 vector org, ang, norm, point;
527 vector tri, a, b, c, p, q, n;
533 org = 0.5 * (self.mins + self.maxs);
535 norm = point = '0 0 0';
537 for(i_s = 0; ; ++i_s)
539 tex = getsurfacetexture(self, i_s);
541 break; // this is beyond the last one
542 if(tex == "textures/common/trigger" || tex == "trigger")
544 n_t = getsurfacenumtriangles(self, i_s);
545 for(i_t = 0; i_t < n_t; ++i_t)
547 tri = getsurfacetriangle(self, i_s, i_t);
548 a = getsurfacepoint(self, i_s, tri_x);
549 b = getsurfacepoint(self, i_s, tri_y);
550 c = getsurfacepoint(self, i_s, tri_z);
553 n = '1 0 0' * (q_y * p_z - q_z * p_y)
554 + '0 1 0' * (q_z * p_x - q_x * p_z)
555 + '0 0 1' * (q_x * p_y - q_y * p_x);
556 area = area + vlen(n);
558 point = point + vlen(n) * (a + b + c);
563 norm = norm * (1 / area);
564 point = point * (1 / (3 * area));
565 if(vlen(norm) < 0.99)
567 print("trigger_warpzone near ", vtos(self.aiment.origin), " is nonplanar. BEWARE.\n");
568 area = 0; // no autofixing in this case
570 norm = normalize(norm);
575 org = self.aiment.origin;
576 ang = self.aiment.angles;
579 org = org - ((org - point) * norm) * norm; // project to plane
581 if(norm * v_forward < 0)
583 print("Position target of trigger_warpzone near ", vtos(self.aiment.origin), " points into trigger_warpzone. BEWARE.\n");
586 ang = vectoangles2(norm, v_up); // keep rotation, but turn exactly against plane
588 if(norm * v_forward < 0.99)
589 print("trigger_warpzone near ", vtos(self.aiment.origin), " has been turned to match plane orientation (", vtos(self.aiment.angles), " -> ", vtos(ang), "\n");
590 if(vlen(org - self.aiment.origin) > 0.5)
591 print("trigger_warpzone near ", vtos(self.aiment.origin), " has been moved to match the plane (", vtos(self.aiment.origin), " -> ", vtos(org), ").\n");
597 ang = vectoangles(norm);
601 error("cannot infer origin/angles for this warpzone, please use a killtarget or a trigger_warpzone_position");
603 self.warpzone_origin = org;
604 self.warpzone_angles = ang;
607 void WarpZone_InitStep_ClearTarget()
610 self.enemy.enemy = world;
614 entity warpzone_first; .entity warpzone_next;
615 void WarpZone_InitStep_FindTarget()
623 // this way only one of the two ents needs to target
624 if(self.target != "")
626 self.enemy = self; // so the if(!e.enemy) check also skips self, saves one IF
629 for(e = world, i = 0; (e = find(e, targetname, self.target)); )
631 if(e.classname == self.classname) // possibly non-warpzones may use the same targetname!
632 if(random() * ++i < 1)
637 error("Warpzone with non-existing target");
645 void WarpZone_Think();
646 void WarpZone_InitStep_FinalizeTransform()
648 if(!self.enemy || self.enemy.enemy != self)
650 error("Invalid warp zone detected. Killed.");
654 warpzone_warpzones_exist = 1;
655 WarpZone_SetUp(self, self.warpzone_origin, self.warpzone_angles, self.enemy.warpzone_origin, self.enemy.warpzone_angles);
656 self.touch = WarpZone_Touch;
657 self.SendFlags = 0xFFFFFF;
658 if(self.spawnflags & 1)
660 self.think = WarpZone_Think;
661 self.nextthink = time;
667 float warpzone_initialized;
668 entity warpzone_first;
669 entity warpzone_position_first;
670 entity warpzone_camera_first;
671 .entity warpzone_next;
672 void spawnfunc_misc_warpzone_position(void)
674 // "target", "angles", "origin"
675 self.warpzone_next = warpzone_position_first;
676 warpzone_position_first = self;
678 void spawnfunc_trigger_warpzone_position(void)
680 spawnfunc_misc_warpzone_position();
682 void spawnfunc_trigger_warpzone(void)
684 // warp zone entities must have:
685 // "killtarget" pointing to a target_position with a direction arrow
686 // that points AWAY from the warp zone, and that is inside
687 // the warp zone trigger
688 // "target" pointing to an identical warp zone at another place in
689 // the map, with another killtarget to designate its
692 #ifndef WARPZONE_USE_FIXANGLE
693 // used when teleporting
694 precache_model("null");
698 self.scale = self.modelscale;
703 WarpZoneLib_ExactTrigger_Init();
707 setmodel(self, m); // no precision needed
709 setorigin(self, self.origin);
711 setsize(self, self.mins * self.scale, self.maxs * self.scale);
713 setsize(self, self.mins, self.maxs);
714 self.SendEntity = WarpZone_Send;
715 self.SendFlags = 0xFFFFFF;
716 BITSET_ASSIGN(self.effects, EF_NODEPTHTEST);
717 self.warpzone_next = warpzone_first;
718 warpzone_first = self;
720 void spawnfunc_func_camera(void)
723 self.scale = self.modelscale;
728 precache_model(self.model);
729 setmodel(self, self.model); // no precision needed
731 setorigin(self, self.origin);
733 setsize(self, self.mins * self.scale, self.maxs * self.scale);
735 setsize(self, self.mins, self.maxs);
737 self.solid = SOLID_BSP;
738 else if(self.solid < 0)
739 self.solid = SOLID_NOT;
740 self.SendEntity = WarpZone_Camera_Send;
741 self.SendFlags = 0xFFFFFF;
742 self.warpzone_next = warpzone_camera_first;
743 warpzone_camera_first = self;
745 void WarpZones_Reconnect()
749 for(self = warpzone_first; self; self = self.warpzone_next)
750 WarpZone_InitStep_ClearTarget();
751 for(self = warpzone_first; self; self = self.warpzone_next)
752 WarpZone_InitStep_FindTarget();
753 for(self = warpzone_camera_first; self; self = self.warpzone_next)
754 WarpZoneCamera_InitStep_FindTarget();
755 for(self = warpzone_first; self; self = self.warpzone_next)
756 WarpZone_InitStep_FinalizeTransform();
760 void WarpZone_Think()
762 if(self.warpzone_save_origin != self.origin
763 || self.warpzone_save_angles != self.angles
764 || self.warpzone_save_eorigin != self.enemy.origin
765 || self.warpzone_save_eangles != self.enemy.angles)
769 WarpZone_InitStep_UpdateTransform();
771 WarpZone_InitStep_UpdateTransform();
773 WarpZone_InitStep_FinalizeTransform();
775 WarpZone_InitStep_FinalizeTransform();
777 self.warpzone_save_origin = self.origin;
778 self.warpzone_save_angles = self.angles;
779 self.warpzone_save_eorigin = self.enemy.origin;
780 self.warpzone_save_eangles = self.enemy.angles;
782 self.nextthink = time;
785 void WarpZone_StartFrame()
788 if(warpzone_initialized == 0)
790 warpzone_initialized = 1;
792 for(self = warpzone_first; self; self = self.warpzone_next)
793 WarpZone_InitStep_FindOriginTarget();
794 for(self = warpzone_position_first; self; self = self.warpzone_next)
795 WarpZonePosition_InitStep_FindTarget();
796 for(self = warpzone_first; self; self = self.warpzone_next)
797 WarpZone_InitStep_UpdateTransform();
799 WarpZones_Reconnect();
800 WarpZone_PostInitialize_Callback();
803 entity oldself, oldother;
806 for(e = world; (e = nextent(e)); )
808 if(warpzone_warpzones_exist) { WarpZone_StoreProjectileData(e); }
810 float f = clienttype(e);
811 if(f == CLIENTTYPE_REAL)
813 if(e.solid == SOLID_NOT) // not spectating?
814 if(e.movetype == MOVETYPE_NOCLIP || e.movetype == MOVETYPE_FLY || e.movetype == MOVETYPE_FLY_WORLDONLY) // not spectating? (this is to catch observers)
819 if(warpzone_warpzones_exist) {
820 self = WarpZone_Find(e.origin + e.mins, e.origin + e.maxs);
822 if(!WarpZoneLib_ExactTrigger_Touch())
823 if(WarpZone_PlaneDist(self, e.origin + e.view_ofs) <= 0)
824 WarpZone_Teleport(self, e, -1, 0); } // NOT triggering targets by this!
827 self = Teleport_Find(e.origin + e.mins, e.origin + e.maxs);
829 if(!WarpZoneLib_ExactTrigger_Touch())
830 Simple_TeleportPlayer(self, other); // NOT triggering targets by this!
834 if(f == CLIENTTYPE_NOTACLIENT)
836 if(warpzone_warpzones_exist)
837 for(; (e = nextent(e)); )
838 WarpZone_StoreProjectileData(e);
846 .float warpzone_reconnecting;
847 float visible_to_some_client(entity ent)
850 for(e = nextent(world); clienttype(e) != CLIENTTYPE_NOTACLIENT; e = nextent(e))
851 if(e.classname == "player" && clienttype(e) == CLIENTTYPE_REAL)
852 if(checkpvs(e.origin + e.view_ofs, ent))
856 void trigger_warpzone_reconnect_use()
860 // NOTE: this matches for target, not targetname, but of course
861 // targetname must be set too on the other entities
862 for(self = warpzone_first; self; self = self.warpzone_next)
863 self.warpzone_reconnecting = ((e.target == "" || self.target == e.target) && !((e.spawnflags & 1) && (visible_to_some_client(self) || visible_to_some_client(self.enemy))));
864 for(self = warpzone_camera_first; self; self = self.warpzone_next)
865 self.warpzone_reconnecting = ((e.target == "" || self.target == e.target) && !((e.spawnflags & 1) && visible_to_some_client(self)));
866 for(self = warpzone_first; self; self = self.warpzone_next)
867 if(self.warpzone_reconnecting)
868 WarpZone_InitStep_ClearTarget();
869 for(self = warpzone_first; self; self = self.warpzone_next)
870 if(self.warpzone_reconnecting)
871 WarpZone_InitStep_FindTarget();
872 for(self = warpzone_camera_first; self; self = self.warpzone_next)
873 if(self.warpzone_reconnecting)
874 WarpZoneCamera_InitStep_FindTarget();
875 for(self = warpzone_first; self; self = self.warpzone_next)
876 if(self.warpzone_reconnecting || self.enemy.warpzone_reconnecting)
877 WarpZone_InitStep_FinalizeTransform();
881 void spawnfunc_trigger_warpzone_reconnect()
883 self.use = trigger_warpzone_reconnect_use;
886 void spawnfunc_target_warpzone_reconnect()
888 spawnfunc_trigger_warpzone_reconnect(); // both names make sense here :(
891 void WarpZone_PlayerPhysics_FixVAngle(void)
893 #ifndef WARPZONE_DONT_FIX_VANGLE
894 if(clienttype(self) == CLIENTTYPE_REAL)
895 if(self.v_angle_z <= 360) // if not already adjusted
896 if(time - self.ping * 0.001 < self.warpzone_teleport_time)
898 self.v_angle = WarpZone_TransformVAngles(self.warpzone_teleport_zone, self.v_angle);
899 self.v_angle_z += 720; // mark as adjusted