]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/warpzonelib/common.qc
Merge branch 'master' into TimePath/experiments/csqc_prediction
[xonotic/xonotic-data.pk3dir.git] / qcsrc / warpzonelib / common.qc
index c2a6e8a89fdfdb1d38e962cc49690f586fb40cb7..6481242dc69aeccea26cf57caed0cb7cf2a7537d 100644 (file)
@@ -1,5 +1,14 @@
-float trace_dphitcontents;
-.float dphitcontentsmask;
+#if defined(CSQC)
+       #include "../dpdefs/csprogsdefs.qh"
+    #include "common.qh"
+    #include "../server/t_items.qh"
+#elif defined(MENUQC)
+#elif defined(SVQC)
+       #include "../dpdefs/progsdefs.qh"
+    #include "../dpdefs/dpextensions.qh"
+    #include "common.qh"
+    #include "../common/weapons/weapons.qh"
+#endif
 
 void WarpZone_Accumulator_Clear(entity acc)
 {
@@ -32,7 +41,7 @@ void WarpZone_Accumulator_AddInverse(entity acc, entity wz)
 }
 
 .vector(vector, vector) camera_transform;
-var float autocvar_cl_warpzone_usetrace = 1;
+float autocvar_cl_warpzone_usetrace = 1;
 vector WarpZone_camera_transform(vector org, vector ang)
 {
        vector vf, vr, vu;
@@ -113,7 +122,7 @@ float WarpZoneLib_BoxTouchesBrush_Recurse()
                return 0;
        }
 #endif
-       if not(trace_ent)
+       if (!trace_ent)
                return 0;
        if (trace_ent == WarpZoneLib_BoxTouchesBrush_ent)
                return 1;
@@ -263,7 +272,7 @@ void WarpZone_TraceBox_ThroughZone(vector org, vector mi, vector ma, vector end,
        sol = -1;
        frac = 0;
        i = 16;
-       for(;;)
+       for (;;)
        {
                if(--i < 1)
                {
@@ -386,7 +395,7 @@ void WarpZone_TraceToss_ThroughZone(entity e, entity forent, entity zone, WarpZo
        }
        WarpZone_MakeAllSolid();
        i = 16;
-       for(;;)
+       for (;;)
        {
                if(--i < 1)
                {
@@ -469,8 +478,7 @@ void WarpZone_TrailParticles_WithMultiplier_trace_callback(vector from, vector e
        boxparticles(WarpZone_TrailParticles_trace_callback_eff, WarpZone_TrailParticles_trace_callback_own, from, endpos, WarpZone_TrailParticles_trace_callback_own.velocity, WarpZone_TrailParticles_trace_callback_own.velocity, WarpZone_TrailParticles_trace_callback_f, WarpZone_TrailParticles_trace_callback_flags);
 }
 
-float PARTICLES_DRAWASTRAIL = 128;
-void WarpZone_TrailParticles_WithMultiplier(entity own, float eff, vector org, vector end, float f, float boxflags)
+void WarpZone_TrailParticles_WithMultiplier(entity own, float eff, vector org, vector end, float f, int boxflags)
 {
        WarpZone_TrailParticles_trace_callback_own = own;
        WarpZone_TrailParticles_trace_callback_eff = eff;
@@ -509,18 +517,18 @@ vector WarpZone_TransformVAngles(entity wz, vector ang)
 {
 #ifdef KEEP_ROLL
        float roll;
-       roll = ang_z;
-       ang_z = 0;
+       roll = ang.z;
+       ang.z = 0;
 #endif
 
        ang = AnglesTransform_ApplyToVAngles(wz.warpzone_transform, ang);
 
 #ifdef KEEP_ROLL
-       ang = AnglesTransform_Normalize(ang, TRUE);
+       ang = AnglesTransform_Normalize(ang, true);
        ang = AnglesTransform_CancelRoll(ang);
-       ang_z = roll;
+       ang.z = roll;
 #else
-       ang = AnglesTransform_Normalize(ang, FALSE);
+       ang = AnglesTransform_Normalize(ang, false);
 #endif
 
        return ang;
@@ -545,23 +553,23 @@ vector WarpZone_UnTransformVAngles(entity wz, vector ang)
 {
        float roll;
 
-       roll = ang_z;
-       ang_z = 0;
+       roll = ang.z;
+       ang.z = 0;
 
        ang = AnglesTransform_ApplyToVAngles(AnglesTransform_Invert(wz.warpzone_transform), ang);
-       ang = AnglesTransform_Normalize(ang, TRUE);
+       ang = AnglesTransform_Normalize(ang, true);
        ang = AnglesTransform_CancelRoll(ang);
 
-       ang_z = roll;
+       ang.z = roll;
        return ang;
 }
 
 vector WarpZoneLib_NearestPointOnBox(vector mi, vector ma, vector org)
 {
        vector nearest;
-       nearest_x = bound(mi_x, org_x, ma_x);
-       nearest_y = bound(mi_y, org_y, ma_y);
-       nearest_z = bound(mi_z, org_z, ma_z);
+       nearest.x = bound(mi.x, org.x, ma.x);
+       nearest.y = bound(mi.y, org.y, ma.y);
+       nearest.z = bound(mi.z, org.z, ma.z);
        return nearest;
 }
 
@@ -764,3 +772,64 @@ entity WarpZone_RefSys_SpawnSameRefSys(entity me)
        WarpZone_RefSys_Copy(e, me);
        return e;
 }
+
+float WarpZoneLib_ExactTrigger_Touch()
+{
+       return !WarpZoneLib_BoxTouchesBrush(other.absmin, other.absmax, self, other);
+}
+
+
+void WarpZoneLib_MoveOutOfSolid_Expand(entity e, vector by)
+{
+       float eps = 0.0625;
+       tracebox(e.origin, e.mins - '1 1 1' * eps, e.maxs + '1 1 1' * eps, e.origin + by, MOVE_WORLDONLY, e);
+       if (trace_startsolid)
+               return;
+       if (trace_fraction < 1)
+       {
+               // hit something
+               // adjust origin in the other direction...
+               setorigin(e,e.origin - by * (1 - trace_fraction));
+       }
+}
+
+float WarpZoneLib_MoveOutOfSolid(entity e)
+{
+       vector o, m0, m1;
+
+       o = e.origin;
+       traceline(o, o, MOVE_WORLDONLY, e);
+       if (trace_startsolid)
+               return false;
+
+       tracebox(o, e.mins, e.maxs, o, MOVE_WORLDONLY, e);
+       if (!trace_startsolid)
+               return true;
+
+       m0 = e.mins;
+       m1 = e.maxs;
+       e.mins = '0 0 0';
+       e.maxs = '0 0 0';
+       WarpZoneLib_MoveOutOfSolid_Expand(e, '1 0 0' * m0_x);
+       e.mins_x = m0_x;
+       WarpZoneLib_MoveOutOfSolid_Expand(e, '1 0 0' * m1_x);
+       e.maxs_x = m1_x;
+       WarpZoneLib_MoveOutOfSolid_Expand(e, '0 1 0' * m0_y);
+       e.mins_y = m0_y;
+       WarpZoneLib_MoveOutOfSolid_Expand(e, '0 1 0' * m1_y);
+       e.maxs_y = m1_y;
+       WarpZoneLib_MoveOutOfSolid_Expand(e, '0 0 1' * m0_z);
+       e.mins_z = m0_z;
+       WarpZoneLib_MoveOutOfSolid_Expand(e, '0 0 1' * m1_z);
+       e.maxs_z = m1_z;
+       setorigin(e, e.origin);
+
+       tracebox(e.origin, e.mins, e.maxs, e.origin, MOVE_WORLDONLY, e);
+       if (trace_startsolid)
+       {
+               setorigin(e, o);
+               return false;
+       }
+
+       return true;
+}