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);
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 (!IS_NOT_A_CLIENT(player))
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(IS_PLAYER(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(IS_NOT_A_CLIENT(other))
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 (!self.target) self.target = save1;
188 if (!self.target3) self.target3 = save2;
192 save1 = self.target; self.target = string_null;
193 save2 = self.target2; self.target2 = string_null;
195 if (!self.target) self.target = save1;
196 if (!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 #ifdef 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 (!self.target) self.target = save1;
352 if (!self.target3) self.target3 = save2;
355 save1 = self.target; self.target = string_null;
356 save2 = self.target2; self.target2 = string_null;
358 if (!self.target) self.target = save1;
359 if (!self.target2) self.target2 = save2;
364 setorigin(player, o0 - player.view_ofs);
365 player.velocity = v0;
373 float WarpZone_Projectile_Touch()
375 if(other.classname == "trigger_warpzone")
378 // no further impacts if we teleported this frame!
379 // this is because even if we did teleport, the engine still may raise
380 // touch events for the previous location
381 // engine now aborts moves on teleport, so this SHOULD not happen any more
382 // but if this is called from TouchAreaGrid of the projectile moving,
383 // then this won't do
384 if(time == self.warpzone_teleport_time)
387 #ifdef WARPZONELIB_KEEPDEBUG
388 // this SEEMS to not happen at the moment, but if it did, it would be more reliable
390 float save_dpstartcontents;
391 float save_dphitcontents;
392 float save_dphitq3surfaceflags;
393 string save_dphittexturename;
395 float save_startsolid;
398 vector save_plane_normal;
399 float save_plane_dist;
403 save_dpstartcontents = trace_dpstartcontents;
404 save_dphitcontents = trace_dphitcontents;
405 save_dphitq3surfaceflags = trace_dphitq3surfaceflags;
406 save_dphittexturename = trace_dphittexturename;
407 save_allsolid = trace_allsolid;
408 save_startsolid = trace_startsolid;
409 save_fraction = trace_fraction;
410 save_endpos = trace_endpos;
411 save_plane_normal = trace_plane_normal;
412 save_plane_dist = trace_plane_dist;
413 save_ent = trace_ent;
414 save_inopen = trace_inopen;
415 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);
576 org = self.aiment.origin;
577 ang = self.aiment.angles;
580 org = org - ((org - point) * norm) * norm; // project to plane
582 if(norm * v_forward < 0)
584 print("Position target of trigger_warpzone near ", vtos(self.aiment.origin), " points into trigger_warpzone. BEWARE.\n");
587 ang = vectoangles2(norm, v_up); // keep rotation, but turn exactly against plane
589 if(norm * v_forward < 0.99)
590 print("trigger_warpzone near ", vtos(self.aiment.origin), " has been turned to match plane orientation (", vtos(self.aiment.angles), " -> ", vtos(ang), "\n");
591 if(vlen(org - self.aiment.origin) > 0.5)
592 print("trigger_warpzone near ", vtos(self.aiment.origin), " has been moved to match the plane (", vtos(self.aiment.origin), " -> ", vtos(org), ").\n");
598 ang = vectoangles(norm);
602 error("cannot infer origin/angles for this warpzone, please use a killtarget or a trigger_warpzone_position");
604 self.warpzone_origin = org;
605 self.warpzone_angles = ang;
608 void WarpZone_InitStep_ClearTarget()
611 self.enemy.enemy = world;
615 entity warpzone_first; .entity warpzone_next;
616 void WarpZone_InitStep_FindTarget()
624 // this way only one of the two ents needs to target
625 if(self.target != "")
627 self.enemy = self; // so the if(!e.enemy) check also skips self, saves one IF
630 for(e = world, i = 0; (e = find(e, targetname, self.target)); )
632 if(e.classname == self.classname) // possibly non-warpzones may use the same targetname!
633 if(random() * ++i < 1)
638 error("Warpzone with non-existing target");
646 void WarpZone_Think();
647 void WarpZone_InitStep_FinalizeTransform()
649 if(!self.enemy || self.enemy.enemy != self)
651 error("Invalid warp zone detected. Killed.");
655 warpzone_warpzones_exist = 1;
656 WarpZone_SetUp(self, self.warpzone_origin, self.warpzone_angles, self.enemy.warpzone_origin, self.enemy.warpzone_angles);
657 self.touch = WarpZone_Touch;
658 self.SendFlags = 0xFFFFFF;
659 if(self.spawnflags & 1)
661 self.think = WarpZone_Think;
662 self.nextthink = time;
668 float warpzone_initialized;
669 entity warpzone_first;
670 entity warpzone_position_first;
671 entity warpzone_camera_first;
672 .entity warpzone_next;
673 void spawnfunc_misc_warpzone_position(void)
675 // "target", "angles", "origin"
676 self.warpzone_next = warpzone_position_first;
677 warpzone_position_first = self;
679 void spawnfunc_trigger_warpzone_position(void)
681 spawnfunc_misc_warpzone_position();
683 void spawnfunc_trigger_warpzone(void)
685 // warp zone entities must have:
686 // "killtarget" pointing to a target_position with a direction arrow
687 // that points AWAY from the warp zone, and that is inside
688 // the warp zone trigger
689 // "target" pointing to an identical warp zone at another place in
690 // the map, with another killtarget to designate its
693 #ifndef WARPZONE_USE_FIXANGLE
694 // used when teleporting
695 precache_model("null");
699 self.scale = self.modelscale;
704 WarpZoneLib_ExactTrigger_Init();
708 setmodel(self, m); // no precision needed
710 setorigin(self, self.origin);
712 setsize(self, self.mins * self.scale, self.maxs * self.scale);
714 setsize(self, self.mins, self.maxs);
715 self.SendEntity = WarpZone_Send;
716 self.SendFlags = 0xFFFFFF;
717 BITSET_ASSIGN(self.effects, EF_NODEPTHTEST);
718 self.warpzone_next = warpzone_first;
719 warpzone_first = self;
721 void spawnfunc_func_camera(void)
724 self.scale = self.modelscale;
729 precache_model(self.model);
730 setmodel(self, self.model); // no precision needed
732 setorigin(self, self.origin);
734 setsize(self, self.mins * self.scale, self.maxs * self.scale);
736 setsize(self, self.mins, self.maxs);
738 self.solid = SOLID_BSP;
739 else if(self.solid < 0)
740 self.solid = SOLID_NOT;
741 self.SendEntity = WarpZone_Camera_Send;
742 self.SendFlags = 0xFFFFFF;
743 self.warpzone_next = warpzone_camera_first;
744 warpzone_camera_first = self;
746 void WarpZones_Reconnect()
750 for(self = warpzone_first; self; self = self.warpzone_next)
751 WarpZone_InitStep_ClearTarget();
752 for(self = warpzone_first; self; self = self.warpzone_next)
753 WarpZone_InitStep_FindTarget();
754 for(self = warpzone_camera_first; self; self = self.warpzone_next)
755 WarpZoneCamera_InitStep_FindTarget();
756 for(self = warpzone_first; self; self = self.warpzone_next)
757 WarpZone_InitStep_FinalizeTransform();
761 void WarpZone_Think()
763 if(self.warpzone_save_origin != self.origin
764 || self.warpzone_save_angles != self.angles
765 || self.warpzone_save_eorigin != self.enemy.origin
766 || self.warpzone_save_eangles != self.enemy.angles)
770 WarpZone_InitStep_UpdateTransform();
772 WarpZone_InitStep_UpdateTransform();
774 WarpZone_InitStep_FinalizeTransform();
776 WarpZone_InitStep_FinalizeTransform();
778 self.warpzone_save_origin = self.origin;
779 self.warpzone_save_angles = self.angles;
780 self.warpzone_save_eorigin = self.enemy.origin;
781 self.warpzone_save_eangles = self.enemy.angles;
783 self.nextthink = time;
786 void WarpZone_StartFrame()
789 if(warpzone_initialized == 0)
791 warpzone_initialized = 1;
793 for(self = warpzone_first; self; self = self.warpzone_next)
794 WarpZone_InitStep_FindOriginTarget();
795 for(self = warpzone_position_first; self; self = self.warpzone_next)
796 WarpZonePosition_InitStep_FindTarget();
797 for(self = warpzone_first; self; self = self.warpzone_next)
798 WarpZone_InitStep_UpdateTransform();
800 WarpZones_Reconnect();
801 WarpZone_PostInitialize_Callback();
804 entity oldself, oldother;
807 for(e = world; (e = nextent(e)); )
809 if(warpzone_warpzones_exist) { WarpZone_StoreProjectileData(e); }
811 if(IS_REAL_CLIENT(e))
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(IS_NOT_A_CLIENT(e))
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); !IS_NOT_A_CLIENT(e); e = nextent(e))
851 if(IS_PLAYER(e) && IS_REAL_CLIENT(e))
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(IS_REAL_CLIENT(self))
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