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>
17 bool autocvar_sv_warpzone_allow_selftarget;
20 #ifdef WARPZONELIB_KEEPDEBUG
21 #define WARPZONELIB_REMOVEHACK
25 .vector warpzone_save_origin;
26 .vector warpzone_save_angles;
27 .vector warpzone_save_eorigin;
28 .vector warpzone_save_eangles;
31 .vector warpzone_oldorigin, warpzone_oldvelocity, warpzone_oldangles;
32 .float warpzone_teleport_time;
33 .float warpzone_teleport_finishtime;
34 .entity warpzone_teleport_zone;
36 #define WarpZone_StoreProjectileData(e_) MACRO_BEGIN \
38 e.warpzone_oldorigin = e.origin; \
39 e.warpzone_oldvelocity = e.velocity; \
40 e.warpzone_oldangles = e.angles; \
43 void WarpZone_TeleportPlayer(entity teleporter, entity player, vector to, vector to_angles, vector to_velocity)
46 player.lastteleport_origin = player.origin;
47 player.lastteleporttime = time;
49 setorigin(player, to); // NOTE: this also aborts the move, when this is called by touch
50 player.angles = to_angles;
52 player.oldorigin = to; // for DP's unsticking
53 player.fixangle = true;
54 if (IS_BOT_CLIENT(player))
56 // FIXME find a way to smooth view's angles change for bots too
57 player.v_angle = player.angles;
58 bot_aim_reset(player);
61 player.velocity = to_velocity;
63 BITXOR_ASSIGN(player.effects, EF_TELEPORT_BIT);
66 BITCLR_ASSIGN(player.flags, FL_ONGROUND);
68 WarpZone_PostTeleportPlayer_Callback(player);
72 bool WarpZone_Teleported_Send(entity this, entity to, int sf)
74 WriteHeader(MSG_ENTITY, ENT_CLIENT_WARPZONE_TELEPORTED);
75 WriteVector(MSG_ENTITY, this.angles);
80 float WarpZone_Teleport(entity wz, entity player, float f0, float f1)
82 vector o0, a0, v0, o1, a1, v1, o10;
84 o0 = player.origin + player.view_ofs;
88 o10 = o1 = WarpZone_TransformOrigin(wz, o0);
89 v1 = WarpZone_TransformVelocity(wz, v0);
90 if (!IS_NOT_A_CLIENT(player))
91 a1 = WarpZone_TransformVAngles(wz, PHYS_INPUT_ANGLES(player));
93 a1 = WarpZone_TransformAngles(wz, a0);
95 if(f0 != 0 || f1 != 0)
97 // retry last move but behind the warpzone!
98 // we must first go back as far as we can, then forward again, to not cause double touch events!
100 tracebox(o1 - player.view_ofs + v1 * frametime * f1, player.mins, player.maxs, o1 - player.view_ofs + v1 * frametime * f0, MOVE_WORLDONLY, player);
105 tracebox(trace_endpos, player.mins, player.maxs, o1 - player.view_ofs + v1 * frametime * f1, MOVE_NORMAL, player); // this should get us through the warpzone
108 o1 = trace_endpos + player.view_ofs;
111 md = max(vlen(player.mins), vlen(player.maxs));
112 d = WarpZone_TargetPlaneDist(wz, o1);
113 dv = WarpZone_TargetPlaneDist(wz, v1);
115 o1 = o1 - v1 * (d / dv);
118 // put him out of solid
119 tracebox(o1 - player.view_ofs, player.mins, player.maxs, o1 - player.view_ofs, MOVE_NOMONSTERS, player);
122 setorigin(player, o1 - player.view_ofs);
123 if(WarpZoneLib_MoveOutOfSolid(player))
125 o1 = player.origin + player.view_ofs;
126 setorigin(player, o0 - player.view_ofs);
130 LOG_INFO("would have to put player in solid, won't do that");
131 setorigin(player, o0 - player.view_ofs);
137 WarpZone_RefSys_Add(player, wz);
138 WarpZone_TeleportPlayer(wz, player, o1 - player.view_ofs, a1, v1);
139 WarpZone_StoreProjectileData(player);
140 player.warpzone_teleport_time = time;
141 player.warpzone_teleport_finishtime = time;
142 player.warpzone_teleport_zone = wz;
145 // prevent further teleports back
146 float dt = (o1 - o10) * v1 * (1 / (v1 * v1));
147 if(dt < PHYS_INPUT_FRAMETIME)
148 player.warpzone_teleport_finishtime += PHYS_INPUT_FRAMETIME - dt;
151 #ifndef WARPZONE_USE_FIXANGLE
153 if(IS_VEHICLE(player) && player.owner)
154 player = player.owner; // hax
155 if(IS_PLAYER(player))
157 // instead of fixangle, send the transform to the client for smoother operation
158 player.fixangle = false;
160 entity ts = new(warpzone_teleported);
161 setmodel(ts, MDL_Null);
162 setSendEntity(ts, WarpZone_Teleported_Send);
163 ts.SendFlags = 0xFFFFFF;
164 ts.drawonlytoclient = player;
165 setthink(ts, SUB_Remove);
166 ts.nextthink = time + 1;
169 ts.effects = EF_NODEPTHTEST;
170 ts.angles = wz.warpzone_transform;
173 setproperty(VF_CL_VIEWANGLES, WarpZone_TransformVAngles(wz, getpropertyvec(VF_CL_VIEWANGLES)));
174 //if(checkextension("DP_CSQC_ROTATEMOVES"))
175 //CL_RotateMoves(wz.warpzone_transform);
182 void WarpZone_Touch(entity this, entity toucher)
184 if(toucher.classname == "trigger_warpzone")
187 if(time <= toucher.warpzone_teleport_finishtime) // already teleported this frame
190 // FIXME needs a better check to know what is safe to teleport and what not
191 if(toucher.move_movetype == MOVETYPE_NONE || toucher.move_movetype == MOVETYPE_FOLLOW || toucher.tag_entity)
194 if(WarpZoneLib_ExactTrigger_Touch(this, toucher))
197 if(WarpZone_PlaneDist(this, toucher.origin + toucher.view_ofs) >= 0) // wrong side of the trigger_warpzone (don't teleport yet)
201 // number of frames we need to go back:
202 // dist = 16*sqrt(2) qu
205 // 24 qu = v*frametime*n
206 // n = 24 qu/(v*frametime)
207 // for clients go only one frame though, may be too irritating otherwise
208 // but max 0.25 sec = 0.25/frametime frames
209 // 24/(0.25/frametime)
212 d = 24 + max(vlen(toucher.mins), vlen(toucher.maxs));
213 if(IS_NOT_A_CLIENT(toucher))
214 f = -d / bound(frametime * d * 1, frametime * vlen(toucher.velocity), d);
217 if(WarpZone_Teleport(this, toucher, f, 0))
220 SUB_UseTargets_SkipTargets(this, toucher, toucher, BIT(1) | BIT(3)); // use toucher too?
221 SUB_UseTargets_SkipTargets(this.enemy, toucher, toucher, BIT(1) | BIT(2)); // use toucher too?
226 LOG_TRACE("WARPZONE FAIL AHAHAHAHAH))");
231 bool WarpZone_Send(entity this, entity to, int sendflags)
233 WriteHeader(MSG_ENTITY, ENT_CLIENT_WARPZONE);
235 // we must send this flag for clientside to match properly too
237 if(this.warpzone_isboxy)
239 if(this.warpzone_fadestart)
241 if(this.origin != '0 0 0')
243 WriteByte(MSG_ENTITY, f);
245 // we need THESE to render the warpzone (and cull properly)...
248 WriteCoord(MSG_ENTITY, this.origin.x);
249 WriteCoord(MSG_ENTITY, this.origin.y);
250 WriteCoord(MSG_ENTITY, this.origin.z);
253 WriteShort(MSG_ENTITY, this.modelindex);
254 WriteCoord(MSG_ENTITY, this.mins.x);
255 WriteCoord(MSG_ENTITY, this.mins.y);
256 WriteCoord(MSG_ENTITY, this.mins.z);
257 WriteCoord(MSG_ENTITY, this.maxs.x);
258 WriteCoord(MSG_ENTITY, this.maxs.y);
259 WriteCoord(MSG_ENTITY, this.maxs.z);
260 WriteByte(MSG_ENTITY, bound(1, this.scale * 16, 255));
262 // we need THESE to calculate the proper transform
263 WriteCoord(MSG_ENTITY, this.warpzone_origin.x);
264 WriteCoord(MSG_ENTITY, this.warpzone_origin.y);
265 WriteCoord(MSG_ENTITY, this.warpzone_origin.z);
266 WriteCoord(MSG_ENTITY, this.warpzone_angles.x);
267 WriteCoord(MSG_ENTITY, this.warpzone_angles.y);
268 WriteCoord(MSG_ENTITY, this.warpzone_angles.z);
269 WriteCoord(MSG_ENTITY, this.warpzone_targetorigin.x);
270 WriteCoord(MSG_ENTITY, this.warpzone_targetorigin.y);
271 WriteCoord(MSG_ENTITY, this.warpzone_targetorigin.z);
272 WriteCoord(MSG_ENTITY, this.warpzone_targetangles.x);
273 WriteCoord(MSG_ENTITY, this.warpzone_targetangles.y);
274 WriteCoord(MSG_ENTITY, this.warpzone_targetangles.z);
278 WriteShort(MSG_ENTITY, this.warpzone_fadestart);
279 WriteShort(MSG_ENTITY, this.warpzone_fadeend);
285 bool WarpZone_Camera_Send(entity this, entity to, int sendflags)
288 WriteHeader(MSG_ENTITY, ENT_CLIENT_WARPZONE_CAMERA);
290 if(this.warpzone_fadestart)
292 if(this.origin != '0 0 0')
294 WriteByte(MSG_ENTITY, f);
296 // we need THESE to render the warpzone (and cull properly)...
299 WriteCoord(MSG_ENTITY, this.origin.x);
300 WriteCoord(MSG_ENTITY, this.origin.y);
301 WriteCoord(MSG_ENTITY, this.origin.z);
304 WriteShort(MSG_ENTITY, this.modelindex);
305 WriteCoord(MSG_ENTITY, this.mins.x);
306 WriteCoord(MSG_ENTITY, this.mins.y);
307 WriteCoord(MSG_ENTITY, this.mins.z);
308 WriteCoord(MSG_ENTITY, this.maxs.x);
309 WriteCoord(MSG_ENTITY, this.maxs.y);
310 WriteCoord(MSG_ENTITY, this.maxs.z);
311 WriteByte(MSG_ENTITY, bound(1, this.scale * 16, 255));
313 // we need THESE to calculate the proper transform
314 WriteCoord(MSG_ENTITY, this.enemy.origin.x);
315 WriteCoord(MSG_ENTITY, this.enemy.origin.y);
316 WriteCoord(MSG_ENTITY, this.enemy.origin.z);
317 WriteCoord(MSG_ENTITY, this.enemy.angles.x);
318 WriteCoord(MSG_ENTITY, this.enemy.angles.y);
319 WriteCoord(MSG_ENTITY, this.enemy.angles.z);
323 WriteShort(MSG_ENTITY, this.warpzone_fadestart);
324 WriteShort(MSG_ENTITY, this.warpzone_fadeend);
330 #ifdef WARPZONELIB_KEEPDEBUG
331 float WarpZone_CheckProjectileImpact(entity player)
335 o0 = player.origin + player.view_ofs;
336 v0 = player.velocity;
338 // if we teleported shortly before, abort
339 if(time <= player.warpzone_teleport_finishtime + 0.1)
342 // if player hit a warpzone, abort
344 wz = WarpZone_Find(o0 + player.mins, o0 + player.maxs);
348 #ifdef WARPZONELIB_REMOVEHACK
349 LOG_INFO("impactfilter found something - and it no longer gets handled correctly - please tell divVerent whether anything behaves broken now");
351 LOG_INFO("impactfilter found something - and it even gets handled correctly - please tell divVerent that this code apparently gets triggered again");
353 LOG_INFO("Entity type: ", player.classname);
354 LOG_INFO("Origin: ", vtos(player.origin));
355 LOG_INFO("Velocity: ", vtos(player.velocity));
357 #ifdef WARPZONELIB_REMOVEHACK
360 // retry previous move
361 setorigin(player, player.warpzone_oldorigin);
362 player.velocity = player.warpzone_oldvelocity;
363 if(WarpZone_Teleport(wz, player, 0, 1))
365 SUB_UseTargets_SkipTargets(wz, player, player, BIT(1) | BIT(3));
366 SUB_UseTargets_SkipTargets(wz.enemy, player, player, BIT(1) | BIT(2));
370 setorigin(player, o0 - player.view_ofs);
371 player.velocity = v0;
380 float WarpZone_Projectile_Touch(entity this, entity toucher)
382 if(toucher.classname == "trigger_warpzone")
385 // no further impacts if we teleported this frame!
386 // this is because even if we did teleport, the engine still may raise
387 // touch events for the previous location
388 // engine now aborts moves on teleport, so this SHOULD not happen any more
389 // but if this is called from TouchAreaGrid of the projectile moving,
390 // then this won't do
391 if(time == this.warpzone_teleport_time)
395 #ifdef WARPZONELIB_KEEPDEBUG
396 // this SEEMS to not happen at the moment, but if it did, it would be more reliable
398 float save_dpstartcontents;
399 float save_dphitcontents;
400 float save_dphitq3surfaceflags;
401 string save_dphittexturename;
403 float save_startsolid;
406 vector save_plane_normal;
407 float save_plane_dist;
411 save_dpstartcontents = trace_dpstartcontents;
412 save_dphitcontents = trace_dphitcontents;
413 save_dphitq3surfaceflags = trace_dphitq3surfaceflags;
414 save_dphittexturename = trace_dphittexturename;
415 save_allsolid = trace_allsolid;
416 save_startsolid = trace_startsolid;
417 save_fraction = trace_fraction;
418 save_endpos = trace_endpos;
419 save_plane_normal = trace_plane_normal;
420 save_plane_dist = trace_plane_dist;
421 save_ent = trace_ent;
422 save_inopen = trace_inopen;
423 save_inwater = trace_inwater;
424 float f = WarpZone_CheckProjectileImpact(this);
425 if (f) return (f > 0);
426 trace_dpstartcontents = save_dpstartcontents;
427 trace_dphitcontents = save_dphitcontents;
428 trace_dphitq3surfaceflags = save_dphitq3surfaceflags;
429 trace_dphittexturename = save_dphittexturename;
430 trace_allsolid = save_allsolid;
431 trace_startsolid = save_startsolid;
432 trace_fraction = save_fraction;
433 trace_endpos = save_endpos;
434 trace_plane_normal = save_plane_normal;
435 trace_plane_dist = save_plane_dist;
436 trace_ent = save_ent;
437 trace_inopen = save_inopen;
438 trace_inwater = save_inwater;
442 if(WarpZone_Projectile_Touch_ImpactFilter_Callback(this, toucher))
451 void WarpZone_InitStep_FindOriginTarget(entity this)
453 if(this.killtarget != "")
455 this.aiment = find(NULL, targetname, this.killtarget);
456 if(this.aiment == NULL)
458 error("Warp zone with nonexisting killtarget");
461 this.killtarget = string_null;
465 void WarpZonePosition_InitStep_FindTarget(entity this)
467 if(this.target == "")
469 error("Warp zone position with no target");
472 this.enemy = find(NULL, targetname, this.target);
473 if(this.enemy == NULL)
475 error("Warp zone position with nonexisting target");
478 if(this.enemy.aiment)
480 // already is positioned
481 error("Warp zone position targeting already oriented warpzone");
484 this.enemy.aiment = this;
487 void WarpZoneCamera_Think(entity this)
489 if(this.warpzone_save_origin != this.origin
490 || this.warpzone_save_angles != this.angles
491 || this.warpzone_save_eorigin != this.enemy.origin
492 || this.warpzone_save_eangles != this.enemy.angles)
494 WarpZone_Camera_SetUp(this, this.enemy.origin, this.enemy.angles);
495 this.warpzone_save_origin = this.origin;
496 this.warpzone_save_angles = this.angles;
497 this.warpzone_save_eorigin = this.enemy.origin;
498 this.warpzone_save_eangles = this.enemy.angles;
500 this.nextthink = time;
503 void WarpZoneCamera_InitStep_FindTarget(entity this)
507 if(this.target == "")
509 error("Camera with no target");
513 for(e = NULL, i = 0; (e = find(e, targetname, this.target)); )
514 if(random() * ++i < 1)
516 if(this.enemy == NULL)
518 error("Camera with nonexisting target");
521 warpzone_cameras_exist = 1;
522 WarpZone_Camera_SetUp(this, this.enemy.origin, this.enemy.angles);
523 this.SendFlags = 0xFFFFFF;
524 if(this.spawnflags & 1)
526 setthink(this, WarpZoneCamera_Think);
527 this.nextthink = time;
533 void WarpZone_InitStep_UpdateTransform(entity this)
535 vector org, ang, norm, point;
537 vector tri, a, b, c, n;
543 org = 0.5 * (this.mins + this.maxs);
545 norm = point = '0 0 0';
547 for(i_s = 0; ; ++i_s)
549 tex = getsurfacetexture(this, i_s);
551 break; // this is beyond the last one
552 if(tex == "textures/common/trigger" || tex == "trigger")
554 n_t = getsurfacenumtriangles(this, i_s);
555 for(i_t = 0; i_t < n_t; ++i_t)
557 tri = getsurfacetriangle(this, i_s, i_t);
558 a = getsurfacepoint(this, i_s, tri.x);
559 b = getsurfacepoint(this, i_s, tri.y);
560 c = getsurfacepoint(this, i_s, tri.z);
561 n = cross(c - a, b - a);
562 area = area + vlen(n);
564 point = point + vlen(n) * (a + b + c);
569 norm = norm * (1 / area);
570 point = point * (1 / (3 * area));
571 if(vdist(norm, <, 0.99))
573 LOG_INFO("trigger_warpzone near ", vtos(this.aiment.origin), " is nonplanar. BEWARE.");
574 area = 0; // no autofixing in this case
576 norm = normalize(norm);
582 org = this.aiment.origin;
583 ang = this.aiment.angles;
586 org = org - ((org - point) * norm) * norm; // project to plane
587 vector forward, right, up;
588 MAKE_VECTORS(ang, forward, right, up);
589 if(norm * forward < 0)
591 LOG_INFO("Position target of trigger_warpzone near ", vtos(this.aiment.origin), " points into trigger_warpzone. BEWARE.");
594 ang = vectoangles2(norm, up); // keep rotation, but turn exactly against plane
596 if(norm * forward < 0.99)
597 LOG_INFO("trigger_warpzone near ", vtos(this.aiment.origin), " has been turned to match plane orientation (", vtos(this.aiment.angles), " -> ", vtos(ang));
598 if(vdist(org - this.aiment.origin, >, 0.5))
599 LOG_INFO("trigger_warpzone near ", vtos(this.aiment.origin), " has been moved to match the plane (", vtos(this.aiment.origin), " -> ", vtos(org), ").");
605 ang = vectoangles(norm);
609 error("cannot infer origin/angles for this warpzone, please use a killtarget or a trigger_warpzone_position");
611 this.warpzone_origin = org;
612 this.warpzone_angles = ang;
615 void WarpZone_InitStep_ClearTarget(entity this)
618 this.enemy.enemy = NULL;
622 void WarpZone_InitStep_FindTarget(entity this)
630 // this way only one of the two ents needs to target
631 if(this.target != "")
633 if(!autocvar_sv_warpzone_allow_selftarget)
634 this.enemy = this; // so the if(!e.enemy) check also skips this, saves one IF
637 for(e = NULL, i = 0; (e = find(e, targetname, this.target)); )
639 if(e.classname == this.classname) // possibly non-warpzones may use the same targetname!
640 if(random() * ++i < 1)
645 error("Warpzone with non-existing target");
653 void WarpZone_Think(entity this);
654 void WarpZone_InitStep_FinalizeTransform(entity this)
656 if(!this.enemy || this.enemy.enemy != this)
658 error("Invalid warp zone detected. Killed.");
662 warpzone_warpzones_exist = 1;
663 WarpZone_SetUp(this, this.warpzone_origin, this.warpzone_angles, this.enemy.warpzone_origin, this.enemy.warpzone_angles);
664 settouch(this, WarpZone_Touch);
665 this.SendFlags = 0xFFFFFF;
666 if(this.spawnflags & 1)
668 setthink(this, WarpZone_Think);
669 this.nextthink = time;
675 float warpzone_initialized;
676 //entity warpzone_first;
677 entity warpzone_position_first;
678 entity warpzone_camera_first;
679 .entity warpzone_next;
680 spawnfunc(misc_warpzone_position)
682 // "target", "angles", "origin"
683 this.warpzone_next = warpzone_position_first;
684 warpzone_position_first = this;
686 spawnfunc(trigger_warpzone_position)
688 spawnfunc_misc_warpzone_position(this);
690 spawnfunc(trigger_warpzone)
692 // warp zone entities must have:
693 // "killtarget" pointing to a target_position with a direction arrow
694 // that points AWAY from the warp zone, and that is inside
695 // the warp zone trigger
696 // "target" pointing to an identical warp zone at another place in
697 // the map, with another killtarget to designate its
701 this.scale = this.modelscale;
706 WarpZoneLib_ExactTrigger_Init(this);
710 _setmodel(this, m); // no precision needed
712 setorigin(this, this.origin);
714 setsize(this, this.mins * this.scale, this.maxs * this.scale);
716 setsize(this, this.mins, this.maxs);
717 setSendEntity(this, WarpZone_Send);
718 this.SendFlags = 0xFFFFFF;
719 BITSET_ASSIGN(this.effects, EF_NODEPTHTEST);
720 this.warpzone_next = warpzone_first;
721 warpzone_first = this;
723 IL_PUSH(g_warpzones, this);
725 spawnfunc(func_camera)
728 this.scale = this.modelscale;
733 precache_model(this.model);
734 _setmodel(this, this.model); // no precision needed
736 setorigin(this, this.origin);
738 setsize(this, this.mins * this.scale, this.maxs * this.scale);
740 setsize(this, this.mins, this.maxs);
742 this.solid = SOLID_BSP;
743 else if(this.solid < 0)
744 this.solid = SOLID_NOT;
745 setSendEntity(this, WarpZone_Camera_Send);
746 this.SendFlags = 0xFFFFFF;
747 this.warpzone_next = warpzone_camera_first;
748 warpzone_camera_first = this;
750 void WarpZones_Reconnect()
752 for(entity e = warpzone_first; e; e = e.warpzone_next)
753 WarpZone_InitStep_ClearTarget(e);
754 for(entity e = warpzone_first; e; e = e.warpzone_next)
755 WarpZone_InitStep_FindTarget(e);
756 for(entity e = warpzone_camera_first; e; e = e.warpzone_next)
757 WarpZoneCamera_InitStep_FindTarget(e);
758 for(entity e = warpzone_first; e; e = e.warpzone_next)
759 WarpZone_InitStep_FinalizeTransform(e);
762 void WarpZone_Think(entity this)
764 if(this.warpzone_save_origin != this.origin
765 || this.warpzone_save_angles != this.angles
766 || this.warpzone_save_eorigin != this.enemy.origin
767 || this.warpzone_save_eangles != this.enemy.angles)
769 WarpZone_InitStep_UpdateTransform(this);
770 WarpZone_InitStep_UpdateTransform(this.enemy);
771 WarpZone_InitStep_FinalizeTransform(this);
772 WarpZone_InitStep_FinalizeTransform(this.enemy);
773 this.warpzone_save_origin = this.origin;
774 this.warpzone_save_angles = this.angles;
775 this.warpzone_save_eorigin = this.enemy.origin;
776 this.warpzone_save_eangles = this.enemy.angles;
778 this.nextthink = time;
781 void WarpZone_StartFrame()
783 if (!warpzone_initialized)
785 warpzone_initialized = true;
786 for(entity e = warpzone_first; e; e = e.warpzone_next)
787 WarpZone_InitStep_FindOriginTarget(e);
788 for(entity e = warpzone_position_first; e; e = e.warpzone_next)
789 WarpZonePosition_InitStep_FindTarget(e);
790 for(entity e = warpzone_first; e; e = e.warpzone_next)
791 WarpZone_InitStep_UpdateTransform(e);
792 WarpZones_Reconnect();
793 WarpZone_PostInitialize_Callback();
796 if(warpzone_warpzones_exist)
798 IL_EACH(g_projectiles, true,
800 WarpZone_StoreProjectileData(it);
807 if(warpzone_warpzones_exist)
808 WarpZone_StoreProjectileData(it); // TODO: not actually needed
810 if(IS_OBSERVER(it) || it.solid == SOLID_NOT)
811 if(IS_CLIENT(it)) // we don't care about it being a bot
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))
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))
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