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 178 of file common.qc.

178#define WarpZone_Trace_AddTransform(wz) \
179 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 561 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 605 of file common.qc.

614{
615 if (rad <= 0)
616 return;
617 entity wz = NULL;
618 FOREACH_ENTITY_RADIUS(org, rad, it.WarpZone_findradius_hit != WarpZone_FindRadius_Hit_BAD, // exclude entities we already know are bad
619 {
620 bool is_warpzone = (it.classname == "trigger_warpzone");
621 if (!is_warpzone // warpzones are never bad entities
622 && WarpZoneLib_BadEntity(it, _WarpZone_FindRadius_cond_cb))
623 {
624 it.WarpZone_findradius_hit = WarpZone_FindRadius_Hit_BAD;
625 it.WarpZone_findradius_next = _WarpZone_FindRadius_badents_first;
626 // use .WarpZone_findradius_next so that .chain isn't changed on entities not included in the returned list_first
627 _WarpZone_FindRadius_badents_first = it;
628 continue;
629 }
630
631 vector p = WarpZoneLib_NearestPointOnBox(it.origin + it.mins, it.origin + it.maxs, org0);
632 if (it.WarpZone_findradius_hit == WarpZone_FindRadius_Hit_GOOD && vlen2(it.WarpZone_findradius_dist) <= vlen2(org0 - p))
633 continue;
635 {
636 traceline(org, p, _WarpZone_FindRadius_nomonsters, it);
637 if (trace_fraction < 1)
638 continue;
639 }
640
641 it.WarpZone_findradius_nearest = p;
642 it.WarpZone_findradius_dist = org0 - p;
643 //it.WarpZone_findradius_findorigin = org;
644 //it.WarpZone_findradius_findradius = rad;
645 if (is_warpzone)
646 {
647 it.WarpZone_findradius_next = wz;
648 wz = it;
649 it.WarpZone_findradius_hit = WarpZone_FindRadius_Hit_GOOD;
650 it.enemy.WarpZone_findradius_dist = '0 0 0'; // we don't want to go through this zone ever again
651 it.enemy.WarpZone_findradius_hit = WarpZone_FindRadius_Hit_GOOD;
652 }
653 else // entity we'll include in the list
654 {
655 it.warpzone_transform = transform;
656 it.warpzone_shift = shift;
657 if (it.WarpZone_findradius_hit != WarpZone_FindRadius_Hit_GOOD) // add to good ents chain if not already in it
658 {
659 it.chain = _WarpZone_FindRadius_goodents_first; // fine to use .chain since FOREACH_ENTITY_RADIUS doesn't use it
661 it.WarpZone_findradius_hit = WarpZone_FindRadius_Hit_GOOD;
662 }
663 }
664 });
665 for (entity e = wz; e; e = e.WarpZone_findradius_next)
666 {
667 vector org0_new = WarpZone_TransformOrigin(e, org);
668 traceline(e.warpzone_targetorigin, org0_new, MOVE_NOMONSTERS, e);
669 vector org_new = trace_endpos;
670
672 org_new,
673 rad - max(8, vlen(org_new - org0_new)),
674 org0_new,
675 AnglesTransform_Multiply(e.warpzone_transform, transform), // new transform
676 AnglesTransform_Multiply_GetPostShift(e.warpzone_transform, e.warpzone_shift, transform, shift)); // new shift
677 e.WarpZone_findradius_hit = e.enemy.WarpZone_findradius_hit = WarpZone_FindRadius_Hit_UNSEEN;
678 }
679}
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:561
const int WarpZone_FindRadius_Hit_GOOD
Definition common.qc:565
const int WarpZone_FindRadius_Hit_BAD
Definition common.qc:566
vector WarpZone_TransformOrigin(entity wz, vector org)
Transforms origin org across warpzone wz.
Definition common.qc:489
void _WarpZone_FindRadius_Recurse(vector org, float rad, vector org0, vector transform, vector shift)
Definition common.qc:605
entity _WarpZone_FindRadius_goodents_first
Definition common.qc:600
float _WarpZone_FindRadius_nomonsters
Definition common.qc:602
const int WarpZone_FindRadius_Hit_UNSEEN
Definition common.qc:564
#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 731 of file common.qc.

732{
733 // remove WarpZone_refsys object attached to 'this'
734 if (this.WarpZone_refsys && this.WarpZone_refsys.owner == this)
735 delete(this.WarpZone_refsys);
736}
entity WarpZone_refsys
Definition common.qc:727

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 455 of file common.qc.

456{
457 te_csqc_trace_callback_func(start, hit);
458}
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 72 of file common.qc.

73{
74 // a fixed camera view
75 if (this.warpzone_fadestart
76 && vdist(org - this.origin - 0.5 * (this.mins + this.maxs), >, this.warpzone_fadeend + 400))
77 return org;
78 // don't transform if zone faded out (plus 400qu safety margin for typical speeds and latencies)
79 // unneeded on client, on server this helps a lot
82 return this.warpzone_origin;
83}
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 85 of file common.qc.

86{
87 e.warpzone_origin = my_org;
88 e.warpzone_angles = my_ang;
90}
vector WarpZone_Camera_camera_transform(entity this, vector org, vector ang)
Definition common.qc:72
#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:495
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 152 of file common.qc.

153{
154 // if we are near any warpzone planes - MOVE AWAY (work around nearclip)
156 IL_EACH(g_warpzones, WarpZoneLib_BoxTouchesBrush(mi, ma, it, NULL), return it);
157 return NULL;
158}
#define IL_EACH(this, cond, body)
float WarpZoneLib_BoxTouchesBrush(vector mi, vector ma, entity e, entity ig)
Definition common.qc:120
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 166 of file common.qc.

167{
169 IL_EACH(g_warpzones, true, it.solid = SOLID_TRIGGER);
170}
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 160 of file common.qc.

161{
163 IL_EACH(g_warpzones, true, it.solid = SOLID_BSP);
164}
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 478 of file common.qc.

479{
480 return (p - wz.warpzone_origin) * wz.warpzone_forward;
481}

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 768 of file common.qc.

769{
770 //vector t, s;
771 if (me.WarpZone_refsys_incremental_transform == ref.WarpZone_refsys.warpzone_transform
772 && me.WarpZone_refsys_incremental_shift == ref.WarpZone_refsys.warpzone_shift)
773 return;
774 WarpZone_Accumulator_AddInverseTransform(me.WarpZone_refsys, me.WarpZone_refsys_incremental_transform, me.WarpZone_refsys_incremental_shift);
775 WarpZone_Accumulator_Add(me.WarpZone_refsys, ref.WarpZone_refsys);
776 me.WarpZone_refsys_incremental_shift = ref.WarpZone_refsys.warpzone_shift;
777 me.WarpZone_refsys_incremental_transform = ref.WarpZone_refsys.warpzone_transform;
778}

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 759 of file common.qc.

760{
761 if (t == '0 0 0' && s == '0 0 0')
762 return;
764 WarpZone_Accumulator_AddInverseTransform(me.WarpZone_refsys, t, s);
765}
void WarpZone_RefSys_CheckCreate(entity me)
Definition common.qc:737

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 752 of file common.qc.

753{
754 if (t == '0 0 0' && s == '0 0 0')
755 return;
757 WarpZone_Accumulator_AddTransform(me.WarpZone_refsys, t, s);
758}

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

◆ WarpZone_RefSys_BeginAddingIncrementally()

void WarpZone_RefSys_BeginAddingIncrementally ( entity me,
entity ref )

Definition at line 779 of file common.qc.

780{
781 me.WarpZone_refsys_incremental_shift = ref.WarpZone_refsys.warpzone_shift;
782 me.WarpZone_refsys_incremental_transform = ref.WarpZone_refsys.warpzone_transform;
783}

References entity().

Referenced by GrapplingHookTouch().

◆ WarpZone_RefSys_CheckCreate()

void WarpZone_RefSys_CheckCreate ( entity me)

Definition at line 737 of file common.qc.

738{
739 if (me.WarpZone_refsys.owner == me)
740 return;
741 me.WarpZone_refsys = new(warpzone_refsys);
742 me.WarpZone_refsys.owner = me;
743 WarpZone_Accumulator_Clear(me.WarpZone_refsys);
744}
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 745 of file common.qc.

746{
747 if (!me.WarpZone_refsys)
748 return;
749 delete(me.WarpZone_refsys);
750 me.WarpZone_refsys = NULL;
751}

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 824 of file common.qc.

825{
826 if (from.WarpZone_refsys)
827 {
829 me.WarpZone_refsys.warpzone_shift = from.WarpZone_refsys.warpzone_shift;
830 me.WarpZone_refsys.warpzone_transform = from.WarpZone_refsys.warpzone_transform;
831 }
832 else
834}
void WarpZone_RefSys_Clear(entity me)
Definition common.qc:745

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 838 of file common.qc.

839{
840 entity e = spawn();
842 return e;
843}
#define spawn
void WarpZone_RefSys_Copy(entity me, entity from)
Copies the warpzone reference of from onto me.
Definition common.qc:824

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 805 of file common.qc.

806{
807 if (from.WarpZone_refsys)
808 ang = WarpZone_UnTransformAngles(from.WarpZone_refsys, ang);
809 if (to.WarpZone_refsys)
810 ang = WarpZone_TransformAngles(to.WarpZone_refsys, ang);
811 return ang;
812}
vector WarpZone_UnTransformAngles(entity wz, vector ang)
Transforms angle ang backwards through warpzone wz, as the inverse of WarpZone_TransformAngles.
Definition common.qc:536
vector WarpZone_TransformAngles(entity wz, vector ang)
Transforms angle v across warpzone wz.
Definition common.qc:500
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 787 of file common.qc.

788{
789 if (from.WarpZone_refsys)
790 org = WarpZone_UnTransformOrigin(from.WarpZone_refsys, org);
791 if (to.WarpZone_refsys)
792 org = WarpZone_TransformOrigin(to.WarpZone_refsys, org);
793 return org;
794}
vector WarpZone_UnTransformOrigin(entity wz, vector org)
Transforms origin org backwards through warpzone wz, as the inverse of WarpZone_TransformOrigin.
Definition common.qc:526

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 814 of file common.qc.

815{
816 if (from.WarpZone_refsys)
817 ang = WarpZone_UnTransformVAngles(from.WarpZone_refsys, ang);
818 if (to.WarpZone_refsys)
819 ang = WarpZone_TransformVAngles(to.WarpZone_refsys, ang);
820 return ang;
821}
vector WarpZone_UnTransformVAngles(entity wz, vector ang)
Transforms v_angle ang backwards through warpzone wz, as the inverse of WarpZone_TransformVAngles.
Definition common.qc:541
vector WarpZone_TransformVAngles(entity wz, vector ang)
Transforms v_angle ang across warpzone wz.
Definition common.qc:505

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 796 of file common.qc.

797{
798 if (from.WarpZone_refsys)
799 vel = WarpZone_UnTransformVelocity(from.WarpZone_refsys, vel);
800 if (to.WarpZone_refsys)
801 vel = WarpZone_TransformVelocity(to.WarpZone_refsys, vel);
802 return vel;
803}
vector WarpZone_UnTransformVelocity(entity wz, vector vel)
Transforms angle vel backwards through warpzone wz, as the inverse of WarpZone_TransformVelocity.
Definition common.qc:531

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 680 of file common.qc.

681{
682 bool nearby_warpzones = false;
683 // use FOREACH_ENTITY_RADIUS if no warpzone is touching the box of side 2 * rad and center org
684 // which includes the sphere of radius rad and center org
686 {
687 vector boxmin = vec3(org.x - rad, org.y - rad, org.z - rad);
688 vector boxmax = vec3(org.x + rad, org.y + rad, org.z + rad);
689 IL_EACH(g_warpzones, boxesoverlap(it.absmin, it.absmax, boxmin, boxmax),
690 {
691 nearby_warpzones = true;
692 break;
693 });
694 }
695
697 if (nearby_warpzones)
698 {
702 _WarpZone_FindRadius_Recurse(org, rad, org, '0 0 0', '0 0 0');
703 FOREACH_LIST(_WarpZone_FindRadius_goodents, chain, true, it.WarpZone_findradius_hit = WarpZone_FindRadius_Hit_UNSEEN);
704 FOREACH_LIST(_WarpZone_FindRadius_badents, WarpZone_findradius_next, true, it.WarpZone_findradius_hit = WarpZone_FindRadius_Hit_UNSEEN);
705 }
706 else // cheaper than _WarpZone_FindRadius_Recurse
708 {
709 vector p = NearestPointOnBoundingBox(it.origin + it.mins, it.origin + it.maxs, org);
710 if (nomonsters != MOVE_NOTHING)
711 {
712 traceline(org, p, nomonsters, it);
713 if (trace_fraction < 1)
714 continue;
715 }
716
717 it.chain = _WarpZone_FindRadius_goodents_first; // fine to use .chain since FOREACH_ENTITY_RADIUS doesn't use it
719 it.WarpZone_findradius_nearest = p;
720 it.WarpZone_findradius_dist = org - p;
721 WarpZone_Accumulator_Clear(it); // reset .warpzone_transform and .warpzone_shift
722 });
723
725}
entity chain
#define FOREACH_LIST(list, next, cond, body)
Definition iter.qh:21
entity WarpZone_findradius_next
Definition common.qc:604
entity _WarpZone_FindRadius_badents_first
Definition common.qc:601
bool WarpZoneLib_BadEntity(entity e, WarpZone_FindRadius_cond_callback_t cb)
Blacklist of entities that WarpZone_FindRadius doesn't care about.
Definition common.qc:568
var WarpZone_FindRadius_cond_callback_t _WarpZone_FindRadius_cond_cb
Definition common.qc:603
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 e.warpzone_shift = AnglesTransform_PrePostShift_GetPostShift(my_org, e.warpzone_transform, other_org);
60 e.warpzone_origin = my_org;
61 e.warpzone_targetorigin = other_org;
62 e.warpzone_angles = my_ang;
63 e.warpzone_targetangles = other_ang;
64 vector forward, right, up;
65 FIXED_MAKE_VECTORS(my_ang, forward, right, up);
66 e.warpzone_forward = forward;
67 FIXED_MAKE_VECTORS(other_ang, forward, right, up);
68 e.warpzone_targetforward = forward;
70}
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

References AnglesTransform_PrePostShift_GetPostShift(), AnglesTransform_RightDivide(), AnglesTransform_TurnDirectionFR(), entity(), 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 483 of file common.qc.

484{
485 return (p - wz.warpzone_targetorigin) * wz.warpzone_targetforward;
486}

References entity(), and vector.

Referenced by WarpZone_Teleport().

◆ WarpZone_Trace_InitTransform()

void WarpZone_Trace_InitTransform ( )

Definition at line 172 of file common.qc.

173{
175 WarpZone_trace_transform = new_pure(warpzone_trace_transform);
177}
#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 183 of file common.qc.

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

335{
336 vector o0 = e.origin;
337 vector v0 = e.velocity;
338 float dt, i, g = PHYS_GRAVITY(NULL) * e.gravity;
339
340 WarpZone_trace_forent = forent;
346 {
347 tracetoss(e, WarpZone_trace_forent);
348 if (cb)
349 cb(e.origin, trace_endpos, trace_endpos);
350 dt = sqrt(vlen2(e.origin - o0) / vlen2(e.velocity));
352 e.velocity.z -= dt * g;
353 WarpZone_tracetoss_velocity = e.velocity;
354 e.velocity = v0;
355 return;
356 }
357
358 vector vf = v_forward;
359 vector vr = v_right;
360 vector vu = v_up;
361
362 // if starting in warpzone, first transform
363 entity wz = WarpZone_Find(e.origin + e.mins, e.origin + e.maxs);
364 if (wz)
365 {
368 if (zone && wz != zone)
369 {
370 // we are in ANOTHER warpzone. This is bad. Make a zero length trace and return.
371
373 trace_endpos = o0;
374 goto fail;
375 }
377 vector org = WarpZone_TransformOrigin(wz, e.origin);
378 setorigin(e, org);
379 e.velocity = WarpZone_TransformVelocity(wz, e.velocity);
380 }
382 i = 16;
383 for (;;)
384 {
385 if (--i < 1)
386 {
387 LOG_TRACE("Too many warpzones in sequence, aborting trace.");
388 trace_ent = NULL;
389 break;
390 }
391 tracetoss(e, WarpZone_trace_forent);
392 if (cb)
393 cb(e.origin, trace_endpos, trace_endpos);
394 dt = sqrt(vlen2(trace_endpos - e.origin) / vlen2(e.velocity));
396 e.origin = trace_endpos;
397 e.velocity.z -= dt * g;
398 if (trace_fraction >= 1)
399 break;
400 if (trace_ent.classname != "trigger_warpzone")
401 break;
402 if (trace_ent == wz)
403 {
404 // FIXME can this check be removed? Do we really need it?
405 LOG_TRACE("I transformed into the same zone again, wtf, aborting the trace");
406 trace_ent = NULL;
407 break;
408 }
409 wz = trace_ent;
413 if (zone && wz != zone)
414 break;
416 // we hit a warpzone... so, let's perform the trace after the warp again
417 e.origin = WarpZone_TransformOrigin(wz, e.origin);
418 e.velocity = WarpZone_TransformVelocity(wz, e.velocity);
419
420 // we got warped, so let's step back a bit
421 e.velocity = -e.velocity;
422 tracetoss(e, WarpZone_trace_forent);
423 dt = sqrt(vlen2(trace_endpos - e.origin) / vlen2(e.velocity));
425 e.origin = trace_endpos;
426 e.velocity = -e.velocity;
427 }
429LABEL(fail)
430 WarpZone_tracetoss_velocity = e.velocity;
431 v_forward = vf;
432 v_right = vr;
433 v_up = vu;
434 // restore old entity data (caller just uses trace_endpos, WarpZone_tracetoss_velocity and the transform)
435 e.velocity = v0;
436 e.origin = o0;
437}
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 446 of file common.qc.

447{
451}
entity WarpZone_TrailParticles_trace_callback_own
Definition common.qc:439
void WarpZone_TrailParticles_trace_callback(vector from, vector endpos, vector to)
Definition common.qc:441
float WarpZone_TrailParticles_trace_callback_eff
Definition common.qc:440
#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 500 of file common.qc.

501{
502 return AnglesTransform_ApplyToAngles(wz.warpzone_transform, ang);
503}
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 489 of file common.qc.

490{
491 return wz.warpzone_shift + AnglesTransform_Apply(wz.warpzone_transform, org);
492}
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 505 of file common.qc.

506{
507#ifdef KEEP_ROLL
508 float roll = ang.z;
509 ang.z = 0;
510#endif
511
512 ang = AnglesTransform_ApplyToVAngles(wz.warpzone_transform, ang);
513#ifdef KEEP_ROLL
516 ang.z = roll;
517#else
519#endif
520 return ang;
521}
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 495 of file common.qc.

496{
497 return AnglesTransform_Apply(wz.warpzone_transform, vel);
498}

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 536 of file common.qc.

537{
538 return AnglesTransform_ApplyToAngles(AnglesTransform_Invert(wz.warpzone_transform), ang);
539}

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 526 of file common.qc.

527{
528 return AnglesTransform_Apply(AnglesTransform_Invert(wz.warpzone_transform), org - wz.warpzone_shift);
529}

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(), 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 541 of file common.qc.

542{
543#ifdef KEEP_ROLL
544 float roll = ang.z;
545 ang.z = 0;
546#endif
547
549#ifdef KEEP_ROLL
552 ang.z = roll;
553#else
555#endif
556 return ang;
557}

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 531 of file common.qc.

532{
533 return AnglesTransform_Apply(AnglesTransform_Invert(wz.warpzone_transform), vel);
534}

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 568 of file common.qc.

569{
570 if (e.WarpZone_findradius_hit != WarpZone_FindRadius_Hit_UNSEEN) // also account for caching
571 return (e.WarpZone_findradius_hit == WarpZone_FindRadius_Hit_BAD); // either BAD or GOOD
572 if (is_pure(e))
573 return true;
574
575 string s = e.classname;
576 switch (s)
577 {
578 case "warpzone_refsys": // ignore, especially: do not overwrite the refsys parameters
579 case "weaponentity":
580 case "exteriorweaponentity":
581 case "sprite_waypoint":
582 case "waypoint":
583 case "spawnfunc":
584 case "weaponchild":
585 case "chatbubbleentity":
586 case "buff_model":
587 //case "net_linked": // actually some real entities are linked without classname, fail
588 case "":
589 return true;
590 }
591 if (startsWith(s, "target_"))
592 return true;
593 if (startsWith(s, "info_"))
594 return true;
595
596 return (cb && !cb(e));
597}
#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 120 of file common.qc.

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

93{
94 tracebox('0 0 0', mi, ma, '0 0 0', MOVE_NOMONSTERS, ig);
95#ifdef CSQC
97 {
98 LOG_TRACE("hit a network ent, cannot continue WarpZoneLib_BoxTouchesBrush");
99 // we cannot continue, as a player blocks us...
100 // so, abort
101 return 0;
102 }
103#endif
104 if (!trace_ent)
105 return 0;
106 if (trace_ent == e)
107 return 1;
108
109 entity se = trace_ent;
110 float s = se.solid;
111 se.solid = SOLID_NOT;
112 setorigin(se, se.origin); // unlink
113 float f = WarpZoneLib_BoxTouchesBrush_Recurse(mi, ma, e, ig);
114 se.solid = s;
115 setorigin(se, se.origin); // relink
116
117 return f;
118}
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 845 of file common.qc.

846{
847 vector emin = toucher.absmin, emax = toucher.absmax;
848 if (!Q3COMPAT_COMMON)
849 {
850 // Xonotic and Nexuiz maps assume triggers will be activated by adjacent players
851 // prior to sv_legacy_bbox_expand 0 DP always did this for SVQC and never for CSQC
852 emin -= '1 1 1';
853 emax += '1 1 1';
854 }
855
856 // if called from a touch func, we can assume the boxes do overlap
857 if (!touchfunc && !boxesoverlap(emin, emax, this.absmin, this.absmax)) // quick
858 return false;
859
860 return WarpZoneLib_BoxTouchesBrush(emin, emax, this, toucher); // accurate
861}
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 875 of file common.qc.

876{
877 vector o = e.origin;
878 traceline(o, o, MOVE_WORLDONLY, e);
880 return 0; // too stuck, giving up
881
882 tracebox(o, e.mins, e.maxs, o, MOVE_WORLDONLY, e);
883 if (!trace_startsolid)
884 return -1; // wasn't stuck
885
886 vector m0 = e.mins;
887 vector m1 = e.maxs;
888 e.mins = '0 0 0';
889 e.maxs = '0 0 0';
890 WarpZoneLib_MoveOutOfSolid_Expand(e, eX * m0.x); e.mins.x = m0.x;
891 WarpZoneLib_MoveOutOfSolid_Expand(e, eX * m1.x); e.maxs.x = m1.x;
892 WarpZoneLib_MoveOutOfSolid_Expand(e, eY * m0.y); e.mins.y = m0.y;
893 WarpZoneLib_MoveOutOfSolid_Expand(e, eY * m1.y); e.maxs.y = m1.y;
894 WarpZoneLib_MoveOutOfSolid_Expand(e, eZ * m0.z); e.mins.z = m0.z;
895 WarpZoneLib_MoveOutOfSolid_Expand(e, eZ * m1.z); e.maxs.z = m1.z;
896 setorigin(e, e.origin);
897
898 tracebox(e.origin, e.mins, e.maxs, e.origin, MOVE_WORLDONLY, e);
900 {
901 setorigin(e, o);
902 return 0; // can't fix
903 }
904
905 return 1; // was stuck but is fixed now
906}
void WarpZoneLib_MoveOutOfSolid_Expand(entity e, vector by)
Definition common.qc:864
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 864 of file common.qc.

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

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 601 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 603 of file common.qc.

Referenced by WarpZone_SearchInRadius().

◆ _WarpZone_FindRadius_goodents_first

entity _WarpZone_FindRadius_goodents_first

Definition at line 600 of file common.qc.

Referenced by _WarpZone_FindRadius_Recurse(), and WarpZone_SearchInRadius().

◆ _WarpZone_FindRadius_nomonsters

float _WarpZone_FindRadius_nomonsters

Definition at line 602 of file common.qc.

Referenced by _WarpZone_FindRadius_Recurse(), and WarpZone_SearchInRadius().

◆ enemy

entity enemy

Definition at line 599 of file common.qc.

◆ WarpZone_findradius_hit

int WarpZone_findradius_hit

Definition at line 563 of file common.qc.

◆ WarpZone_FindRadius_Hit_BAD

const int WarpZone_FindRadius_Hit_BAD = 2

Definition at line 566 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 565 of file common.qc.

Referenced by _WarpZone_FindRadius_Recurse().

◆ WarpZone_FindRadius_Hit_UNSEEN

const int WarpZone_FindRadius_Hit_UNSEEN = 0

Definition at line 564 of file common.qc.

Referenced by WarpZone_SearchInRadius(), and WarpZoneLib_BadEntity().

◆ WarpZone_findradius_next

entity WarpZone_findradius_next

Definition at line 604 of file common.qc.

Referenced by WarpZone_SearchInRadius().

◆ WarpZone_refsys

entity WarpZone_refsys

Definition at line 727 of file common.qc.

Referenced by ONREMOVE().

◆ WarpZone_refsys_incremental_shift

vector WarpZone_refsys_incremental_shift

Definition at line 766 of file common.qc.

◆ WarpZone_refsys_incremental_transform

vector WarpZone_refsys_incremental_transform

Definition at line 767 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