7 #include <common/constants.qh>
8 #include <common/net_linked.qh>
9 #include <common/mapobjects/subs.qh>
10 #include <common/util.qh>
11 #include <server/constants.qh>
12 #include <server/defs.qh>
13 #include <server/utils.qh>
16 #ifdef WARPZONELIB_KEEPDEBUG
17 #define WARPZONELIB_REMOVEHACK
21 .vector warpzone_save_origin;
22 .vector warpzone_save_angles;
23 .vector warpzone_save_eorigin;
24 .vector warpzone_save_eangles;
27 .vector warpzone_oldorigin, warpzone_oldvelocity, warpzone_oldangles;
28 .float warpzone_teleport_time;
29 .float warpzone_teleport_finishtime;
30 .entity warpzone_teleport_zone;
32 #define WarpZone_StoreProjectileData(e_) MACRO_BEGIN { \
34 e.warpzone_oldorigin = e.origin; \
35 e.warpzone_oldvelocity = e.velocity; \
36 e.warpzone_oldangles = e.angles; \
39 void WarpZone_TeleportPlayer(entity teleporter, entity player, vector to, vector to_angles, vector to_velocity)
42 player.lastteleport_origin = player.origin;
43 player.lastteleporttime = time;
45 setorigin(player, to); // NOTE: this also aborts the move, when this is called by touch
46 player.angles = to_angles;
48 player.oldorigin = to; // for DP's unsticking
49 player.fixangle = true;
50 if (IS_BOT_CLIENT(player))
52 // FIXME find a way to smooth view's angles change for bots too
53 player.v_angle = player.angles;
54 bot_aim_reset(player);
57 player.velocity = to_velocity;
59 BITXOR_ASSIGN(player.effects, EF_TELEPORT_BIT);
62 BITCLR_ASSIGN(player.flags, FL_ONGROUND);
64 WarpZone_PostTeleportPlayer_Callback(player);
68 bool WarpZone_Teleported_Send(entity this, entity to, int sf)
70 WriteHeader(MSG_ENTITY, ENT_CLIENT_WARPZONE_TELEPORTED);
71 WriteVector(MSG_ENTITY, this.angles);
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 (!IS_NOT_A_CLIENT(player))
87 a1 = WarpZone_TransformVAngles(wz, PHYS_INPUT_ANGLES(player));
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);
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 out of solid
115 tracebox(o1 - player.view_ofs, player.mins, player.maxs, o1 - player.view_ofs, MOVE_NOMONSTERS, player);
118 setorigin(player, o1 - player.view_ofs);
119 if(WarpZoneLib_MoveOutOfSolid(player))
121 o1 = player.origin + player.view_ofs;
122 setorigin(player, o0 - player.view_ofs);
126 LOG_INFO("would have to put player in solid, won't do that");
127 setorigin(player, o0 - player.view_ofs);
133 WarpZone_RefSys_Add(player, wz);
134 WarpZone_TeleportPlayer(wz, player, o1 - player.view_ofs, a1, v1);
135 WarpZone_StoreProjectileData(player);
136 player.warpzone_teleport_time = time;
137 player.warpzone_teleport_finishtime = time;
138 player.warpzone_teleport_zone = wz;
141 // prevent further teleports back
142 float dt = (o1 - o10) * v1 * (1 / (v1 * v1));
143 if(dt < PHYS_INPUT_FRAMETIME)
144 player.warpzone_teleport_finishtime += PHYS_INPUT_FRAMETIME - dt;
147 #ifndef WARPZONE_USE_FIXANGLE
149 if(IS_VEHICLE(player) && player.owner)
150 player = player.owner; // hax
151 if(IS_PLAYER(player))
153 // instead of fixangle, send the transform to the client for smoother operation
154 player.fixangle = false;
156 entity ts = new(warpzone_teleported);
157 setmodel(ts, MDL_Null);
158 setSendEntity(ts, WarpZone_Teleported_Send);
159 ts.SendFlags = 0xFFFFFF;
160 ts.drawonlytoclient = player;
161 setthink(ts, SUB_Remove);
162 ts.nextthink = time + 1;
165 ts.effects = EF_NODEPTHTEST;
166 ts.angles = wz.warpzone_transform;
169 setproperty(VF_CL_VIEWANGLES, WarpZone_TransformVAngles(wz, getpropertyvec(VF_CL_VIEWANGLES)));
170 //if(checkextension("DP_CSQC_ROTATEMOVES"))
171 //CL_RotateMoves(wz.warpzone_transform);
178 void WarpZone_Touch(entity this, entity toucher)
180 if(toucher.classname == "trigger_warpzone")
183 if(time <= toucher.warpzone_teleport_finishtime) // already teleported this frame
186 // FIXME needs a better check to know what is safe to teleport and what not
187 if(toucher.move_movetype == MOVETYPE_NONE || toucher.move_movetype == MOVETYPE_FOLLOW || toucher.tag_entity)
190 if(WarpZoneLib_ExactTrigger_Touch(this, toucher))
193 if(WarpZone_PlaneDist(this, toucher.origin + toucher.view_ofs) >= 0) // wrong side of the trigger_warpzone (don't teleport yet)
197 // number of frames we need to go back:
198 // dist = 16*sqrt(2) qu
201 // 24 qu = v*frametime*n
202 // n = 24 qu/(v*frametime)
203 // for clients go only one frame though, may be too irritating otherwise
204 // but max 0.25 sec = 0.25/frametime frames
205 // 24/(0.25/frametime)
208 d = 24 + max(vlen(toucher.mins), vlen(toucher.maxs));
209 if(IS_NOT_A_CLIENT(toucher))
210 f = -d / bound(frametime * d * 1, frametime * vlen(toucher.velocity), d);
213 if(WarpZone_Teleport(this, toucher, f, 0))
218 save1 = this.target; this.target = string_null;
219 save2 = this.target3; this.target3 = string_null;
220 SUB_UseTargets(this, toucher, toucher); // use toucher too?
221 if (!this.target) this.target = save1;
222 if (!this.target3) this.target3 = save2;
224 save1 = this.target; this.target = string_null;
225 save2 = this.target2; this.target2 = string_null;
226 SUB_UseTargets(this.enemy, toucher, toucher); // use toucher too?
227 if (!this.target) this.target = save1;
228 if (!this.target2) this.target2 = save2;
233 LOG_TRACE("WARPZONE FAIL AHAHAHAHAH))");
238 bool WarpZone_Send(entity this, entity to, int sendflags)
240 WriteHeader(MSG_ENTITY, ENT_CLIENT_WARPZONE);
242 // we must send this flag for clientside to match properly too
244 if(this.warpzone_isboxy)
246 if(this.warpzone_fadestart)
248 if(this.origin != '0 0 0')
250 WriteByte(MSG_ENTITY, f);
252 // we need THESE to render the warpzone (and cull properly)...
255 WriteCoord(MSG_ENTITY, this.origin.x);
256 WriteCoord(MSG_ENTITY, this.origin.y);
257 WriteCoord(MSG_ENTITY, this.origin.z);
260 WriteShort(MSG_ENTITY, this.modelindex);
261 WriteCoord(MSG_ENTITY, this.mins.x);
262 WriteCoord(MSG_ENTITY, this.mins.y);
263 WriteCoord(MSG_ENTITY, this.mins.z);
264 WriteCoord(MSG_ENTITY, this.maxs.x);
265 WriteCoord(MSG_ENTITY, this.maxs.y);
266 WriteCoord(MSG_ENTITY, this.maxs.z);
267 WriteByte(MSG_ENTITY, bound(1, this.scale * 16, 255));
269 // we need THESE to calculate the proper transform
270 WriteCoord(MSG_ENTITY, this.warpzone_origin.x);
271 WriteCoord(MSG_ENTITY, this.warpzone_origin.y);
272 WriteCoord(MSG_ENTITY, this.warpzone_origin.z);
273 WriteCoord(MSG_ENTITY, this.warpzone_angles.x);
274 WriteCoord(MSG_ENTITY, this.warpzone_angles.y);
275 WriteCoord(MSG_ENTITY, this.warpzone_angles.z);
276 WriteCoord(MSG_ENTITY, this.warpzone_targetorigin.x);
277 WriteCoord(MSG_ENTITY, this.warpzone_targetorigin.y);
278 WriteCoord(MSG_ENTITY, this.warpzone_targetorigin.z);
279 WriteCoord(MSG_ENTITY, this.warpzone_targetangles.x);
280 WriteCoord(MSG_ENTITY, this.warpzone_targetangles.y);
281 WriteCoord(MSG_ENTITY, this.warpzone_targetangles.z);
285 WriteShort(MSG_ENTITY, this.warpzone_fadestart);
286 WriteShort(MSG_ENTITY, this.warpzone_fadeend);
292 bool WarpZone_Camera_Send(entity this, entity to, int sendflags)
295 WriteHeader(MSG_ENTITY, ENT_CLIENT_WARPZONE_CAMERA);
297 if(this.warpzone_fadestart)
299 if(this.origin != '0 0 0')
301 WriteByte(MSG_ENTITY, f);
303 // we need THESE to render the warpzone (and cull properly)...
306 WriteCoord(MSG_ENTITY, this.origin.x);
307 WriteCoord(MSG_ENTITY, this.origin.y);
308 WriteCoord(MSG_ENTITY, this.origin.z);
311 WriteShort(MSG_ENTITY, this.modelindex);
312 WriteCoord(MSG_ENTITY, this.mins.x);
313 WriteCoord(MSG_ENTITY, this.mins.y);
314 WriteCoord(MSG_ENTITY, this.mins.z);
315 WriteCoord(MSG_ENTITY, this.maxs.x);
316 WriteCoord(MSG_ENTITY, this.maxs.y);
317 WriteCoord(MSG_ENTITY, this.maxs.z);
318 WriteByte(MSG_ENTITY, bound(1, this.scale * 16, 255));
320 // we need THESE to calculate the proper transform
321 WriteCoord(MSG_ENTITY, this.enemy.origin.x);
322 WriteCoord(MSG_ENTITY, this.enemy.origin.y);
323 WriteCoord(MSG_ENTITY, this.enemy.origin.z);
324 WriteCoord(MSG_ENTITY, this.enemy.angles.x);
325 WriteCoord(MSG_ENTITY, this.enemy.angles.y);
326 WriteCoord(MSG_ENTITY, this.enemy.angles.z);
330 WriteShort(MSG_ENTITY, this.warpzone_fadestart);
331 WriteShort(MSG_ENTITY, this.warpzone_fadeend);
337 #ifdef WARPZONELIB_KEEPDEBUG
338 float WarpZone_CheckProjectileImpact(entity player)
342 o0 = player.origin + player.view_ofs;
343 v0 = player.velocity;
345 // if we teleported shortly before, abort
346 if(time <= player.warpzone_teleport_finishtime + 0.1)
349 // if player hit a warpzone, abort
351 wz = WarpZone_Find(o0 + player.mins, o0 + player.maxs);
355 #ifdef WARPZONELIB_REMOVEHACK
356 LOG_INFO("impactfilter found something - and it no longer gets handled correctly - please tell divVerent whether anything behaves broken now");
358 LOG_INFO("impactfilter found something - and it even gets handled correctly - please tell divVerent that this code apparently gets triggered again");
360 LOG_INFO("Entity type: ", player.classname);
361 LOG_INFO("Origin: ", vtos(player.origin));
362 LOG_INFO("Velocity: ", vtos(player.velocity));
364 #ifdef WARPZONELIB_REMOVEHACK
367 // retry previous move
368 setorigin(player, player.warpzone_oldorigin);
369 player.velocity = player.warpzone_oldvelocity;
370 if(WarpZone_Teleport(wz, player, 0, 1))
374 save1 = wz.target; wz.target = string_null;
375 save2 = wz.target3; wz.target3 = string_null;
376 SUB_UseTargets(wz, player, player);
377 if (!wz.target) wz.target = save1;
378 if (!wz.target3) wz.target3 = save2;
380 save1 = wz.enemy.target; wz.enemy.target = string_null;
381 save2 = wz.enemy.target2; wz.enemy.target2 = string_null;
382 SUB_UseTargets(wz.enemy, player, player);
383 if (!wz.enemy.target) wz.enemy.target = save1;
384 if (!wz.enemy.target2) wz.enemy.target2 = save2;
388 setorigin(player, o0 - player.view_ofs);
389 player.velocity = v0;
398 float WarpZone_Projectile_Touch(entity this, entity toucher)
400 if(toucher.classname == "trigger_warpzone")
403 // no further impacts if we teleported this frame!
404 // this is because even if we did teleport, the engine still may raise
405 // touch events for the previous location
406 // engine now aborts moves on teleport, so this SHOULD not happen any more
407 // but if this is called from TouchAreaGrid of the projectile moving,
408 // then this won't do
409 if(time == this.warpzone_teleport_time)
413 #ifdef WARPZONELIB_KEEPDEBUG
414 // this SEEMS to not happen at the moment, but if it did, it would be more reliable
416 float save_dpstartcontents;
417 float save_dphitcontents;
418 float save_dphitq3surfaceflags;
419 string save_dphittexturename;
421 float save_startsolid;
424 vector save_plane_normal;
425 float save_plane_dist;
429 save_dpstartcontents = trace_dpstartcontents;
430 save_dphitcontents = trace_dphitcontents;
431 save_dphitq3surfaceflags = trace_dphitq3surfaceflags;
432 save_dphittexturename = trace_dphittexturename;
433 save_allsolid = trace_allsolid;
434 save_startsolid = trace_startsolid;
435 save_fraction = trace_fraction;
436 save_endpos = trace_endpos;
437 save_plane_normal = trace_plane_normal;
438 save_plane_dist = trace_plane_dist;
439 save_ent = trace_ent;
440 save_inopen = trace_inopen;
441 save_inwater = trace_inwater;
442 float f = WarpZone_CheckProjectileImpact(this);
443 if (f) return (f > 0);
444 trace_dpstartcontents = save_dpstartcontents;
445 trace_dphitcontents = save_dphitcontents;
446 trace_dphitq3surfaceflags = save_dphitq3surfaceflags;
447 trace_dphittexturename = save_dphittexturename;
448 trace_allsolid = save_allsolid;
449 trace_startsolid = save_startsolid;
450 trace_fraction = save_fraction;
451 trace_endpos = save_endpos;
452 trace_plane_normal = save_plane_normal;
453 trace_plane_dist = save_plane_dist;
454 trace_ent = save_ent;
455 trace_inopen = save_inopen;
456 trace_inwater = save_inwater;
460 if(WarpZone_Projectile_Touch_ImpactFilter_Callback(this, toucher))
469 void WarpZone_InitStep_FindOriginTarget(entity this)
471 if(this.killtarget != "")
473 this.aiment = find(NULL, targetname, this.killtarget);
474 if(this.aiment == NULL)
476 error("Warp zone with nonexisting killtarget");
479 this.killtarget = string_null;
483 void WarpZonePosition_InitStep_FindTarget(entity this)
485 if(this.target == "")
487 error("Warp zone position with no target");
490 this.enemy = find(NULL, targetname, this.target);
491 if(this.enemy == NULL)
493 error("Warp zone position with nonexisting target");
496 if(this.enemy.aiment)
498 // already is positioned
499 error("Warp zone position targeting already oriented warpzone");
502 this.enemy.aiment = this;
505 void WarpZoneCamera_Think(entity this)
507 if(this.warpzone_save_origin != this.origin
508 || this.warpzone_save_angles != this.angles
509 || this.warpzone_save_eorigin != this.enemy.origin
510 || this.warpzone_save_eangles != this.enemy.angles)
512 WarpZone_Camera_SetUp(this, this.enemy.origin, this.enemy.angles);
513 this.warpzone_save_origin = this.origin;
514 this.warpzone_save_angles = this.angles;
515 this.warpzone_save_eorigin = this.enemy.origin;
516 this.warpzone_save_eangles = this.enemy.angles;
518 this.nextthink = time;
521 void WarpZoneCamera_InitStep_FindTarget(entity this)
525 if(this.target == "")
527 error("Camera with no target");
531 for(e = NULL, i = 0; (e = find(e, targetname, this.target)); )
532 if(random() * ++i < 1)
534 if(this.enemy == NULL)
536 error("Camera with nonexisting target");
539 warpzone_cameras_exist = 1;
540 WarpZone_Camera_SetUp(this, this.enemy.origin, this.enemy.angles);
541 this.SendFlags = 0xFFFFFF;
542 if(this.spawnflags & 1)
544 setthink(this, WarpZoneCamera_Think);
545 this.nextthink = time;
551 void WarpZone_InitStep_UpdateTransform(entity this)
553 vector org, ang, norm, point;
555 vector tri, a, b, c, n;
561 org = 0.5 * (this.mins + this.maxs);
563 norm = point = '0 0 0';
565 for(i_s = 0; ; ++i_s)
567 tex = getsurfacetexture(this, i_s);
569 break; // this is beyond the last one
570 if(tex == "textures/common/trigger" || tex == "trigger")
572 n_t = getsurfacenumtriangles(this, i_s);
573 for(i_t = 0; i_t < n_t; ++i_t)
575 tri = getsurfacetriangle(this, i_s, i_t);
576 a = getsurfacepoint(this, i_s, tri.x);
577 b = getsurfacepoint(this, i_s, tri.y);
578 c = getsurfacepoint(this, i_s, tri.z);
579 n = cross(c - a, b - a);
580 area = area + vlen(n);
582 point = point + vlen(n) * (a + b + c);
587 norm = norm * (1 / area);
588 point = point * (1 / (3 * area));
589 if(vdist(norm, <, 0.99))
591 LOG_INFO("trigger_warpzone near ", vtos(this.aiment.origin), " is nonplanar. BEWARE.");
592 area = 0; // no autofixing in this case
594 norm = normalize(norm);
600 org = this.aiment.origin;
601 ang = this.aiment.angles;
604 org = org - ((org - point) * norm) * norm; // project to plane
606 if(norm * v_forward < 0)
608 LOG_INFO("Position target of trigger_warpzone near ", vtos(this.aiment.origin), " points into trigger_warpzone. BEWARE.");
611 ang = vectoangles2(norm, v_up); // keep rotation, but turn exactly against plane
613 if(norm * v_forward < 0.99)
614 LOG_INFO("trigger_warpzone near ", vtos(this.aiment.origin), " has been turned to match plane orientation (", vtos(this.aiment.angles), " -> ", vtos(ang));
615 if(vdist(org - this.aiment.origin, >, 0.5))
616 LOG_INFO("trigger_warpzone near ", vtos(this.aiment.origin), " has been moved to match the plane (", vtos(this.aiment.origin), " -> ", vtos(org), ").");
622 ang = vectoangles(norm);
626 error("cannot infer origin/angles for this warpzone, please use a killtarget or a trigger_warpzone_position");
628 this.warpzone_origin = org;
629 this.warpzone_angles = ang;
632 void WarpZone_InitStep_ClearTarget(entity this)
635 this.enemy.enemy = NULL;
639 void WarpZone_InitStep_FindTarget(entity this)
647 // this way only one of the two ents needs to target
648 if(this.target != "")
650 this.enemy = this; // so the if(!e.enemy) check also skips this, saves one IF
653 for(e = NULL, i = 0; (e = find(e, targetname, this.target)); )
655 if(e.classname == this.classname) // possibly non-warpzones may use the same targetname!
656 if(random() * ++i < 1)
661 error("Warpzone with non-existing target");
669 void WarpZone_Think(entity this);
670 void WarpZone_InitStep_FinalizeTransform(entity this)
672 if(!this.enemy || this.enemy.enemy != this)
674 error("Invalid warp zone detected. Killed.");
678 warpzone_warpzones_exist = 1;
679 WarpZone_SetUp(this, this.warpzone_origin, this.warpzone_angles, this.enemy.warpzone_origin, this.enemy.warpzone_angles);
680 settouch(this, WarpZone_Touch);
681 this.SendFlags = 0xFFFFFF;
682 if(this.spawnflags & 1)
684 setthink(this, WarpZone_Think);
685 this.nextthink = time;
691 float warpzone_initialized;
692 //entity warpzone_first;
693 entity warpzone_position_first;
694 entity warpzone_camera_first;
695 .entity warpzone_next;
696 spawnfunc(misc_warpzone_position)
698 // "target", "angles", "origin"
699 this.warpzone_next = warpzone_position_first;
700 warpzone_position_first = this;
702 spawnfunc(trigger_warpzone_position)
704 spawnfunc_misc_warpzone_position(this);
706 spawnfunc(trigger_warpzone)
708 // warp zone entities must have:
709 // "killtarget" pointing to a target_position with a direction arrow
710 // that points AWAY from the warp zone, and that is inside
711 // the warp zone trigger
712 // "target" pointing to an identical warp zone at another place in
713 // the map, with another killtarget to designate its
717 this.scale = this.modelscale;
722 WarpZoneLib_ExactTrigger_Init(this);
726 _setmodel(this, m); // no precision needed
728 setorigin(this, this.origin);
730 setsize(this, this.mins * this.scale, this.maxs * this.scale);
732 setsize(this, this.mins, this.maxs);
733 setSendEntity(this, WarpZone_Send);
734 this.SendFlags = 0xFFFFFF;
735 BITSET_ASSIGN(this.effects, EF_NODEPTHTEST);
736 this.warpzone_next = warpzone_first;
737 warpzone_first = this;
739 IL_PUSH(g_warpzones, this);
741 spawnfunc(func_camera)
744 this.scale = this.modelscale;
749 precache_model(this.model);
750 _setmodel(this, this.model); // no precision needed
752 setorigin(this, this.origin);
754 setsize(this, this.mins * this.scale, this.maxs * this.scale);
756 setsize(this, this.mins, this.maxs);
758 this.solid = SOLID_BSP;
759 else if(this.solid < 0)
760 this.solid = SOLID_NOT;
761 setSendEntity(this, WarpZone_Camera_Send);
762 this.SendFlags = 0xFFFFFF;
763 this.warpzone_next = warpzone_camera_first;
764 warpzone_camera_first = this;
766 void WarpZones_Reconnect()
768 for(entity e = warpzone_first; e; e = e.warpzone_next)
769 WarpZone_InitStep_ClearTarget(e);
770 for(entity e = warpzone_first; e; e = e.warpzone_next)
771 WarpZone_InitStep_FindTarget(e);
772 for(entity e = warpzone_camera_first; e; e = e.warpzone_next)
773 WarpZoneCamera_InitStep_FindTarget(e);
774 for(entity e = warpzone_first; e; e = e.warpzone_next)
775 WarpZone_InitStep_FinalizeTransform(e);
778 void WarpZone_Think(entity this)
780 if(this.warpzone_save_origin != this.origin
781 || this.warpzone_save_angles != this.angles
782 || this.warpzone_save_eorigin != this.enemy.origin
783 || this.warpzone_save_eangles != this.enemy.angles)
785 WarpZone_InitStep_UpdateTransform(this);
786 WarpZone_InitStep_UpdateTransform(this.enemy);
787 WarpZone_InitStep_FinalizeTransform(this);
788 WarpZone_InitStep_FinalizeTransform(this.enemy);
789 this.warpzone_save_origin = this.origin;
790 this.warpzone_save_angles = this.angles;
791 this.warpzone_save_eorigin = this.enemy.origin;
792 this.warpzone_save_eangles = this.enemy.angles;
794 this.nextthink = time;
797 void WarpZone_StartFrame()
799 if (!warpzone_initialized)
801 warpzone_initialized = true;
802 for(entity e = warpzone_first; e; e = e.warpzone_next)
803 WarpZone_InitStep_FindOriginTarget(e);
804 for(entity e = warpzone_position_first; e; e = e.warpzone_next)
805 WarpZonePosition_InitStep_FindTarget(e);
806 for(entity e = warpzone_first; e; e = e.warpzone_next)
807 WarpZone_InitStep_UpdateTransform(e);
808 WarpZones_Reconnect();
809 WarpZone_PostInitialize_Callback();
812 if(warpzone_warpzones_exist)
814 IL_EACH(g_projectiles, true,
816 WarpZone_StoreProjectileData(it);
823 if(warpzone_warpzones_exist)
824 WarpZone_StoreProjectileData(it); // TODO: not actually needed
826 if(IS_OBSERVER(it) || it.solid == SOLID_NOT)
827 if(IS_CLIENT(it)) // we don't care about it being a bot
830 if (warpzone_warpzones_exist) {
831 entity e = WarpZone_Find(it.origin + it.mins, it.origin + it.maxs);
833 if (!WarpZoneLib_ExactTrigger_Touch(e, it))
834 if (WarpZone_PlaneDist(e, it.origin + it.view_ofs) <= 0)
835 WarpZone_Teleport(e, it, -1, 0); // NOT triggering targets by this!
841 entity ent = Teleport_Find(it.origin + it.mins, it.origin + it.maxs);
843 if (!WarpZoneLib_ExactTrigger_Touch(ent, it))
844 Simple_TeleportPlayer(ent, it); // NOT triggering targets by this!
850 .float warpzone_reconnecting;
851 bool visible_to_some_client(entity ent)
853 FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it) && checkpvs(it.origin + it.view_ofs, ent),
859 void trigger_warpzone_reconnect_use(entity this, entity actor, entity trigger)
861 // NOTE: this matches for target, not targetname, but of course
862 // targetname must be set too on the other entities
863 for(entity e = warpzone_first; e; e = e.warpzone_next)
864 e.warpzone_reconnecting = ((this.target == "" || e.target == this.target) && !((this.spawnflags & 1) && (visible_to_some_client(e) || visible_to_some_client(e.enemy))));
865 for(entity e = warpzone_camera_first; e; e = e.warpzone_next)
866 e.warpzone_reconnecting = ((this.target == "" || e.target == this.target) && !((this.spawnflags & 1) && visible_to_some_client(e)));
867 for(entity e = warpzone_first; e; e = e.warpzone_next)
868 if(e.warpzone_reconnecting)
869 WarpZone_InitStep_ClearTarget(e);
870 for(entity e = warpzone_first; e; e = e.warpzone_next)
871 if(e.warpzone_reconnecting)
872 WarpZone_InitStep_FindTarget(e);
873 for(entity e = warpzone_camera_first; e; e = e.warpzone_next)
874 if(e.warpzone_reconnecting)
875 WarpZoneCamera_InitStep_FindTarget(e);
876 for(entity e = warpzone_first; e; e = e.warpzone_next)
877 if(e.warpzone_reconnecting || e.enemy.warpzone_reconnecting)
878 WarpZone_InitStep_FinalizeTransform(e);
881 spawnfunc(trigger_warpzone_reconnect)
883 this.use = trigger_warpzone_reconnect_use;
886 spawnfunc(target_warpzone_reconnect)
888 spawnfunc_trigger_warpzone_reconnect(this); // both names make sense here :(
891 void WarpZone_PlayerPhysics_FixVAngle(entity this)
893 #ifndef WARPZONE_DONT_FIX_VANGLE
894 if(IS_REAL_CLIENT(this))
895 if(this.v_angle.z <= 360) // if not already adjusted
896 if(time - CS(this).ping * 0.001 < this.warpzone_teleport_time)
898 this.v_angle = WarpZone_TransformVAngles(this.warpzone_teleport_zone, this.v_angle);
899 this.v_angle_z += 720; // mark as adjusted