4 #include <common/t_items.qh>
7 #include <common/weapons/all.qh>
10 void WarpZone_Accumulator_Clear(entity acc)
12 acc.warpzone_transform = '0 0 0';
13 acc.warpzone_shift = '0 0 0';
15 void WarpZone_Accumulator_AddTransform(entity acc, vector t, vector s)
18 tr = AnglesTransform_Multiply(t, acc.warpzone_transform);
19 st = AnglesTransform_Multiply_GetPostShift(t, s, acc.warpzone_transform, acc.warpzone_shift);
20 acc.warpzone_transform = tr;
21 acc.warpzone_shift = st;
23 void WarpZone_Accumulator_Add(entity acc, entity wz)
25 WarpZone_Accumulator_AddTransform(acc, wz.warpzone_transform, wz.warpzone_shift);
27 void WarpZone_Accumulator_AddInverseTransform(entity acc, vector t, vector s)
30 tt = AnglesTransform_Invert(t);
31 ss = AnglesTransform_PrePostShift_GetPostShift(s, tt, '0 0 0');
32 WarpZone_Accumulator_AddTransform(acc, tt, ss);
33 // yes, this probably can be done simpler... but this way is "obvious" :)
35 void WarpZone_Accumulator_AddInverse(entity acc, entity wz)
37 WarpZone_Accumulator_AddInverseTransform(acc, wz.warpzone_transform, wz.warpzone_shift);
40 .vector(vector, vector) camera_transform;
41 float autocvar_cl_warpzone_usetrace = 1;
42 vector WarpZone_camera_transform(vector org, vector ang)
45 if(this.warpzone_fadestart)
46 if(vdist(org - this.origin - 0.5 * (this.mins + this.maxs), >, this.warpzone_fadeend + 400))
48 // don't transform if zone faded out (plus 400qu safety margin for typical speeds and latencies)
49 // unneeded on client, on server this helps a lot
53 org = WarpZone_TransformOrigin(this, org);
54 vf = WarpZone_TransformVelocity(this, vf);
55 vr = WarpZone_TransformVelocity(this, vr);
56 vu = WarpZone_TransformVelocity(this, vu);
57 if(autocvar_cl_warpzone_usetrace)
58 traceline(this.warpzone_targetorigin, org, MOVE_NOMONSTERS, world);
60 trace_endpos = this.warpzone_targetorigin;
67 void WarpZone_SetUp(entity e, vector my_org, vector my_ang, vector other_org, vector other_ang)
69 e.warpzone_transform = AnglesTransform_RightDivide(other_ang, AnglesTransform_TurnDirectionFR(my_ang));
70 e.warpzone_shift = AnglesTransform_PrePostShift_GetPostShift(my_org, e.warpzone_transform, other_org);
71 e.warpzone_origin = my_org;
72 e.warpzone_targetorigin = other_org;
73 e.warpzone_angles = my_ang;
74 e.warpzone_targetangles = other_ang;
75 fixedmakevectors(my_ang); e.warpzone_forward = v_forward;
76 fixedmakevectors(other_ang); e.warpzone_targetforward = v_forward;
77 e.camera_transform = WarpZone_camera_transform;
80 vector WarpZone_Camera_camera_transform(vector org, vector ang)
82 // a fixed camera view
83 if(this.warpzone_fadestart)
84 if(vdist(org - this.origin - 0.5 * (this.mins + this.maxs), >, this.warpzone_fadeend + 400))
86 // don't transform if zone faded out (plus 400qu safety margin for typical speeds and latencies)
87 // unneeded on client, on server this helps a lot
88 trace_endpos = this.warpzone_origin;
89 makevectors(this.warpzone_angles);
90 return this.warpzone_origin;
93 void WarpZone_Camera_SetUp(entity e, vector my_org, vector my_ang) // we assume that e.oldorigin and e.avelocity point to view origin and direction
95 e.warpzone_origin = my_org;
96 e.warpzone_angles = my_ang;
97 e.camera_transform = WarpZone_Camera_camera_transform;
102 vector WarpZoneLib_BoxTouchesBrush_mins;
103 vector WarpZoneLib_BoxTouchesBrush_maxs;
104 entity WarpZoneLib_BoxTouchesBrush_ent;
105 entity WarpZoneLib_BoxTouchesBrush_ignore;
106 float WarpZoneLib_BoxTouchesBrush_Recurse()
112 tracebox('0 0 0', WarpZoneLib_BoxTouchesBrush_mins, WarpZoneLib_BoxTouchesBrush_maxs, '0 0 0', MOVE_NOMONSTERS, WarpZoneLib_BoxTouchesBrush_ignore);
114 if (trace_networkentity)
116 LOG_TRACE("hit a network ent, cannot continue WarpZoneLib_BoxTouchesBrush\n");
117 // we cannot continue, as a player blocks us...
124 if (trace_ent == WarpZoneLib_BoxTouchesBrush_ent)
129 se.solid = SOLID_NOT;
130 f = WarpZoneLib_BoxTouchesBrush_Recurse();
136 float WarpZoneLib_BoxTouchesBrush(vector mi, vector ma, entity e, entity ig)
140 if(!e.modelindex || e.warpzone_isboxy)
145 WarpZoneLib_BoxTouchesBrush_mins = mi;
146 WarpZoneLib_BoxTouchesBrush_maxs = ma;
147 WarpZoneLib_BoxTouchesBrush_ent = e;
148 WarpZoneLib_BoxTouchesBrush_ignore = ig;
149 f = WarpZoneLib_BoxTouchesBrush_Recurse();
155 entity WarpZone_Find(vector mi, vector ma)
157 // if we are near any warpzone planes - MOVE AWAY (work around nearclip)
159 if(!warpzone_warpzones_exist)
161 for(e = world; (e = find(e, classname, "trigger_warpzone")); )
162 if(WarpZoneLib_BoxTouchesBrush(mi, ma, e, world))
167 void WarpZone_MakeAllSolid()
170 if(!warpzone_warpzones_exist)
172 for(e = world; (e = find(e, classname, "trigger_warpzone")); )
176 void WarpZone_MakeAllOther()
179 if(!warpzone_warpzones_exist)
181 for(e = world; (e = find(e, classname, "trigger_warpzone")); )
182 e.solid = SOLID_TRIGGER;
185 void WarpZone_Trace_InitTransform()
187 if(!WarpZone_trace_transform)
189 WarpZone_trace_transform = new_pure(warpzone_trace_transform);
191 WarpZone_Accumulator_Clear(WarpZone_trace_transform);
193 void WarpZone_Trace_AddTransform(entity wz)
195 WarpZone_Accumulator_Add(WarpZone_trace_transform, wz);
198 void WarpZone_TraceBox_ThroughZone(vector org, vector mi, vector ma, vector end, float nomonsters, entity forent, entity zone, WarpZone_trace_callback_t cb)
200 float nomonsters_adjusted;
207 WarpZone_trace_forent = forent;
208 WarpZone_trace_firstzone = world;
209 WarpZone_trace_lastzone = world;
210 WarpZone_Trace_InitTransform();
211 if(!warpzone_warpzones_exist)
213 if(nomonsters == MOVE_NOTHING)
218 cb(org, trace_endpos, end);
223 tracebox(org, mi, ma, end, nomonsters, WarpZone_trace_forent);
225 cb(org, trace_endpos, end);
240 nomonsters_adjusted = MOVE_NOMONSTERS;
243 nomonsters_adjusted = nomonsters;
246 if((contentshack = (WarpZone_trace_forent.dphitcontentsmask && !(WarpZone_trace_forent.dphitcontentsmask & DPCONTENTS_SOLID))))
247 BITSET_ASSIGN(WarpZone_trace_forent.dphitcontentsmask, DPCONTENTS_SOLID);
249 // if starting in warpzone, first transform
250 wz = WarpZone_Find(org + mi, org + ma);
253 WarpZone_trace_firstzone = wz;
254 WarpZone_trace_lastzone = wz;
255 if(zone && wz != zone)
257 // we are in ANOTHER warpzone. This is bad. Make a zero length trace and return.
263 WarpZone_Trace_AddTransform(wz);
264 org = WarpZone_TransformOrigin(wz, org);
265 end = WarpZone_TransformOrigin(wz, end);
267 WarpZone_MakeAllSolid();
275 LOG_TRACE("Too many warpzones in sequence, aborting trace.\n");
279 tracebox(org, mi, ma, end, nomonsters_adjusted, WarpZone_trace_forent);
281 cb(org, trace_endpos, end);
283 sol = trace_startsolid;
285 frac = trace_fraction = frac + (1 - frac) * trace_fraction;
286 if(trace_fraction >= 1)
288 if(trace_ent.classname != "trigger_warpzone")
290 if((nomonsters == MOVE_NOTHING) || ((nomonsters == MOVE_WORLDONLY) && trace_ent) || (contentshack && (trace_dphitcontents & WarpZone_trace_forent.dphitcontentsmask) == DPCONTENTS_SOLID))
292 // continue the trace, ignoring this hit (we only care for warpzones)
293 org = trace_endpos + normalize(end - org);
295 // we cannot do an inverted trace here, as we do care for further warpzones inside that "solid" to be found
296 // otherwise, players could block entrances that way
302 // FIXME can this check be removed? Do we really need it?
303 LOG_TRACE("I transformed into the same zone again, wtf, aborting the trace\n");
308 if(!WarpZone_trace_firstzone)
309 WarpZone_trace_firstzone = wz;
310 WarpZone_trace_lastzone = wz;
311 if(zone && wz != zone)
313 WarpZone_Trace_AddTransform(wz);
314 // we hit a warpzone... so, let's perform the trace after the warp again
315 org = WarpZone_TransformOrigin(wz, trace_endpos);
316 end = WarpZone_TransformOrigin(wz, end);
318 // we got warped, so let's step back a bit
319 tracebox(org, mi, ma, org + normalize(org - end) * 32, nomonsters_adjusted, WarpZone_trace_forent);
322 WarpZone_MakeAllOther();
325 BITCLR_ASSIGN(WarpZone_trace_forent.dphitcontentsmask, DPCONTENTS_SOLID);
326 trace_startsolid = sol;
332 void WarpZone_TraceBox(vector org, vector mi, vector ma, vector end, float nomonsters, entity forent)
334 WarpZone_TraceBox_ThroughZone(org, mi, ma, end, nomonsters, forent, world, WarpZone_trace_callback_t_null);
337 void WarpZone_TraceLine(vector org, vector end, float nomonsters, entity forent)
339 WarpZone_TraceBox(org, '0 0 0', '0 0 0', end, nomonsters, forent);
342 void WarpZone_TraceToss_ThroughZone(entity e, entity forent, entity zone, WarpZone_trace_callback_t cb)
345 vector vf, vr, vu, v0, o0;
350 g = cvar("sv_gravity") * e.gravity;
352 WarpZone_trace_forent = forent;
353 WarpZone_trace_firstzone = world;
354 WarpZone_trace_lastzone = world;
355 WarpZone_Trace_InitTransform();
356 WarpZone_tracetoss_time = 0;
357 if(!warpzone_warpzones_exist)
359 tracetoss(e, WarpZone_trace_forent);
361 cb(e.origin, trace_endpos, trace_endpos);
362 dt = vlen(e.origin - o0) / vlen(e.velocity);
363 WarpZone_tracetoss_time += dt;
364 e.velocity_z -= dt * g;
365 WarpZone_tracetoss_velocity = e.velocity;
374 // if starting in warpzone, first transform
375 wz = WarpZone_Find(e.origin + e.mins, e.origin + e.maxs);
378 WarpZone_trace_firstzone = wz;
379 WarpZone_trace_lastzone = wz;
380 if(zone && wz != zone)
382 // we are in ANOTHER warpzone. This is bad. Make a zero length trace and return.
384 WarpZone_tracetoss_time = 0;
388 WarpZone_Trace_AddTransform(wz);
389 vector org = WarpZone_TransformOrigin(wz, e.origin);
391 e.velocity = WarpZone_TransformVelocity(wz, e.velocity);
393 WarpZone_MakeAllSolid();
399 LOG_TRACE("Too many warpzones in sequence, aborting trace.\n");
403 tracetoss(e, WarpZone_trace_forent);
405 cb(e.origin, trace_endpos, trace_endpos);
406 dt = vlen(trace_endpos - e.origin) / vlen(e.velocity);
407 WarpZone_tracetoss_time += dt;
408 e.origin = trace_endpos;
409 e.velocity_z -= dt * g;
410 if(trace_fraction >= 1)
412 if(trace_ent.classname != "trigger_warpzone")
416 // FIXME can this check be removed? Do we really need it?
417 LOG_TRACE("I transformed into the same zone again, wtf, aborting the trace\n");
422 if(!WarpZone_trace_firstzone)
423 WarpZone_trace_firstzone = wz;
424 WarpZone_trace_lastzone = wz;
425 if(zone && wz != zone)
427 WarpZone_Trace_AddTransform(wz);
428 // we hit a warpzone... so, let's perform the trace after the warp again
429 e.origin = WarpZone_TransformOrigin(wz, e.origin);
430 e.velocity = WarpZone_TransformVelocity(wz, e.velocity);
432 // we got warped, so let's step back a bit
433 e.velocity = -e.velocity;
434 tracetoss(e, WarpZone_trace_forent);
435 dt = vlen(trace_endpos - e.origin) / vlen(e.velocity);
436 WarpZone_tracetoss_time -= dt;
437 e.origin = trace_endpos;
438 e.velocity = -e.velocity;
440 WarpZone_MakeAllOther();
442 WarpZone_tracetoss_velocity = e.velocity;
446 // restore old entity data (caller just uses trace_endpos, WarpZone_tracetoss_velocity and the transform)
451 void WarpZone_TraceToss(entity e, entity forent)
453 WarpZone_TraceToss_ThroughZone(e, forent, world, WarpZone_trace_callback_t_null);
456 entity WarpZone_TrailParticles_trace_callback_own;
457 float WarpZone_TrailParticles_trace_callback_eff;
458 void WarpZone_TrailParticles_trace_callback(vector from, vector endpos, vector to)
460 __trailparticles(WarpZone_TrailParticles_trace_callback_own, WarpZone_TrailParticles_trace_callback_eff, from, endpos);
463 void WarpZone_TrailParticles(entity own, float eff, vector org, vector end)
465 WarpZone_TrailParticles_trace_callback_own = own;
466 WarpZone_TrailParticles_trace_callback_eff = eff;
467 WarpZone_TraceBox_ThroughZone(org, '0 0 0', '0 0 0', end, MOVE_NOMONSTERS, world, world, WarpZone_TrailParticles_trace_callback);
471 float WarpZone_TrailParticles_trace_callback_f;
472 float WarpZone_TrailParticles_trace_callback_flags;
473 void WarpZone_TrailParticles_WithMultiplier_trace_callback(vector from, vector endpos, vector to)
475 boxparticles(WarpZone_TrailParticles_trace_callback_eff, WarpZone_TrailParticles_trace_callback_own, from, endpos, WarpZone_TrailParticles_trace_callback_own.velocity, WarpZone_TrailParticles_trace_callback_own.velocity, WarpZone_TrailParticles_trace_callback_f, WarpZone_TrailParticles_trace_callback_flags);
478 void WarpZone_TrailParticles_WithMultiplier(entity own, float eff, vector org, vector end, float f, int boxflags)
480 WarpZone_TrailParticles_trace_callback_own = own;
481 WarpZone_TrailParticles_trace_callback_eff = eff;
482 WarpZone_TrailParticles_trace_callback_f = f;
483 WarpZone_TrailParticles_trace_callback_flags = boxflags | PARTICLES_DRAWASTRAIL;
484 WarpZone_TraceBox_ThroughZone(org, '0 0 0', '0 0 0', end, MOVE_NOMONSTERS, world, world, WarpZone_TrailParticles_WithMultiplier_trace_callback);
488 float WarpZone_PlaneDist(entity wz, vector v)
490 return (v - wz.warpzone_origin) * wz.warpzone_forward;
493 float WarpZone_TargetPlaneDist(entity wz, vector v)
495 return (v - wz.warpzone_targetorigin) * wz.warpzone_targetforward;
498 vector WarpZone_TransformOrigin(entity wz, vector v)
500 return wz.warpzone_shift + AnglesTransform_Apply(wz.warpzone_transform, v);
503 vector WarpZone_TransformVelocity(entity wz, vector v)
505 return AnglesTransform_Apply(wz.warpzone_transform, v);
508 vector WarpZone_TransformAngles(entity wz, vector v)
510 return AnglesTransform_ApplyToAngles(wz.warpzone_transform, v);
513 vector WarpZone_TransformVAngles(entity wz, vector ang)
521 ang = AnglesTransform_ApplyToVAngles(wz.warpzone_transform, ang);
524 ang = AnglesTransform_Normalize(ang, true);
525 ang = AnglesTransform_CancelRoll(ang);
528 ang = AnglesTransform_Normalize(ang, false);
534 vector WarpZone_UnTransformOrigin(entity wz, vector v)
536 return AnglesTransform_Apply(AnglesTransform_Invert(wz.warpzone_transform), v - wz.warpzone_shift);
539 vector WarpZone_UnTransformVelocity(entity wz, vector v)
541 return AnglesTransform_Apply(AnglesTransform_Invert(wz.warpzone_transform), v);
544 vector WarpZone_UnTransformAngles(entity wz, vector v)
546 return AnglesTransform_ApplyToAngles(AnglesTransform_Invert(wz.warpzone_transform), v);
549 vector WarpZone_UnTransformVAngles(entity wz, vector ang)
556 ang = AnglesTransform_ApplyToVAngles(AnglesTransform_Invert(wz.warpzone_transform), ang);
557 ang = AnglesTransform_Normalize(ang, true);
558 ang = AnglesTransform_CancelRoll(ang);
564 vector WarpZoneLib_NearestPointOnBox(vector mi, vector ma, vector org)
567 nearest.x = bound(mi.x, org.x, ma.x);
568 nearest.y = bound(mi.y, org.y, ma.y);
569 nearest.z = bound(mi.z, org.z, ma.z);
573 bool WarpZoneLib_BadEntity(entity e)
575 if (is_pure(e)) return true;
576 string s = e.classname;
579 // case "net_linked": // actually some real entities are linked without classname, fail
584 if (startsWith(s, "target_")) return true;
586 if (startsWith(s, "info_")) return true;
591 .float WarpZone_findradius_hit;
592 .entity WarpZone_findradius_next;
593 void WarpZone_FindRadius_Recurse(
594 /** blast origin of current search */
597 /** original blast origin */
599 /** how to untransform (victim to blast system) */
602 bool needlineofsight)
604 if (rad <= 0) return;
606 FOREACH_ENTITY_RADIUS(org, rad, !WarpZoneLib_BadEntity(it), {
607 vector p = WarpZoneLib_NearestPointOnBox(it.origin + it.mins, it.origin + it.maxs, org0);
610 traceline(org, p, MOVE_NOMONSTERS, it);
611 if (trace_fraction < 1) continue;
613 if (!it.WarpZone_findradius_hit || vlen2(it.WarpZone_findradius_dist) > vlen2(org0 - p))
615 it.WarpZone_findradius_nearest = p;
616 it.WarpZone_findradius_dist = org0 - p;
617 it.WarpZone_findradius_findorigin = org;
618 it.WarpZone_findradius_findradius = rad;
619 if (it.classname == "warpzone_refsys")
621 // ignore, especially: do not overwrite the refsys parameters
623 else if (it.classname == "trigger_warpzone")
625 it.WarpZone_findradius_next = wz;
627 it.WarpZone_findradius_hit = 1;
628 it.enemy.WarpZone_findradius_dist = '0 0 0'; // we don't want to go through this zone ever again
629 it.enemy.WarpZone_findradius_hit = 1;
633 it.warpzone_transform = transform;
634 it.warpzone_shift = shift;
635 it.WarpZone_findradius_hit = 1;
639 for(entity e = wz; e; e = e.WarpZone_findradius_next)
641 if (WarpZoneLib_BadEntity(e)) continue;
643 vector org0_new = WarpZone_TransformOrigin(e, org);
644 traceline(e.warpzone_targetorigin, org0_new, MOVE_NOMONSTERS, e);
645 vector org_new = trace_endpos;
647 vector transform_new = AnglesTransform_Multiply(e.warpzone_transform, transform);
648 vector shift_new = AnglesTransform_Multiply_GetPostShift(e.warpzone_transform, e.warpzone_shift, transform, shift);
649 WarpZone_FindRadius_Recurse(
651 bound(0, rad - vlen(org_new - org0_new), rad - 8),
653 transform_new, shift_new,
655 e.WarpZone_findradius_hit = 0;
656 e.enemy.WarpZone_findradius_hit = 0;
659 entity WarpZone_FindRadius(vector org, float rad, bool needlineofsight)
661 // FIXME: why can't we do this? (sometimes finds nothing, breaking explosions)
662 // if (!warpzone_warpzones_exist && !needlineofsight) return findradius(org, rad);
663 WarpZone_FindRadius_Recurse(org, rad, org, '0 0 0', '0 0 0', needlineofsight);
664 entity list_first = findchainfloat(WarpZone_findradius_hit, 1);
665 FOREACH_LIST(list, chain, true, it.WarpZone_findradius_hit = 0);
669 .entity WarpZone_refsys;
670 void WarpZone_RefSys_GC()
672 // garbage collect unused reference systems
673 this.nextthink = time + 1;
674 if(this.owner.WarpZone_refsys != this)
677 void WarpZone_RefSys_CheckCreate(entity me)
679 if(me.WarpZone_refsys.owner != me)
681 me.WarpZone_refsys = new(warpzone_refsys);
682 me.WarpZone_refsys.owner = me;
683 me.WarpZone_refsys.think = WarpZone_RefSys_GC;
684 me.WarpZone_refsys.nextthink = time + 1;
685 WarpZone_Accumulator_Clear(me.WarpZone_refsys);
688 void WarpZone_RefSys_Clear(entity me)
690 if(me.WarpZone_refsys)
692 remove(me.WarpZone_refsys);
693 me.WarpZone_refsys = world;
696 void WarpZone_RefSys_AddTransform(entity me, vector t, vector s)
698 if(t != '0 0 0' || s != '0 0 0')
700 WarpZone_RefSys_CheckCreate(me);
701 WarpZone_Accumulator_AddTransform(me.WarpZone_refsys, t, s);
704 void WarpZone_RefSys_Add(entity me, entity wz)
706 WarpZone_RefSys_AddTransform(me, wz.warpzone_transform, wz.warpzone_shift);
708 void WarpZone_RefSys_AddInverseTransform(entity me, vector t, vector s)
710 if(t != '0 0 0' || s != '0 0 0')
712 WarpZone_RefSys_CheckCreate(me);
713 WarpZone_Accumulator_AddInverseTransform(me.WarpZone_refsys, t, s);
716 void WarpZone_RefSys_AddInverse(entity me, entity wz)
718 WarpZone_RefSys_AddInverseTransform(me, wz.warpzone_transform, wz.warpzone_shift);
720 .vector WarpZone_refsys_incremental_shift;
721 .vector WarpZone_refsys_incremental_transform;
722 void WarpZone_RefSys_AddIncrementally(entity me, entity ref)
725 if(me.WarpZone_refsys_incremental_transform == ref.WarpZone_refsys.warpzone_transform)
726 if(me.WarpZone_refsys_incremental_shift == ref.WarpZone_refsys.warpzone_shift)
728 WarpZone_Accumulator_AddInverseTransform(me.WarpZone_refsys, me.WarpZone_refsys_incremental_transform, me.WarpZone_refsys_incremental_shift);
729 WarpZone_Accumulator_Add(me.WarpZone_refsys, ref.WarpZone_refsys);
730 me.WarpZone_refsys_incremental_shift = ref.WarpZone_refsys.warpzone_shift;
731 me.WarpZone_refsys_incremental_transform = ref.WarpZone_refsys.warpzone_transform;
733 void WarpZone_RefSys_BeginAddingIncrementally(entity me, entity ref)
735 me.WarpZone_refsys_incremental_shift = ref.WarpZone_refsys.warpzone_shift;
736 me.WarpZone_refsys_incremental_transform = ref.WarpZone_refsys.warpzone_transform;
738 vector WarpZone_RefSys_TransformOrigin(entity from, entity to, vector org)
740 if(from.WarpZone_refsys)
741 org = WarpZone_UnTransformOrigin(from.WarpZone_refsys, org);
742 if(to.WarpZone_refsys)
743 org = WarpZone_TransformOrigin(to.WarpZone_refsys, org);
746 vector WarpZone_RefSys_TransformVelocity(entity from, entity to, vector vel)
748 if(from.WarpZone_refsys)
749 vel = WarpZone_UnTransformVelocity(from.WarpZone_refsys, vel);
750 if(to.WarpZone_refsys)
751 vel = WarpZone_TransformVelocity(to.WarpZone_refsys, vel);
754 vector WarpZone_RefSys_TransformAngles(entity from, entity to, vector ang)
756 if(from.WarpZone_refsys)
757 ang = WarpZone_UnTransformAngles(from.WarpZone_refsys, ang);
758 if(to.WarpZone_refsys)
759 ang = WarpZone_TransformAngles(to.WarpZone_refsys, ang);
762 vector WarpZone_RefSys_TransformVAngles(entity from, entity to, vector ang)
764 if(from.WarpZone_refsys)
765 ang = WarpZone_UnTransformVAngles(from.WarpZone_refsys, ang);
766 if(to.WarpZone_refsys)
767 ang = WarpZone_TransformVAngles(to.WarpZone_refsys, ang);
770 void WarpZone_RefSys_Copy(entity me, entity from)
772 if(from.WarpZone_refsys)
774 WarpZone_RefSys_CheckCreate(me);
775 me.WarpZone_refsys.warpzone_shift = from.WarpZone_refsys.warpzone_shift;
776 me.WarpZone_refsys.warpzone_transform = from.WarpZone_refsys.warpzone_transform;
779 WarpZone_RefSys_Clear(me);
781 entity WarpZone_RefSys_SpawnSameRefSys(entity me)
785 WarpZone_RefSys_Copy(e, me);
789 float WarpZoneLib_ExactTrigger_Touch(entity this, entity toucher)
791 return !WarpZoneLib_BoxTouchesBrush(toucher.absmin, toucher.absmax, this, toucher);
795 void WarpZoneLib_MoveOutOfSolid_Expand(entity e, vector by)
798 tracebox(e.origin, e.mins - '1 1 1' * eps, e.maxs + '1 1 1' * eps, e.origin + by, MOVE_WORLDONLY, e);
799 if (trace_startsolid)
801 if (trace_fraction < 1)
804 // adjust origin in the other direction...
805 setorigin(e,e.origin - by * (1 - trace_fraction));
809 float WarpZoneLib_MoveOutOfSolid(entity e)
814 traceline(o, o, MOVE_WORLDONLY, e);
815 if (trace_startsolid)
818 tracebox(o, e.mins, e.maxs, o, MOVE_WORLDONLY, e);
819 if (!trace_startsolid)
826 WarpZoneLib_MoveOutOfSolid_Expand(e, '1 0 0' * m0_x);
828 WarpZoneLib_MoveOutOfSolid_Expand(e, '1 0 0' * m1_x);
830 WarpZoneLib_MoveOutOfSolid_Expand(e, '0 1 0' * m0_y);
832 WarpZoneLib_MoveOutOfSolid_Expand(e, '0 1 0' * m1_y);
834 WarpZoneLib_MoveOutOfSolid_Expand(e, '0 0 1' * m0_z);
836 WarpZoneLib_MoveOutOfSolid_Expand(e, '0 0 1' * m1_z);
838 setorigin(e, e.origin);
840 tracebox(e.origin, e.mins, e.maxs, e.origin, MOVE_WORLDONLY, e);
841 if (trace_startsolid)