Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
common.qc File Reference
Include dependency graph for common.qc:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define CHOOSE_AXIS(axis)
#define WarpZone_Accumulator_Add(acc, wz)
#define WarpZone_Accumulator_AddInverse(acc, wz)
#define WarpZone_Trace_AddTransform(wz)
#define WarpZoneLib_NearestPointOnBox(mi, ma, org)

Functions

void _WarpZone_FindRadius_Recurse (vector org, float rad, vector org0, vector transform, vector shift)
ACCUMULATE void ONREMOVE (entity this)
void te_csqc_trace_callback (vector start, vector hit, vector end)
 Callback function for WarpZone_TraceBox_ThroughZone, for use with te_csqc_* functions.
void WarpZone_Accumulator_AddInverseTransform (entity acc, vector t, vector s)
void WarpZone_Accumulator_AddTransform (entity acc, vector t, vector s)
void WarpZone_Accumulator_Clear (entity acc)
vector WarpZone_Camera_camera_transform (entity this, vector org, vector ang)
void WarpZone_Camera_SetUp (entity e, vector my_org, vector my_ang)
vector WarpZone_camera_transform (entity this, vector org, vector ang)
entity WarpZone_Find (vector mi, vector ma)
void WarpZone_MakeAllOther ()
void WarpZone_MakeAllSolid ()
float WarpZone_PlaneDist (entity wz, vector p)
void WarpZone_RefSys_AddIncrementally (entity me, entity ref)
void WarpZone_RefSys_AddInverseTransform (entity me, vector t, vector s)
void WarpZone_RefSys_AddTransform (entity me, vector t, vector s)
void WarpZone_RefSys_BeginAddingIncrementally (entity me, entity ref)
void WarpZone_RefSys_CheckCreate (entity me)
void WarpZone_RefSys_Clear (entity me)
void WarpZone_RefSys_Copy (entity me, entity from)
 Copies the warpzone reference of from onto me.
entity WarpZone_RefSys_SpawnSameRefSys (entity me)
 Spawns an entity in the same warpzone reference as me, and sets up its reference.
vector WarpZone_RefSys_TransformAngles (entity from, entity to, vector ang)
 Transform angle ang in from's reference into to's reference.
vector WarpZone_RefSys_TransformOrigin (entity from, entity to, vector org)
 Transform origin org in from's reference into to's reference.
vector WarpZone_RefSys_TransformVAngles (entity from, entity to, vector ang)
 Transform v_angle ang in from's reference into to's reference.
vector WarpZone_RefSys_TransformVelocity (entity from, entity to, vector vel)
 Transform velocity vel in from's reference into to's reference.
entity WarpZone_SearchInRadius (vector org, float rad, float nomonsters, WarpZone_FindRadius_cond_callback_t cb)
 Modified findradius aware of warpzones, that only includes entities that meet the "cb" criteria.
void WarpZone_SetUp (entity e, vector my_org, vector my_ang, vector other_org, vector other_ang)
float WarpZone_TargetPlaneDist (entity wz, vector p)
void WarpZone_Trace_InitTransform ()
void WarpZone_TraceBox_ThroughZone (vector org, vector mi, vector ma, vector end, float nomonsters, entity forent, entity zone, WarpZone_trace_callback_t cb)
 Traces a box from org to end, shifting & transforming each time it goes through a warpzone.
void WarpZone_TraceToss_ThroughZone (entity e, entity forent, entity zone, WarpZone_trace_callback_t cb)
 Traces tossing e, shifting & transforming each time it goes through a warpzone.
void WarpZone_TrailParticles (entity own, float eff, vector org, vector end)
void WarpZone_TrailParticles_trace_callback (vector from, vector endpos, vector to)
void WarpZone_TrailParticles_WithMultiplier (entity own, float eff, vector org, vector end, float f, int boxflags)
void WarpZone_TrailParticles_WithMultiplier_trace_callback (vector from, vector endpos, vector to)
vector WarpZone_TransformAngles (entity wz, vector ang)
 Transforms angle v across warpzone wz.
vector WarpZone_TransformOrigin (entity wz, vector org)
 Transforms origin org across warpzone wz.
vector WarpZone_TransformVAngles (entity wz, vector ang)
 Transforms v_angle ang across warpzone wz.
vector WarpZone_TransformVelocity (entity wz, vector vel)
 Transforms velocity v across warpzone wz.
vector WarpZone_UnTransformAngles (entity wz, vector ang)
 Transforms angle ang backwards through warpzone wz, as the inverse of WarpZone_TransformAngles.
vector WarpZone_UnTransformOrigin (entity wz, vector org)
 Transforms origin org backwards through warpzone wz, as the inverse of WarpZone_TransformOrigin.
vector WarpZone_UnTransformVAngles (entity wz, vector ang)
 Transforms v_angle ang backwards through warpzone wz, as the inverse of WarpZone_TransformVAngles.
vector WarpZone_UnTransformVelocity (entity wz, vector vel)
 Transforms angle vel backwards through warpzone wz, as the inverse of WarpZone_TransformVelocity.
bool WarpZoneLib_BadEntity (entity e, WarpZone_FindRadius_cond_callback_t cb)
 Blacklist of entities that WarpZone_FindRadius doesn't care about.
float WarpZoneLib_BoxTouchesBrush (vector mi, vector ma, entity e, entity ig)
float WarpZoneLib_BoxTouchesBrush_Recurse (vector mi, vector ma, entity e, entity ig)
bool WarpZoneLib_ExactTrigger_Touch (entity this, entity toucher, bool touchfunc)
int WarpZoneLib_MoveOutOfSolid (entity e)
void WarpZoneLib_MoveOutOfSolid_Expand (entity e, vector by)

Variables

entity _WarpZone_FindRadius_badents_first
var WarpZone_FindRadius_cond_callback_t _WarpZone_FindRadius_cond_cb
entity _WarpZone_FindRadius_goodents_first
float _WarpZone_FindRadius_nomonsters
entity enemy
int WarpZone_findradius_hit
const int WarpZone_FindRadius_Hit_BAD = 2
const int WarpZone_FindRadius_Hit_GOOD = 1
const int WarpZone_FindRadius_Hit_UNSEEN = 0
entity WarpZone_findradius_next
entity WarpZone_refsys
vector WarpZone_refsys_incremental_shift
vector WarpZone_refsys_incremental_transform
float WarpZone_TrailParticles_trace_callback_eff
float WarpZone_TrailParticles_trace_callback_f
float WarpZone_TrailParticles_trace_callback_flags
entity WarpZone_TrailParticles_trace_callback_own

Macro Definition Documentation

◆ CHOOSE_AXIS

#define CHOOSE_AXIS ( axis)
Value:
if (org.axis < end.axis) { boxmin.axis += org.axis; boxmax.axis += end.axis; } \
else { boxmin.axis += end.axis; boxmax.axis += org.axis; }
vector org
Definition self.qh:96

Referenced by WarpZone_TraceBox_ThroughZone().

◆ WarpZone_Accumulator_Add

#define WarpZone_Accumulator_Add ( acc,
wz )
Value:
void WarpZone_Accumulator_AddTransform(entity acc, vector t, vector s)
Definition common.qc:16
vector warpzone_shift
Both a warpzone property, and set on entities found by WarpZone_SearchInRadius.
Definition common.qh:17
vector warpzone_transform
Both a warpzone property, and set on entities found by WarpZone_SearchInRadius.
Definition common.qh:16

Definition at line 23 of file common.qc.

23#define WarpZone_Accumulator_Add(acc, wz) \
24 WarpZone_Accumulator_AddTransform(acc, (wz).warpzone_transform, (wz).warpzone_shift)

Referenced by WarpZone_RefSys_AddIncrementally().

◆ WarpZone_Accumulator_AddInverse

#define WarpZone_Accumulator_AddInverse ( acc,
wz )
Value:
void WarpZone_Accumulator_AddInverseTransform(entity acc, vector t, vector s)
Definition common.qc:25

Definition at line 32 of file common.qc.

32#define WarpZone_Accumulator_AddInverse(acc, wz) \
33 WarpZone_Accumulator_AddInverseTransform(acc, (wz).warpzone_transform, (wz).warpzone_shift)

◆ WarpZone_Trace_AddTransform

#define WarpZone_Trace_AddTransform ( wz)
Value:
#define WarpZone_Accumulator_Add(acc, wz)
Definition common.qc:23
entity WarpZone_trace_transform
Transform accumulator during a trace.
Definition common.qh:40

Definition at line 182 of file common.qc.

182#define WarpZone_Trace_AddTransform(wz) \
183 WarpZone_Accumulator_Add(WarpZone_trace_transform, wz)

Referenced by WarpZone_TraceBox_ThroughZone(), and WarpZone_TraceToss_ThroughZone().

◆ WarpZoneLib_NearestPointOnBox

#define WarpZoneLib_NearestPointOnBox ( mi,
ma,
org )
Value:
ERASEABLE vector NearestPointOnBoundingBox(vector mi, vector ma, vector org)
Definition vector.qh:200

Definition at line 565 of file common.qc.

Referenced by _WarpZone_FindRadius_Recurse().

Function Documentation

◆ _WarpZone_FindRadius_Recurse()

void _WarpZone_FindRadius_Recurse ( vector org,
float rad,
vector org0,
vector transform,
vector shift )
Parameters
orgblast origin of current search
org0original blast origin
transformhow to untransform (victim to blast system)

Definition at line 609 of file common.qc.

618{
619 if (rad <= 0)
620 return;
621 entity wz = NULL;
622 FOREACH_ENTITY_RADIUS(org, rad, it.WarpZone_findradius_hit != WarpZone_FindRadius_Hit_BAD, // exclude entities we already know are bad
623 {
624 bool is_warpzone = (it.classname == "trigger_warpzone");
625 if (!is_warpzone // warpzones are never bad entities
626 && WarpZoneLib_BadEntity(it, _WarpZone_FindRadius_cond_cb))
627 {
628 it.WarpZone_findradius_hit = WarpZone_FindRadius_Hit_BAD;
629 it.WarpZone_findradius_next = _WarpZone_FindRadius_badents_first;
630 // use .WarpZone_findradius_next so that .chain isn't changed on entities not included in the returned list_first
631 _WarpZone_FindRadius_badents_first = it;
632 continue;
633 }
634
635 vector p = WarpZoneLib_NearestPointOnBox(it.origin + it.mins, it.origin + it.maxs, org0);
636 if (it.WarpZone_findradius_hit == WarpZone_FindRadius_Hit_GOOD && vlen2(it.WarpZone_findradius_dist) <= vlen2(org0 - p))
637 continue;
639 {
640 traceline(org, p, _WarpZone_FindRadius_nomonsters, it);
641 if (trace_fraction < 1)
642 continue;
643 }
644
645 it.WarpZone_findradius_nearest = p;
646 it.WarpZone_findradius_dist = org0 - p;
647 //it.WarpZone_findradius_findorigin = org;
648 //it.WarpZone_findradius_findradius = rad;
649 if (is_warpzone)
650 {
651 it.WarpZone_findradius_next = wz;
652 wz = it;
653 it.WarpZone_findradius_hit = WarpZone_FindRadius_Hit_GOOD;
654 it.enemy.WarpZone_findradius_dist = '0 0 0'; // we don't want to go through this zone ever again
655 it.enemy.WarpZone_findradius_hit = WarpZone_FindRadius_Hit_GOOD;
656 }
657 else // entity we'll include in the list
658 {
659 it.warpzone_transform = transform;
660 it.warpzone_shift = shift;
661 if (it.WarpZone_findradius_hit != WarpZone_FindRadius_Hit_GOOD) // add to good ents chain if not already in it
662 {
663 it.chain = _WarpZone_FindRadius_goodents_first; // fine to use .chain since FOREACH_ENTITY_RADIUS doesn't use it
665 it.WarpZone_findradius_hit = WarpZone_FindRadius_Hit_GOOD;
666 }
667 }
668 });
669 for (entity e = wz; e; e = e.WarpZone_findradius_next)
670 {
671 vector org0_new = WarpZone_TransformOrigin(e, org);
672 traceline(e.warpzone_targetorigin, org0_new, MOVE_NOMONSTERS, e);
673 vector org_new = trace_endpos;
674
676 org_new,
677 rad - max(8, vlen(org_new - org0_new)),
678 org0_new,
679 AnglesTransform_Multiply(e.warpzone_transform, transform), // new transform
680 AnglesTransform_Multiply_GetPostShift(e.warpzone_transform, e.warpzone_shift, transform, shift)); // new shift
681 e.WarpZone_findradius_hit = e.enemy.WarpZone_findradius_hit = WarpZone_FindRadius_Hit_UNSEEN;
682 }
683}
vector AnglesTransform_Multiply_GetPostShift(vector t0, vector st0, vector t1, vector st1)
vector AnglesTransform_Multiply(vector t1, vector t2)
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
const float MOVE_NOMONSTERS
vector trace_endpos
float trace_fraction
#define FOREACH_ENTITY_RADIUS(org, dist, cond, body)
Definition iter.qh:160
#define WarpZoneLib_NearestPointOnBox(mi, ma, org)
Definition common.qc:565
const int WarpZone_FindRadius_Hit_GOOD
Definition common.qc:569
const int WarpZone_FindRadius_Hit_BAD
Definition common.qc:570
vector WarpZone_TransformOrigin(entity wz, vector org)
Transforms origin org across warpzone wz.
Definition common.qc:493
void _WarpZone_FindRadius_Recurse(vector org, float rad, vector org0, vector transform, vector shift)
Definition common.qc:609
entity _WarpZone_FindRadius_goodents_first
Definition common.qc:604
float _WarpZone_FindRadius_nomonsters
Definition common.qc:606
const int WarpZone_FindRadius_Hit_UNSEEN
Definition common.qc:568
#define MOVE_NOTHING
Definition common.qh:35
float vlen(vector v)
float max(float f,...)
#define NULL
Definition post.qh:14
vector
Definition self.qh:96
if(frag_attacker.flagcarried)
Definition sv_ctf.qc:2319
#define vlen2(v)
Definition vector.qh:4

References _WarpZone_FindRadius_goodents_first, _WarpZone_FindRadius_nomonsters, entity(), FOREACH_ENTITY_RADIUS, if(), MOVE_NOTHING, NULL, org, trace_fraction, vector, vlen2, WarpZone_FindRadius_Hit_BAD, WarpZone_FindRadius_Hit_GOOD, and WarpZoneLib_NearestPointOnBox.

Referenced by WarpZone_SearchInRadius().

◆ ONREMOVE()

ACCUMULATE void ONREMOVE ( entity this)

Definition at line 735 of file common.qc.

736{
737 // remove WarpZone_refsys object attached to 'this'
738 if (this.WarpZone_refsys && this.WarpZone_refsys.owner == this)
739 delete(this.WarpZone_refsys);
740}
entity WarpZone_refsys
Definition common.qc:731

References entity(), and WarpZone_refsys.

◆ te_csqc_trace_callback()

void te_csqc_trace_callback ( vector start,
vector hit,
vector end )

Callback function for WarpZone_TraceBox_ThroughZone, for use with te_csqc_* functions.

Must set te_csqc_trace_callback_func first

Definition at line 459 of file common.qc.

460{
461 te_csqc_trace_callback_func(start, hit);
462}
var void te_csqc_trace_callback_func(vector start, vector hit)

References te_csqc_trace_callback_func(), and vector.

◆ WarpZone_Accumulator_AddInverseTransform()

void WarpZone_Accumulator_AddInverseTransform ( entity acc,
vector t,
vector s )

Definition at line 25 of file common.qc.

26{
30 // yes, this probably can be done simpler... but this way is "obvious" :)
31}
vector AnglesTransform_Invert(vector transform)
vector AnglesTransform_PrePostShift_GetPostShift(vector sf, vector t, vector st)

References AnglesTransform_Invert(), AnglesTransform_PrePostShift_GetPostShift(), entity(), vector, and WarpZone_Accumulator_AddTransform().

Referenced by WarpZone_RefSys_AddIncrementally(), and WarpZone_RefSys_AddInverseTransform().

◆ WarpZone_Accumulator_AddTransform()

void WarpZone_Accumulator_AddTransform ( entity acc,
vector t,
vector s )

Definition at line 16 of file common.qc.

17{
18 vector tr = AnglesTransform_Multiply(t, acc.warpzone_transform);
19 vector st = AnglesTransform_Multiply_GetPostShift(t, s, acc.warpzone_transform, acc.warpzone_shift);
20 acc.warpzone_transform = tr;
21 acc.warpzone_shift = st;
22}

References AnglesTransform_Multiply(), AnglesTransform_Multiply_GetPostShift(), entity(), and vector.

Referenced by WarpZone_Accumulator_AddInverseTransform(), and WarpZone_RefSys_AddTransform().

◆ WarpZone_Accumulator_Clear()

void WarpZone_Accumulator_Clear ( entity acc)

Definition at line 11 of file common.qc.

12{
13 acc.warpzone_transform = '0 0 0';
14 acc.warpzone_shift = '0 0 0';
15}

References entity().

Referenced by WarpZone_RefSys_CheckCreate(), WarpZone_SearchInRadius(), and WarpZone_Trace_InitTransform().

◆ WarpZone_Camera_camera_transform()

vector WarpZone_Camera_camera_transform ( entity this,
vector org,
vector ang )

Definition at line 76 of file common.qc.

77{
78 // a fixed camera view
79 if (this.warpzone_fadestart
80 && vdist(org - this.origin - 0.5 * (this.mins + this.maxs), >, this.warpzone_fadeend + 400))
81 return org;
82 // don't transform if zone faded out (plus 400qu safety margin for typical speeds and latencies)
83 // unneeded on client, on server this helps a lot
86 return this.warpzone_origin;
87}
vector mins
vector maxs
vector origin
float warpzone_fadestart
Definition common.qh:24
float warpzone_fadeend
Definition common.qh:25
vector warpzone_origin
Definition common.qh:18
vector warpzone_angles
Definition common.qh:19
#define makevectors
Definition post.qh:21
#define vdist(v, cmp, f)
Vector distance comparison, avoids sqrt().
Definition vector.qh:8

References ang, entity(), makevectors, maxs, mins, org, origin, trace_endpos, vdist, vector, warpzone_angles, warpzone_fadeend, warpzone_fadestart, and warpzone_origin.

Referenced by WarpZone_Camera_SetUp().

◆ WarpZone_Camera_SetUp()

void WarpZone_Camera_SetUp ( entity e,
vector my_org,
vector my_ang )

Definition at line 89 of file common.qc.

90{
91 e.warpzone_origin = my_org;
92 e.warpzone_angles = my_ang;
94}
vector WarpZone_Camera_camera_transform(entity this, vector org, vector ang)
Definition common.qc:76
#define setcamera_transform(e, f)
Definition self.qh:97

References entity(), setcamera_transform, vector, and WarpZone_Camera_camera_transform().

Referenced by NET_HANDLE(), WarpZoneCamera_InitStep_FindTarget(), and WarpZoneCamera_Think().

◆ WarpZone_camera_transform()

vector WarpZone_camera_transform ( entity this,
vector org,
vector ang )

Definition at line 35 of file common.qc.

36{
37 if (this.warpzone_fadestart
38 && vdist(org - this.origin - 0.5 * (this.mins + this.maxs), >, this.warpzone_fadeend + 400))
39 return org;
40 // don't transform if zone faded out (plus 400qu safety margin for typical speeds and latencies)
41 // unneeded on client, on server this helps a lot
42 vector vf = v_forward;
43 vector vr = v_right;
44 vector vu = v_up;
46 vf = WarpZone_TransformVelocity(this, vf);
47 vr = WarpZone_TransformVelocity(this, vr);
48 vu = WarpZone_TransformVelocity(this, vu);
50 v_forward = vf;
51 v_right = vr;
52 v_up = vu;
53 return org;
54}
vector v_up
vector v_right
vector v_forward
vector WarpZone_TransformVelocity(entity wz, vector vel)
Transforms velocity v across warpzone wz.
Definition common.qc:499
vector warpzone_targetorigin
Definition common.qh:21

References ang, entity(), maxs, mins, MOVE_NOMONSTERS, NULL, org, origin, v_forward, v_right, v_up, vdist, vector, warpzone_fadeend, warpzone_fadestart, warpzone_targetorigin, WarpZone_TransformOrigin(), and WarpZone_TransformVelocity().

Referenced by WarpZone_SetUp().

◆ WarpZone_Find()

entity WarpZone_Find ( vector mi,
vector ma )

Definition at line 156 of file common.qc.

157{
158 // if we are near any warpzone planes - MOVE AWAY (work around nearclip)
160 IL_EACH(g_warpzones, WarpZoneLib_BoxTouchesBrush(mi, ma, it, NULL), return it);
161 return NULL;
162}
#define IL_EACH(this, cond, body)
float WarpZoneLib_BoxTouchesBrush(vector mi, vector ma, entity e, entity ig)
Definition common.qc:124
IntrusiveList g_warpzones
Definition common.qh:6
float warpzone_warpzones_exist
Definition common.qh:12

References entity(), g_warpzones, IL_EACH, NULL, vector, warpzone_warpzones_exist, and WarpZoneLib_BoxTouchesBrush().

Referenced by WarpZone_FixNearClip(), WarpZone_FixPMove(), WarpZone_FixView(), WarpZone_StartFrame(), WarpZone_TraceBox_ThroughZone(), and WarpZone_TraceToss_ThroughZone().

◆ WarpZone_MakeAllOther()

void WarpZone_MakeAllOther ( )

Definition at line 170 of file common.qc.

171{
173 IL_EACH(g_warpzones, true, it.solid = SOLID_TRIGGER);
174}
const float SOLID_TRIGGER

References g_warpzones, IL_EACH, SOLID_TRIGGER, and warpzone_warpzones_exist.

Referenced by WarpZone_TraceBox_ThroughZone(), and WarpZone_TraceToss_ThroughZone().

◆ WarpZone_MakeAllSolid()

void WarpZone_MakeAllSolid ( )

Definition at line 164 of file common.qc.

165{
167 IL_EACH(g_warpzones, true, it.solid = SOLID_BSP);
168}
const float SOLID_BSP

References g_warpzones, IL_EACH, SOLID_BSP, and warpzone_warpzones_exist.

Referenced by WarpZone_TraceBox_ThroughZone(), and WarpZone_TraceToss_ThroughZone().

◆ WarpZone_PlaneDist()

float WarpZone_PlaneDist ( entity wz,
vector p )

Definition at line 482 of file common.qc.

483{
484 return (p - wz.warpzone_origin) * wz.warpzone_forward;
485}

References entity(), and vector.

Referenced by WarpZone_FixNearClip(), WarpZone_StartFrame(), and WarpZone_Touch().

◆ WarpZone_RefSys_AddIncrementally()

void WarpZone_RefSys_AddIncrementally ( entity me,
entity ref )

Definition at line 772 of file common.qc.

773{
774 //vector t, s;
775 if (me.WarpZone_refsys_incremental_transform == ref.WarpZone_refsys.warpzone_transform
776 && me.WarpZone_refsys_incremental_shift == ref.WarpZone_refsys.warpzone_shift)
777 return;
778 WarpZone_Accumulator_AddInverseTransform(me.WarpZone_refsys, me.WarpZone_refsys_incremental_transform, me.WarpZone_refsys_incremental_shift);
779 WarpZone_Accumulator_Add(me.WarpZone_refsys, ref.WarpZone_refsys);
780 me.WarpZone_refsys_incremental_shift = ref.WarpZone_refsys.warpzone_shift;
781 me.WarpZone_refsys_incremental_transform = ref.WarpZone_refsys.warpzone_transform;
782}

References entity(), WarpZone_Accumulator_Add, and WarpZone_Accumulator_AddInverseTransform().

Referenced by GrapplingHookThink().

◆ WarpZone_RefSys_AddInverseTransform()

void WarpZone_RefSys_AddInverseTransform ( entity me,
vector t,
vector s )

Definition at line 763 of file common.qc.

764{
765 if (t == '0 0 0' && s == '0 0 0')
766 return;
768 WarpZone_Accumulator_AddInverseTransform(me.WarpZone_refsys, t, s);
769}
void WarpZone_RefSys_CheckCreate(entity me)
Definition common.qc:741

References entity(), vector, WarpZone_Accumulator_AddInverseTransform(), and WarpZone_RefSys_CheckCreate().

◆ WarpZone_RefSys_AddTransform()

void WarpZone_RefSys_AddTransform ( entity me,
vector t,
vector s )

Definition at line 756 of file common.qc.

757{
758 if (t == '0 0 0' && s == '0 0 0')
759 return;
761 WarpZone_Accumulator_AddTransform(me.WarpZone_refsys, t, s);
762}

References entity(), vector, WarpZone_Accumulator_AddTransform(), and WarpZone_RefSys_CheckCreate().

◆ WarpZone_RefSys_BeginAddingIncrementally()

void WarpZone_RefSys_BeginAddingIncrementally ( entity me,
entity ref )

Definition at line 783 of file common.qc.

784{
785 me.WarpZone_refsys_incremental_shift = ref.WarpZone_refsys.warpzone_shift;
786 me.WarpZone_refsys_incremental_transform = ref.WarpZone_refsys.warpzone_transform;
787}

References entity().

Referenced by GrapplingHookTouch().

◆ WarpZone_RefSys_CheckCreate()

void WarpZone_RefSys_CheckCreate ( entity me)

Definition at line 741 of file common.qc.

742{
743 if (me.WarpZone_refsys.owner == me)
744 return;
745 me.WarpZone_refsys = new(warpzone_refsys);
746 me.WarpZone_refsys.owner = me;
747 WarpZone_Accumulator_Clear(me.WarpZone_refsys);
748}
void WarpZone_Accumulator_Clear(entity acc)
Definition common.qc:11

References entity(), and WarpZone_Accumulator_Clear().

Referenced by WarpZone_RefSys_AddInverseTransform(), WarpZone_RefSys_AddTransform(), and WarpZone_RefSys_Copy().

◆ WarpZone_RefSys_Clear()

void WarpZone_RefSys_Clear ( entity me)

Definition at line 749 of file common.qc.

750{
751 if (!me.WarpZone_refsys)
752 return;
753 delete(me.WarpZone_refsys);
754 me.WarpZone_refsys = NULL;
755}

References entity(), and NULL.

Referenced by MUTATOR_HOOKFUNCTION(), and WarpZone_RefSys_Copy().

◆ WarpZone_RefSys_Copy()

void WarpZone_RefSys_Copy ( entity me,
entity from )

Copies the warpzone reference of from onto me.

In other words, makes it be "on the same side of the warpzones"

Definition at line 828 of file common.qc.

829{
830 if (from.WarpZone_refsys)
831 {
833 me.WarpZone_refsys.warpzone_shift = from.WarpZone_refsys.warpzone_shift;
834 me.WarpZone_refsys.warpzone_transform = from.WarpZone_refsys.warpzone_transform;
835 }
836 else
838}
void WarpZone_RefSys_Clear(entity me)
Definition common.qc:749

References entity(), WarpZone_RefSys_CheckCreate(), and WarpZone_RefSys_Clear().

Referenced by ctf_Handle_Throw(), FireGrapplingHook(), M_Mage_Attack_Spike(), Monster_Enemy_Check(), MUTATOR_HOOKFUNCTION(), spawn_held_nade(), W_Crylink_Attack(), W_Crylink_Attack2(), W_Devastator_Attack(), W_Fireball_Attack1(), W_Fireball_Attack2(), W_MineLayer_Attack(), W_Seeker_Fire_Missile(), W_Seeker_Fire_Tag(), W_Seeker_Tag_Touch(), and WarpZone_RefSys_SpawnSameRefSys().

◆ WarpZone_RefSys_SpawnSameRefSys()

entity WarpZone_RefSys_SpawnSameRefSys ( entity me)

Spawns an entity in the same warpzone reference as me, and sets up its reference.

Used when you need to spawn en entity, set up the reference system, and you know you're setting its origin "on the same side of the warpzones" as me

Definition at line 842 of file common.qc.

843{
844 entity e = spawn();
846 return e;
847}
#define spawn
void WarpZone_RefSys_Copy(entity me, entity from)
Copies the warpzone reference of from onto me.
Definition common.qc:828

References entity(), spawn, and WarpZone_RefSys_Copy().

◆ WarpZone_RefSys_TransformAngles()

vector WarpZone_RefSys_TransformAngles ( entity from,
entity to,
vector ang )

Transform angle ang in from's reference into to's reference.

Definition at line 809 of file common.qc.

810{
811 if (from.WarpZone_refsys)
812 ang = WarpZone_UnTransformAngles(from.WarpZone_refsys, ang);
813 if (to.WarpZone_refsys)
814 ang = WarpZone_TransformAngles(to.WarpZone_refsys, ang);
815 return ang;
816}
vector WarpZone_UnTransformAngles(entity wz, vector ang)
Transforms angle ang backwards through warpzone wz, as the inverse of WarpZone_TransformAngles.
Definition common.qc:540
vector WarpZone_TransformAngles(entity wz, vector ang)
Transforms angle v across warpzone wz.
Definition common.qc:504
vector vector ang
Definition self.qh:96

References ang, entity(), vector, WarpZone_TransformAngles(), and WarpZone_UnTransformAngles().

Referenced by nade_translocate_boom().

◆ WarpZone_RefSys_TransformOrigin()

vector WarpZone_RefSys_TransformOrigin ( entity from,
entity to,
vector org )

Transform origin org in from's reference into to's reference.

E.g., WarpZone_RefSys_TransformOrigin(receiver, flag, receiver.origin + receiver.view_ofs): Returns receiver's view origin as seen by flag

Definition at line 791 of file common.qc.

792{
793 if (from.WarpZone_refsys)
794 org = WarpZone_UnTransformOrigin(from.WarpZone_refsys, org);
795 if (to.WarpZone_refsys)
796 org = WarpZone_TransformOrigin(to.WarpZone_refsys, org);
797 return org;
798}
vector WarpZone_UnTransformOrigin(entity wz, vector org)
Transforms origin org backwards through warpzone wz, as the inverse of WarpZone_TransformOrigin.
Definition common.qc:530

References entity(), org, vector, WarpZone_TransformOrigin(), and WarpZone_UnTransformOrigin().

Referenced by ctf_FlagThink(), ctf_Handle_Throw(), GrapplingHookThink(), Monster_Enemy_Check(), Monster_Move_Target(), MUTATOR_HOOKFUNCTION(), W_Crylink_LinkJoin(), W_Devastator_RemoteExplode(), W_Devastator_Think(), W_Fireball_Explode(), W_Fireball_Firemine_Think(), W_Nexball_Think(), and W_SeekOutEnemy().

◆ WarpZone_RefSys_TransformVAngles()

vector WarpZone_RefSys_TransformVAngles ( entity from,
entity to,
vector ang )

Transform v_angle ang in from's reference into to's reference.

Definition at line 818 of file common.qc.

819{
820 if (from.WarpZone_refsys)
821 ang = WarpZone_UnTransformVAngles(from.WarpZone_refsys, ang);
822 if (to.WarpZone_refsys)
823 ang = WarpZone_TransformVAngles(to.WarpZone_refsys, ang);
824 return ang;
825}
vector WarpZone_UnTransformVAngles(entity wz, vector ang)
Transforms v_angle ang backwards through warpzone wz, as the inverse of WarpZone_TransformVAngles.
Definition common.qc:545
vector WarpZone_TransformVAngles(entity wz, vector ang)
Transforms v_angle ang across warpzone wz.
Definition common.qc:509

References ang, entity(), vector, WarpZone_TransformVAngles(), and WarpZone_UnTransformVAngles().

◆ WarpZone_RefSys_TransformVelocity()

vector WarpZone_RefSys_TransformVelocity ( entity from,
entity to,
vector vel )

Transform velocity vel in from's reference into to's reference.

Definition at line 800 of file common.qc.

801{
802 if (from.WarpZone_refsys)
803 vel = WarpZone_UnTransformVelocity(from.WarpZone_refsys, vel);
804 if (to.WarpZone_refsys)
805 vel = WarpZone_TransformVelocity(to.WarpZone_refsys, vel);
806 return vel;
807}
vector WarpZone_UnTransformVelocity(entity wz, vector vel)
Transforms angle vel backwards through warpzone wz, as the inverse of WarpZone_TransformVelocity.
Definition common.qc:535

References entity(), vector, WarpZone_TransformVelocity(), and WarpZone_UnTransformVelocity().

Referenced by GrapplingHookThink(), nade_translocate_boom(), W_Crylink_LinkJoin(), and W_Devastator_Think().

◆ WarpZone_SearchInRadius()

entity WarpZone_SearchInRadius ( vector org,
float radius,
float nomonsters,
WarpZone_FindRadius_cond_callback_t cb )

Modified findradius aware of warpzones, that only includes entities that meet the "cb" criteria.

Most useful if lineofsight, when searching with very specific criteria, or over a range likely to contain many entities.

Definition at line 684 of file common.qc.

685{
686 bool nearby_warpzones = false;
687 // use FOREACH_ENTITY_RADIUS if no warpzone is touching the box of side 2 * rad and center org
688 // which includes the sphere of radius rad and center org
690 {
691 vector boxmin = vec3(org.x - rad, org.y - rad, org.z - rad);
692 vector boxmax = vec3(org.x + rad, org.y + rad, org.z + rad);
693 IL_EACH(g_warpzones, boxesoverlap(it.absmin, it.absmax, boxmin, boxmax),
694 {
695 nearby_warpzones = true;
696 break;
697 });
698 }
699
701 if (nearby_warpzones)
702 {
706 _WarpZone_FindRadius_Recurse(org, rad, org, '0 0 0', '0 0 0');
707 FOREACH_LIST(_WarpZone_FindRadius_goodents, chain, true, it.WarpZone_findradius_hit = WarpZone_FindRadius_Hit_UNSEEN);
708 FOREACH_LIST(_WarpZone_FindRadius_badents, WarpZone_findradius_next, true, it.WarpZone_findradius_hit = WarpZone_FindRadius_Hit_UNSEEN);
709 }
710 else // cheaper than _WarpZone_FindRadius_Recurse
712 {
713 vector p = NearestPointOnBoundingBox(it.origin + it.mins, it.origin + it.maxs, org);
714 if (nomonsters != MOVE_NOTHING)
715 {
716 traceline(org, p, nomonsters, it);
717 if (trace_fraction < 1)
718 continue;
719 }
720
721 it.chain = _WarpZone_FindRadius_goodents_first; // fine to use .chain since FOREACH_ENTITY_RADIUS doesn't use it
723 it.WarpZone_findradius_nearest = p;
724 it.WarpZone_findradius_dist = org - p;
725 WarpZone_Accumulator_Clear(it); // reset .warpzone_transform and .warpzone_shift
726 });
727
729}
entity chain
#define FOREACH_LIST(list, next, cond, body)
Definition iter.qh:21
entity WarpZone_findradius_next
Definition common.qc:608
entity _WarpZone_FindRadius_badents_first
Definition common.qc:605
bool WarpZoneLib_BadEntity(entity e, WarpZone_FindRadius_cond_callback_t cb)
Blacklist of entities that WarpZone_FindRadius doesn't care about.
Definition common.qc:572
var WarpZone_FindRadius_cond_callback_t _WarpZone_FindRadius_cond_cb
Definition common.qc:607
ERASEABLE float boxesoverlap(vector m1, vector m2, vector m3, vector m4)
Requires that m2>m1 in all coordinates, and that m4>m3.
Definition vector.qh:72
#define vec3(_x, _y, _z)
Definition vector.qh:100

References _WarpZone_FindRadius_badents_first, _WarpZone_FindRadius_cond_cb, _WarpZone_FindRadius_goodents_first, _WarpZone_FindRadius_nomonsters, _WarpZone_FindRadius_Recurse(), boxesoverlap(), chain, entity(), FOREACH_ENTITY_RADIUS, FOREACH_LIST, g_warpzones, IL_EACH, MOVE_NOTHING, NearestPointOnBoundingBox(), NULL, org, trace_fraction, vec3, vector, WarpZone_Accumulator_Clear(), WarpZone_FindRadius_Hit_UNSEEN, WarpZone_findradius_next, warpzone_warpzones_exist, and WarpZoneLib_BadEntity().

Referenced by M_Golem_Attack_Lightning_Explode(), M_Mage_Defend_Heal(), M_Spider_Attack_Web_Explode(), M_Wyvern_Attack_Fireball_Explode(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), nade_darkness_think(), nade_ice_think(), PlayerFrame(), PlayerUseKey(), RadiusDamageForSource(), setItemGroup(), turret_tesla_toast(), W_Crylink_Touch_WouldHitFriendly(), W_Devastator_DoRemoteExplode(), W_Electro_Bolt_Think(), W_Electro_TriggerCombo(), W_Fireball_Explode(), W_LaserPlay(), W_MineLayer_ProximityExplode(), W_MineLayer_RemoteExplode(), W_MineLayer_Think(), and walker_melee_do_dmg().

◆ WarpZone_SetUp()

void WarpZone_SetUp ( entity e,
vector my_org,
vector my_ang,
vector other_org,
vector other_ang )

Definition at line 56 of file common.qc.

57{
58 e.warpzone_transform = AnglesTransform_RightDivide(other_ang, AnglesTransform_TurnDirectionFR(my_ang));
59 // fix small representation errors so that math operations with 0 will be cheaper
60 if (fabs(e.warpzone_transform.x) <= 0.000000000001) e.warpzone_transform.x = 0;
61 if (fabs(e.warpzone_transform.y) <= 0.000000000001) e.warpzone_transform.y = 0;
62 if (fabs(e.warpzone_transform.z) <= 0.000000000001) e.warpzone_transform.z = 0;
63 e.warpzone_shift = AnglesTransform_PrePostShift_GetPostShift(my_org, e.warpzone_transform, other_org);
64 e.warpzone_origin = my_org;
65 e.warpzone_targetorigin = other_org;
66 e.warpzone_angles = my_ang;
67 e.warpzone_targetangles = other_ang;
68 vector forward, right, up;
69 FIXED_MAKE_VECTORS(my_ang, forward, right, up);
70 e.warpzone_forward = forward;
71 FIXED_MAKE_VECTORS(other_ang, forward, right, up);
72 e.warpzone_targetforward = forward;
74}
vector AnglesTransform_TurnDirectionFR(vector transform)
vector AnglesTransform_RightDivide(vector to_transform, vector from_transform)
#define FIXED_MAKE_VECTORS(angles, forward, right, up)
vector WarpZone_camera_transform(entity this, vector org, vector ang)
Definition common.qc:35
float fabs(float f)

References AnglesTransform_PrePostShift_GetPostShift(), AnglesTransform_RightDivide(), AnglesTransform_TurnDirectionFR(), entity(), fabs(), FIXED_MAKE_VECTORS, setcamera_transform, vector, and WarpZone_camera_transform().

Referenced by NET_HANDLE(), and WarpZone_InitStep_FinalizeTransform().

◆ WarpZone_TargetPlaneDist()

float WarpZone_TargetPlaneDist ( entity wz,
vector p )

Definition at line 487 of file common.qc.

488{
489 return (p - wz.warpzone_targetorigin) * wz.warpzone_targetforward;
490}

References entity(), and vector.

Referenced by WarpZone_Teleport().

◆ WarpZone_Trace_InitTransform()

void WarpZone_Trace_InitTransform ( )

Definition at line 176 of file common.qc.

177{
179 WarpZone_trace_transform = new_pure(warpzone_trace_transform);
181}
#define new_pure(class)
purely logical entities (not linked to the area grid)
Definition oo.qh:66

References new_pure, WarpZone_Accumulator_Clear(), and WarpZone_trace_transform.

Referenced by WarpZone_TraceBox_ThroughZone(), and WarpZone_TraceToss_ThroughZone().

◆ WarpZone_TraceBox_ThroughZone()

void WarpZone_TraceBox_ThroughZone ( vector org,
vector mi,
vector ma,
vector end,
float nomonsters,
entity forent,
entity zone,
WarpZone_trace_callback_t cb )

Traces a box from org to end, shifting & transforming each time it goes through a warpzone.

Hence it only ends at end if it didn't hit something along the way AND it went through no warpzones

Definition at line 187 of file common.qc.

188{
189 WarpZone_trace_forent = forent;
193
194 bool nearby_warpzones = false;
195 // use tracebox if no warpzone is touching the box the entity would be traced through
197 {
198 vector boxmin = mi;
199 vector boxmax = ma;
200 #define CHOOSE_AXIS(axis) \
201 if (org.axis < end.axis) { boxmin.axis += org.axis; boxmax.axis += end.axis; } \
202 else { boxmin.axis += end.axis; boxmax.axis += org.axis; }
203 CHOOSE_AXIS(x);
204 CHOOSE_AXIS(y);
205 CHOOSE_AXIS(z);
206 #undef CHOOSE_AXIS
207 /* Above is equivalent to the following, but more efficient
208 * boxmin += vec_to_min(org, end);
209 * boxmax += vec_to_max(org, end);
210 */
211 IL_EACH(g_warpzones, boxesoverlap(it.absmin, it.absmax, boxmin, boxmax),
212 {
213 nearby_warpzones = true;
214 break;
215 });
216 }
217 if (!nearby_warpzones)
218 {
219 if (nomonsters == MOVE_NOTHING)
220 {
221 trace_endpos = end;
222 trace_fraction = 1;
223 }
224 else
225 tracebox(org, mi, ma, end, nomonsters, WarpZone_trace_forent);
226
227 if (cb)
228 cb(org, trace_endpos, end);
229 return;
230 }
231
232 vector vf = v_forward;
233 vector vr = v_right;
234 vector vu = v_up;
235
236 float nomonsters_adjusted;
237 switch (nomonsters)
238 {
239 case MOVE_WORLDONLY:
240 case MOVE_NOTHING:
241 nomonsters_adjusted = MOVE_NOMONSTERS;
242 break;
243 default:
244 nomonsters_adjusted = nomonsters;
245 break;
246 }
247 bool contents_hack = (WarpZone_trace_forent.dphitcontentsmask && !(WarpZone_trace_forent.dphitcontentsmask & DPCONTENTS_SOLID));
248 if (contents_hack)
250
251 // if starting in warpzone, first transform
252 entity wz = WarpZone_Find(org + mi, org + ma);
253 float sol;
254 if (wz)
255 {
258 if (zone && wz != zone)
259 {
260 // we are in ANOTHER warpzone. This is bad. Make a zero length trace and return.
261 sol = 1;
262 trace_fraction = 0;
264 goto fail;
265 }
268 end = WarpZone_TransformOrigin(wz, end);
269 }
271 sol = -1;
272 float frac = 0;
273 float i = 16;
274 for (;;)
275 {
276 if (--i < 1)
277 {
278 LOG_TRACE("Too many warpzones in sequence, aborting trace.");
279 trace_ent = NULL;
280 break;
281 }
282 tracebox(org, mi, ma, end, nomonsters_adjusted, WarpZone_trace_forent);
283 if (cb)
284 cb(org, trace_endpos, end);
285 if (sol < 0)
286 sol = trace_startsolid;
287
288 frac = trace_fraction = frac + (1 - frac) * trace_fraction;
289 if (trace_fraction >= 1)
290 break;
291 if (trace_ent.classname != "trigger_warpzone")
292 {
293 if (nomonsters == MOVE_NOTHING
294 || (nomonsters == MOVE_WORLDONLY && trace_ent)
295 || (contents_hack && (trace_dphitcontents & WarpZone_trace_forent.dphitcontentsmask) == DPCONTENTS_SOLID))
296 {
297 // continue the trace, ignoring this hit (we only care for warpzones)
298 org = trace_endpos + normalize(end - org);
299 continue;
300 // we cannot do an inverted trace here, as we do care for further warpzones inside that "solid" to be found
301 // otherwise, players could block entrances that way
302 }
303 break;
304 }
305 /*if (trace_ent == wz)
306 {
307 // FIXME can this check be removed? Do we really need it?
308 LOG_TRACE("I transformed into the same zone again, wtf, aborting the trace");
309 trace_ent = NULL;
310 break;
311 }*/
312 wz = trace_ent;
316 if (zone && wz != zone)
317 break;
319 // we hit a warpzone... so, let's perform the trace after the warp again
321 end = WarpZone_TransformOrigin(wz, end);
322
323 // we got warped, so let's step back a bit
324 tracebox(org, mi, ma, org + normalize(org - end) * 32, nomonsters_adjusted, WarpZone_trace_forent);
326 }
328LABEL(fail)
329 if (contents_hack)
331 trace_startsolid = sol;
332 v_forward = vf;
333 v_right = vr;
334 v_up = vu;
335}
#define LABEL(id)
Definition compiler.qh:34
float trace_dphitcontents
entity trace_ent
float DPCONTENTS_SOLID
float trace_startsolid
float MOVE_WORLDONLY
v y
Definition ent_cs.qc:146
v z
Definition ent_cs.qc:146
v x
Definition ent_cs.qc:146
entity WarpZone_Find(vector mi, vector ma)
Definition common.qc:156
void WarpZone_Trace_InitTransform()
Definition common.qc:176
#define WarpZone_Trace_AddTransform(wz)
Definition common.qc:182
void WarpZone_MakeAllOther()
Definition common.qc:170
void WarpZone_MakeAllSolid()
Definition common.qc:164
#define CHOOSE_AXIS(axis)
entity WarpZone_trace_firstzone
First warpzone hit by a trace (can differ from the requested zone in case of _ThroughZone,...
Definition common.qh:41
#define BITSET_ASSIGN(a, b)
Definition common.qh:122
#define BITCLR_ASSIGN(a, b)
Definition common.qh:119
entity WarpZone_trace_lastzone
First warpzone hit by a trace (can differ from the requested zone in case of _ThroughZone,...
Definition common.qh:42
entity WarpZone_trace_forent
Temp, callback is allowed to change it.
Definition common.qh:36
#define LOG_TRACE(...)
Definition log.qh:74
vector normalize(vector v)

References BITCLR_ASSIGN, BITSET_ASSIGN, boxesoverlap(), CHOOSE_AXIS, DPCONTENTS_SOLID, entity(), g_warpzones, IL_EACH, LABEL, LOG_TRACE, MOVE_NOMONSTERS, MOVE_NOTHING, MOVE_WORLDONLY, normalize(), NULL, org, trace_dphitcontents, trace_endpos, trace_ent, trace_fraction, trace_startsolid, v_forward, v_right, v_up, vector, WarpZone_Find(), WarpZone_MakeAllOther(), WarpZone_MakeAllSolid(), WarpZone_Trace_AddTransform, WarpZone_trace_firstzone, WarpZone_trace_forent, WarpZone_Trace_InitTransform(), WarpZone_trace_lastzone, WarpZone_TransformOrigin(), warpzone_warpzones_exist, x, y, and z.

Referenced by tracebox_antilag_force_wz().

◆ WarpZone_TraceToss_ThroughZone()

void WarpZone_TraceToss_ThroughZone ( entity e,
entity forent,
entity zone,
WarpZone_trace_callback_t cb )

Traces tossing e, shifting & transforming each time it goes through a warpzone.

Definition at line 338 of file common.qc.

339{
340 vector o0 = e.origin;
341 vector v0 = e.velocity;
342 float dt, i, g = PHYS_GRAVITY(NULL) * e.gravity;
343
344 WarpZone_trace_forent = forent;
350 {
351 tracetoss(e, WarpZone_trace_forent);
352 if (cb)
353 cb(e.origin, trace_endpos, trace_endpos);
354 dt = sqrt(vlen2(e.origin - o0) / vlen2(e.velocity));
356 e.velocity.z -= dt * g;
357 WarpZone_tracetoss_velocity = e.velocity;
358 e.velocity = v0;
359 return;
360 }
361
362 vector vf = v_forward;
363 vector vr = v_right;
364 vector vu = v_up;
365
366 // if starting in warpzone, first transform
367 entity wz = WarpZone_Find(e.origin + e.mins, e.origin + e.maxs);
368 if (wz)
369 {
372 if (zone && wz != zone)
373 {
374 // we are in ANOTHER warpzone. This is bad. Make a zero length trace and return.
375
377 trace_endpos = o0;
378 goto fail;
379 }
381 vector org = WarpZone_TransformOrigin(wz, e.origin);
382 setorigin(e, org);
383 e.velocity = WarpZone_TransformVelocity(wz, e.velocity);
384 }
386 i = 16;
387 for (;;)
388 {
389 if (--i < 1)
390 {
391 LOG_TRACE("Too many warpzones in sequence, aborting trace.");
392 trace_ent = NULL;
393 break;
394 }
395 tracetoss(e, WarpZone_trace_forent);
396 if (cb)
397 cb(e.origin, trace_endpos, trace_endpos);
398 dt = sqrt(vlen2(trace_endpos - e.origin) / vlen2(e.velocity));
400 e.origin = trace_endpos;
401 e.velocity.z -= dt * g;
402 if (trace_fraction >= 1)
403 break;
404 if (trace_ent.classname != "trigger_warpzone")
405 break;
406 if (trace_ent == wz)
407 {
408 // FIXME can this check be removed? Do we really need it?
409 LOG_TRACE("I transformed into the same zone again, wtf, aborting the trace");
410 trace_ent = NULL;
411 break;
412 }
413 wz = trace_ent;
417 if (zone && wz != zone)
418 break;
420 // we hit a warpzone... so, let's perform the trace after the warp again
421 e.origin = WarpZone_TransformOrigin(wz, e.origin);
422 e.velocity = WarpZone_TransformVelocity(wz, e.velocity);
423
424 // we got warped, so let's step back a bit
425 e.velocity = -e.velocity;
426 tracetoss(e, WarpZone_trace_forent);
427 dt = sqrt(vlen2(trace_endpos - e.origin) / vlen2(e.velocity));
429 e.origin = trace_endpos;
430 e.velocity = -e.velocity;
431 }
433LABEL(fail)
434 WarpZone_tracetoss_velocity = e.velocity;
435 v_forward = vf;
436 v_right = vr;
437 v_up = vu;
438 // restore old entity data (caller just uses trace_endpos, WarpZone_tracetoss_velocity and the transform)
439 e.velocity = v0;
440 e.origin = o0;
441}
vector WarpZone_tracetoss_velocity
Ending velocity of a tracetoss (post-transform).
Definition common.qh:43
float WarpZone_tracetoss_time
Duration of toss (approximate).
Definition common.qh:44
float sqrt(float f)
#define PHYS_GRAVITY(s)
Definition movetypes.qh:54

References entity(), LABEL, LOG_TRACE, NULL, org, PHYS_GRAVITY, sqrt(), trace_endpos, trace_ent, trace_fraction, v_forward, v_right, v_up, vector, vlen2, WarpZone_Find(), WarpZone_MakeAllOther(), WarpZone_MakeAllSolid(), WarpZone_Trace_AddTransform, WarpZone_trace_firstzone, WarpZone_trace_forent, WarpZone_Trace_InitTransform(), WarpZone_trace_lastzone, WarpZone_tracetoss_time, WarpZone_tracetoss_velocity, WarpZone_TransformOrigin(), WarpZone_TransformVelocity(), and warpzone_warpzones_exist.

◆ WarpZone_TrailParticles()

void WarpZone_TrailParticles ( entity own,
float eff,
vector org,
vector end )

Definition at line 450 of file common.qc.

451{
455}
entity WarpZone_TrailParticles_trace_callback_own
Definition common.qc:443
void WarpZone_TrailParticles_trace_callback(vector from, vector endpos, vector to)
Definition common.qc:445
float WarpZone_TrailParticles_trace_callback_eff
Definition common.qc:444
#define WarpZone_TraceLine_ThroughZone(org, end, nomonsters, forent, zone, cb)
Definition common.qh:47

References entity(), MOVE_NOMONSTERS, NULL, org, vector, WarpZone_TraceLine_ThroughZone, WarpZone_TrailParticles_trace_callback(), WarpZone_TrailParticles_trace_callback_eff, and WarpZone_TrailParticles_trace_callback_own.

Referenced by CheatCommand(), and ctf_Handle_Throw().

◆ WarpZone_TrailParticles_trace_callback()

void WarpZone_TrailParticles_trace_callback ( vector from,
vector endpos,
vector to )

◆ WarpZone_TrailParticles_WithMultiplier()

◆ WarpZone_TrailParticles_WithMultiplier_trace_callback()

◆ WarpZone_TransformAngles()

vector WarpZone_TransformAngles ( entity wz,
vector ang )

Transforms angle v across warpzone wz.

Definition at line 504 of file common.qc.

505{
506 return AnglesTransform_ApplyToAngles(wz.warpzone_transform, ang);
507}
vector AnglesTransform_ApplyToAngles(vector transform, vector v)

References ang, AnglesTransform_ApplyToAngles(), entity(), and vector.

Referenced by WarpZone_RefSys_TransformAngles(), and WarpZone_Teleport().

◆ WarpZone_TransformOrigin()

vector WarpZone_TransformOrigin ( entity wz,
vector org )

Transforms origin org across warpzone wz.

For example, this'd give you the origin a projectile will have after it crosses the warpzone

Definition at line 493 of file common.qc.

494{
495 return wz.warpzone_shift + AnglesTransform_Apply(wz.warpzone_transform, org);
496}
vector AnglesTransform_Apply(vector transform, vector v)
angles transforms angles in fixedmakevectors/fixedvectoangles space

References AnglesTransform_Apply(), entity(), org, and vector.

Referenced by CheatCommand(), Draw_ArcBeam(), Draw_ArcBeam_callback(), Draw_GrapplingHook(), Draw_GrapplingHook_trace_callback(), Draw_VaporizerBeam_trace_callback(), fireBullet_falloff(), W_Arc_Beam_Think(), W_Fireball_Explode(), W_OverkillRocketPropelledChainsaw_Think(), WarpZone_camera_transform(), WarpZone_FixPMove(), WarpZone_FixView(), WarpZone_RefSys_TransformOrigin(), WarpZone_Teleport(), WarpZone_TraceBox_ThroughZone(), and WarpZone_TraceToss_ThroughZone().

◆ WarpZone_TransformVAngles()

vector WarpZone_TransformVAngles ( entity wz,
vector ang )

Transforms v_angle ang across warpzone wz.

Definition at line 509 of file common.qc.

510{
511#ifdef KEEP_ROLL
512 float roll = ang.z;
513 ang.z = 0;
514#endif
515
516 ang = AnglesTransform_ApplyToVAngles(wz.warpzone_transform, ang);
517#ifdef KEEP_ROLL
520 ang.z = roll;
521#else
523#endif
524 return ang;
525}
vector AnglesTransform_ApplyToVAngles(vector transform, vector v)
vector AnglesTransform_CancelRoll(vector t)
vector AnglesTransform_Normalize(vector t, float minimize_roll)

References ang, AnglesTransform_ApplyToVAngles(), AnglesTransform_CancelRoll(), AnglesTransform_Normalize(), entity(), and vector.

Referenced by NET_HANDLE(), sandbox_ObjectSpawn(), View_EventChase(), WarpZone_FixPMove(), WarpZone_FixView(), WarpZone_PlayerPhysics_FixVAngle(), WarpZone_RefSys_TransformVAngles(), and WarpZone_Teleport().

◆ WarpZone_TransformVelocity()

vector WarpZone_TransformVelocity ( entity wz,
vector vel )

Transforms velocity v across warpzone wz.

For example, this can give you the updated v_forward after crossing the warpzone

Definition at line 499 of file common.qc.

500{
501 return AnglesTransform_Apply(wz.warpzone_transform, vel);
502}

References AnglesTransform_Apply(), entity(), and vector.

Referenced by Draw_ArcBeam(), fireBullet_falloff(), FireImoBeam(), FireRailgunBullet(), W_Arc_Beam_Think(), W_Shotgun_Melee_Think(), walker_melee_do_dmg(), WarpZone_camera_transform(), WarpZone_RefSys_TransformVelocity(), WarpZone_Teleport(), and WarpZone_TraceToss_ThroughZone().

◆ WarpZone_UnTransformAngles()

vector WarpZone_UnTransformAngles ( entity wz,
vector ang )

Transforms angle ang backwards through warpzone wz, as the inverse of WarpZone_TransformAngles.

Definition at line 540 of file common.qc.

541{
542 return AnglesTransform_ApplyToAngles(AnglesTransform_Invert(wz.warpzone_transform), ang);
543}

References ang, AnglesTransform_ApplyToAngles(), AnglesTransform_Invert(), entity(), and vector.

Referenced by WarpZone_RefSys_TransformAngles().

◆ WarpZone_UnTransformOrigin()

vector WarpZone_UnTransformOrigin ( entity wz,
vector org )

Transforms origin org backwards through warpzone wz, as the inverse of WarpZone_TransformOrigin.

E.g., WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos): Returns the endpoint of a warpzone-aware trace, as if the trace had never gone through warpzones

Definition at line 530 of file common.qc.

531{
532 return AnglesTransform_Apply(AnglesTransform_Invert(wz.warpzone_transform), org - wz.warpzone_shift);
533}

References AnglesTransform_Apply(), AnglesTransform_Invert(), entity(), org, and vector.

Referenced by beam_think(), ctf_CalculatePassVelocity(), Draw_ArcBeam(), Draw_ArcBeam_callback(), fireBullet_falloff(), FireImoBeam(), FireRailgunBullet(), M_Golem_Attack_Lightning_Explode(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), PlayerUseKey(), RadiusDamageForSource(), sandbox_ObjectEdit_Get(), SendCSQCVaporizerBeamParticle(), SendCSQCVortexBeamParticle(), turret_tesla_toast(), W_Arc_Beam_Think(), W_LaserPlay(), W_SeekOutEnemy(), W_SetupShot_Dir_ProjectileSize_Range(), W_Vaporizer_Attack(), W_Vortex_Attack(), and WarpZone_RefSys_TransformOrigin().

◆ WarpZone_UnTransformVAngles()

vector WarpZone_UnTransformVAngles ( entity wz,
vector ang )

Transforms v_angle ang backwards through warpzone wz, as the inverse of WarpZone_TransformVAngles.

Definition at line 545 of file common.qc.

546{
547#ifdef KEEP_ROLL
548 float roll = ang.z;
549 ang.z = 0;
550#endif
551
553#ifdef KEEP_ROLL
556 ang.z = roll;
557#else
559#endif
560 return ang;
561}

References ang, AnglesTransform_ApplyToVAngles(), AnglesTransform_CancelRoll(), AnglesTransform_Invert(), AnglesTransform_Normalize(), entity(), and vector.

Referenced by WarpZone_RefSys_TransformVAngles().

◆ WarpZone_UnTransformVelocity()

vector WarpZone_UnTransformVelocity ( entity wz,
vector vel )

Transforms angle vel backwards through warpzone wz, as the inverse of WarpZone_TransformVelocity.

Definition at line 535 of file common.qc.

536{
537 return AnglesTransform_Apply(AnglesTransform_Invert(wz.warpzone_transform), vel);
538}

References AnglesTransform_Apply(), AnglesTransform_Invert(), entity(), and vector.

Referenced by WarpZone_RefSys_TransformVelocity().

◆ WarpZoneLib_BadEntity()

bool WarpZoneLib_BadEntity ( entity e,
WarpZone_FindRadius_cond_callback_t cb )

Blacklist of entities that WarpZone_FindRadius doesn't care about.

Definition at line 572 of file common.qc.

573{
574 if (e.WarpZone_findradius_hit != WarpZone_FindRadius_Hit_UNSEEN) // also account for caching
575 return (e.WarpZone_findradius_hit == WarpZone_FindRadius_Hit_BAD); // either BAD or GOOD
576 if (is_pure(e))
577 return true;
578
579 string s = e.classname;
580 switch (s)
581 {
582 case "warpzone_refsys": // ignore, especially: do not overwrite the refsys parameters
583 case "weaponentity":
584 case "exteriorweaponentity":
585 case "sprite_waypoint":
586 case "waypoint":
587 case "spawnfunc":
588 case "weaponchild":
589 case "chatbubbleentity":
590 case "buff_model":
591 //case "net_linked": // actually some real entities are linked without classname, fail
592 case "":
593 return true;
594 }
595 if (startsWith(s, "target_"))
596 return true;
597 if (startsWith(s, "info_"))
598 return true;
599
600 return (cb && !cb(e));
601}
#define is_pure(e)
Definition oo.qh:16
#define startsWith(haystack, needle)
Definition string.qh:234

References entity(), is_pure, startsWith, WarpZone_FindRadius_Hit_BAD, and WarpZone_FindRadius_Hit_UNSEEN.

Referenced by WarpZone_SearchInRadius().

◆ WarpZoneLib_BoxTouchesBrush()

float WarpZoneLib_BoxTouchesBrush ( vector mi,
vector ma,
entity e,
entity ig )

Definition at line 124 of file common.qc.

125{
126 // bones_was_here: TODO: when findbox_OrFallback() is available, use it to
127 // optimise this into a single non-recursive function that only calls tracebox once
128
129 if (!e.modelindex || e.warpzone_isboxy)
130 return 1;
131
132 // work around trigger_hurt on geit3ctf1 not being detected by tracebox
133 // bones_was_here: FIXME: WHY do these triggers only have supercontents == 128 ?!
134 if (Q3COMPAT_COMMON && ig != world)
135 ig.dphitcontentsmask |= 128;
136
137 float s = e.solid;
138 if (e.solid != SOLID_BSP)
139 {
140 e.solid = SOLID_BSP;
141 setorigin(e, e.origin); // update linking
142 }
143 float f = WarpZoneLib_BoxTouchesBrush_Recurse(mi, ma, e, ig);
144 if (e.solid != s) // if we needed to change .solid temporarily
145 {
146 e.solid = s; // restore it
147 setorigin(e, e.origin); // update linking
148 }
149
150 if (Q3COMPAT_COMMON && ig != world)
151 ig.dphitcontentsmask &= ~128;
152
153 return f;
154}
#define Q3COMPAT_COMMON
Definition stats.qh:370
float WarpZoneLib_BoxTouchesBrush_Recurse(vector mi, vector ma, entity e, entity ig)
Definition common.qc:96
#define world
Definition post.qh:15

References entity(), Q3COMPAT_COMMON, SOLID_BSP, vector, WarpZoneLib_BoxTouchesBrush_Recurse(), and world.

Referenced by havocbot_moveto(), Teleport_Find(), WarpZone_Find(), and WarpZoneLib_ExactTrigger_Touch().

◆ WarpZoneLib_BoxTouchesBrush_Recurse()

float WarpZoneLib_BoxTouchesBrush_Recurse ( vector mi,
vector ma,
entity e,
entity ig )

Definition at line 96 of file common.qc.

97{
98 tracebox('0 0 0', mi, ma, '0 0 0', MOVE_NOMONSTERS, ig);
99#ifdef CSQC
101 {
102 LOG_TRACE("hit a network ent, cannot continue WarpZoneLib_BoxTouchesBrush");
103 // we cannot continue, as a player blocks us...
104 // so, abort
105 return 0;
106 }
107#endif
108 if (!trace_ent)
109 return 0;
110 if (trace_ent == e)
111 return 1;
112
113 entity se = trace_ent;
114 float s = se.solid;
115 se.solid = SOLID_NOT;
116 setorigin(se, se.origin); // unlink
117 float f = WarpZoneLib_BoxTouchesBrush_Recurse(mi, ma, e, ig);
118 se.solid = s;
119 setorigin(se, se.origin); // relink
120
121 return f;
122}
const float SOLID_NOT
float trace_networkentity

References entity(), LOG_TRACE, MOVE_NOMONSTERS, SOLID_NOT, trace_ent, trace_networkentity, vector, and WarpZoneLib_BoxTouchesBrush_Recurse().

Referenced by WarpZoneLib_BoxTouchesBrush(), and WarpZoneLib_BoxTouchesBrush_Recurse().

◆ WarpZoneLib_ExactTrigger_Touch()

bool WarpZoneLib_ExactTrigger_Touch ( entity this,
entity toucher,
bool touchfunc )

Definition at line 849 of file common.qc.

850{
851 vector emin = toucher.absmin, emax = toucher.absmax;
852 if (!Q3COMPAT_COMMON)
853 {
854 // Xonotic and Nexuiz maps assume triggers will be activated by adjacent players
855 // prior to sv_legacy_bbox_expand 0 DP always did this for SVQC and never for CSQC
856 emin -= '1 1 1';
857 emax += '1 1 1';
858 }
859
860 // if called from a touch func, we can assume the boxes do overlap
861 if (!touchfunc && !boxesoverlap(emin, emax, this.absmin, this.absmax)) // quick
862 return false;
863
864 return WarpZoneLib_BoxTouchesBrush(emin, emax, this, toucher); // accurate
865}
vector absmax
vector absmin
entity entity toucher
Definition self.qh:76

References absmax, absmin, boxesoverlap(), entity(), Q3COMPAT_COMMON, toucher, vector, and WarpZoneLib_BoxTouchesBrush().

Referenced by conveyor_think(), func_ladder_think(), SV_PlayerPhysics(), swamp_think(), viewloc_think(), and WarpZone_StartFrame().

◆ WarpZoneLib_MoveOutOfSolid()

int WarpZoneLib_MoveOutOfSolid ( entity e)

Definition at line 879 of file common.qc.

880{
881 vector o = e.origin;
882 traceline(o, o, MOVE_WORLDONLY, e);
884 return 0; // too stuck, giving up
885
886 tracebox(o, e.mins, e.maxs, o, MOVE_WORLDONLY, e);
887 if (!trace_startsolid)
888 return -1; // wasn't stuck
889
890 vector m0 = e.mins;
891 vector m1 = e.maxs;
892 e.mins = '0 0 0';
893 e.maxs = '0 0 0';
894 WarpZoneLib_MoveOutOfSolid_Expand(e, eX * m0.x); e.mins.x = m0.x;
895 WarpZoneLib_MoveOutOfSolid_Expand(e, eX * m1.x); e.maxs.x = m1.x;
896 WarpZoneLib_MoveOutOfSolid_Expand(e, eY * m0.y); e.mins.y = m0.y;
897 WarpZoneLib_MoveOutOfSolid_Expand(e, eY * m1.y); e.maxs.y = m1.y;
898 WarpZoneLib_MoveOutOfSolid_Expand(e, eZ * m0.z); e.mins.z = m0.z;
899 WarpZoneLib_MoveOutOfSolid_Expand(e, eZ * m1.z); e.maxs.z = m1.z;
900 setorigin(e, e.origin);
901
902 tracebox(e.origin, e.mins, e.maxs, e.origin, MOVE_WORLDONLY, e);
904 {
905 setorigin(e, o);
906 return 0; // can't fix
907 }
908
909 return 1; // was stuck but is fixed now
910}
void WarpZoneLib_MoveOutOfSolid_Expand(entity e, vector by)
Definition common.qc:868
const vector eY
Definition vector.qh:44
const vector eZ
Definition vector.qh:45
const vector eX
Definition vector.qh:43

References entity(), eX, eY, eZ, MOVE_WORLDONLY, trace_startsolid, vector, and WarpZoneLib_MoveOutOfSolid_Expand().

Referenced by CheckEngineExtensions(), and WarpZone_Teleport().

◆ WarpZoneLib_MoveOutOfSolid_Expand()

void WarpZoneLib_MoveOutOfSolid_Expand ( entity e,
vector by )

Definition at line 868 of file common.qc.

869{
870 const float eps = 1/16; // 0.0625
871 tracebox(e.origin, e.mins - '1 1 1' * eps, e.maxs + '1 1 1' * eps, e.origin + by, MOVE_WORLDONLY, e);
873 return;
874 if (trace_fraction < 1)
875 // hit something, adjust origin in the other direction...
876 setorigin(e, e.origin - by * (1 - trace_fraction));
877}

References entity(), MOVE_WORLDONLY, trace_fraction, trace_startsolid, and vector.

Referenced by WarpZoneLib_MoveOutOfSolid().

Variable Documentation

◆ _WarpZone_FindRadius_badents_first

entity _WarpZone_FindRadius_badents_first

Definition at line 605 of file common.qc.

Referenced by WarpZone_SearchInRadius().

◆ _WarpZone_FindRadius_cond_cb

var WarpZone_FindRadius_cond_callback_t _WarpZone_FindRadius_cond_cb

Definition at line 607 of file common.qc.

Referenced by WarpZone_SearchInRadius().

◆ _WarpZone_FindRadius_goodents_first

entity _WarpZone_FindRadius_goodents_first

Definition at line 604 of file common.qc.

Referenced by _WarpZone_FindRadius_Recurse(), and WarpZone_SearchInRadius().

◆ _WarpZone_FindRadius_nomonsters

float _WarpZone_FindRadius_nomonsters

Definition at line 606 of file common.qc.

Referenced by _WarpZone_FindRadius_Recurse(), and WarpZone_SearchInRadius().

◆ enemy

entity enemy

Definition at line 603 of file common.qc.

◆ WarpZone_findradius_hit

int WarpZone_findradius_hit

Definition at line 567 of file common.qc.

◆ WarpZone_FindRadius_Hit_BAD

const int WarpZone_FindRadius_Hit_BAD = 2

Definition at line 570 of file common.qc.

Referenced by _WarpZone_FindRadius_Recurse(), and WarpZoneLib_BadEntity().

◆ WarpZone_FindRadius_Hit_GOOD

const int WarpZone_FindRadius_Hit_GOOD = 1

Definition at line 569 of file common.qc.

Referenced by _WarpZone_FindRadius_Recurse().

◆ WarpZone_FindRadius_Hit_UNSEEN

const int WarpZone_FindRadius_Hit_UNSEEN = 0

Definition at line 568 of file common.qc.

Referenced by WarpZone_SearchInRadius(), and WarpZoneLib_BadEntity().

◆ WarpZone_findradius_next

entity WarpZone_findradius_next

Definition at line 608 of file common.qc.

Referenced by WarpZone_SearchInRadius().

◆ WarpZone_refsys

entity WarpZone_refsys

Definition at line 731 of file common.qc.

Referenced by ONREMOVE().

◆ WarpZone_refsys_incremental_shift

vector WarpZone_refsys_incremental_shift

Definition at line 770 of file common.qc.

◆ WarpZone_refsys_incremental_transform

vector WarpZone_refsys_incremental_transform

Definition at line 771 of file common.qc.

◆ WarpZone_TrailParticles_trace_callback_eff

◆ WarpZone_TrailParticles_trace_callback_f

float WarpZone_TrailParticles_trace_callback_f

◆ WarpZone_TrailParticles_trace_callback_flags

float WarpZone_TrailParticles_trace_callback_flags

◆ WarpZone_TrailParticles_trace_callback_own