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 player.lastteleport_origin = player.origin;
41 player.lastteleporttime = time;
42 setorigin(player, to); // NOTE: this also aborts the move, when this is called by touch
44 player.oldorigin = to; // for DP's unsticking
45 player.fixangle = true;
47 player.angles = to_angles;
48 player.velocity = to_velocity;
50 BITXOR_ASSIGN(player.effects, EF_TELEPORT_BIT);
53 BITCLR_ASSIGN(player.flags, FL_ONGROUND);
55 WarpZone_PostTeleportPlayer_Callback(player);
59 bool WarpZone_Teleported_Send(entity this, entity to, int sf)
61 WriteHeader(MSG_ENTITY, ENT_CLIENT_WARPZONE_TELEPORTED);
62 WriteCoord(MSG_ENTITY, this.angles.x);
63 WriteCoord(MSG_ENTITY, this.angles.y);
64 WriteCoord(MSG_ENTITY, this.angles.z);
69 float WarpZone_Teleport(entity wz, entity player, float f0, float f1)
71 vector o0, a0, v0, o1, a1, v1, o10;
73 o0 = player.origin + player.view_ofs;
77 o10 = o1 = WarpZone_TransformOrigin(wz, o0);
78 v1 = WarpZone_TransformVelocity(wz, v0);
79 if (!IS_NOT_A_CLIENT(player))
80 a1 = WarpZone_TransformVAngles(wz, PHYS_INPUT_ANGLES(player));
82 a1 = WarpZone_TransformAngles(wz, a0);
84 if(f0 != 0 || f1 != 0)
86 // retry last move but behind the warpzone!
87 // we must first go back as far as we can, then forward again, to not cause double touch events!
89 tracebox(o1 - player.view_ofs + v1 * frametime * f1, player.mins, player.maxs, o1 - player.view_ofs + v1 * frametime * f0, MOVE_WORLDONLY, player);
94 tracebox(trace_endpos, player.mins, player.maxs, o1 - player.view_ofs + v1 * frametime * f1, MOVE_NORMAL, player); // this should get us through the warpzone
97 o1 = trace_endpos + player.view_ofs;
100 md = max(vlen(player.mins), vlen(player.maxs));
101 d = WarpZone_TargetPlaneDist(wz, o1);
102 dv = WarpZone_TargetPlaneDist(wz, v1);
104 o1 = o1 - v1 * (d / dv);
107 // put him out of solid
108 tracebox(o1 - player.view_ofs, player.mins, player.maxs, o1 - player.view_ofs, MOVE_NOMONSTERS, player);
111 setorigin(player, o1 - player.view_ofs);
112 if(WarpZoneLib_MoveOutOfSolid(player))
114 o1 = player.origin + player.view_ofs;
115 setorigin(player, o0 - player.view_ofs);
119 LOG_INFO("would have to put player in solid, won't do that");
120 setorigin(player, o0 - player.view_ofs);
126 WarpZone_RefSys_Add(player, wz);
127 WarpZone_TeleportPlayer(wz, player, o1 - player.view_ofs, a1, v1);
128 WarpZone_StoreProjectileData(player);
129 player.warpzone_teleport_time = time;
130 player.warpzone_teleport_finishtime = time;
131 player.warpzone_teleport_zone = wz;
134 // prevent further teleports back
135 float dt = (o1 - o10) * v1 * (1 / (v1 * v1));
136 if(dt < PHYS_INPUT_FRAMETIME)
137 player.warpzone_teleport_finishtime += PHYS_INPUT_FRAMETIME - dt;
140 #ifndef WARPZONE_USE_FIXANGLE
142 if(IS_VEHICLE(player) && player.owner)
143 player = player.owner; // hax
144 if(IS_PLAYER(player))
146 // instead of fixangle, send the transform to the client for smoother operation
147 player.fixangle = false;
149 entity ts = new(warpzone_teleported);
150 setmodel(ts, MDL_Null);
151 setSendEntity(ts, WarpZone_Teleported_Send);
152 ts.SendFlags = 0xFFFFFF;
153 ts.drawonlytoclient = player;
154 setthink(ts, SUB_Remove);
155 ts.nextthink = time + 1;
158 ts.effects = EF_NODEPTHTEST;
159 ts.angles = wz.warpzone_transform;
162 setproperty(VF_CL_VIEWANGLES, WarpZone_TransformVAngles(wz, getpropertyvec(VF_CL_VIEWANGLES)));
163 //if(checkextension("DP_CSQC_ROTATEMOVES"))
164 //CL_RotateMoves(wz.warpzone_transform);
171 void WarpZone_Touch(entity this, entity toucher)
173 if(toucher.classname == "trigger_warpzone")
176 if(time <= toucher.warpzone_teleport_finishtime) // already teleported this frame
179 // FIXME needs a better check to know what is safe to teleport and what not
180 if((toucher.move_movetype == MOVETYPE_NONE && toucher.move_movetype == MOVETYPE_NONE) || toucher.move_movetype == MOVETYPE_FOLLOW || toucher.move_movetype == MOVETYPE_FOLLOW || toucher.tag_entity
187 if(WarpZoneLib_ExactTrigger_Touch(this, toucher))
190 if(WarpZone_PlaneDist(this, toucher.origin + toucher.view_ofs) >= 0) // wrong side of the trigger_warpzone (don't teleport yet)
194 // number of frames we need to go back:
195 // dist = 16*sqrt(2) qu
198 // 24 qu = v*frametime*n
199 // n = 24 qu/(v*frametime)
200 // for clients go only one frame though, may be too irritating otherwise
201 // but max 0.25 sec = 0.25/frametime frames
202 // 24/(0.25/frametime)
205 d = 24 + max(vlen(toucher.mins), vlen(toucher.maxs));
206 if(IS_NOT_A_CLIENT(toucher))
207 f = -d / bound(frametime * d * 1, frametime * vlen(toucher.velocity), d);
210 if(WarpZone_Teleport(this, toucher, f, 0))
215 save1 = this.target; this.target = string_null;
216 save2 = this.target3; this.target3 = string_null;
217 SUB_UseTargets(this, toucher, toucher); // use toucher too?
218 if (!this.target) this.target = save1;
219 if (!this.target3) this.target3 = save2;
221 save1 = this.target; this.target = string_null;
222 save2 = this.target2; this.target2 = string_null;
223 SUB_UseTargets(this.enemy, toucher, toucher); // use toucher too?
224 if (!this.target) this.target = save1;
225 if (!this.target2) this.target2 = save2;
230 LOG_TRACE("WARPZONE FAIL AHAHAHAHAH))");
235 bool WarpZone_Send(entity this, entity to, int sendflags)
237 WriteHeader(MSG_ENTITY, ENT_CLIENT_WARPZONE);
239 // we must send this flag for clientside to match properly too
241 if(this.warpzone_isboxy)
243 if(this.warpzone_fadestart)
245 if(this.origin != '0 0 0')
247 WriteByte(MSG_ENTITY, f);
249 // we need THESE to render the warpzone (and cull properly)...
252 WriteCoord(MSG_ENTITY, this.origin.x);
253 WriteCoord(MSG_ENTITY, this.origin.y);
254 WriteCoord(MSG_ENTITY, this.origin.z);
257 WriteShort(MSG_ENTITY, this.modelindex);
258 WriteCoord(MSG_ENTITY, this.mins.x);
259 WriteCoord(MSG_ENTITY, this.mins.y);
260 WriteCoord(MSG_ENTITY, this.mins.z);
261 WriteCoord(MSG_ENTITY, this.maxs.x);
262 WriteCoord(MSG_ENTITY, this.maxs.y);
263 WriteCoord(MSG_ENTITY, this.maxs.z);
264 WriteByte(MSG_ENTITY, bound(1, this.scale * 16, 255));
266 // we need THESE to calculate the proper transform
267 WriteCoord(MSG_ENTITY, this.warpzone_origin.x);
268 WriteCoord(MSG_ENTITY, this.warpzone_origin.y);
269 WriteCoord(MSG_ENTITY, this.warpzone_origin.z);
270 WriteCoord(MSG_ENTITY, this.warpzone_angles.x);
271 WriteCoord(MSG_ENTITY, this.warpzone_angles.y);
272 WriteCoord(MSG_ENTITY, this.warpzone_angles.z);
273 WriteCoord(MSG_ENTITY, this.warpzone_targetorigin.x);
274 WriteCoord(MSG_ENTITY, this.warpzone_targetorigin.y);
275 WriteCoord(MSG_ENTITY, this.warpzone_targetorigin.z);
276 WriteCoord(MSG_ENTITY, this.warpzone_targetangles.x);
277 WriteCoord(MSG_ENTITY, this.warpzone_targetangles.y);
278 WriteCoord(MSG_ENTITY, this.warpzone_targetangles.z);
282 WriteShort(MSG_ENTITY, this.warpzone_fadestart);
283 WriteShort(MSG_ENTITY, this.warpzone_fadeend);
289 bool WarpZone_Camera_Send(entity this, entity to, int sendflags)
292 WriteHeader(MSG_ENTITY, ENT_CLIENT_WARPZONE_CAMERA);
294 if(this.warpzone_fadestart)
296 if(this.origin != '0 0 0')
298 WriteByte(MSG_ENTITY, f);
300 // we need THESE to render the warpzone (and cull properly)...
303 WriteCoord(MSG_ENTITY, this.origin.x);
304 WriteCoord(MSG_ENTITY, this.origin.y);
305 WriteCoord(MSG_ENTITY, this.origin.z);
308 WriteShort(MSG_ENTITY, this.modelindex);
309 WriteCoord(MSG_ENTITY, this.mins.x);
310 WriteCoord(MSG_ENTITY, this.mins.y);
311 WriteCoord(MSG_ENTITY, this.mins.z);
312 WriteCoord(MSG_ENTITY, this.maxs.x);
313 WriteCoord(MSG_ENTITY, this.maxs.y);
314 WriteCoord(MSG_ENTITY, this.maxs.z);
315 WriteByte(MSG_ENTITY, bound(1, this.scale * 16, 255));
317 // we need THESE to calculate the proper transform
318 WriteCoord(MSG_ENTITY, this.enemy.origin.x);
319 WriteCoord(MSG_ENTITY, this.enemy.origin.y);
320 WriteCoord(MSG_ENTITY, this.enemy.origin.z);
321 WriteCoord(MSG_ENTITY, this.enemy.angles.x);
322 WriteCoord(MSG_ENTITY, this.enemy.angles.y);
323 WriteCoord(MSG_ENTITY, this.enemy.angles.z);
327 WriteShort(MSG_ENTITY, this.warpzone_fadestart);
328 WriteShort(MSG_ENTITY, this.warpzone_fadeend);
334 #ifdef WARPZONELIB_KEEPDEBUG
335 float WarpZone_CheckProjectileImpact(entity player)
339 o0 = player.origin + player.view_ofs;
340 v0 = player.velocity;
342 // if we teleported shortly before, abort
343 if(time <= player.warpzone_teleport_finishtime + 0.1)
346 // if player hit a warpzone, abort
348 wz = WarpZone_Find(o0 + player.mins, o0 + player.maxs);
352 #ifdef WARPZONELIB_REMOVEHACK
353 LOG_INFO("impactfilter found something - and it no longer gets handled correctly - please tell divVerent whether anything behaves broken now");
355 LOG_INFO("impactfilter found something - and it even gets handled correctly - please tell divVerent that this code apparently gets triggered again");
357 LOG_INFO("Entity type: ", player.classname);
358 LOG_INFO("Origin: ", vtos(player.origin));
359 LOG_INFO("Velocity: ", vtos(player.velocity));
361 #ifdef WARPZONELIB_REMOVEHACK
364 // retry previous move
365 setorigin(player, player.warpzone_oldorigin);
366 player.velocity = player.warpzone_oldvelocity;
367 if(WarpZone_Teleport(wz, player, 0, 1))
371 save1 = wz.target; wz.target = string_null;
372 save2 = wz.target3; wz.target3 = string_null;
373 SUB_UseTargets(wz, player, player);
374 if (!wz.target) wz.target = save1;
375 if (!wz.target3) wz.target3 = save2;
377 save1 = wz.enemy.target; wz.enemy.target = string_null;
378 save2 = wz.enemy.target2; wz.enemy.target2 = string_null;
379 SUB_UseTargets(wz.enemy, player, player);
380 if (!wz.enemy.target) wz.enemy.target = save1;
381 if (!wz.enemy.target2) wz.enemy.target2 = save2;
385 setorigin(player, o0 - player.view_ofs);
386 player.velocity = v0;
395 float WarpZone_Projectile_Touch(entity this, entity toucher)
397 if(toucher.classname == "trigger_warpzone")
400 // no further impacts if we teleported this frame!
401 // this is because even if we did teleport, the engine still may raise
402 // touch events for the previous location
403 // engine now aborts moves on teleport, so this SHOULD not happen any more
404 // but if this is called from TouchAreaGrid of the projectile moving,
405 // then this won't do
406 if(time == this.warpzone_teleport_time)
410 #ifdef WARPZONELIB_KEEPDEBUG
411 // this SEEMS to not happen at the moment, but if it did, it would be more reliable
413 float save_dpstartcontents;
414 float save_dphitcontents;
415 float save_dphitq3surfaceflags;
416 string save_dphittexturename;
418 float save_startsolid;
421 vector save_plane_normal;
422 float save_plane_dist;
426 save_dpstartcontents = trace_dpstartcontents;
427 save_dphitcontents = trace_dphitcontents;
428 save_dphitq3surfaceflags = trace_dphitq3surfaceflags;
429 save_dphittexturename = trace_dphittexturename;
430 save_allsolid = trace_allsolid;
431 save_startsolid = trace_startsolid;
432 save_fraction = trace_fraction;
433 save_endpos = trace_endpos;
434 save_plane_normal = trace_plane_normal;
435 save_plane_dist = trace_plane_dist;
436 save_ent = trace_ent;
437 save_inopen = trace_inopen;
438 save_inwater = trace_inwater;
439 float f = WarpZone_CheckProjectileImpact(this);
440 if (f) return (f > 0);
441 trace_dpstartcontents = save_dpstartcontents;
442 trace_dphitcontents = save_dphitcontents;
443 trace_dphitq3surfaceflags = save_dphitq3surfaceflags;
444 trace_dphittexturename = save_dphittexturename;
445 trace_allsolid = save_allsolid;
446 trace_startsolid = save_startsolid;
447 trace_fraction = save_fraction;
448 trace_endpos = save_endpos;
449 trace_plane_normal = save_plane_normal;
450 trace_plane_dist = save_plane_dist;
451 trace_ent = save_ent;
452 trace_inopen = save_inopen;
453 trace_inwater = save_inwater;
457 if(WarpZone_Projectile_Touch_ImpactFilter_Callback(this, toucher))
466 void WarpZone_InitStep_FindOriginTarget(entity this)
468 if(this.killtarget != "")
470 this.aiment = find(NULL, targetname, this.killtarget);
471 if(this.aiment == NULL)
473 error("Warp zone with nonexisting killtarget");
476 this.killtarget = string_null;
480 void WarpZonePosition_InitStep_FindTarget(entity this)
482 if(this.target == "")
484 error("Warp zone position with no target");
487 this.enemy = find(NULL, targetname, this.target);
488 if(this.enemy == NULL)
490 error("Warp zone position with nonexisting target");
493 if(this.enemy.aiment)
495 // already is positioned
496 error("Warp zone position targeting already oriented warpzone");
499 this.enemy.aiment = this;
502 void WarpZoneCamera_Think(entity this)
504 if(this.warpzone_save_origin != this.origin
505 || this.warpzone_save_angles != this.angles
506 || this.warpzone_save_eorigin != this.enemy.origin
507 || this.warpzone_save_eangles != this.enemy.angles)
509 WarpZone_Camera_SetUp(this, this.enemy.origin, this.enemy.angles);
510 this.warpzone_save_origin = this.origin;
511 this.warpzone_save_angles = this.angles;
512 this.warpzone_save_eorigin = this.enemy.origin;
513 this.warpzone_save_eangles = this.enemy.angles;
515 this.nextthink = time;
518 void WarpZoneCamera_InitStep_FindTarget(entity this)
522 if(this.target == "")
524 error("Camera with no target");
528 for(e = NULL, i = 0; (e = find(e, targetname, this.target)); )
529 if(random() * ++i < 1)
531 if(this.enemy == NULL)
533 error("Camera with nonexisting target");
536 warpzone_cameras_exist = 1;
537 WarpZone_Camera_SetUp(this, this.enemy.origin, this.enemy.angles);
538 this.SendFlags = 0xFFFFFF;
539 if(this.spawnflags & 1)
541 setthink(this, WarpZoneCamera_Think);
542 this.nextthink = time;
548 void WarpZone_InitStep_UpdateTransform(entity this)
550 vector org, ang, norm, point;
552 vector tri, a, b, c, n;
558 org = 0.5 * (this.mins + this.maxs);
560 norm = point = '0 0 0';
562 for(i_s = 0; ; ++i_s)
564 tex = getsurfacetexture(this, i_s);
566 break; // this is beyond the last one
567 if(tex == "textures/common/trigger" || tex == "trigger")
569 n_t = getsurfacenumtriangles(this, i_s);
570 for(i_t = 0; i_t < n_t; ++i_t)
572 tri = getsurfacetriangle(this, i_s, i_t);
573 a = getsurfacepoint(this, i_s, tri.x);
574 b = getsurfacepoint(this, i_s, tri.y);
575 c = getsurfacepoint(this, i_s, tri.z);
576 n = cross(c - a, b - a);
577 area = area + vlen(n);
579 point = point + vlen(n) * (a + b + c);
584 norm = norm * (1 / area);
585 point = point * (1 / (3 * area));
586 if(vdist(norm, <, 0.99))
588 LOG_INFO("trigger_warpzone near ", vtos(this.aiment.origin), " is nonplanar. BEWARE.");
589 area = 0; // no autofixing in this case
591 norm = normalize(norm);
597 org = this.aiment.origin;
598 ang = this.aiment.angles;
601 org = org - ((org - point) * norm) * norm; // project to plane
603 if(norm * v_forward < 0)
605 LOG_INFO("Position target of trigger_warpzone near ", vtos(this.aiment.origin), " points into trigger_warpzone. BEWARE.");
608 ang = vectoangles2(norm, v_up); // keep rotation, but turn exactly against plane
610 if(norm * v_forward < 0.99)
611 LOG_INFO("trigger_warpzone near ", vtos(this.aiment.origin), " has been turned to match plane orientation (", vtos(this.aiment.angles), " -> ", vtos(ang));
612 if(vdist(org - this.aiment.origin, >, 0.5))
613 LOG_INFO("trigger_warpzone near ", vtos(this.aiment.origin), " has been moved to match the plane (", vtos(this.aiment.origin), " -> ", vtos(org), ").");
619 ang = vectoangles(norm);
623 error("cannot infer origin/angles for this warpzone, please use a killtarget or a trigger_warpzone_position");
625 this.warpzone_origin = org;
626 this.warpzone_angles = ang;
629 void WarpZone_InitStep_ClearTarget(entity this)
632 this.enemy.enemy = NULL;
636 void WarpZone_InitStep_FindTarget(entity this)
644 // this way only one of the two ents needs to target
645 if(this.target != "")
647 this.enemy = this; // so the if(!e.enemy) check also skips this, saves one IF
650 for(e = NULL, i = 0; (e = find(e, targetname, this.target)); )
652 if(e.classname == this.classname) // possibly non-warpzones may use the same targetname!
653 if(random() * ++i < 1)
658 error("Warpzone with non-existing target");
666 void WarpZone_Think(entity this);
667 void WarpZone_InitStep_FinalizeTransform(entity this)
669 if(!this.enemy || this.enemy.enemy != this)
671 error("Invalid warp zone detected. Killed.");
675 warpzone_warpzones_exist = 1;
676 WarpZone_SetUp(this, this.warpzone_origin, this.warpzone_angles, this.enemy.warpzone_origin, this.enemy.warpzone_angles);
677 settouch(this, WarpZone_Touch);
678 this.SendFlags = 0xFFFFFF;
679 if(this.spawnflags & 1)
681 setthink(this, WarpZone_Think);
682 this.nextthink = time;
688 float warpzone_initialized;
689 //entity warpzone_first;
690 entity warpzone_position_first;
691 entity warpzone_camera_first;
692 .entity warpzone_next;
693 spawnfunc(misc_warpzone_position)
695 // "target", "angles", "origin"
696 this.warpzone_next = warpzone_position_first;
697 warpzone_position_first = this;
699 spawnfunc(trigger_warpzone_position)
701 spawnfunc_misc_warpzone_position(this);
703 spawnfunc(trigger_warpzone)
705 // warp zone entities must have:
706 // "killtarget" pointing to a target_position with a direction arrow
707 // that points AWAY from the warp zone, and that is inside
708 // the warp zone trigger
709 // "target" pointing to an identical warp zone at another place in
710 // the map, with another killtarget to designate its
714 this.scale = this.modelscale;
719 WarpZoneLib_ExactTrigger_Init(this);
723 _setmodel(this, m); // no precision needed
725 setorigin(this, this.origin);
727 setsize(this, this.mins * this.scale, this.maxs * this.scale);
729 setsize(this, this.mins, this.maxs);
730 setSendEntity(this, WarpZone_Send);
731 this.SendFlags = 0xFFFFFF;
732 BITSET_ASSIGN(this.effects, EF_NODEPTHTEST);
733 this.warpzone_next = warpzone_first;
734 warpzone_first = this;
736 IL_PUSH(g_warpzones, this);
738 spawnfunc(func_camera)
741 this.scale = this.modelscale;
746 precache_model(this.model);
747 _setmodel(this, this.model); // no precision needed
749 setorigin(this, this.origin);
751 setsize(this, this.mins * this.scale, this.maxs * this.scale);
753 setsize(this, this.mins, this.maxs);
755 this.solid = SOLID_BSP;
756 else if(this.solid < 0)
757 this.solid = SOLID_NOT;
758 setSendEntity(this, WarpZone_Camera_Send);
759 this.SendFlags = 0xFFFFFF;
760 this.warpzone_next = warpzone_camera_first;
761 warpzone_camera_first = this;
763 void WarpZones_Reconnect()
765 for(entity e = warpzone_first; e; e = e.warpzone_next)
766 WarpZone_InitStep_ClearTarget(e);
767 for(entity e = warpzone_first; e; e = e.warpzone_next)
768 WarpZone_InitStep_FindTarget(e);
769 for(entity e = warpzone_camera_first; e; e = e.warpzone_next)
770 WarpZoneCamera_InitStep_FindTarget(e);
771 for(entity e = warpzone_first; e; e = e.warpzone_next)
772 WarpZone_InitStep_FinalizeTransform(e);
775 void WarpZone_Think(entity this)
777 if(this.warpzone_save_origin != this.origin
778 || this.warpzone_save_angles != this.angles
779 || this.warpzone_save_eorigin != this.enemy.origin
780 || this.warpzone_save_eangles != this.enemy.angles)
782 WarpZone_InitStep_UpdateTransform(this);
783 WarpZone_InitStep_UpdateTransform(this.enemy);
784 WarpZone_InitStep_FinalizeTransform(this);
785 WarpZone_InitStep_FinalizeTransform(this.enemy);
786 this.warpzone_save_origin = this.origin;
787 this.warpzone_save_angles = this.angles;
788 this.warpzone_save_eorigin = this.enemy.origin;
789 this.warpzone_save_eangles = this.enemy.angles;
791 this.nextthink = time;
794 void WarpZone_StartFrame()
796 if (!warpzone_initialized)
798 warpzone_initialized = true;
799 for(entity e = warpzone_first; e; e = e.warpzone_next)
800 WarpZone_InitStep_FindOriginTarget(e);
801 for(entity e = warpzone_position_first; e; e = e.warpzone_next)
802 WarpZonePosition_InitStep_FindTarget(e);
803 for(entity e = warpzone_first; e; e = e.warpzone_next)
804 WarpZone_InitStep_UpdateTransform(e);
805 WarpZones_Reconnect();
806 WarpZone_PostInitialize_Callback();
809 if(warpzone_warpzones_exist)
811 IL_EACH(g_projectiles, true,
813 WarpZone_StoreProjectileData(it);
820 if(warpzone_warpzones_exist)
821 WarpZone_StoreProjectileData(it); // TODO: not actually needed
823 if(IS_OBSERVER(it) || it.solid == SOLID_NOT)
824 if(IS_CLIENT(it)) // we don't care about it being a bot
827 if (warpzone_warpzones_exist) {
828 entity e = WarpZone_Find(it.origin + it.mins, it.origin + it.maxs);
830 if (!WarpZoneLib_ExactTrigger_Touch(e, it))
831 if (WarpZone_PlaneDist(e, it.origin + it.view_ofs) <= 0)
832 WarpZone_Teleport(e, it, -1, 0); // NOT triggering targets by this!
838 entity ent = Teleport_Find(it.origin + it.mins, it.origin + it.maxs);
840 if (!WarpZoneLib_ExactTrigger_Touch(ent, it))
841 Simple_TeleportPlayer(ent, it); // NOT triggering targets by this!
847 .float warpzone_reconnecting;
848 bool visible_to_some_client(entity ent)
850 FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it) && checkpvs(it.origin + it.view_ofs, ent),
856 void trigger_warpzone_reconnect_use(entity this, entity actor, entity trigger)
858 // NOTE: this matches for target, not targetname, but of course
859 // targetname must be set too on the other entities
860 for(entity e = warpzone_first; e; e = e.warpzone_next)
861 e.warpzone_reconnecting = ((this.target == "" || e.target == this.target) && !((this.spawnflags & 1) && (visible_to_some_client(e) || visible_to_some_client(e.enemy))));
862 for(entity e = warpzone_camera_first; e; e = e.warpzone_next)
863 e.warpzone_reconnecting = ((this.target == "" || e.target == this.target) && !((this.spawnflags & 1) && visible_to_some_client(e)));
864 for(entity e = warpzone_first; e; e = e.warpzone_next)
865 if(e.warpzone_reconnecting)
866 WarpZone_InitStep_ClearTarget(e);
867 for(entity e = warpzone_first; e; e = e.warpzone_next)
868 if(e.warpzone_reconnecting)
869 WarpZone_InitStep_FindTarget(e);
870 for(entity e = warpzone_camera_first; e; e = e.warpzone_next)
871 if(e.warpzone_reconnecting)
872 WarpZoneCamera_InitStep_FindTarget(e);
873 for(entity e = warpzone_first; e; e = e.warpzone_next)
874 if(e.warpzone_reconnecting || e.enemy.warpzone_reconnecting)
875 WarpZone_InitStep_FinalizeTransform(e);
878 spawnfunc(trigger_warpzone_reconnect)
880 this.use = trigger_warpzone_reconnect_use;
883 spawnfunc(target_warpzone_reconnect)
885 spawnfunc_trigger_warpzone_reconnect(this); // both names make sense here :(
888 void WarpZone_PlayerPhysics_FixVAngle(entity this)
890 #ifndef WARPZONE_DONT_FIX_VANGLE
891 if(IS_REAL_CLIENT(this))
892 if(this.v_angle.z <= 360) // if not already adjusted
893 if(time - CS(this).ping * 0.001 < this.warpzone_teleport_time)
895 this.v_angle = WarpZone_TransformVAngles(this.warpzone_teleport_zone, this.v_angle);
896 this.v_angle_z += 720; // mark as adjusted