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 WriteCoord(MSG_ENTITY, this.angles.x);
65 WriteCoord(MSG_ENTITY, this.angles.y);
66 WriteCoord(MSG_ENTITY, this.angles.z);
71 float WarpZone_Teleport(entity wz, entity player, float f0, float f1)
73 vector o0, a0, v0, o1, a1, v1, o10;
75 o0 = player.origin + player.view_ofs;
79 o10 = o1 = WarpZone_TransformOrigin(wz, o0);
80 v1 = WarpZone_TransformVelocity(wz, v0);
81 if (!IS_NOT_A_CLIENT(player))
82 a1 = WarpZone_TransformVAngles(wz, PHYS_INPUT_ANGLES(player));
84 a1 = WarpZone_TransformAngles(wz, a0);
86 if(f0 != 0 || f1 != 0)
88 // retry last move but behind the warpzone!
89 // we must first go back as far as we can, then forward again, to not cause double touch events!
91 tracebox(o1 - player.view_ofs + v1 * frametime * f1, player.mins, player.maxs, o1 - player.view_ofs + v1 * frametime * f0, MOVE_WORLDONLY, player);
96 tracebox(trace_endpos, player.mins, player.maxs, o1 - player.view_ofs + v1 * frametime * f1, MOVE_NORMAL, player); // this should get us through the warpzone
99 o1 = trace_endpos + player.view_ofs;
102 md = max(vlen(player.mins), vlen(player.maxs));
103 d = WarpZone_TargetPlaneDist(wz, o1);
104 dv = WarpZone_TargetPlaneDist(wz, v1);
106 o1 = o1 - v1 * (d / dv);
109 // put him out of solid
110 tracebox(o1 - player.view_ofs, player.mins, player.maxs, o1 - player.view_ofs, MOVE_NOMONSTERS, player);
113 setorigin(player, o1 - player.view_ofs);
114 if(WarpZoneLib_MoveOutOfSolid(player))
116 o1 = player.origin + player.view_ofs;
117 setorigin(player, o0 - player.view_ofs);
121 LOG_INFO("would have to put player in solid, won't do that");
122 setorigin(player, o0 - player.view_ofs);
128 WarpZone_RefSys_Add(player, wz);
129 WarpZone_TeleportPlayer(wz, player, o1 - player.view_ofs, a1, v1);
130 WarpZone_StoreProjectileData(player);
131 player.warpzone_teleport_time = time;
132 player.warpzone_teleport_finishtime = time;
133 player.warpzone_teleport_zone = wz;
136 // prevent further teleports back
137 float dt = (o1 - o10) * v1 * (1 / (v1 * v1));
138 if(dt < PHYS_INPUT_FRAMETIME)
139 player.warpzone_teleport_finishtime += PHYS_INPUT_FRAMETIME - dt;
142 #ifndef WARPZONE_USE_FIXANGLE
144 if(IS_VEHICLE(player) && player.owner)
145 player = player.owner; // hax
146 if(IS_PLAYER(player))
148 // instead of fixangle, send the transform to the client for smoother operation
149 player.fixangle = false;
151 entity ts = new(warpzone_teleported);
152 setmodel(ts, MDL_Null);
153 setSendEntity(ts, WarpZone_Teleported_Send);
154 ts.SendFlags = 0xFFFFFF;
155 ts.drawonlytoclient = player;
156 setthink(ts, SUB_Remove);
157 ts.nextthink = time + 1;
160 ts.effects = EF_NODEPTHTEST;
161 ts.angles = wz.warpzone_transform;
164 setproperty(VF_CL_VIEWANGLES, WarpZone_TransformVAngles(wz, getpropertyvec(VF_CL_VIEWANGLES)));
165 //if(checkextension("DP_CSQC_ROTATEMOVES"))
166 //CL_RotateMoves(wz.warpzone_transform);
173 void WarpZone_Touch(entity this, entity toucher)
175 if(toucher.classname == "trigger_warpzone")
178 if(time <= toucher.warpzone_teleport_finishtime) // already teleported this frame
181 // FIXME needs a better check to know what is safe to teleport and what not
182 if((toucher.move_movetype == MOVETYPE_NONE && toucher.move_movetype == MOVETYPE_NONE) || toucher.move_movetype == MOVETYPE_FOLLOW || toucher.move_movetype == MOVETYPE_FOLLOW || toucher.tag_entity
189 if(WarpZoneLib_ExactTrigger_Touch(this, toucher))
192 if(WarpZone_PlaneDist(this, toucher.origin + toucher.view_ofs) >= 0) // wrong side of the trigger_warpzone (don't teleport yet)
196 // number of frames we need to go back:
197 // dist = 16*sqrt(2) qu
200 // 24 qu = v*frametime*n
201 // n = 24 qu/(v*frametime)
202 // for clients go only one frame though, may be too irritating otherwise
203 // but max 0.25 sec = 0.25/frametime frames
204 // 24/(0.25/frametime)
207 d = 24 + max(vlen(toucher.mins), vlen(toucher.maxs));
208 if(IS_NOT_A_CLIENT(toucher))
209 f = -d / bound(frametime * d * 1, frametime * vlen(toucher.velocity), d);
212 if(WarpZone_Teleport(this, toucher, f, 0))
217 save1 = this.target; this.target = string_null;
218 save2 = this.target3; this.target3 = string_null;
219 SUB_UseTargets(this, toucher, toucher); // use toucher too?
220 if (!this.target) this.target = save1;
221 if (!this.target3) this.target3 = save2;
223 save1 = this.target; this.target = string_null;
224 save2 = this.target2; this.target2 = string_null;
225 SUB_UseTargets(this.enemy, toucher, toucher); // use toucher too?
226 if (!this.target) this.target = save1;
227 if (!this.target2) this.target2 = save2;
232 LOG_TRACE("WARPZONE FAIL AHAHAHAHAH))");
237 bool WarpZone_Send(entity this, entity to, int sendflags)
239 WriteHeader(MSG_ENTITY, ENT_CLIENT_WARPZONE);
241 // we must send this flag for clientside to match properly too
243 if(this.warpzone_isboxy)
245 if(this.warpzone_fadestart)
247 if(this.origin != '0 0 0')
249 WriteByte(MSG_ENTITY, f);
251 // we need THESE to render the warpzone (and cull properly)...
254 WriteCoord(MSG_ENTITY, this.origin.x);
255 WriteCoord(MSG_ENTITY, this.origin.y);
256 WriteCoord(MSG_ENTITY, this.origin.z);
259 WriteShort(MSG_ENTITY, this.modelindex);
260 WriteCoord(MSG_ENTITY, this.mins.x);
261 WriteCoord(MSG_ENTITY, this.mins.y);
262 WriteCoord(MSG_ENTITY, this.mins.z);
263 WriteCoord(MSG_ENTITY, this.maxs.x);
264 WriteCoord(MSG_ENTITY, this.maxs.y);
265 WriteCoord(MSG_ENTITY, this.maxs.z);
266 WriteByte(MSG_ENTITY, bound(1, this.scale * 16, 255));
268 // we need THESE to calculate the proper transform
269 WriteCoord(MSG_ENTITY, this.warpzone_origin.x);
270 WriteCoord(MSG_ENTITY, this.warpzone_origin.y);
271 WriteCoord(MSG_ENTITY, this.warpzone_origin.z);
272 WriteCoord(MSG_ENTITY, this.warpzone_angles.x);
273 WriteCoord(MSG_ENTITY, this.warpzone_angles.y);
274 WriteCoord(MSG_ENTITY, this.warpzone_angles.z);
275 WriteCoord(MSG_ENTITY, this.warpzone_targetorigin.x);
276 WriteCoord(MSG_ENTITY, this.warpzone_targetorigin.y);
277 WriteCoord(MSG_ENTITY, this.warpzone_targetorigin.z);
278 WriteCoord(MSG_ENTITY, this.warpzone_targetangles.x);
279 WriteCoord(MSG_ENTITY, this.warpzone_targetangles.y);
280 WriteCoord(MSG_ENTITY, this.warpzone_targetangles.z);
284 WriteShort(MSG_ENTITY, this.warpzone_fadestart);
285 WriteShort(MSG_ENTITY, this.warpzone_fadeend);
291 bool WarpZone_Camera_Send(entity this, entity to, int sendflags)
294 WriteHeader(MSG_ENTITY, ENT_CLIENT_WARPZONE_CAMERA);
296 if(this.warpzone_fadestart)
298 if(this.origin != '0 0 0')
300 WriteByte(MSG_ENTITY, f);
302 // we need THESE to render the warpzone (and cull properly)...
305 WriteCoord(MSG_ENTITY, this.origin.x);
306 WriteCoord(MSG_ENTITY, this.origin.y);
307 WriteCoord(MSG_ENTITY, this.origin.z);
310 WriteShort(MSG_ENTITY, this.modelindex);
311 WriteCoord(MSG_ENTITY, this.mins.x);
312 WriteCoord(MSG_ENTITY, this.mins.y);
313 WriteCoord(MSG_ENTITY, this.mins.z);
314 WriteCoord(MSG_ENTITY, this.maxs.x);
315 WriteCoord(MSG_ENTITY, this.maxs.y);
316 WriteCoord(MSG_ENTITY, this.maxs.z);
317 WriteByte(MSG_ENTITY, bound(1, this.scale * 16, 255));
319 // we need THESE to calculate the proper transform
320 WriteCoord(MSG_ENTITY, this.enemy.origin.x);
321 WriteCoord(MSG_ENTITY, this.enemy.origin.y);
322 WriteCoord(MSG_ENTITY, this.enemy.origin.z);
323 WriteCoord(MSG_ENTITY, this.enemy.angles.x);
324 WriteCoord(MSG_ENTITY, this.enemy.angles.y);
325 WriteCoord(MSG_ENTITY, this.enemy.angles.z);
329 WriteShort(MSG_ENTITY, this.warpzone_fadestart);
330 WriteShort(MSG_ENTITY, this.warpzone_fadeend);
336 #ifdef WARPZONELIB_KEEPDEBUG
337 float WarpZone_CheckProjectileImpact(entity player)
341 o0 = player.origin + player.view_ofs;
342 v0 = player.velocity;
344 // if we teleported shortly before, abort
345 if(time <= player.warpzone_teleport_finishtime + 0.1)
348 // if player hit a warpzone, abort
350 wz = WarpZone_Find(o0 + player.mins, o0 + player.maxs);
354 #ifdef WARPZONELIB_REMOVEHACK
355 LOG_INFO("impactfilter found something - and it no longer gets handled correctly - please tell divVerent whether anything behaves broken now");
357 LOG_INFO("impactfilter found something - and it even gets handled correctly - please tell divVerent that this code apparently gets triggered again");
359 LOG_INFO("Entity type: ", player.classname);
360 LOG_INFO("Origin: ", vtos(player.origin));
361 LOG_INFO("Velocity: ", vtos(player.velocity));
363 #ifdef WARPZONELIB_REMOVEHACK
366 // retry previous move
367 setorigin(player, player.warpzone_oldorigin);
368 player.velocity = player.warpzone_oldvelocity;
369 if(WarpZone_Teleport(wz, player, 0, 1))
373 save1 = wz.target; wz.target = string_null;
374 save2 = wz.target3; wz.target3 = string_null;
375 SUB_UseTargets(wz, player, player);
376 if (!wz.target) wz.target = save1;
377 if (!wz.target3) wz.target3 = save2;
379 save1 = wz.enemy.target; wz.enemy.target = string_null;
380 save2 = wz.enemy.target2; wz.enemy.target2 = string_null;
381 SUB_UseTargets(wz.enemy, player, player);
382 if (!wz.enemy.target) wz.enemy.target = save1;
383 if (!wz.enemy.target2) wz.enemy.target2 = save2;
387 setorigin(player, o0 - player.view_ofs);
388 player.velocity = v0;
397 float WarpZone_Projectile_Touch(entity this, entity toucher)
399 if(toucher.classname == "trigger_warpzone")
402 // no further impacts if we teleported this frame!
403 // this is because even if we did teleport, the engine still may raise
404 // touch events for the previous location
405 // engine now aborts moves on teleport, so this SHOULD not happen any more
406 // but if this is called from TouchAreaGrid of the projectile moving,
407 // then this won't do
408 if(time == this.warpzone_teleport_time)
412 #ifdef WARPZONELIB_KEEPDEBUG
413 // this SEEMS to not happen at the moment, but if it did, it would be more reliable
415 float save_dpstartcontents;
416 float save_dphitcontents;
417 float save_dphitq3surfaceflags;
418 string save_dphittexturename;
420 float save_startsolid;
423 vector save_plane_normal;
424 float save_plane_dist;
428 save_dpstartcontents = trace_dpstartcontents;
429 save_dphitcontents = trace_dphitcontents;
430 save_dphitq3surfaceflags = trace_dphitq3surfaceflags;
431 save_dphittexturename = trace_dphittexturename;
432 save_allsolid = trace_allsolid;
433 save_startsolid = trace_startsolid;
434 save_fraction = trace_fraction;
435 save_endpos = trace_endpos;
436 save_plane_normal = trace_plane_normal;
437 save_plane_dist = trace_plane_dist;
438 save_ent = trace_ent;
439 save_inopen = trace_inopen;
440 save_inwater = trace_inwater;
441 float f = WarpZone_CheckProjectileImpact(this);
442 if (f) return (f > 0);
443 trace_dpstartcontents = save_dpstartcontents;
444 trace_dphitcontents = save_dphitcontents;
445 trace_dphitq3surfaceflags = save_dphitq3surfaceflags;
446 trace_dphittexturename = save_dphittexturename;
447 trace_allsolid = save_allsolid;
448 trace_startsolid = save_startsolid;
449 trace_fraction = save_fraction;
450 trace_endpos = save_endpos;
451 trace_plane_normal = save_plane_normal;
452 trace_plane_dist = save_plane_dist;
453 trace_ent = save_ent;
454 trace_inopen = save_inopen;
455 trace_inwater = save_inwater;
459 if(WarpZone_Projectile_Touch_ImpactFilter_Callback(this, toucher))
468 void WarpZone_InitStep_FindOriginTarget(entity this)
470 if(this.killtarget != "")
472 this.aiment = find(NULL, targetname, this.killtarget);
473 if(this.aiment == NULL)
475 error("Warp zone with nonexisting killtarget");
478 this.killtarget = string_null;
482 void WarpZonePosition_InitStep_FindTarget(entity this)
484 if(this.target == "")
486 error("Warp zone position with no target");
489 this.enemy = find(NULL, targetname, this.target);
490 if(this.enemy == NULL)
492 error("Warp zone position with nonexisting target");
495 if(this.enemy.aiment)
497 // already is positioned
498 error("Warp zone position targeting already oriented warpzone");
501 this.enemy.aiment = this;
504 void WarpZoneCamera_Think(entity this)
506 if(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 WarpZone_Camera_SetUp(this, this.enemy.origin, this.enemy.angles);
512 this.warpzone_save_origin = this.origin;
513 this.warpzone_save_angles = this.angles;
514 this.warpzone_save_eorigin = this.enemy.origin;
515 this.warpzone_save_eangles = this.enemy.angles;
517 this.nextthink = time;
520 void WarpZoneCamera_InitStep_FindTarget(entity this)
524 if(this.target == "")
526 error("Camera with no target");
530 for(e = NULL, i = 0; (e = find(e, targetname, this.target)); )
531 if(random() * ++i < 1)
533 if(this.enemy == NULL)
535 error("Camera with nonexisting target");
538 warpzone_cameras_exist = 1;
539 WarpZone_Camera_SetUp(this, this.enemy.origin, this.enemy.angles);
540 this.SendFlags = 0xFFFFFF;
541 if(this.spawnflags & 1)
543 setthink(this, WarpZoneCamera_Think);
544 this.nextthink = time;
550 void WarpZone_InitStep_UpdateTransform(entity this)
552 vector org, ang, norm, point;
554 vector tri, a, b, c, n;
560 org = 0.5 * (this.mins + this.maxs);
562 norm = point = '0 0 0';
564 for(i_s = 0; ; ++i_s)
566 tex = getsurfacetexture(this, i_s);
568 break; // this is beyond the last one
569 if(tex == "textures/common/trigger" || tex == "trigger")
571 n_t = getsurfacenumtriangles(this, i_s);
572 for(i_t = 0; i_t < n_t; ++i_t)
574 tri = getsurfacetriangle(this, i_s, i_t);
575 a = getsurfacepoint(this, i_s, tri.x);
576 b = getsurfacepoint(this, i_s, tri.y);
577 c = getsurfacepoint(this, i_s, tri.z);
578 n = cross(c - a, b - a);
579 area = area + vlen(n);
581 point = point + vlen(n) * (a + b + c);
586 norm = norm * (1 / area);
587 point = point * (1 / (3 * area));
588 if(vdist(norm, <, 0.99))
590 LOG_INFO("trigger_warpzone near ", vtos(this.aiment.origin), " is nonplanar. BEWARE.");
591 area = 0; // no autofixing in this case
593 norm = normalize(norm);
599 org = this.aiment.origin;
600 ang = this.aiment.angles;
603 org = org - ((org - point) * norm) * norm; // project to plane
605 if(norm * v_forward < 0)
607 LOG_INFO("Position target of trigger_warpzone near ", vtos(this.aiment.origin), " points into trigger_warpzone. BEWARE.");
610 ang = vectoangles2(norm, v_up); // keep rotation, but turn exactly against plane
612 if(norm * v_forward < 0.99)
613 LOG_INFO("trigger_warpzone near ", vtos(this.aiment.origin), " has been turned to match plane orientation (", vtos(this.aiment.angles), " -> ", vtos(ang));
614 if(vdist(org - this.aiment.origin, >, 0.5))
615 LOG_INFO("trigger_warpzone near ", vtos(this.aiment.origin), " has been moved to match the plane (", vtos(this.aiment.origin), " -> ", vtos(org), ").");
621 ang = vectoangles(norm);
625 error("cannot infer origin/angles for this warpzone, please use a killtarget or a trigger_warpzone_position");
627 this.warpzone_origin = org;
628 this.warpzone_angles = ang;
631 void WarpZone_InitStep_ClearTarget(entity this)
634 this.enemy.enemy = NULL;
638 void WarpZone_InitStep_FindTarget(entity this)
646 // this way only one of the two ents needs to target
647 if(this.target != "")
649 this.enemy = this; // so the if(!e.enemy) check also skips this, saves one IF
652 for(e = NULL, i = 0; (e = find(e, targetname, this.target)); )
654 if(e.classname == this.classname) // possibly non-warpzones may use the same targetname!
655 if(random() * ++i < 1)
660 error("Warpzone with non-existing target");
668 void WarpZone_Think(entity this);
669 void WarpZone_InitStep_FinalizeTransform(entity this)
671 if(!this.enemy || this.enemy.enemy != this)
673 error("Invalid warp zone detected. Killed.");
677 warpzone_warpzones_exist = 1;
678 WarpZone_SetUp(this, this.warpzone_origin, this.warpzone_angles, this.enemy.warpzone_origin, this.enemy.warpzone_angles);
679 settouch(this, WarpZone_Touch);
680 this.SendFlags = 0xFFFFFF;
681 if(this.spawnflags & 1)
683 setthink(this, WarpZone_Think);
684 this.nextthink = time;
690 float warpzone_initialized;
691 //entity warpzone_first;
692 entity warpzone_position_first;
693 entity warpzone_camera_first;
694 .entity warpzone_next;
695 spawnfunc(misc_warpzone_position)
697 // "target", "angles", "origin"
698 this.warpzone_next = warpzone_position_first;
699 warpzone_position_first = this;
701 spawnfunc(trigger_warpzone_position)
703 spawnfunc_misc_warpzone_position(this);
705 spawnfunc(trigger_warpzone)
707 // warp zone entities must have:
708 // "killtarget" pointing to a target_position with a direction arrow
709 // that points AWAY from the warp zone, and that is inside
710 // the warp zone trigger
711 // "target" pointing to an identical warp zone at another place in
712 // the map, with another killtarget to designate its
716 this.scale = this.modelscale;
721 WarpZoneLib_ExactTrigger_Init(this);
725 _setmodel(this, m); // no precision needed
727 setorigin(this, this.origin);
729 setsize(this, this.mins * this.scale, this.maxs * this.scale);
731 setsize(this, this.mins, this.maxs);
732 setSendEntity(this, WarpZone_Send);
733 this.SendFlags = 0xFFFFFF;
734 BITSET_ASSIGN(this.effects, EF_NODEPTHTEST);
735 this.warpzone_next = warpzone_first;
736 warpzone_first = this;
738 IL_PUSH(g_warpzones, this);
740 spawnfunc(func_camera)
743 this.scale = this.modelscale;
748 precache_model(this.model);
749 _setmodel(this, this.model); // no precision needed
751 setorigin(this, this.origin);
753 setsize(this, this.mins * this.scale, this.maxs * this.scale);
755 setsize(this, this.mins, this.maxs);
757 this.solid = SOLID_BSP;
758 else if(this.solid < 0)
759 this.solid = SOLID_NOT;
760 setSendEntity(this, WarpZone_Camera_Send);
761 this.SendFlags = 0xFFFFFF;
762 this.warpzone_next = warpzone_camera_first;
763 warpzone_camera_first = this;
765 void WarpZones_Reconnect()
767 for(entity e = warpzone_first; e; e = e.warpzone_next)
768 WarpZone_InitStep_ClearTarget(e);
769 for(entity e = warpzone_first; e; e = e.warpzone_next)
770 WarpZone_InitStep_FindTarget(e);
771 for(entity e = warpzone_camera_first; e; e = e.warpzone_next)
772 WarpZoneCamera_InitStep_FindTarget(e);
773 for(entity e = warpzone_first; e; e = e.warpzone_next)
774 WarpZone_InitStep_FinalizeTransform(e);
777 void WarpZone_Think(entity this)
779 if(this.warpzone_save_origin != this.origin
780 || this.warpzone_save_angles != this.angles
781 || this.warpzone_save_eorigin != this.enemy.origin
782 || this.warpzone_save_eangles != this.enemy.angles)
784 WarpZone_InitStep_UpdateTransform(this);
785 WarpZone_InitStep_UpdateTransform(this.enemy);
786 WarpZone_InitStep_FinalizeTransform(this);
787 WarpZone_InitStep_FinalizeTransform(this.enemy);
788 this.warpzone_save_origin = this.origin;
789 this.warpzone_save_angles = this.angles;
790 this.warpzone_save_eorigin = this.enemy.origin;
791 this.warpzone_save_eangles = this.enemy.angles;
793 this.nextthink = time;
796 void WarpZone_StartFrame()
798 if (!warpzone_initialized)
800 warpzone_initialized = true;
801 for(entity e = warpzone_first; e; e = e.warpzone_next)
802 WarpZone_InitStep_FindOriginTarget(e);
803 for(entity e = warpzone_position_first; e; e = e.warpzone_next)
804 WarpZonePosition_InitStep_FindTarget(e);
805 for(entity e = warpzone_first; e; e = e.warpzone_next)
806 WarpZone_InitStep_UpdateTransform(e);
807 WarpZones_Reconnect();
808 WarpZone_PostInitialize_Callback();
811 if(warpzone_warpzones_exist)
813 IL_EACH(g_projectiles, true,
815 WarpZone_StoreProjectileData(it);
822 if(warpzone_warpzones_exist)
823 WarpZone_StoreProjectileData(it); // TODO: not actually needed
825 if(IS_OBSERVER(it) || it.solid == SOLID_NOT)
826 if(IS_CLIENT(it)) // we don't care about it being a bot
829 if (warpzone_warpzones_exist) {
830 entity e = WarpZone_Find(it.origin + it.mins, it.origin + it.maxs);
832 if (!WarpZoneLib_ExactTrigger_Touch(e, it))
833 if (WarpZone_PlaneDist(e, it.origin + it.view_ofs) <= 0)
834 WarpZone_Teleport(e, it, -1, 0); // NOT triggering targets by this!
840 entity ent = Teleport_Find(it.origin + it.mins, it.origin + it.maxs);
842 if (!WarpZoneLib_ExactTrigger_Touch(ent, it))
843 Simple_TeleportPlayer(ent, it); // NOT triggering targets by this!
849 .float warpzone_reconnecting;
850 bool visible_to_some_client(entity ent)
852 FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it) && checkpvs(it.origin + it.view_ofs, ent),
858 void trigger_warpzone_reconnect_use(entity this, entity actor, entity trigger)
860 // NOTE: this matches for target, not targetname, but of course
861 // targetname must be set too on the other entities
862 for(entity e = warpzone_first; e; e = e.warpzone_next)
863 e.warpzone_reconnecting = ((this.target == "" || e.target == this.target) && !((this.spawnflags & 1) && (visible_to_some_client(e) || visible_to_some_client(e.enemy))));
864 for(entity e = warpzone_camera_first; e; e = e.warpzone_next)
865 e.warpzone_reconnecting = ((this.target == "" || e.target == this.target) && !((this.spawnflags & 1) && visible_to_some_client(e)));
866 for(entity e = warpzone_first; e; e = e.warpzone_next)
867 if(e.warpzone_reconnecting)
868 WarpZone_InitStep_ClearTarget(e);
869 for(entity e = warpzone_first; e; e = e.warpzone_next)
870 if(e.warpzone_reconnecting)
871 WarpZone_InitStep_FindTarget(e);
872 for(entity e = warpzone_camera_first; e; e = e.warpzone_next)
873 if(e.warpzone_reconnecting)
874 WarpZoneCamera_InitStep_FindTarget(e);
875 for(entity e = warpzone_first; e; e = e.warpzone_next)
876 if(e.warpzone_reconnecting || e.enemy.warpzone_reconnecting)
877 WarpZone_InitStep_FinalizeTransform(e);
880 spawnfunc(trigger_warpzone_reconnect)
882 this.use = trigger_warpzone_reconnect_use;
885 spawnfunc(target_warpzone_reconnect)
887 spawnfunc_trigger_warpzone_reconnect(this); // both names make sense here :(
890 void WarpZone_PlayerPhysics_FixVAngle(entity this)
892 #ifndef WARPZONE_DONT_FIX_VANGLE
893 if(IS_REAL_CLIENT(this))
894 if(this.v_angle.z <= 360) // if not already adjusted
895 if(time - CS(this).ping * 0.001 < this.warpzone_teleport_time)
897 this.v_angle = WarpZone_TransformVAngles(this.warpzone_teleport_zone, this.v_angle);
898 this.v_angle_z += 720; // mark as adjusted