7 #include <common/constants.qh>
8 #include <common/net_linked.qh>
9 #include <common/mapobjects/subs.qh>
10 #include <common/mapobjects/teleporters.qh>
11 #include <common/util.qh>
12 #include <common/weapons/_all.qh>
13 #include <common/stats.qh>
14 #include <server/utils.qh>
15 #include <server/weapons/common.qh>
19 bool autocvar_sv_warpzone_allow_selftarget;
22 #ifdef WARPZONELIB_KEEPDEBUG
23 #define WARPZONELIB_REMOVEHACK
27 .vector warpzone_save_origin;
28 .vector warpzone_save_angles;
29 .vector warpzone_save_eorigin;
30 .vector warpzone_save_eangles;
33 .vector warpzone_oldorigin, warpzone_oldvelocity, warpzone_oldangles;
34 .float warpzone_teleport_time;
35 .float warpzone_teleport_finishtime;
36 .entity warpzone_teleport_zone;
38 #define WarpZone_StoreProjectileData(e_) MACRO_BEGIN \
40 e.warpzone_oldorigin = e.origin; \
41 e.warpzone_oldvelocity = e.velocity; \
42 e.warpzone_oldangles = e.angles; \
45 void WarpZone_TeleportPlayer(entity teleporter, entity player, vector to, vector to_angles, vector to_velocity)
48 player.lastteleport_origin = player.origin;
49 player.lastteleporttime = time;
51 setorigin(player, to); // NOTE: this also aborts the move, when this is called by touch
52 player.angles = to_angles;
54 player.oldorigin = to; // for DP's unsticking
55 player.fixangle = true;
56 if (IS_BOT_CLIENT(player))
58 // FIXME find a way to smooth view's angles change for bots too
59 player.v_angle = player.angles;
60 bot_aim_reset(player);
63 player.velocity = to_velocity;
65 BITXOR_ASSIGN(player.effects, EF_TELEPORT_BIT);
68 BITCLR_ASSIGN(player.flags, FL_ONGROUND);
70 WarpZone_PostTeleportPlayer_Callback(player);
74 bool WarpZone_Teleported_Send(entity this, entity to, int sf)
76 WriteHeader(MSG_ENTITY, ENT_CLIENT_WARPZONE_TELEPORTED);
77 WriteVector(MSG_ENTITY, this.angles);
82 float WarpZone_Teleport(entity wz, entity player, float f0, float f1)
84 vector o0, a0, v0, o1, a1, v1, o10;
86 o0 = player.origin + player.view_ofs;
90 o10 = o1 = WarpZone_TransformOrigin(wz, o0);
91 v1 = WarpZone_TransformVelocity(wz, v0);
92 if (!IS_NOT_A_CLIENT(player))
93 a1 = WarpZone_TransformVAngles(wz, PHYS_INPUT_ANGLES(player));
95 a1 = WarpZone_TransformAngles(wz, a0);
97 if(f0 != 0 || f1 != 0)
99 // retry last move but behind the warpzone!
100 // we must first go back as far as we can, then forward again, to not cause double touch events!
102 tracebox(o1 - player.view_ofs + v1 * frametime * f1, player.mins, player.maxs, o1 - player.view_ofs + v1 * frametime * f0, MOVE_WORLDONLY, player);
107 tracebox(trace_endpos, player.mins, player.maxs, o1 - player.view_ofs + v1 * frametime * f1, MOVE_NORMAL, player); // this should get us through the warpzone
110 o1 = trace_endpos + player.view_ofs;
113 md = max(vlen(player.mins), vlen(player.maxs));
114 d = WarpZone_TargetPlaneDist(wz, o1);
115 dv = WarpZone_TargetPlaneDist(wz, v1);
117 o1 = o1 - v1 * (d / dv);
120 // put them out of solid
121 tracebox(o1 - player.view_ofs, player.mins, player.maxs, o1 - player.view_ofs, MOVE_NOMONSTERS, player);
124 setorigin(player, o1 - player.view_ofs);
125 if(WarpZoneLib_MoveOutOfSolid(player))
127 o1 = player.origin + player.view_ofs;
128 setorigin(player, o0 - player.view_ofs);
132 LOG_INFO("would have to put player in solid, won't do that");
133 setorigin(player, o0 - player.view_ofs);
139 WarpZone_RefSys_Add(player, wz);
140 WarpZone_TeleportPlayer(wz, player, o1 - player.view_ofs, a1, v1);
141 WarpZone_StoreProjectileData(player);
142 player.warpzone_teleport_time = time;
143 player.warpzone_teleport_finishtime = time;
144 player.warpzone_teleport_zone = wz;
147 // prevent further teleports back
148 float dt = (o1 - o10) * v1 * (1 / (v1 * v1));
149 if(dt < PHYS_INPUT_FRAMETIME)
150 player.warpzone_teleport_finishtime += PHYS_INPUT_FRAMETIME - dt;
153 #ifndef WARPZONE_USE_FIXANGLE
155 if(IS_VEHICLE(player) && player.owner)
156 player = player.owner; // hax
157 if(IS_PLAYER(player))
159 // instead of fixangle, send the transform to the client for smoother operation
160 player.fixangle = false;
162 entity ts = new(warpzone_teleported);
163 setmodel(ts, MDL_Null);
164 setSendEntity(ts, WarpZone_Teleported_Send);
165 ts.SendFlags = 0xFFFFFF;
166 ts.drawonlytoclient = player;
167 setthink(ts, SUB_Remove);
168 ts.nextthink = time + 1;
171 ts.effects = EF_NODEPTHTEST;
172 ts.angles = wz.warpzone_transform;
175 setproperty(VF_CL_VIEWANGLES, WarpZone_TransformVAngles(wz, getpropertyvec(VF_CL_VIEWANGLES)));
176 //if(checkextension("DP_CSQC_ROTATEMOVES"))
177 //CL_RotateMoves(wz.warpzone_transform);
184 void WarpZone_Touch(entity this, entity toucher)
186 if(toucher.classname == "trigger_warpzone")
189 if(time <= toucher.warpzone_teleport_finishtime) // already teleported this frame
192 // FIXME needs a better check to know what is safe to teleport and what not
193 if(toucher.move_movetype == MOVETYPE_NONE || toucher.move_movetype == MOVETYPE_FOLLOW || toucher.tag_entity)
196 EXACTTRIGGER_TOUCH(this, toucher);
198 if(WarpZone_PlaneDist(this, toucher.origin + toucher.view_ofs) >= 0) // wrong side of the trigger_warpzone (don't teleport yet)
202 // number of frames we need to go back:
203 // dist = 16*sqrt(2) qu
206 // 24 qu = v*frametime*n
207 // n = 24 qu/(v*frametime)
208 // for clients go only one frame though, may be too irritating otherwise
209 // but max 0.25 sec = 0.25/frametime frames
210 // 24/(0.25/frametime)
213 d = 24 + max(vlen(toucher.mins), vlen(toucher.maxs));
214 if(IS_NOT_A_CLIENT(toucher))
215 f = -d / bound(frametime * d * 1, frametime * vlen(toucher.velocity), d);
218 if(WarpZone_Teleport(this, toucher, f, 0))
221 SUB_UseTargets_SkipTargets(this, toucher, toucher, BIT(1) | BIT(3)); // use toucher too?
222 SUB_UseTargets_SkipTargets(this.enemy, toucher, toucher, BIT(1) | BIT(2)); // use toucher too?
227 LOG_TRACE("WARPZONE FAIL AHAHAHAHAH))");
232 bool WarpZone_Send(entity this, entity to, int sendflags)
234 WriteHeader(MSG_ENTITY, ENT_CLIENT_WARPZONE);
236 // we must send this flag for clientside to match properly too
238 if(this.warpzone_isboxy)
240 if(this.warpzone_fadestart)
242 if(this.origin != '0 0 0')
244 WriteByte(MSG_ENTITY, f);
246 // we need THESE to render the warpzone (and cull properly)...
249 WriteCoord(MSG_ENTITY, this.origin.x);
250 WriteCoord(MSG_ENTITY, this.origin.y);
251 WriteCoord(MSG_ENTITY, this.origin.z);
254 WriteShort(MSG_ENTITY, this.modelindex);
255 WriteCoord(MSG_ENTITY, this.mins.x);
256 WriteCoord(MSG_ENTITY, this.mins.y);
257 WriteCoord(MSG_ENTITY, this.mins.z);
258 WriteCoord(MSG_ENTITY, this.maxs.x);
259 WriteCoord(MSG_ENTITY, this.maxs.y);
260 WriteCoord(MSG_ENTITY, this.maxs.z);
261 WriteByte(MSG_ENTITY, bound(1, this.scale * 16, 255));
263 // we need THESE to calculate the proper transform
264 WriteCoord(MSG_ENTITY, this.warpzone_origin.x);
265 WriteCoord(MSG_ENTITY, this.warpzone_origin.y);
266 WriteCoord(MSG_ENTITY, this.warpzone_origin.z);
267 WriteCoord(MSG_ENTITY, this.warpzone_angles.x);
268 WriteCoord(MSG_ENTITY, this.warpzone_angles.y);
269 WriteCoord(MSG_ENTITY, this.warpzone_angles.z);
270 WriteCoord(MSG_ENTITY, this.warpzone_targetorigin.x);
271 WriteCoord(MSG_ENTITY, this.warpzone_targetorigin.y);
272 WriteCoord(MSG_ENTITY, this.warpzone_targetorigin.z);
273 WriteCoord(MSG_ENTITY, this.warpzone_targetangles.x);
274 WriteCoord(MSG_ENTITY, this.warpzone_targetangles.y);
275 WriteCoord(MSG_ENTITY, this.warpzone_targetangles.z);
279 WriteShort(MSG_ENTITY, this.warpzone_fadestart);
280 WriteShort(MSG_ENTITY, this.warpzone_fadeend);
286 bool WarpZone_Camera_Send(entity this, entity to, int sendflags)
289 WriteHeader(MSG_ENTITY, ENT_CLIENT_WARPZONE_CAMERA);
291 if(this.warpzone_fadestart)
293 if(this.origin != '0 0 0')
295 WriteByte(MSG_ENTITY, f);
297 // we need THESE to render the warpzone (and cull properly)...
300 WriteCoord(MSG_ENTITY, this.origin.x);
301 WriteCoord(MSG_ENTITY, this.origin.y);
302 WriteCoord(MSG_ENTITY, this.origin.z);
305 WriteShort(MSG_ENTITY, this.modelindex);
306 WriteCoord(MSG_ENTITY, this.mins.x);
307 WriteCoord(MSG_ENTITY, this.mins.y);
308 WriteCoord(MSG_ENTITY, this.mins.z);
309 WriteCoord(MSG_ENTITY, this.maxs.x);
310 WriteCoord(MSG_ENTITY, this.maxs.y);
311 WriteCoord(MSG_ENTITY, this.maxs.z);
312 WriteByte(MSG_ENTITY, bound(1, this.scale * 16, 255));
314 // we need THESE to calculate the proper transform
315 WriteCoord(MSG_ENTITY, this.enemy.origin.x);
316 WriteCoord(MSG_ENTITY, this.enemy.origin.y);
317 WriteCoord(MSG_ENTITY, this.enemy.origin.z);
318 WriteCoord(MSG_ENTITY, this.enemy.angles.x);
319 WriteCoord(MSG_ENTITY, this.enemy.angles.y);
320 WriteCoord(MSG_ENTITY, this.enemy.angles.z);
324 WriteShort(MSG_ENTITY, this.warpzone_fadestart);
325 WriteShort(MSG_ENTITY, this.warpzone_fadeend);
331 #ifdef WARPZONELIB_KEEPDEBUG
332 float WarpZone_CheckProjectileImpact(entity player)
336 o0 = player.origin + player.view_ofs;
337 v0 = player.velocity;
339 // if we teleported shortly before, abort
340 if(time <= player.warpzone_teleport_finishtime + 0.1)
343 // if player hit a warpzone, abort
345 wz = WarpZone_Find(o0 + player.mins, o0 + player.maxs);
349 #ifdef WARPZONELIB_REMOVEHACK
350 LOG_INFO("impactfilter found something - and it no longer gets handled correctly - please tell divVerent whether anything behaves broken now");
352 LOG_INFO("impactfilter found something - and it even gets handled correctly - please tell divVerent that this code apparently gets triggered again");
354 LOG_INFO("Entity type: ", player.classname);
355 LOG_INFO("Origin: ", vtos(player.origin));
356 LOG_INFO("Velocity: ", vtos(player.velocity));
358 #ifdef WARPZONELIB_REMOVEHACK
361 // retry previous move
362 setorigin(player, player.warpzone_oldorigin);
363 player.velocity = player.warpzone_oldvelocity;
364 if(WarpZone_Teleport(wz, player, 0, 1))
366 SUB_UseTargets_SkipTargets(wz, player, player, BIT(1) | BIT(3));
367 SUB_UseTargets_SkipTargets(wz.enemy, player, player, BIT(1) | BIT(2));
371 setorigin(player, o0 - player.view_ofs);
372 player.velocity = v0;
381 float WarpZone_Projectile_Touch(entity this, entity toucher)
383 if(toucher.classname == "trigger_warpzone")
386 // no further impacts if we teleported this frame!
387 // this is because even if we did teleport, the engine still may raise
388 // touch events for the previous location
389 // engine now aborts moves on teleport, so this SHOULD not happen any more
390 // but if this is called from TouchAreaGrid of the projectile moving,
391 // then this won't do
392 if(time == this.warpzone_teleport_time)
396 #ifdef WARPZONELIB_KEEPDEBUG
397 // this SEEMS to not happen at the moment, but if it did, it would be more reliable
399 float save_dpstartcontents;
400 float save_dphitcontents;
401 float save_dphitq3surfaceflags;
402 string save_dphittexturename;
404 float save_startsolid;
407 vector save_plane_normal;
408 float save_plane_dist;
412 save_dpstartcontents = trace_dpstartcontents;
413 save_dphitcontents = trace_dphitcontents;
414 save_dphitq3surfaceflags = trace_dphitq3surfaceflags;
415 save_dphittexturename = trace_dphittexturename;
416 save_allsolid = trace_allsolid;
417 save_startsolid = trace_startsolid;
418 save_fraction = trace_fraction;
419 save_endpos = trace_endpos;
420 save_plane_normal = trace_plane_normal;
421 save_plane_dist = trace_plane_dist;
422 save_ent = trace_ent;
423 save_inopen = trace_inopen;
424 save_inwater = trace_inwater;
425 float f = WarpZone_CheckProjectileImpact(this);
426 if (f) return (f > 0);
427 trace_dpstartcontents = save_dpstartcontents;
428 trace_dphitcontents = save_dphitcontents;
429 trace_dphitq3surfaceflags = save_dphitq3surfaceflags;
430 trace_dphittexturename = save_dphittexturename;
431 trace_allsolid = save_allsolid;
432 trace_startsolid = save_startsolid;
433 trace_fraction = save_fraction;
434 trace_endpos = save_endpos;
435 trace_plane_normal = save_plane_normal;
436 trace_plane_dist = save_plane_dist;
437 trace_ent = save_ent;
438 trace_inopen = save_inopen;
439 trace_inwater = save_inwater;
443 if(WarpZone_Projectile_Touch_ImpactFilter_Callback(this, toucher))
452 void WarpZone_InitStep_FindOriginTarget(entity this)
454 if(this.killtarget != "")
456 this.aiment = find(NULL, targetname, this.killtarget);
457 if(this.aiment == NULL)
459 error("Warp zone with nonexisting killtarget");
462 this.killtarget = string_null;
466 void WarpZonePosition_InitStep_FindTarget(entity this)
468 if(this.target == "")
470 error("Warp zone position with no target");
473 this.enemy = find(NULL, targetname, this.target);
474 if(this.enemy == NULL)
476 error("Warp zone position with nonexisting target");
479 if(this.enemy.aiment)
481 // already is positioned
482 error("Warp zone position targeting already oriented warpzone");
485 this.enemy.aiment = this;
488 void WarpZoneCamera_Think(entity this)
490 if(this.warpzone_save_origin != this.origin
491 || this.warpzone_save_angles != this.angles
492 || this.warpzone_save_eorigin != this.enemy.origin
493 || this.warpzone_save_eangles != this.enemy.angles)
495 WarpZone_Camera_SetUp(this, this.enemy.origin, this.enemy.angles);
496 this.warpzone_save_origin = this.origin;
497 this.warpzone_save_angles = this.angles;
498 this.warpzone_save_eorigin = this.enemy.origin;
499 this.warpzone_save_eangles = this.enemy.angles;
501 this.nextthink = time;
504 void WarpZoneCamera_InitStep_FindTarget(entity this)
508 if(this.target == "")
510 error("Camera with no target");
514 for(e = NULL, i = 0; (e = find(e, targetname, this.target)); )
515 if(random() * ++i < 1)
517 if(this.enemy == NULL)
519 error("Camera with nonexisting target");
522 warpzone_cameras_exist = 1;
523 WarpZone_Camera_SetUp(this, this.enemy.origin, this.enemy.angles);
524 this.SendFlags = 0xFFFFFF;
525 if(this.spawnflags & 1)
527 setthink(this, WarpZoneCamera_Think);
528 this.nextthink = time;
534 void WarpZone_InitStep_UpdateTransform(entity this)
536 vector org, ang, norm, point;
538 vector tri, a, b, c, n;
544 org = 0.5 * (this.mins + this.maxs);
546 norm = point = '0 0 0';
548 for(i_s = 0; ; ++i_s)
550 tex = getsurfacetexture(this, i_s);
552 break; // this is beyond the last one
553 if(tex == "textures/common/trigger" || tex == "trigger")
555 n_t = getsurfacenumtriangles(this, i_s);
556 for(i_t = 0; i_t < n_t; ++i_t)
558 tri = getsurfacetriangle(this, i_s, i_t);
559 a = getsurfacepoint(this, i_s, tri.x);
560 b = getsurfacepoint(this, i_s, tri.y);
561 c = getsurfacepoint(this, i_s, tri.z);
562 n = cross(c - a, b - a);
563 area = area + vlen(n);
565 point = point + vlen(n) * (a + b + c);
570 norm = norm * (1 / area);
571 point = point * (1 / (3 * area));
572 if(vdist(norm, <, 0.99))
574 LOG_INFO("trigger_warpzone near ", vtos(this.aiment.origin), " is nonplanar. BEWARE.");
575 area = 0; // no autofixing in this case
577 norm = normalize(norm);
583 org = this.aiment.origin;
584 ang = this.aiment.angles;
587 org = org - ((org - point) * norm) * norm; // project to plane
588 vector forward, right, up;
589 MAKE_VECTORS(ang, forward, right, up);
590 if(norm * forward < 0)
592 LOG_INFO("Position target of trigger_warpzone near ", vtos(this.aiment.origin), " points into trigger_warpzone. BEWARE.");
595 ang = vectoangles2(norm, up); // keep rotation, but turn exactly against plane
597 if(norm * forward < 0.99)
598 LOG_INFO("trigger_warpzone near ", vtos(this.aiment.origin), " has been turned to match plane orientation (", vtos(this.aiment.angles), " -> ", vtos(ang));
599 if(vdist(org - this.aiment.origin, >, 0.5))
600 LOG_INFO("trigger_warpzone near ", vtos(this.aiment.origin), " has been moved to match the plane (", vtos(this.aiment.origin), " -> ", vtos(org), ").");
606 ang = vectoangles(norm);
610 error("cannot infer origin/angles for this warpzone, please use a killtarget or a trigger_warpzone_position");
612 this.warpzone_origin = org;
613 this.warpzone_angles = ang;
616 void WarpZone_InitStep_ClearTarget(entity this)
619 this.enemy.enemy = NULL;
623 void WarpZone_InitStep_FindTarget(entity this)
631 // this way only one of the two ents needs to target
632 if(this.target != "")
634 if(!autocvar_sv_warpzone_allow_selftarget)
635 this.enemy = this; // so the if(!e.enemy) check also skips this, saves one IF
638 for(e = NULL, i = 0; (e = find(e, targetname, this.target)); )
640 if(e.classname == this.classname) // possibly non-warpzones may use the same targetname!
641 if(random() * ++i < 1)
646 error("Warpzone with non-existing target");
654 void WarpZone_Think(entity this);
655 void WarpZone_InitStep_FinalizeTransform(entity this)
657 if(!this.enemy || this.enemy.enemy != this)
659 error("Invalid warp zone detected. Killed.");
663 warpzone_warpzones_exist = 1;
664 WarpZone_SetUp(this, this.warpzone_origin, this.warpzone_angles, this.enemy.warpzone_origin, this.enemy.warpzone_angles);
665 settouch(this, WarpZone_Touch);
666 this.SendFlags = 0xFFFFFF;
667 if(this.spawnflags & 1)
669 setthink(this, WarpZone_Think);
670 this.nextthink = time;
676 float warpzone_initialized;
677 //entity warpzone_first;
678 entity warpzone_position_first;
679 entity warpzone_camera_first;
680 .entity warpzone_next;
681 spawnfunc(misc_warpzone_position)
683 // "target", "angles", "origin"
684 this.warpzone_next = warpzone_position_first;
685 warpzone_position_first = this;
687 spawnfunc(trigger_warpzone_position)
689 spawnfunc_misc_warpzone_position(this);
691 spawnfunc(trigger_warpzone)
693 // warp zone entities must have:
694 // "killtarget" pointing to a target_position with a direction arrow
695 // that points AWAY from the warp zone, and that is inside
696 // the warp zone trigger
697 // "target" pointing to an identical warp zone at another place in
698 // the map, with another killtarget to designate its
702 this.scale = this.modelscale;
707 WarpZoneLib_ExactTrigger_Init(this);
711 _setmodel(this, m); // no precision needed
713 setorigin(this, this.origin);
715 setsize(this, this.mins * this.scale, this.maxs * this.scale);
717 setsize(this, this.mins, this.maxs);
718 setSendEntity(this, WarpZone_Send);
719 this.SendFlags = 0xFFFFFF;
720 BITSET_ASSIGN(this.effects, EF_NODEPTHTEST);
721 this.warpzone_next = warpzone_first;
722 warpzone_first = this;
724 IL_PUSH(g_warpzones, this);
726 spawnfunc(func_camera)
729 this.scale = this.modelscale;
734 precache_model(this.model);
735 _setmodel(this, this.model); // no precision needed
737 setorigin(this, this.origin);
739 setsize(this, this.mins * this.scale, this.maxs * this.scale);
741 setsize(this, this.mins, this.maxs);
743 this.solid = SOLID_BSP;
744 else if(this.solid < 0)
745 this.solid = SOLID_NOT;
746 setSendEntity(this, WarpZone_Camera_Send);
747 this.SendFlags = 0xFFFFFF;
748 this.warpzone_next = warpzone_camera_first;
749 warpzone_camera_first = this;
751 void WarpZones_Reconnect()
753 for(entity e = warpzone_first; e; e = e.warpzone_next)
754 WarpZone_InitStep_ClearTarget(e);
755 for(entity e = warpzone_first; e; e = e.warpzone_next)
756 WarpZone_InitStep_FindTarget(e);
757 for(entity e = warpzone_camera_first; e; e = e.warpzone_next)
758 WarpZoneCamera_InitStep_FindTarget(e);
759 for(entity e = warpzone_first; e; e = e.warpzone_next)
760 WarpZone_InitStep_FinalizeTransform(e);
763 void WarpZone_Think(entity this)
765 if(this.warpzone_save_origin != this.origin
766 || this.warpzone_save_angles != this.angles
767 || this.warpzone_save_eorigin != this.enemy.origin
768 || this.warpzone_save_eangles != this.enemy.angles)
770 WarpZone_InitStep_UpdateTransform(this);
771 WarpZone_InitStep_UpdateTransform(this.enemy);
772 WarpZone_InitStep_FinalizeTransform(this);
773 WarpZone_InitStep_FinalizeTransform(this.enemy);
774 this.warpzone_save_origin = this.origin;
775 this.warpzone_save_angles = this.angles;
776 this.warpzone_save_eorigin = this.enemy.origin;
777 this.warpzone_save_eangles = this.enemy.angles;
779 this.nextthink = time;
782 void WarpZone_StartFrame()
784 if (!warpzone_initialized)
786 warpzone_initialized = true;
787 for(entity e = warpzone_first; e; e = e.warpzone_next)
788 WarpZone_InitStep_FindOriginTarget(e);
789 for(entity e = warpzone_position_first; e; e = e.warpzone_next)
790 WarpZonePosition_InitStep_FindTarget(e);
791 for(entity e = warpzone_first; e; e = e.warpzone_next)
792 WarpZone_InitStep_UpdateTransform(e);
793 WarpZones_Reconnect();
794 WarpZone_PostInitialize_Callback();
797 if(warpzone_warpzones_exist)
799 IL_EACH(g_projectiles, true,
801 WarpZone_StoreProjectileData(it);
808 if(warpzone_warpzones_exist)
809 WarpZone_StoreProjectileData(it); // TODO: not actually needed
811 if((IS_OBSERVER(it) || it.solid == SOLID_NOT))
814 if (warpzone_warpzones_exist) {
815 entity e = WarpZone_Find(it.origin + it.mins, it.origin + it.maxs);
817 if (WarpZoneLib_ExactTrigger_Touch(e, it, false))
818 if (WarpZone_PlaneDist(e, it.origin + it.view_ofs) <= 0)
819 WarpZone_Teleport(e, it, -1, 0); // NOT triggering targets by this!
825 entity ent = Teleport_Find(it.origin + it.mins, it.origin + it.maxs);
827 if (WarpZoneLib_ExactTrigger_Touch(ent, it, false))
828 Simple_TeleportPlayer(ent, it); // NOT triggering targets by this!
834 .float warpzone_reconnecting;
835 bool visible_to_some_client(entity ent)
837 FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it) && checkpvs(it.origin + it.view_ofs, ent),
843 void trigger_warpzone_reconnect_use(entity this, entity actor, entity trigger)
845 // NOTE: this matches for target, not targetname, but of course
846 // targetname must be set too on the other entities
847 for(entity e = warpzone_first; e; e = e.warpzone_next)
848 e.warpzone_reconnecting = ((this.target == "" || e.target == this.target) && !((this.spawnflags & 1) && (visible_to_some_client(e) || visible_to_some_client(e.enemy))));
849 for(entity e = warpzone_camera_first; e; e = e.warpzone_next)
850 e.warpzone_reconnecting = ((this.target == "" || e.target == this.target) && !((this.spawnflags & 1) && visible_to_some_client(e)));
851 for(entity e = warpzone_first; e; e = e.warpzone_next)
852 if(e.warpzone_reconnecting)
853 WarpZone_InitStep_ClearTarget(e);
854 for(entity e = warpzone_first; e; e = e.warpzone_next)
855 if(e.warpzone_reconnecting)
856 WarpZone_InitStep_FindTarget(e);
857 for(entity e = warpzone_camera_first; e; e = e.warpzone_next)
858 if(e.warpzone_reconnecting)
859 WarpZoneCamera_InitStep_FindTarget(e);
860 for(entity e = warpzone_first; e; e = e.warpzone_next)
861 if(e.warpzone_reconnecting || e.enemy.warpzone_reconnecting)
862 WarpZone_InitStep_FinalizeTransform(e);
865 spawnfunc(trigger_warpzone_reconnect)
867 this.use = trigger_warpzone_reconnect_use;
870 spawnfunc(target_warpzone_reconnect)
872 spawnfunc_trigger_warpzone_reconnect(this); // both names make sense here :(
875 void WarpZone_PlayerPhysics_FixVAngle(entity this)
877 #ifndef WARPZONE_DONT_FIX_VANGLE
878 if(IS_REAL_CLIENT(this))
879 if(this.v_angle.z <= 360) // if not already adjusted
880 if(time - CS(this).ping * 0.001 < this.warpzone_teleport_time)
882 this.v_angle = WarpZone_TransformVAngles(this.warpzone_teleport_zone, this.v_angle);
883 this.v_angle_z += 720; // mark as adjusted