4 .vector warpzone_save_origin;
5 .vector warpzone_save_angles;
6 .vector warpzone_save_eorigin;
7 .vector warpzone_save_eangles;
10 .vector warpzone_oldorigin, warpzone_oldvelocity, warpzone_oldangles;
11 .float warpzone_teleport_time;
12 .float warpzone_teleport_finishtime;
13 .entity warpzone_teleport_zone;
15 void WarpZone_StoreProjectileData(entity e)
17 e.warpzone_oldorigin = e.origin;
18 e.warpzone_oldvelocity = e.velocity;
19 e.warpzone_oldangles = e.angles;
22 void WarpZone_TeleportPlayer(entity teleporter, entity player, vector to, vector to_angles, vector to_velocity)
24 setorigin (player, to);
25 player.oldorigin = to; // for DP's unsticking
26 player.angles = to_angles;
27 player.fixangle = TRUE;
28 player.velocity = to_velocity;
30 BITXOR_ASSIGN(player.effects, EF_TELEPORT_BIT);
32 if(player.classname == "player")
33 BITCLR_ASSIGN(player.flags, FL_ONGROUND);
35 WarpZone_PostTeleportPlayer_Callback(player);
38 float WarpZone_Teleported_Send(entity to, float sf)
40 WriteByte(MSG_ENTITY, ENT_CLIENT_WARPZONE_TELEPORTED);
41 WriteCoord(MSG_ENTITY, self.angles_x);
42 WriteCoord(MSG_ENTITY, self.angles_y);
43 WriteCoord(MSG_ENTITY, self.angles_z);
47 #define WARPZONE_TELEPORT_FIXSOLID(ret) \
50 setorigin(player, o1 - player.view_ofs); \
51 if(WarpZoneLib_MoveOutOfSolid(player)) \
53 o1 = player.origin + player.view_ofs; \
54 setorigin(player, o0 - player.view_ofs); \
58 print("would have to put player in solid, won't do that\n"); \
59 setorigin(player, o0 - player.view_ofs); \
64 #define WARPZONE_TELEPORT_DOTELEPORT() \
67 WarpZone_RefSys_Add(player, wz); \
68 WarpZone_TeleportPlayer(wz, player, o1 - player.view_ofs, a1, v1); \
69 WarpZone_StoreProjectileData(player); \
70 player.warpzone_teleport_time = time; \
71 player.warpzone_teleport_finishtime = time; \
72 player.warpzone_teleport_zone = wz; \
76 float WarpZone_Teleport(entity wz, entity player, float f0, float f1)
78 vector o0, a0, v0, o1, a1, v1, o10;
80 o0 = player.origin + player.view_ofs;
84 o10 = o1 = WarpZone_TransformOrigin(wz, o0);
85 v1 = WarpZone_TransformVelocity(wz, v0);
86 if(clienttype(player) != CLIENTTYPE_NOTACLIENT)
87 a1 = WarpZone_TransformVAngles(wz, player.v_angle);
89 a1 = WarpZone_TransformAngles(wz, a0);
91 if(f0 != 0 || f1 != 0)
93 // retry last move but behind the warpzone!
94 // we must first go back as far as we can, then forward again, to not cause double touch events!
96 tracebox(o1 - player.view_ofs + v1 * frametime * f1, player.mins, player.maxs, o1 - player.view_ofs + v1 * frametime * f0, MOVE_WORLDONLY, player);
100 player.owner = world;
101 tracebox(trace_endpos, player.mins, player.maxs, o1 - player.view_ofs + v1 * frametime * f1, MOVE_NORMAL, player); // this should get us through the warpzone
104 o1 = trace_endpos + player.view_ofs;
107 md = max(vlen(player.mins), vlen(player.maxs));
108 d = WarpZone_TargetPlaneDist(wz, o1);
109 dv = WarpZone_TargetPlaneDist(wz, v1);
111 o1 = o1 - v1 * (d / dv);
114 // put him inside solid
115 tracebox(o1 - player.view_ofs, player.mins, player.maxs, o1 - player.view_ofs, MOVE_NOMONSTERS, player);
117 WARPZONE_TELEPORT_FIXSOLID(0);
119 WARPZONE_TELEPORT_DOTELEPORT();
121 // prevent further teleports back
122 float dt = (o1 - o10) * v1 * (1 / (v1 * v1));
123 if(dt < sys_frametime)
124 player.warpzone_teleport_finishtime += sys_frametime - dt;
126 #ifndef WARPZONE_USE_FIXANGLE
127 if(player.classname == "player")
129 // instead of fixangle, send the transform to the client for smoother operation
130 player.fixangle = FALSE;
133 setmodel(ts, "null");
134 ts.SendEntity = WarpZone_Teleported_Send;
135 ts.SendFlags = 0xFFFFFF;
136 ts.drawonlytoclient = player;
137 ts.think = SUB_Remove;
138 ts.nextthink = time + 1;
141 ts.effects = EF_NODEPTHTEST;
142 ts.classname = "warpzone_teleported";
143 ts.angles = wz.warpzone_transform;
150 void WarpZone_Touch (void)
154 if(other.classname == "trigger_warpzone")
157 if(time <= other.warpzone_teleport_finishtime) // already teleported this frame
160 // FIXME needs a better check to know what is safe to teleport and what not
161 if(other.movetype == MOVETYPE_NONE || other.movetype == MOVETYPE_FOLLOW || other.tag_entity)
164 if(WarpZoneLib_ExactTrigger_Touch())
167 if(WarpZone_PlaneDist(self, other.origin + other.view_ofs) >= 0) // wrong side of the trigger_warpzone (don't teleport yet)
171 // number of frames we need to go back:
172 // dist = 16*sqrt(2) qu
175 // 24 qu = v*frametime*n
176 // n = 24 qu/(v*frametime)
177 // for clients go only one frame though, may be too irritating otherwise
178 // but max 0.25 sec = 0.25/frametime frames
179 // 24/(0.25/frametime)
182 d = 24 + max(vlen(other.mins), vlen(other.maxs));
183 if(clienttype(other) == CLIENTTYPE_NOTACLIENT)
184 f = -d / bound(frametime * d * 1, frametime * vlen(other.velocity), d);
187 if(WarpZone_Teleport(self, other, f, 0))
192 save1 = self.target; self.target = string_null;
193 save2 = self.target3; self.target3 = string_null;
195 if not(self.target) self.target = save1;
196 if not(self.target3) self.target3 = save2;
200 save1 = self.target; self.target = string_null;
201 save2 = self.target2; self.target2 = string_null;
203 if not(self.target) self.target = save1;
204 if not(self.target2) self.target2 = save2;
209 dprint("WARPZONE FAIL AHAHAHAHAH))\n");
213 float WarpZone_Send(entity to, float sendflags)
216 WriteByte(MSG_ENTITY, ENT_CLIENT_WARPZONE);
218 // we must send this flag for clientside to match properly too
220 if(self.warpzone_isboxy)
222 if(self.warpzone_fadestart)
224 if(self.origin != '0 0 0')
226 WriteByte(MSG_ENTITY, f);
228 // we need THESE to render the warpzone (and cull properly)...
231 WriteCoord(MSG_ENTITY, self.origin_x);
232 WriteCoord(MSG_ENTITY, self.origin_y);
233 WriteCoord(MSG_ENTITY, self.origin_z);
236 WriteShort(MSG_ENTITY, self.modelindex);
237 WriteCoord(MSG_ENTITY, self.mins_x);
238 WriteCoord(MSG_ENTITY, self.mins_y);
239 WriteCoord(MSG_ENTITY, self.mins_z);
240 WriteCoord(MSG_ENTITY, self.maxs_x);
241 WriteCoord(MSG_ENTITY, self.maxs_y);
242 WriteCoord(MSG_ENTITY, self.maxs_z);
243 WriteByte(MSG_ENTITY, bound(1, self.scale * 16, 255));
245 // we need THESE to calculate the proper transform
246 WriteCoord(MSG_ENTITY, self.warpzone_origin_x);
247 WriteCoord(MSG_ENTITY, self.warpzone_origin_y);
248 WriteCoord(MSG_ENTITY, self.warpzone_origin_z);
249 WriteCoord(MSG_ENTITY, self.warpzone_angles_x);
250 WriteCoord(MSG_ENTITY, self.warpzone_angles_y);
251 WriteCoord(MSG_ENTITY, self.warpzone_angles_z);
252 WriteCoord(MSG_ENTITY, self.warpzone_targetorigin_x);
253 WriteCoord(MSG_ENTITY, self.warpzone_targetorigin_y);
254 WriteCoord(MSG_ENTITY, self.warpzone_targetorigin_z);
255 WriteCoord(MSG_ENTITY, self.warpzone_targetangles_x);
256 WriteCoord(MSG_ENTITY, self.warpzone_targetangles_y);
257 WriteCoord(MSG_ENTITY, self.warpzone_targetangles_z);
261 WriteShort(MSG_ENTITY, self.warpzone_fadestart);
262 WriteShort(MSG_ENTITY, self.warpzone_fadeend);
268 float WarpZone_Camera_Send(entity to, float sendflags)
271 WriteByte(MSG_ENTITY, ENT_CLIENT_WARPZONE_CAMERA);
273 if(self.warpzone_fadestart)
275 if(self.origin != '0 0 0')
277 WriteByte(MSG_ENTITY, f);
279 // we need THESE to render the warpzone (and cull properly)...
282 WriteCoord(MSG_ENTITY, self.origin_x);
283 WriteCoord(MSG_ENTITY, self.origin_y);
284 WriteCoord(MSG_ENTITY, self.origin_z);
287 WriteShort(MSG_ENTITY, self.modelindex);
288 WriteCoord(MSG_ENTITY, self.mins_x);
289 WriteCoord(MSG_ENTITY, self.mins_y);
290 WriteCoord(MSG_ENTITY, self.mins_z);
291 WriteCoord(MSG_ENTITY, self.maxs_x);
292 WriteCoord(MSG_ENTITY, self.maxs_y);
293 WriteCoord(MSG_ENTITY, self.maxs_z);
294 WriteByte(MSG_ENTITY, bound(1, self.scale * 16, 255));
296 // we need THESE to calculate the proper transform
297 WriteCoord(MSG_ENTITY, self.enemy.origin_x);
298 WriteCoord(MSG_ENTITY, self.enemy.origin_y);
299 WriteCoord(MSG_ENTITY, self.enemy.origin_z);
300 WriteCoord(MSG_ENTITY, self.enemy.angles_x);
301 WriteCoord(MSG_ENTITY, self.enemy.angles_y);
302 WriteCoord(MSG_ENTITY, self.enemy.angles_z);
306 WriteShort(MSG_ENTITY, self.warpzone_fadestart);
307 WriteShort(MSG_ENTITY, self.warpzone_fadeend);
313 float WarpZone_CheckProjectileImpact(entity player)
317 o0 = player.origin + player.view_ofs;
318 v0 = player.velocity;
320 // if we teleported shortly before, abort
321 if(time <= player.warpzone_teleport_finishtime + 0.1)
324 // if player hit a warpzone, abort
326 wz = WarpZone_Find(o0 + player.mins, o0 + player.maxs);
331 print("impactfilter found something - and it no longer gets handled correctly - please tell divVerent whether anything behaves broken now\n");
333 print("impactfilter found something - and it even gets handled correctly - please tell divVerent that this code apparently gets triggered again\n");
335 print("Entity type: ", player.classname, "\n");
336 print("Origin: ", vtos(player.origin), "\n");
337 print("Velocity: ", vtos(player.velocity), "\n");
343 // retry previous move
344 setorigin(player, player.warpzone_oldorigin);
345 player.velocity = player.warpzone_oldvelocity;
346 if(WarpZone_Teleport(wz, player, 0, 1))
356 save1 = self.target; self.target = string_null;
357 save2 = self.target3; self.target3 = string_null;
359 if not(self.target) self.target = save1;
360 if not(self.target3) self.target3 = save2;
363 save1 = self.target; self.target = string_null;
364 save2 = self.target2; self.target2 = string_null;
366 if not(self.target) self.target = save1;
367 if not(self.target2) self.target2 = save2;
372 setorigin(player, o0 - player.view_ofs);
373 player.velocity = v0;
378 float WarpZone_Projectile_Touch()
381 if(other.classname == "trigger_warpzone")
384 // no further impacts if we teleported this frame!
385 if(time == self.warpzone_teleport_time)
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;
416 if((f = WarpZone_CheckProjectileImpact(self)) != 0)
418 trace_dpstartcontents = save_dpstartcontents;
419 trace_dphitcontents = save_dphitcontents;
420 trace_dphitq3surfaceflags = save_dphitq3surfaceflags;
421 trace_dphittexturename = save_dphittexturename;
422 trace_allsolid = save_allsolid;
423 trace_startsolid = save_startsolid;
424 trace_fraction = save_fraction;
425 trace_endpos = save_endpos;
426 trace_plane_normal = save_plane_normal;
427 trace_plane_dist = save_plane_dist;
428 trace_ent = save_ent;
429 trace_inopen = save_inopen;
430 trace_inwater = save_inwater;
433 if(WarpZone_Projectile_Touch_ImpactFilter_Callback())
439 void WarpZone_InitStep_FindOriginTarget()
441 if(self.killtarget != "")
443 self.aiment = find(world, targetname, self.killtarget);
444 if(self.aiment == world)
446 error("Warp zone with nonexisting killtarget");
449 self.killtarget = string_null;
453 void WarpZonePosition_InitStep_FindTarget()
455 if(self.target == "")
457 error("Warp zone position with no target");
460 self.enemy = find(world, targetname, self.target);
461 if(self.enemy == world)
463 error("Warp zone position with nonexisting target");
466 if(self.enemy.aiment)
468 // already is positioned
469 error("Warp zone position targeting already oriented warpzone");
472 self.enemy.aiment = self;
475 void WarpZoneCamera_Think(void)
477 if(self.warpzone_save_origin != self.origin
478 || self.warpzone_save_angles != self.angles
479 || self.warpzone_save_eorigin != self.enemy.origin
480 || self.warpzone_save_eangles != self.enemy.angles)
482 WarpZone_Camera_SetUp(self, self.enemy.origin, self.enemy.angles);
483 self.warpzone_save_origin = self.origin;
484 self.warpzone_save_angles = self.angles;
485 self.warpzone_save_eorigin = self.enemy.origin;
486 self.warpzone_save_eangles = self.enemy.angles;
488 self.nextthink = time;
491 void WarpZoneCamera_InitStep_FindTarget()
495 if(self.target == "")
497 error("Camera with no target");
501 for(e = world, i = 0; (e = find(e, targetname, self.target)); )
502 if(random() * ++i < 1)
504 if(self.enemy == world)
506 error("Camera with nonexisting target");
509 warpzone_cameras_exist = 1;
510 WarpZone_Camera_SetUp(self, self.enemy.origin, self.enemy.angles);
511 self.SendFlags = 0xFFFFFF;
512 if(self.spawnflags & 1)
514 self.think = WarpZoneCamera_Think;
515 self.nextthink = time;
521 void WarpZone_InitStep_UpdateTransform()
523 vector org, ang, norm, point;
525 vector tri, a, b, c, p, q, n;
531 org = 0.5 * (self.mins + self.maxs);
533 norm = point = '0 0 0';
535 for(i_s = 0; ; ++i_s)
537 tex = getsurfacetexture(self, i_s);
539 break; // this is beyond the last one
540 if(tex == "textures/common/trigger" || tex == "trigger")
542 n_t = getsurfacenumtriangles(self, i_s);
543 for(i_t = 0; i_t < n_t; ++i_t)
545 tri = getsurfacetriangle(self, i_s, i_t);
546 a = getsurfacepoint(self, i_s, tri_x);
547 b = getsurfacepoint(self, i_s, tri_y);
548 c = getsurfacepoint(self, i_s, tri_z);
551 n = '1 0 0' * (q_y * p_z - q_z * p_y)
552 + '0 1 0' * (q_z * p_x - q_x * p_z)
553 + '0 0 1' * (q_x * p_y - q_y * p_x);
554 area = area + vlen(n);
556 point = point + vlen(n) * (a + b + c);
561 norm = norm * (1 / area);
562 point = point * (1 / (3 * area));
563 if(vlen(norm) < 0.99)
565 print("trigger_warpzone near ", vtos(self.aiment.origin), " is nonplanar. BEWARE.\n");
566 area = 0; // no autofixing in this case
568 norm = normalize(norm);
573 org = self.aiment.origin;
574 ang = self.aiment.angles;
577 org = org - ((org - point) * norm) * norm; // project to plane
579 if(norm * v_forward < 0)
581 print("Position target of trigger_warpzone near ", vtos(self.aiment.origin), " points into trigger_warpzone. BEWARE.\n");
584 ang = vectoangles(norm, v_up); // keep rotation, but turn exactly against plane
586 if(norm * v_forward < 0.99)
587 print("trigger_warpzone near ", vtos(self.aiment.origin), " has been turned to match plane orientation (", vtos(self.aiment.angles), " -> ", vtos(ang), "\n");
588 if(vlen(org - self.aiment.origin) > 0.5)
589 print("trigger_warpzone near ", vtos(self.aiment.origin), " has been moved to match the plane (", vtos(self.aiment.origin), " -> ", vtos(org), ").\n");
595 ang = vectoangles(norm);
599 error("cannot infer origin/angles for this warpzone, please use a killtarget or a trigger_warpzone_position");
601 self.warpzone_origin = org;
602 self.warpzone_angles = ang;
605 void WarpZone_InitStep_ClearTarget()
608 self.enemy.enemy = world;
612 entity warpzone_first; .entity warpzone_next;
613 void WarpZone_InitStep_FindTarget()
621 // this way only one of the two ents needs to target
622 if(self.target != "")
624 self.enemy = self; // so the if(!e.enemy) check also skips self, saves one IF
627 for(e = world, i = 0; (e = find(e, targetname, self.target)); )
629 if(e.classname == self.classname) // possibly non-warpzones may use the same targetname!
630 if(random() * ++i < 1)
635 error("Warpzone with non-existing target");
643 void WarpZone_Think();
644 void WarpZone_InitStep_FinalizeTransform()
646 if(!self.enemy || self.enemy.enemy != self)
648 error("Invalid warp zone detected. Killed.");
652 warpzone_warpzones_exist = 1;
653 WarpZone_SetUp(self, self.warpzone_origin, self.warpzone_angles, self.enemy.warpzone_origin, self.enemy.warpzone_angles);
654 self.touch = WarpZone_Touch;
655 self.SendFlags = 0xFFFFFF;
656 if(self.spawnflags & 1)
658 self.think = WarpZone_Think;
659 self.nextthink = time;
665 float warpzone_initialized;
666 entity warpzone_first;
667 entity warpzone_position_first;
668 entity warpzone_camera_first;
669 .entity warpzone_next;
670 void spawnfunc_misc_warpzone_position(void)
672 // "target", "angles", "origin"
673 self.warpzone_next = warpzone_position_first;
674 warpzone_position_first = self;
676 void spawnfunc_trigger_warpzone_position(void)
678 spawnfunc_misc_warpzone_position();
680 void spawnfunc_trigger_warpzone(void)
682 // warp zone entities must have:
683 // "killtarget" pointing to a target_position with a direction arrow
684 // that points AWAY from the warp zone, and that is inside
685 // the warp zone trigger
686 // "target" pointing to an identical warp zone at another place in
687 // the map, with another killtarget to designate its
690 #ifndef WARPZONE_USE_FIXANGLE
691 // used when teleporting
692 precache_model("null");
696 self.scale = self.modelscale;
701 WarpZoneLib_ExactTrigger_Init();
705 setmodel(self, m); // no precision needed
707 setorigin(self, self.origin);
709 setsize(self, self.mins * self.scale, self.maxs * self.scale);
711 setsize(self, self.mins, self.maxs);
712 self.SendEntity = WarpZone_Send;
713 self.SendFlags = 0xFFFFFF;
714 BITSET_ASSIGN(self.effects, EF_NODEPTHTEST);
715 self.warpzone_next = warpzone_first;
716 warpzone_first = self;
718 void spawnfunc_func_camera(void)
721 self.scale = self.modelscale;
726 precache_model(self.model);
727 setmodel(self, self.model); // no precision needed
729 setorigin(self, self.origin);
731 setsize(self, self.mins * self.scale, self.maxs * self.scale);
733 setsize(self, self.mins, self.maxs);
735 self.solid = SOLID_BSP;
736 else if(self.solid < 0)
737 self.solid = SOLID_NOT;
738 self.SendEntity = WarpZone_Camera_Send;
739 self.SendFlags = 0xFFFFFF;
740 self.warpzone_next = warpzone_camera_first;
741 warpzone_camera_first = self;
743 void WarpZones_Reconnect()
747 for(self = warpzone_first; self; self = self.warpzone_next)
748 WarpZone_InitStep_ClearTarget();
749 for(self = warpzone_first; self; self = self.warpzone_next)
750 WarpZone_InitStep_FindTarget();
751 for(self = warpzone_camera_first; self; self = self.warpzone_next)
752 WarpZoneCamera_InitStep_FindTarget();
753 for(self = warpzone_first; self; self = self.warpzone_next)
754 WarpZone_InitStep_FinalizeTransform();
758 void WarpZone_Think()
760 if(self.warpzone_save_origin != self.origin
761 || self.warpzone_save_angles != self.angles
762 || self.warpzone_save_eorigin != self.enemy.origin
763 || self.warpzone_save_eangles != self.enemy.angles)
767 WarpZone_InitStep_UpdateTransform();
769 WarpZone_InitStep_UpdateTransform();
771 WarpZone_InitStep_FinalizeTransform();
773 WarpZone_InitStep_FinalizeTransform();
775 self.warpzone_save_origin = self.origin;
776 self.warpzone_save_angles = self.angles;
777 self.warpzone_save_eorigin = self.enemy.origin;
778 self.warpzone_save_eangles = self.enemy.angles;
780 self.nextthink = time;
783 void WarpZone_StartFrame()
786 if(warpzone_initialized == 0)
788 warpzone_initialized = 1;
790 for(self = warpzone_first; self; self = self.warpzone_next)
791 WarpZone_InitStep_FindOriginTarget();
792 for(self = warpzone_position_first; self; self = self.warpzone_next)
793 WarpZonePosition_InitStep_FindTarget();
794 for(self = warpzone_first; self; self = self.warpzone_next)
795 WarpZone_InitStep_UpdateTransform();
797 WarpZones_Reconnect();
798 WarpZone_PostInitialize_Callback();
801 entity oldself, oldother;
804 for(e = world; (e = nextent(e)); )
806 if(warpzone_warpzones_exist) { WarpZone_StoreProjectileData(e); }
808 float f = clienttype(e);
809 if(f == CLIENTTYPE_REAL)
811 if(e.solid == SOLID_NOT) // not spectating?
812 if(e.movetype == MOVETYPE_NOCLIP || e.movetype == MOVETYPE_FLY || e.movetype == MOVETYPE_FLY_WORLDONLY) // not spectating? (this is to catch observers)
817 if(warpzone_warpzones_exist) {
818 self = WarpZone_Find(e.origin + e.mins, e.origin + e.maxs);
820 if(!WarpZoneLib_ExactTrigger_Touch())
821 if(WarpZone_PlaneDist(self, e.origin + e.view_ofs) <= 0)
822 WarpZone_Teleport(self, e, -1, 0); } // NOT triggering targets by this!
825 self = Teleport_Find(e.origin + e.mins, e.origin + e.maxs);
827 if(!WarpZoneLib_ExactTrigger_Touch())
828 Simple_TeleportPlayer(self, other); // NOT triggering targets by this!
832 if(f == CLIENTTYPE_NOTACLIENT)
834 if(warpzone_warpzones_exist)
835 for(; (e = nextent(e)); )
836 WarpZone_StoreProjectileData(e);
844 .float warpzone_reconnecting;
845 float visible_to_some_client(entity ent)
848 for(e = nextent(world); clienttype(e) != CLIENTTYPE_NOTACLIENT; e = nextent(e))
849 if(e.classname == "player" && clienttype(e) == CLIENTTYPE_REAL)
850 if(checkpvs(e.origin + e.view_ofs, ent))
854 void trigger_warpzone_reconnect_use()
858 // NOTE: this matches for target, not targetname, but of course
859 // targetname must be set too on the other entities
860 for(self = warpzone_first; self; self = self.warpzone_next)
861 self.warpzone_reconnecting = ((e.target == "" || self.target == e.target) && !((e.spawnflags & 1) && (visible_to_some_client(self) || visible_to_some_client(self.enemy))));
862 for(self = warpzone_camera_first; self; self = self.warpzone_next)
863 self.warpzone_reconnecting = ((e.target == "" || self.target == e.target) && !((e.spawnflags & 1) && visible_to_some_client(self)));
864 for(self = warpzone_first; self; self = self.warpzone_next)
865 if(self.warpzone_reconnecting)
866 WarpZone_InitStep_ClearTarget();
867 for(self = warpzone_first; self; self = self.warpzone_next)
868 if(self.warpzone_reconnecting)
869 WarpZone_InitStep_FindTarget();
870 for(self = warpzone_camera_first; self; self = self.warpzone_next)
871 if(self.warpzone_reconnecting)
872 WarpZoneCamera_InitStep_FindTarget();
873 for(self = warpzone_first; self; self = self.warpzone_next)
874 if(self.warpzone_reconnecting || self.enemy.warpzone_reconnecting)
875 WarpZone_InitStep_FinalizeTransform();
879 void spawnfunc_trigger_warpzone_reconnect()
881 self.use = trigger_warpzone_reconnect_use;
884 void spawnfunc_target_warpzone_reconnect()
886 spawnfunc_trigger_warpzone_reconnect(); // both names make sense here :(
889 void WarpZone_PlayerPhysics_FixVAngle(void)
891 #ifndef WARPZONE_DONT_FIX_VANGLE
892 if(clienttype(self) == CLIENTTYPE_REAL)
893 if(self.v_angle_z <= 360) // if not already adjusted
894 if(time - self.ping * 0.001 < self.warpzone_teleport_time)
896 self.v_angle = WarpZone_TransformVAngles(self.warpzone_teleport_zone, self.v_angle);
897 self.v_angle_z += 720; // mark as adjusted