7 #include <common/constants.qh>
8 #include <common/net_linked.qh>
9 #include <common/triggers/subs.qh>
10 #include <common/util.qh>
11 #include <server/constants.qh>
12 #include <server/defs.qh>
15 #ifdef WARPZONELIB_KEEPDEBUG
16 #define WARPZONELIB_REMOVEHACK
20 .vector warpzone_save_origin;
21 .vector warpzone_save_angles;
22 .vector warpzone_save_eorigin;
23 .vector warpzone_save_eangles;
26 .vector warpzone_oldorigin, warpzone_oldvelocity, warpzone_oldangles;
27 .float warpzone_teleport_time;
28 .float warpzone_teleport_finishtime;
29 .entity warpzone_teleport_zone;
31 #define WarpZone_StoreProjectileData(e_) MACRO_BEGIN { \
33 e.warpzone_oldorigin = e.origin; \
34 e.warpzone_oldvelocity = e.velocity; \
35 e.warpzone_oldangles = e.angles; \
38 void WarpZone_TeleportPlayer(entity teleporter, entity player, vector to, vector to_angles, vector to_velocity)
41 player.lastteleport_origin = player.origin;
42 player.lastteleporttime = time;
44 setorigin(player, to); // NOTE: this also aborts the move, when this is called by touch
46 player.oldorigin = to; // for DP's unsticking
47 player.fixangle = true;
49 player.angles = to_angles;
50 player.velocity = to_velocity;
52 BITXOR_ASSIGN(player.effects, EF_TELEPORT_BIT);
55 BITCLR_ASSIGN(player.flags, FL_ONGROUND);
57 WarpZone_PostTeleportPlayer_Callback(player);
61 bool WarpZone_Teleported_Send(entity this, entity to, int sf)
63 WriteHeader(MSG_ENTITY, ENT_CLIENT_WARPZONE_TELEPORTED);
64 WriteVector(MSG_ENTITY, this.angles);
69 float WarpZone_Teleport(entity wz, entity player, float f0, float f1)
71 vector o0, a0, v0, o1, a1, v1, o10;
73 o0 = player.origin + player.view_ofs;
77 o10 = o1 = WarpZone_TransformOrigin(wz, o0);
78 v1 = WarpZone_TransformVelocity(wz, v0);
79 if (!IS_NOT_A_CLIENT(player))
80 a1 = WarpZone_TransformVAngles(wz, PHYS_INPUT_ANGLES(player));
82 a1 = WarpZone_TransformAngles(wz, a0);
84 if(f0 != 0 || f1 != 0)
86 // retry last move but behind the warpzone!
87 // we must first go back as far as we can, then forward again, to not cause double touch events!
89 tracebox(o1 - player.view_ofs + v1 * frametime * f1, player.mins, player.maxs, o1 - player.view_ofs + v1 * frametime * f0, MOVE_WORLDONLY, player);
94 tracebox(trace_endpos, player.mins, player.maxs, o1 - player.view_ofs + v1 * frametime * f1, MOVE_NORMAL, player); // this should get us through the warpzone
97 o1 = trace_endpos + player.view_ofs;
100 md = max(vlen(player.mins), vlen(player.maxs));
101 d = WarpZone_TargetPlaneDist(wz, o1);
102 dv = WarpZone_TargetPlaneDist(wz, v1);
104 o1 = o1 - v1 * (d / dv);
107 // put him out of solid
108 tracebox(o1 - player.view_ofs, player.mins, player.maxs, o1 - player.view_ofs, MOVE_NOMONSTERS, player);
111 setorigin(player, o1 - player.view_ofs);
112 if(WarpZoneLib_MoveOutOfSolid(player))
114 o1 = player.origin + player.view_ofs;
115 setorigin(player, o0 - player.view_ofs);
119 LOG_INFO("would have to put player in solid, won't do that");
120 setorigin(player, o0 - player.view_ofs);
126 WarpZone_RefSys_Add(player, wz);
127 WarpZone_TeleportPlayer(wz, player, o1 - player.view_ofs, a1, v1);
128 WarpZone_StoreProjectileData(player);
129 player.warpzone_teleport_time = time;
130 player.warpzone_teleport_finishtime = time;
131 player.warpzone_teleport_zone = wz;
134 // prevent further teleports back
135 float dt = (o1 - o10) * v1 * (1 / (v1 * v1));
136 if(dt < PHYS_INPUT_FRAMETIME)
137 player.warpzone_teleport_finishtime += PHYS_INPUT_FRAMETIME - dt;
140 #ifndef WARPZONE_USE_FIXANGLE
142 if(IS_VEHICLE(player) && player.owner)
143 player = player.owner; // hax
144 if(IS_PLAYER(player))
146 // instead of fixangle, send the transform to the client for smoother operation
147 player.fixangle = false;
149 entity ts = new(warpzone_teleported);
150 setmodel(ts, MDL_Null);
151 setSendEntity(ts, WarpZone_Teleported_Send);
152 ts.SendFlags = 0xFFFFFF;
153 ts.drawonlytoclient = player;
154 setthink(ts, SUB_Remove);
155 ts.nextthink = time + 1;
158 ts.effects = EF_NODEPTHTEST;
159 ts.angles = wz.warpzone_transform;
162 setproperty(VF_CL_VIEWANGLES, WarpZone_TransformVAngles(wz, getpropertyvec(VF_CL_VIEWANGLES)));
163 //if(checkextension("DP_CSQC_ROTATEMOVES"))
164 //CL_RotateMoves(wz.warpzone_transform);
171 void WarpZone_Touch(entity this, entity toucher)
173 if(toucher.classname == "trigger_warpzone")
176 if(time <= toucher.warpzone_teleport_finishtime) // already teleported this frame
179 // FIXME needs a better check to know what is safe to teleport and what not
180 if(toucher.move_movetype == MOVETYPE_NONE || toucher.move_movetype == MOVETYPE_FOLLOW || toucher.tag_entity)
183 if(WarpZoneLib_ExactTrigger_Touch(this, toucher))
186 if(WarpZone_PlaneDist(this, toucher.origin + toucher.view_ofs) >= 0) // wrong side of the trigger_warpzone (don't teleport yet)
190 // number of frames we need to go back:
191 // dist = 16*sqrt(2) qu
194 // 24 qu = v*frametime*n
195 // n = 24 qu/(v*frametime)
196 // for clients go only one frame though, may be too irritating otherwise
197 // but max 0.25 sec = 0.25/frametime frames
198 // 24/(0.25/frametime)
201 d = 24 + max(vlen(toucher.mins), vlen(toucher.maxs));
202 if(IS_NOT_A_CLIENT(toucher))
203 f = -d / bound(frametime * d * 1, frametime * vlen(toucher.velocity), d);
206 if(WarpZone_Teleport(this, toucher, f, 0))
211 save1 = this.target; this.target = string_null;
212 save2 = this.target3; this.target3 = string_null;
213 SUB_UseTargets(this, toucher, toucher); // use toucher too?
214 if (!this.target) this.target = save1;
215 if (!this.target3) this.target3 = save2;
217 save1 = this.target; this.target = string_null;
218 save2 = this.target2; this.target2 = string_null;
219 SUB_UseTargets(this.enemy, toucher, toucher); // use toucher too?
220 if (!this.target) this.target = save1;
221 if (!this.target2) this.target2 = save2;
226 LOG_TRACE("WARPZONE FAIL AHAHAHAHAH))");
231 bool WarpZone_Send(entity this, entity to, int sendflags)
233 WriteHeader(MSG_ENTITY, ENT_CLIENT_WARPZONE);
235 // we must send this flag for clientside to match properly too
237 if(this.warpzone_isboxy)
239 if(this.warpzone_fadestart)
241 if(this.origin != '0 0 0')
243 WriteByte(MSG_ENTITY, f);
245 // we need THESE to render the warpzone (and cull properly)...
248 WriteCoord(MSG_ENTITY, this.origin.x);
249 WriteCoord(MSG_ENTITY, this.origin.y);
250 WriteCoord(MSG_ENTITY, this.origin.z);
253 WriteShort(MSG_ENTITY, this.modelindex);
254 WriteCoord(MSG_ENTITY, this.mins.x);
255 WriteCoord(MSG_ENTITY, this.mins.y);
256 WriteCoord(MSG_ENTITY, this.mins.z);
257 WriteCoord(MSG_ENTITY, this.maxs.x);
258 WriteCoord(MSG_ENTITY, this.maxs.y);
259 WriteCoord(MSG_ENTITY, this.maxs.z);
260 WriteByte(MSG_ENTITY, bound(1, this.scale * 16, 255));
262 // we need THESE to calculate the proper transform
263 WriteCoord(MSG_ENTITY, this.warpzone_origin.x);
264 WriteCoord(MSG_ENTITY, this.warpzone_origin.y);
265 WriteCoord(MSG_ENTITY, this.warpzone_origin.z);
266 WriteCoord(MSG_ENTITY, this.warpzone_angles.x);
267 WriteCoord(MSG_ENTITY, this.warpzone_angles.y);
268 WriteCoord(MSG_ENTITY, this.warpzone_angles.z);
269 WriteCoord(MSG_ENTITY, this.warpzone_targetorigin.x);
270 WriteCoord(MSG_ENTITY, this.warpzone_targetorigin.y);
271 WriteCoord(MSG_ENTITY, this.warpzone_targetorigin.z);
272 WriteCoord(MSG_ENTITY, this.warpzone_targetangles.x);
273 WriteCoord(MSG_ENTITY, this.warpzone_targetangles.y);
274 WriteCoord(MSG_ENTITY, this.warpzone_targetangles.z);
278 WriteShort(MSG_ENTITY, this.warpzone_fadestart);
279 WriteShort(MSG_ENTITY, this.warpzone_fadeend);
285 bool WarpZone_Camera_Send(entity this, entity to, int sendflags)
288 WriteHeader(MSG_ENTITY, ENT_CLIENT_WARPZONE_CAMERA);
290 if(this.warpzone_fadestart)
292 if(this.origin != '0 0 0')
294 WriteByte(MSG_ENTITY, f);
296 // we need THESE to render the warpzone (and cull properly)...
299 WriteCoord(MSG_ENTITY, this.origin.x);
300 WriteCoord(MSG_ENTITY, this.origin.y);
301 WriteCoord(MSG_ENTITY, this.origin.z);
304 WriteShort(MSG_ENTITY, this.modelindex);
305 WriteCoord(MSG_ENTITY, this.mins.x);
306 WriteCoord(MSG_ENTITY, this.mins.y);
307 WriteCoord(MSG_ENTITY, this.mins.z);
308 WriteCoord(MSG_ENTITY, this.maxs.x);
309 WriteCoord(MSG_ENTITY, this.maxs.y);
310 WriteCoord(MSG_ENTITY, this.maxs.z);
311 WriteByte(MSG_ENTITY, bound(1, this.scale * 16, 255));
313 // we need THESE to calculate the proper transform
314 WriteCoord(MSG_ENTITY, this.enemy.origin.x);
315 WriteCoord(MSG_ENTITY, this.enemy.origin.y);
316 WriteCoord(MSG_ENTITY, this.enemy.origin.z);
317 WriteCoord(MSG_ENTITY, this.enemy.angles.x);
318 WriteCoord(MSG_ENTITY, this.enemy.angles.y);
319 WriteCoord(MSG_ENTITY, this.enemy.angles.z);
323 WriteShort(MSG_ENTITY, this.warpzone_fadestart);
324 WriteShort(MSG_ENTITY, this.warpzone_fadeend);
330 #ifdef WARPZONELIB_KEEPDEBUG
331 float WarpZone_CheckProjectileImpact(entity player)
335 o0 = player.origin + player.view_ofs;
336 v0 = player.velocity;
338 // if we teleported shortly before, abort
339 if(time <= player.warpzone_teleport_finishtime + 0.1)
342 // if player hit a warpzone, abort
344 wz = WarpZone_Find(o0 + player.mins, o0 + player.maxs);
348 #ifdef WARPZONELIB_REMOVEHACK
349 LOG_INFO("impactfilter found something - and it no longer gets handled correctly - please tell divVerent whether anything behaves broken now");
351 LOG_INFO("impactfilter found something - and it even gets handled correctly - please tell divVerent that this code apparently gets triggered again");
353 LOG_INFO("Entity type: ", player.classname);
354 LOG_INFO("Origin: ", vtos(player.origin));
355 LOG_INFO("Velocity: ", vtos(player.velocity));
357 #ifdef WARPZONELIB_REMOVEHACK
360 // retry previous move
361 setorigin(player, player.warpzone_oldorigin);
362 player.velocity = player.warpzone_oldvelocity;
363 if(WarpZone_Teleport(wz, player, 0, 1))
367 save1 = wz.target; wz.target = string_null;
368 save2 = wz.target3; wz.target3 = string_null;
369 SUB_UseTargets(wz, player, player);
370 if (!wz.target) wz.target = save1;
371 if (!wz.target3) wz.target3 = save2;
373 save1 = wz.enemy.target; wz.enemy.target = string_null;
374 save2 = wz.enemy.target2; wz.enemy.target2 = string_null;
375 SUB_UseTargets(wz.enemy, player, player);
376 if (!wz.enemy.target) wz.enemy.target = save1;
377 if (!wz.enemy.target2) wz.enemy.target2 = save2;
381 setorigin(player, o0 - player.view_ofs);
382 player.velocity = v0;
391 float WarpZone_Projectile_Touch(entity this, entity toucher)
393 if(toucher.classname == "trigger_warpzone")
396 // no further impacts if we teleported this frame!
397 // this is because even if we did teleport, the engine still may raise
398 // touch events for the previous location
399 // engine now aborts moves on teleport, so this SHOULD not happen any more
400 // but if this is called from TouchAreaGrid of the projectile moving,
401 // then this won't do
402 if(time == this.warpzone_teleport_time)
406 #ifdef WARPZONELIB_KEEPDEBUG
407 // this SEEMS to not happen at the moment, but if it did, it would be more reliable
409 float save_dpstartcontents;
410 float save_dphitcontents;
411 float save_dphitq3surfaceflags;
412 string save_dphittexturename;
414 float save_startsolid;
417 vector save_plane_normal;
418 float save_plane_dist;
422 save_dpstartcontents = trace_dpstartcontents;
423 save_dphitcontents = trace_dphitcontents;
424 save_dphitq3surfaceflags = trace_dphitq3surfaceflags;
425 save_dphittexturename = trace_dphittexturename;
426 save_allsolid = trace_allsolid;
427 save_startsolid = trace_startsolid;
428 save_fraction = trace_fraction;
429 save_endpos = trace_endpos;
430 save_plane_normal = trace_plane_normal;
431 save_plane_dist = trace_plane_dist;
432 save_ent = trace_ent;
433 save_inopen = trace_inopen;
434 save_inwater = trace_inwater;
435 float f = WarpZone_CheckProjectileImpact(this);
436 if (f) return (f > 0);
437 trace_dpstartcontents = save_dpstartcontents;
438 trace_dphitcontents = save_dphitcontents;
439 trace_dphitq3surfaceflags = save_dphitq3surfaceflags;
440 trace_dphittexturename = save_dphittexturename;
441 trace_allsolid = save_allsolid;
442 trace_startsolid = save_startsolid;
443 trace_fraction = save_fraction;
444 trace_endpos = save_endpos;
445 trace_plane_normal = save_plane_normal;
446 trace_plane_dist = save_plane_dist;
447 trace_ent = save_ent;
448 trace_inopen = save_inopen;
449 trace_inwater = save_inwater;
453 if(WarpZone_Projectile_Touch_ImpactFilter_Callback(this, toucher))
462 void WarpZone_InitStep_FindOriginTarget(entity this)
464 if(this.killtarget != "")
466 this.aiment = find(NULL, targetname, this.killtarget);
467 if(this.aiment == NULL)
469 error("Warp zone with nonexisting killtarget");
472 this.killtarget = string_null;
476 void WarpZonePosition_InitStep_FindTarget(entity this)
478 if(this.target == "")
480 error("Warp zone position with no target");
483 this.enemy = find(NULL, targetname, this.target);
484 if(this.enemy == NULL)
486 error("Warp zone position with nonexisting target");
489 if(this.enemy.aiment)
491 // already is positioned
492 error("Warp zone position targeting already oriented warpzone");
495 this.enemy.aiment = this;
498 void WarpZoneCamera_Think(entity this)
500 if(this.warpzone_save_origin != this.origin
501 || this.warpzone_save_angles != this.angles
502 || this.warpzone_save_eorigin != this.enemy.origin
503 || this.warpzone_save_eangles != this.enemy.angles)
505 WarpZone_Camera_SetUp(this, this.enemy.origin, this.enemy.angles);
506 this.warpzone_save_origin = this.origin;
507 this.warpzone_save_angles = this.angles;
508 this.warpzone_save_eorigin = this.enemy.origin;
509 this.warpzone_save_eangles = this.enemy.angles;
511 this.nextthink = time;
514 void WarpZoneCamera_InitStep_FindTarget(entity this)
518 if(this.target == "")
520 error("Camera with no target");
524 for(e = NULL, i = 0; (e = find(e, targetname, this.target)); )
525 if(random() * ++i < 1)
527 if(this.enemy == NULL)
529 error("Camera with nonexisting target");
532 warpzone_cameras_exist = 1;
533 WarpZone_Camera_SetUp(this, this.enemy.origin, this.enemy.angles);
534 this.SendFlags = 0xFFFFFF;
535 if(this.spawnflags & 1)
537 setthink(this, WarpZoneCamera_Think);
538 this.nextthink = time;
544 void WarpZone_InitStep_UpdateTransform(entity this)
546 vector org, ang, norm, point;
548 vector tri, a, b, c, n;
554 org = 0.5 * (this.mins + this.maxs);
556 norm = point = '0 0 0';
558 for(i_s = 0; ; ++i_s)
560 tex = getsurfacetexture(this, i_s);
562 break; // this is beyond the last one
563 if(tex == "textures/common/trigger" || tex == "trigger")
565 n_t = getsurfacenumtriangles(this, i_s);
566 for(i_t = 0; i_t < n_t; ++i_t)
568 tri = getsurfacetriangle(this, i_s, i_t);
569 a = getsurfacepoint(this, i_s, tri.x);
570 b = getsurfacepoint(this, i_s, tri.y);
571 c = getsurfacepoint(this, i_s, tri.z);
572 n = cross(c - a, b - a);
573 area = area + vlen(n);
575 point = point + vlen(n) * (a + b + c);
580 norm = norm * (1 / area);
581 point = point * (1 / (3 * area));
582 if(vdist(norm, <, 0.99))
584 LOG_INFO("trigger_warpzone near ", vtos(this.aiment.origin), " is nonplanar. BEWARE.");
585 area = 0; // no autofixing in this case
587 norm = normalize(norm);
593 org = this.aiment.origin;
594 ang = this.aiment.angles;
597 org = org - ((org - point) * norm) * norm; // project to plane
599 if(norm * v_forward < 0)
601 LOG_INFO("Position target of trigger_warpzone near ", vtos(this.aiment.origin), " points into trigger_warpzone. BEWARE.");
604 ang = vectoangles2(norm, v_up); // keep rotation, but turn exactly against plane
606 if(norm * v_forward < 0.99)
607 LOG_INFO("trigger_warpzone near ", vtos(this.aiment.origin), " has been turned to match plane orientation (", vtos(this.aiment.angles), " -> ", vtos(ang));
608 if(vdist(org - this.aiment.origin, >, 0.5))
609 LOG_INFO("trigger_warpzone near ", vtos(this.aiment.origin), " has been moved to match the plane (", vtos(this.aiment.origin), " -> ", vtos(org), ").");
615 ang = vectoangles(norm);
619 error("cannot infer origin/angles for this warpzone, please use a killtarget or a trigger_warpzone_position");
621 this.warpzone_origin = org;
622 this.warpzone_angles = ang;
625 void WarpZone_InitStep_ClearTarget(entity this)
628 this.enemy.enemy = NULL;
632 void WarpZone_InitStep_FindTarget(entity this)
640 // this way only one of the two ents needs to target
641 if(this.target != "")
643 this.enemy = this; // so the if(!e.enemy) check also skips this, saves one IF
646 for(e = NULL, i = 0; (e = find(e, targetname, this.target)); )
648 if(e.classname == this.classname) // possibly non-warpzones may use the same targetname!
649 if(random() * ++i < 1)
654 error("Warpzone with non-existing target");
662 void WarpZone_Think(entity this);
663 void WarpZone_InitStep_FinalizeTransform(entity this)
665 if(!this.enemy || this.enemy.enemy != this)
667 error("Invalid warp zone detected. Killed.");
671 warpzone_warpzones_exist = 1;
672 WarpZone_SetUp(this, this.warpzone_origin, this.warpzone_angles, this.enemy.warpzone_origin, this.enemy.warpzone_angles);
673 settouch(this, WarpZone_Touch);
674 this.SendFlags = 0xFFFFFF;
675 if(this.spawnflags & 1)
677 setthink(this, WarpZone_Think);
678 this.nextthink = time;
684 float warpzone_initialized;
685 //entity warpzone_first;
686 entity warpzone_position_first;
687 entity warpzone_camera_first;
688 .entity warpzone_next;
689 spawnfunc(misc_warpzone_position)
691 // "target", "angles", "origin"
692 this.warpzone_next = warpzone_position_first;
693 warpzone_position_first = this;
695 spawnfunc(trigger_warpzone_position)
697 spawnfunc_misc_warpzone_position(this);
699 spawnfunc(trigger_warpzone)
701 // warp zone entities must have:
702 // "killtarget" pointing to a target_position with a direction arrow
703 // that points AWAY from the warp zone, and that is inside
704 // the warp zone trigger
705 // "target" pointing to an identical warp zone at another place in
706 // the map, with another killtarget to designate its
710 this.scale = this.modelscale;
715 WarpZoneLib_ExactTrigger_Init(this);
719 _setmodel(this, m); // no precision needed
721 setorigin(this, this.origin);
723 setsize(this, this.mins * this.scale, this.maxs * this.scale);
725 setsize(this, this.mins, this.maxs);
726 setSendEntity(this, WarpZone_Send);
727 this.SendFlags = 0xFFFFFF;
728 BITSET_ASSIGN(this.effects, EF_NODEPTHTEST);
729 this.warpzone_next = warpzone_first;
730 warpzone_first = this;
732 IL_PUSH(g_warpzones, this);
734 spawnfunc(func_camera)
737 this.scale = this.modelscale;
742 precache_model(this.model);
743 _setmodel(this, this.model); // no precision needed
745 setorigin(this, this.origin);
747 setsize(this, this.mins * this.scale, this.maxs * this.scale);
749 setsize(this, this.mins, this.maxs);
751 this.solid = SOLID_BSP;
752 else if(this.solid < 0)
753 this.solid = SOLID_NOT;
754 setSendEntity(this, WarpZone_Camera_Send);
755 this.SendFlags = 0xFFFFFF;
756 this.warpzone_next = warpzone_camera_first;
757 warpzone_camera_first = this;
759 void WarpZones_Reconnect()
761 for(entity e = warpzone_first; e; e = e.warpzone_next)
762 WarpZone_InitStep_ClearTarget(e);
763 for(entity e = warpzone_first; e; e = e.warpzone_next)
764 WarpZone_InitStep_FindTarget(e);
765 for(entity e = warpzone_camera_first; e; e = e.warpzone_next)
766 WarpZoneCamera_InitStep_FindTarget(e);
767 for(entity e = warpzone_first; e; e = e.warpzone_next)
768 WarpZone_InitStep_FinalizeTransform(e);
771 void WarpZone_Think(entity this)
773 if(this.warpzone_save_origin != this.origin
774 || this.warpzone_save_angles != this.angles
775 || this.warpzone_save_eorigin != this.enemy.origin
776 || this.warpzone_save_eangles != this.enemy.angles)
778 WarpZone_InitStep_UpdateTransform(this);
779 WarpZone_InitStep_UpdateTransform(this.enemy);
780 WarpZone_InitStep_FinalizeTransform(this);
781 WarpZone_InitStep_FinalizeTransform(this.enemy);
782 this.warpzone_save_origin = this.origin;
783 this.warpzone_save_angles = this.angles;
784 this.warpzone_save_eorigin = this.enemy.origin;
785 this.warpzone_save_eangles = this.enemy.angles;
787 this.nextthink = time;
790 void WarpZone_StartFrame()
792 if (!warpzone_initialized)
794 warpzone_initialized = true;
795 for(entity e = warpzone_first; e; e = e.warpzone_next)
796 WarpZone_InitStep_FindOriginTarget(e);
797 for(entity e = warpzone_position_first; e; e = e.warpzone_next)
798 WarpZonePosition_InitStep_FindTarget(e);
799 for(entity e = warpzone_first; e; e = e.warpzone_next)
800 WarpZone_InitStep_UpdateTransform(e);
801 WarpZones_Reconnect();
802 WarpZone_PostInitialize_Callback();
805 if(warpzone_warpzones_exist)
807 IL_EACH(g_projectiles, true,
809 WarpZone_StoreProjectileData(it);
816 if(warpzone_warpzones_exist)
817 WarpZone_StoreProjectileData(it); // TODO: not actually needed
819 if(IS_OBSERVER(it) || it.solid == SOLID_NOT)
820 if(IS_CLIENT(it)) // we don't care about it being a bot
823 if (warpzone_warpzones_exist) {
824 entity e = WarpZone_Find(it.origin + it.mins, it.origin + it.maxs);
826 if (!WarpZoneLib_ExactTrigger_Touch(e, it))
827 if (WarpZone_PlaneDist(e, it.origin + it.view_ofs) <= 0)
828 WarpZone_Teleport(e, it, -1, 0); // NOT triggering targets by this!
834 entity ent = Teleport_Find(it.origin + it.mins, it.origin + it.maxs);
836 if (!WarpZoneLib_ExactTrigger_Touch(ent, it))
837 Simple_TeleportPlayer(ent, it); // NOT triggering targets by this!
843 .float warpzone_reconnecting;
844 bool visible_to_some_client(entity ent)
846 FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it) && checkpvs(it.origin + it.view_ofs, ent),
852 void trigger_warpzone_reconnect_use(entity this, entity actor, entity trigger)
854 // NOTE: this matches for target, not targetname, but of course
855 // targetname must be set too on the other entities
856 for(entity e = warpzone_first; e; e = e.warpzone_next)
857 e.warpzone_reconnecting = ((this.target == "" || e.target == this.target) && !((this.spawnflags & 1) && (visible_to_some_client(e) || visible_to_some_client(e.enemy))));
858 for(entity e = warpzone_camera_first; e; e = e.warpzone_next)
859 e.warpzone_reconnecting = ((this.target == "" || e.target == this.target) && !((this.spawnflags & 1) && visible_to_some_client(e)));
860 for(entity e = warpzone_first; e; e = e.warpzone_next)
861 if(e.warpzone_reconnecting)
862 WarpZone_InitStep_ClearTarget(e);
863 for(entity e = warpzone_first; e; e = e.warpzone_next)
864 if(e.warpzone_reconnecting)
865 WarpZone_InitStep_FindTarget(e);
866 for(entity e = warpzone_camera_first; e; e = e.warpzone_next)
867 if(e.warpzone_reconnecting)
868 WarpZoneCamera_InitStep_FindTarget(e);
869 for(entity e = warpzone_first; e; e = e.warpzone_next)
870 if(e.warpzone_reconnecting || e.enemy.warpzone_reconnecting)
871 WarpZone_InitStep_FinalizeTransform(e);
874 spawnfunc(trigger_warpzone_reconnect)
876 this.use = trigger_warpzone_reconnect_use;
879 spawnfunc(target_warpzone_reconnect)
881 spawnfunc_trigger_warpzone_reconnect(this); // both names make sense here :(
884 void WarpZone_PlayerPhysics_FixVAngle(entity this)
886 #ifndef WARPZONE_DONT_FIX_VANGLE
887 if(IS_REAL_CLIENT(this))
888 if(this.v_angle.z <= 360) // if not already adjusted
889 if(time - CS(this).ping * 0.001 < this.warpzone_teleport_time)
891 this.v_angle = WarpZone_TransformVAngles(this.warpzone_teleport_zone, this.v_angle);
892 this.v_angle_z += 720; // mark as adjusted