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)
40 setorigin(player, to); // NOTE: this also aborts the move, when this is called by touch
42 player.oldorigin = to; // for DP's unsticking
43 player.fixangle = true;
45 player.angles = to_angles;
46 player.velocity = to_velocity;
48 BITXOR_ASSIGN(player.effects, EF_TELEPORT_BIT);
51 BITCLR_ASSIGN(player.flags, FL_ONGROUND);
53 WarpZone_PostTeleportPlayer_Callback(player);
57 bool WarpZone_Teleported_Send(entity this, entity to, int sf)
59 WriteHeader(MSG_ENTITY, ENT_CLIENT_WARPZONE_TELEPORTED);
60 WriteCoord(MSG_ENTITY, this.angles.x);
61 WriteCoord(MSG_ENTITY, this.angles.y);
62 WriteCoord(MSG_ENTITY, this.angles.z);
67 float WarpZone_Teleport(entity wz, entity player, float f0, float f1)
69 vector o0, a0, v0, o1, a1, v1, o10;
71 o0 = player.origin + player.view_ofs;
75 o10 = o1 = WarpZone_TransformOrigin(wz, o0);
76 v1 = WarpZone_TransformVelocity(wz, v0);
77 if (!IS_NOT_A_CLIENT(player))
78 a1 = WarpZone_TransformVAngles(wz, PHYS_INPUT_ANGLES(player));
80 a1 = WarpZone_TransformAngles(wz, a0);
82 if(f0 != 0 || f1 != 0)
84 // retry last move but behind the warpzone!
85 // we must first go back as far as we can, then forward again, to not cause double touch events!
87 tracebox(o1 - player.view_ofs + v1 * frametime * f1, player.mins, player.maxs, o1 - player.view_ofs + v1 * frametime * f0, MOVE_WORLDONLY, player);
92 tracebox(trace_endpos, player.mins, player.maxs, o1 - player.view_ofs + v1 * frametime * f1, MOVE_NORMAL, player); // this should get us through the warpzone
95 o1 = trace_endpos + player.view_ofs;
98 md = max(vlen(player.mins), vlen(player.maxs));
99 d = WarpZone_TargetPlaneDist(wz, o1);
100 dv = WarpZone_TargetPlaneDist(wz, v1);
102 o1 = o1 - v1 * (d / dv);
105 // put him out of solid
106 tracebox(o1 - player.view_ofs, player.mins, player.maxs, o1 - player.view_ofs, MOVE_NOMONSTERS, player);
109 setorigin(player, o1 - player.view_ofs);
110 if(WarpZoneLib_MoveOutOfSolid(player))
112 o1 = player.origin + player.view_ofs;
113 setorigin(player, o0 - player.view_ofs);
117 LOG_INFO("would have to put player in solid, won't do that\n");
118 setorigin(player, o0 - player.view_ofs);
124 WarpZone_RefSys_Add(player, wz);
125 WarpZone_TeleportPlayer(wz, player, o1 - player.view_ofs, a1, v1);
126 WarpZone_StoreProjectileData(player);
127 player.warpzone_teleport_time = time;
128 player.warpzone_teleport_finishtime = time;
129 player.warpzone_teleport_zone = wz;
132 // prevent further teleports back
133 float dt = (o1 - o10) * v1 * (1 / (v1 * v1));
134 if(dt < PHYS_INPUT_FRAMETIME)
135 player.warpzone_teleport_finishtime += PHYS_INPUT_FRAMETIME - dt;
138 #ifndef WARPZONE_USE_FIXANGLE
140 if(IS_VEHICLE(player) && player.owner)
141 player = player.owner; // hax
142 if(IS_PLAYER(player))
144 // instead of fixangle, send the transform to the client for smoother operation
145 player.fixangle = false;
147 entity ts = new(warpzone_teleported);
148 setmodel(ts, MDL_Null);
149 setSendEntity(ts, WarpZone_Teleported_Send);
150 ts.SendFlags = 0xFFFFFF;
151 ts.drawonlytoclient = player;
152 setthink(ts, SUB_Remove);
153 ts.nextthink = time + 1;
156 ts.effects = EF_NODEPTHTEST;
157 ts.angles = wz.warpzone_transform;
160 setproperty(VF_CL_VIEWANGLES, WarpZone_TransformVAngles(wz, getpropertyvec(VF_CL_VIEWANGLES)));
161 //if(checkextension("DP_CSQC_ROTATEMOVES"))
162 //CL_RotateMoves(wz.warpzone_transform);
169 void WarpZone_Touch(entity this, entity toucher)
171 if(toucher.classname == "trigger_warpzone")
174 if(time <= toucher.warpzone_teleport_finishtime) // already teleported this frame
177 // FIXME needs a better check to know what is safe to teleport and what not
178 if((toucher.move_movetype == MOVETYPE_NONE && toucher.move_movetype == MOVETYPE_NONE) || toucher.move_movetype == MOVETYPE_FOLLOW || toucher.move_movetype == MOVETYPE_FOLLOW || toucher.tag_entity
185 if(WarpZoneLib_ExactTrigger_Touch(this, toucher))
188 if(WarpZone_PlaneDist(this, toucher.origin + toucher.view_ofs) >= 0) // wrong side of the trigger_warpzone (don't teleport yet)
192 // number of frames we need to go back:
193 // dist = 16*sqrt(2) qu
196 // 24 qu = v*frametime*n
197 // n = 24 qu/(v*frametime)
198 // for clients go only one frame though, may be too irritating otherwise
199 // but max 0.25 sec = 0.25/frametime frames
200 // 24/(0.25/frametime)
203 d = 24 + max(vlen(toucher.mins), vlen(toucher.maxs));
204 if(IS_NOT_A_CLIENT(toucher))
205 f = -d / bound(frametime * d * 1, frametime * vlen(toucher.velocity), d);
208 if(WarpZone_Teleport(this, toucher, f, 0))
213 save1 = this.target; this.target = string_null;
214 save2 = this.target3; this.target3 = string_null;
215 SUB_UseTargets(this, toucher, toucher); // use toucher too?
216 if (!this.target) this.target = save1;
217 if (!this.target3) this.target3 = save2;
219 save1 = this.target; this.target = string_null;
220 save2 = this.target2; this.target2 = string_null;
221 SUB_UseTargets(this.enemy, toucher, toucher); // use toucher too?
222 if (!this.target) this.target = save1;
223 if (!this.target2) this.target2 = save2;
228 LOG_TRACE("WARPZONE FAIL AHAHAHAHAH))");
233 bool WarpZone_Send(entity this, entity to, int sendflags)
235 WriteHeader(MSG_ENTITY, ENT_CLIENT_WARPZONE);
237 // we must send this flag for clientside to match properly too
239 if(this.warpzone_isboxy)
241 if(this.warpzone_fadestart)
243 if(this.origin != '0 0 0')
245 WriteByte(MSG_ENTITY, f);
247 // we need THESE to render the warpzone (and cull properly)...
250 WriteCoord(MSG_ENTITY, this.origin.x);
251 WriteCoord(MSG_ENTITY, this.origin.y);
252 WriteCoord(MSG_ENTITY, this.origin.z);
255 WriteShort(MSG_ENTITY, this.modelindex);
256 WriteCoord(MSG_ENTITY, this.mins.x);
257 WriteCoord(MSG_ENTITY, this.mins.y);
258 WriteCoord(MSG_ENTITY, this.mins.z);
259 WriteCoord(MSG_ENTITY, this.maxs.x);
260 WriteCoord(MSG_ENTITY, this.maxs.y);
261 WriteCoord(MSG_ENTITY, this.maxs.z);
262 WriteByte(MSG_ENTITY, bound(1, this.scale * 16, 255));
264 // we need THESE to calculate the proper transform
265 WriteCoord(MSG_ENTITY, this.warpzone_origin.x);
266 WriteCoord(MSG_ENTITY, this.warpzone_origin.y);
267 WriteCoord(MSG_ENTITY, this.warpzone_origin.z);
268 WriteCoord(MSG_ENTITY, this.warpzone_angles.x);
269 WriteCoord(MSG_ENTITY, this.warpzone_angles.y);
270 WriteCoord(MSG_ENTITY, this.warpzone_angles.z);
271 WriteCoord(MSG_ENTITY, this.warpzone_targetorigin.x);
272 WriteCoord(MSG_ENTITY, this.warpzone_targetorigin.y);
273 WriteCoord(MSG_ENTITY, this.warpzone_targetorigin.z);
274 WriteCoord(MSG_ENTITY, this.warpzone_targetangles.x);
275 WriteCoord(MSG_ENTITY, this.warpzone_targetangles.y);
276 WriteCoord(MSG_ENTITY, this.warpzone_targetangles.z);
280 WriteShort(MSG_ENTITY, this.warpzone_fadestart);
281 WriteShort(MSG_ENTITY, this.warpzone_fadeend);
287 bool WarpZone_Camera_Send(entity this, entity to, int sendflags)
290 WriteHeader(MSG_ENTITY, ENT_CLIENT_WARPZONE_CAMERA);
292 if(this.warpzone_fadestart)
294 if(this.origin != '0 0 0')
296 WriteByte(MSG_ENTITY, f);
298 // we need THESE to render the warpzone (and cull properly)...
301 WriteCoord(MSG_ENTITY, this.origin.x);
302 WriteCoord(MSG_ENTITY, this.origin.y);
303 WriteCoord(MSG_ENTITY, this.origin.z);
306 WriteShort(MSG_ENTITY, this.modelindex);
307 WriteCoord(MSG_ENTITY, this.mins.x);
308 WriteCoord(MSG_ENTITY, this.mins.y);
309 WriteCoord(MSG_ENTITY, this.mins.z);
310 WriteCoord(MSG_ENTITY, this.maxs.x);
311 WriteCoord(MSG_ENTITY, this.maxs.y);
312 WriteCoord(MSG_ENTITY, this.maxs.z);
313 WriteByte(MSG_ENTITY, bound(1, this.scale * 16, 255));
315 // we need THESE to calculate the proper transform
316 WriteCoord(MSG_ENTITY, this.enemy.origin.x);
317 WriteCoord(MSG_ENTITY, this.enemy.origin.y);
318 WriteCoord(MSG_ENTITY, this.enemy.origin.z);
319 WriteCoord(MSG_ENTITY, this.enemy.angles.x);
320 WriteCoord(MSG_ENTITY, this.enemy.angles.y);
321 WriteCoord(MSG_ENTITY, this.enemy.angles.z);
325 WriteShort(MSG_ENTITY, this.warpzone_fadestart);
326 WriteShort(MSG_ENTITY, this.warpzone_fadeend);
332 #ifdef WARPZONELIB_KEEPDEBUG
333 float WarpZone_CheckProjectileImpact(entity player)
337 o0 = player.origin + player.view_ofs;
338 v0 = player.velocity;
340 // if we teleported shortly before, abort
341 if(time <= player.warpzone_teleport_finishtime + 0.1)
344 // if player hit a warpzone, abort
346 wz = WarpZone_Find(o0 + player.mins, o0 + player.maxs);
350 #ifdef WARPZONELIB_REMOVEHACK
351 LOG_INFO("impactfilter found something - and it no longer gets handled correctly - please tell divVerent whether anything behaves broken now\n");
353 LOG_INFO("impactfilter found something - and it even gets handled correctly - please tell divVerent that this code apparently gets triggered again\n");
355 LOG_INFO("Entity type: ", player.classname, "\n");
356 LOG_INFO("Origin: ", vtos(player.origin), "\n");
357 LOG_INFO("Velocity: ", vtos(player.velocity), "\n");
359 #ifdef WARPZONELIB_REMOVEHACK
362 // retry previous move
363 setorigin(player, player.warpzone_oldorigin);
364 player.velocity = player.warpzone_oldvelocity;
365 if(WarpZone_Teleport(wz, player, 0, 1))
369 save1 = wz.target; wz.target = string_null;
370 save2 = wz.target3; wz.target3 = string_null;
371 SUB_UseTargets(wz, player, player);
372 if (!wz.target) wz.target = save1;
373 if (!wz.target3) wz.target3 = save2;
375 save1 = wz.enemy.target; wz.enemy.target = string_null;
376 save2 = wz.enemy.target2; wz.enemy.target2 = string_null;
377 SUB_UseTargets(wz.enemy, player, player);
378 if (!wz.enemy.target) wz.enemy.target = save1;
379 if (!wz.enemy.target2) wz.enemy.target2 = save2;
383 setorigin(player, o0 - player.view_ofs);
384 player.velocity = v0;
393 float WarpZone_Projectile_Touch(entity this, entity toucher)
395 if(toucher.classname == "trigger_warpzone")
398 // no further impacts if we teleported this frame!
399 // this is because even if we did teleport, the engine still may raise
400 // touch events for the previous location
401 // engine now aborts moves on teleport, so this SHOULD not happen any more
402 // but if this is called from TouchAreaGrid of the projectile moving,
403 // then this won't do
404 if(time == this.warpzone_teleport_time)
408 #ifdef WARPZONELIB_KEEPDEBUG
409 // this SEEMS to not happen at the moment, but if it did, it would be more reliable
411 float save_dpstartcontents;
412 float save_dphitcontents;
413 float save_dphitq3surfaceflags;
414 string save_dphittexturename;
416 float save_startsolid;
419 vector save_plane_normal;
420 float save_plane_dist;
424 save_dpstartcontents = trace_dpstartcontents;
425 save_dphitcontents = trace_dphitcontents;
426 save_dphitq3surfaceflags = trace_dphitq3surfaceflags;
427 save_dphittexturename = trace_dphittexturename;
428 save_allsolid = trace_allsolid;
429 save_startsolid = trace_startsolid;
430 save_fraction = trace_fraction;
431 save_endpos = trace_endpos;
432 save_plane_normal = trace_plane_normal;
433 save_plane_dist = trace_plane_dist;
434 save_ent = trace_ent;
435 save_inopen = trace_inopen;
436 save_inwater = trace_inwater;
437 float f = WarpZone_CheckProjectileImpact(this);
438 if (f) return (f > 0);
439 trace_dpstartcontents = save_dpstartcontents;
440 trace_dphitcontents = save_dphitcontents;
441 trace_dphitq3surfaceflags = save_dphitq3surfaceflags;
442 trace_dphittexturename = save_dphittexturename;
443 trace_allsolid = save_allsolid;
444 trace_startsolid = save_startsolid;
445 trace_fraction = save_fraction;
446 trace_endpos = save_endpos;
447 trace_plane_normal = save_plane_normal;
448 trace_plane_dist = save_plane_dist;
449 trace_ent = save_ent;
450 trace_inopen = save_inopen;
451 trace_inwater = save_inwater;
455 if(WarpZone_Projectile_Touch_ImpactFilter_Callback(this, toucher))
464 void WarpZone_InitStep_FindOriginTarget(entity this)
466 if(this.killtarget != "")
468 this.aiment = find(NULL, targetname, this.killtarget);
469 if(this.aiment == NULL)
471 error("Warp zone with nonexisting killtarget");
474 this.killtarget = string_null;
478 void WarpZonePosition_InitStep_FindTarget(entity this)
480 if(this.target == "")
482 error("Warp zone position with no target");
485 this.enemy = find(NULL, targetname, this.target);
486 if(this.enemy == NULL)
488 error("Warp zone position with nonexisting target");
491 if(this.enemy.aiment)
493 // already is positioned
494 error("Warp zone position targeting already oriented warpzone");
497 this.enemy.aiment = this;
500 void WarpZoneCamera_Think(entity this)
502 if(this.warpzone_save_origin != this.origin
503 || this.warpzone_save_angles != this.angles
504 || this.warpzone_save_eorigin != this.enemy.origin
505 || this.warpzone_save_eangles != this.enemy.angles)
507 WarpZone_Camera_SetUp(this, this.enemy.origin, this.enemy.angles);
508 this.warpzone_save_origin = this.origin;
509 this.warpzone_save_angles = this.angles;
510 this.warpzone_save_eorigin = this.enemy.origin;
511 this.warpzone_save_eangles = this.enemy.angles;
513 this.nextthink = time;
516 void WarpZoneCamera_InitStep_FindTarget(entity this)
520 if(this.target == "")
522 error("Camera with no target");
526 for(e = NULL, i = 0; (e = find(e, targetname, this.target)); )
527 if(random() * ++i < 1)
529 if(this.enemy == NULL)
531 error("Camera with nonexisting target");
534 warpzone_cameras_exist = 1;
535 WarpZone_Camera_SetUp(this, this.enemy.origin, this.enemy.angles);
536 this.SendFlags = 0xFFFFFF;
537 if(this.spawnflags & 1)
539 setthink(this, WarpZoneCamera_Think);
540 this.nextthink = time;
546 void WarpZone_InitStep_UpdateTransform(entity this)
548 vector org, ang, norm, point;
550 vector tri, a, b, c, n;
556 org = 0.5 * (this.mins + this.maxs);
558 norm = point = '0 0 0';
560 for(i_s = 0; ; ++i_s)
562 tex = getsurfacetexture(this, i_s);
564 break; // this is beyond the last one
565 if(tex == "textures/common/trigger" || tex == "trigger")
567 n_t = getsurfacenumtriangles(this, i_s);
568 for(i_t = 0; i_t < n_t; ++i_t)
570 tri = getsurfacetriangle(this, i_s, i_t);
571 a = getsurfacepoint(this, i_s, tri.x);
572 b = getsurfacepoint(this, i_s, tri.y);
573 c = getsurfacepoint(this, i_s, tri.z);
574 n = cross(c - a, b - a);
575 area = area + vlen(n);
577 point = point + vlen(n) * (a + b + c);
582 norm = norm * (1 / area);
583 point = point * (1 / (3 * area));
584 if(vdist(norm, <, 0.99))
586 LOG_INFO("trigger_warpzone near ", vtos(this.aiment.origin), " is nonplanar. BEWARE.\n");
587 area = 0; // no autofixing in this case
589 norm = normalize(norm);
595 org = this.aiment.origin;
596 ang = this.aiment.angles;
599 org = org - ((org - point) * norm) * norm; // project to plane
601 if(norm * v_forward < 0)
603 LOG_INFO("Position target of trigger_warpzone near ", vtos(this.aiment.origin), " points into trigger_warpzone. BEWARE.\n");
606 ang = vectoangles2(norm, v_up); // keep rotation, but turn exactly against plane
608 if(norm * v_forward < 0.99)
609 LOG_INFO("trigger_warpzone near ", vtos(this.aiment.origin), " has been turned to match plane orientation (", vtos(this.aiment.angles), " -> ", vtos(ang), "\n");
610 if(vdist(org - this.aiment.origin, >, 0.5))
611 LOG_INFO("trigger_warpzone near ", vtos(this.aiment.origin), " has been moved to match the plane (", vtos(this.aiment.origin), " -> ", vtos(org), ").\n");
617 ang = vectoangles(norm);
621 error("cannot infer origin/angles for this warpzone, please use a killtarget or a trigger_warpzone_position");
623 this.warpzone_origin = org;
624 this.warpzone_angles = ang;
627 void WarpZone_InitStep_ClearTarget(entity this)
630 this.enemy.enemy = NULL;
634 void WarpZone_InitStep_FindTarget(entity this)
642 // this way only one of the two ents needs to target
643 if(this.target != "")
645 this.enemy = this; // so the if(!e.enemy) check also skips this, saves one IF
648 for(e = NULL, i = 0; (e = find(e, targetname, this.target)); )
650 if(e.classname == this.classname) // possibly non-warpzones may use the same targetname!
651 if(random() * ++i < 1)
656 error("Warpzone with non-existing target");
664 void WarpZone_Think(entity this);
665 void WarpZone_InitStep_FinalizeTransform(entity this)
667 if(!this.enemy || this.enemy.enemy != this)
669 error("Invalid warp zone detected. Killed.");
673 warpzone_warpzones_exist = 1;
674 WarpZone_SetUp(this, this.warpzone_origin, this.warpzone_angles, this.enemy.warpzone_origin, this.enemy.warpzone_angles);
675 settouch(this, WarpZone_Touch);
676 this.SendFlags = 0xFFFFFF;
677 if(this.spawnflags & 1)
679 setthink(this, WarpZone_Think);
680 this.nextthink = time;
686 float warpzone_initialized;
687 //entity warpzone_first;
688 entity warpzone_position_first;
689 entity warpzone_camera_first;
690 .entity warpzone_next;
691 spawnfunc(misc_warpzone_position)
693 // "target", "angles", "origin"
694 this.warpzone_next = warpzone_position_first;
695 warpzone_position_first = this;
697 spawnfunc(trigger_warpzone_position)
699 spawnfunc_misc_warpzone_position(this);
701 spawnfunc(trigger_warpzone)
703 // warp zone entities must have:
704 // "killtarget" pointing to a target_position with a direction arrow
705 // that points AWAY from the warp zone, and that is inside
706 // the warp zone trigger
707 // "target" pointing to an identical warp zone at another place in
708 // the map, with another killtarget to designate its
712 this.scale = this.modelscale;
717 WarpZoneLib_ExactTrigger_Init(this);
721 _setmodel(this, m); // no precision needed
723 setorigin(this, this.origin);
725 setsize(this, this.mins * this.scale, this.maxs * this.scale);
727 setsize(this, this.mins, this.maxs);
728 setSendEntity(this, WarpZone_Send);
729 this.SendFlags = 0xFFFFFF;
730 BITSET_ASSIGN(this.effects, EF_NODEPTHTEST);
731 this.warpzone_next = warpzone_first;
732 warpzone_first = this;
734 IL_PUSH(g_warpzones, this);
736 spawnfunc(func_camera)
739 this.scale = this.modelscale;
744 precache_model(this.model);
745 _setmodel(this, this.model); // no precision needed
747 setorigin(this, this.origin);
749 setsize(this, this.mins * this.scale, this.maxs * this.scale);
751 setsize(this, this.mins, this.maxs);
753 this.solid = SOLID_BSP;
754 else if(this.solid < 0)
755 this.solid = SOLID_NOT;
756 setSendEntity(this, WarpZone_Camera_Send);
757 this.SendFlags = 0xFFFFFF;
758 this.warpzone_next = warpzone_camera_first;
759 warpzone_camera_first = this;
761 void WarpZones_Reconnect()
763 for(entity e = warpzone_first; e; e = e.warpzone_next)
764 WarpZone_InitStep_ClearTarget(e);
765 for(entity e = warpzone_first; e; e = e.warpzone_next)
766 WarpZone_InitStep_FindTarget(e);
767 for(entity e = warpzone_camera_first; e; e = e.warpzone_next)
768 WarpZoneCamera_InitStep_FindTarget(e);
769 for(entity e = warpzone_first; e; e = e.warpzone_next)
770 WarpZone_InitStep_FinalizeTransform(e);
773 void WarpZone_Think(entity this)
775 if(this.warpzone_save_origin != this.origin
776 || this.warpzone_save_angles != this.angles
777 || this.warpzone_save_eorigin != this.enemy.origin
778 || this.warpzone_save_eangles != this.enemy.angles)
780 WarpZone_InitStep_UpdateTransform(this);
781 WarpZone_InitStep_UpdateTransform(this.enemy);
782 WarpZone_InitStep_FinalizeTransform(this);
783 WarpZone_InitStep_FinalizeTransform(this.enemy);
784 this.warpzone_save_origin = this.origin;
785 this.warpzone_save_angles = this.angles;
786 this.warpzone_save_eorigin = this.enemy.origin;
787 this.warpzone_save_eangles = this.enemy.angles;
789 this.nextthink = time;
792 void WarpZone_StartFrame()
794 if (!warpzone_initialized)
796 warpzone_initialized = true;
797 for(entity e = warpzone_first; e; e = e.warpzone_next)
798 WarpZone_InitStep_FindOriginTarget(e);
799 for(entity e = warpzone_position_first; e; e = e.warpzone_next)
800 WarpZonePosition_InitStep_FindTarget(e);
801 for(entity e = warpzone_first; e; e = e.warpzone_next)
802 WarpZone_InitStep_UpdateTransform(e);
803 WarpZones_Reconnect();
804 WarpZone_PostInitialize_Callback();
807 if(warpzone_warpzones_exist)
809 IL_EACH(g_projectiles, true,
811 WarpZone_StoreProjectileData(it);
818 if(warpzone_warpzones_exist)
819 WarpZone_StoreProjectileData(it); // TODO: not actually needed
821 if(IS_OBSERVER(it) || it.solid == SOLID_NOT)
822 if(IS_CLIENT(it)) // we don't care about it being a bot
825 if (warpzone_warpzones_exist) {
826 entity e = WarpZone_Find(it.origin + it.mins, it.origin + it.maxs);
828 if (!WarpZoneLib_ExactTrigger_Touch(e, it))
829 if (WarpZone_PlaneDist(e, it.origin + it.view_ofs) <= 0)
830 WarpZone_Teleport(e, it, -1, 0); // NOT triggering targets by this!
836 entity ent = Teleport_Find(it.origin + it.mins, it.origin + it.maxs);
838 if (!WarpZoneLib_ExactTrigger_Touch(ent, it))
839 Simple_TeleportPlayer(ent, it); // NOT triggering targets by this!
845 .float warpzone_reconnecting;
846 bool visible_to_some_client(entity ent)
848 FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it) && checkpvs(it.origin + it.view_ofs, ent),
854 void trigger_warpzone_reconnect_use(entity this, entity actor, entity trigger)
856 // NOTE: this matches for target, not targetname, but of course
857 // targetname must be set too on the other entities
858 for(entity e = warpzone_first; e; e = e.warpzone_next)
859 e.warpzone_reconnecting = ((this.target == "" || e.target == this.target) && !((this.spawnflags & 1) && (visible_to_some_client(e) || visible_to_some_client(e.enemy))));
860 for(entity e = warpzone_camera_first; e; e = e.warpzone_next)
861 e.warpzone_reconnecting = ((this.target == "" || e.target == this.target) && !((this.spawnflags & 1) && visible_to_some_client(e)));
862 for(entity e = warpzone_first; e; e = e.warpzone_next)
863 if(e.warpzone_reconnecting)
864 WarpZone_InitStep_ClearTarget(e);
865 for(entity e = warpzone_first; e; e = e.warpzone_next)
866 if(e.warpzone_reconnecting)
867 WarpZone_InitStep_FindTarget(e);
868 for(entity e = warpzone_camera_first; e; e = e.warpzone_next)
869 if(e.warpzone_reconnecting)
870 WarpZoneCamera_InitStep_FindTarget(e);
871 for(entity e = warpzone_first; e; e = e.warpzone_next)
872 if(e.warpzone_reconnecting || e.enemy.warpzone_reconnecting)
873 WarpZone_InitStep_FinalizeTransform(e);
876 spawnfunc(trigger_warpzone_reconnect)
878 this.use = trigger_warpzone_reconnect_use;
881 spawnfunc(target_warpzone_reconnect)
883 spawnfunc_trigger_warpzone_reconnect(this); // both names make sense here :(
886 void WarpZone_PlayerPhysics_FixVAngle(entity this)
888 #ifndef WARPZONE_DONT_FIX_VANGLE
889 if(IS_REAL_CLIENT(this))
890 if(this.v_angle.z <= 360) // if not already adjusted
891 if(time - this.ping * 0.001 < this.warpzone_teleport_time)
893 this.v_angle = WarpZone_TransformVAngles(this.warpzone_teleport_zone, this.v_angle);
894 this.v_angle_z += 720; // mark as adjusted