]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/warpzonelib/common.qc
Merge remote-tracking branch 'origin/terencehill/better_dom_hud_stats'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / warpzonelib / common.qc
index 1e4fc3e630c392be3223e02d4eceb526d234215c..25a67a1731eaa9e3118dc69ae77674defbd28a35 100644 (file)
@@ -1,5 +1,5 @@
 float trace_dphitcontents;
-.float dphitcontents;
+.float dphitcontentsmask;
 
 void WarpZone_Accumulator_Clear(entity acc)
 {
@@ -52,7 +52,7 @@ vector WarpZone_camera_transform(vector org, vector ang)
 
 void WarpZone_SetUp(entity e, vector my_org, vector my_ang, vector other_org, vector other_ang)
 {
-       e.warpzone_transform = AnglesTransform_Divide(other_ang, AnglesTransform_TurnDirectionFR(my_ang));
+       e.warpzone_transform = AnglesTransform_RightDivide(other_ang, AnglesTransform_TurnDirectionFR(my_ang));
        e.warpzone_shift = AnglesTransform_PrePostShift_GetPostShift(my_org, e.warpzone_transform, other_org);
        e.warpzone_origin = my_org;
        e.warpzone_targetorigin = other_org;
@@ -191,6 +191,8 @@ void WarpZone_TraceBox_ThroughZone(vector org, vector mi, vector ma, vector end,
        entity wz;
        vector vf, vr, vu;
 
+       WarpZone_trace_firstzone = world;
+       WarpZone_trace_lastzone = world;
        WarpZone_Trace_InitTransform();
        if(!warpzone_warpzones_exist)
        {
@@ -228,12 +230,14 @@ void WarpZone_TraceBox_ThroughZone(vector org, vector mi, vector ma, vector end,
                        break;
        }
        if((contentshack = (forent.dphitcontentsmask && !(forent.dphitcontentsmask & DPCONTENTS_SOLID))))
-               forent.dphitcontentsmask |= DPCONTENTS_SOLID;
+               BITSET_ASSIGN(forent.dphitcontentsmask, DPCONTENTS_SOLID);
 
        // if starting in warpzone, first transform
        wz = WarpZone_Find(org + mi, org + ma);
        if(wz)
        {
+               WarpZone_trace_firstzone = wz;
+               WarpZone_trace_lastzone = wz;
                if(zone && wz != zone)
                {
                        // we are in ANOTHER warpzone. This is bad. Make a zero length trace and return.
@@ -281,11 +285,15 @@ void WarpZone_TraceBox_ThroughZone(vector org, vector mi, vector ma, vector end,
                }
                if(trace_ent == wz)
                {
+                       // FIXME can this check be removed? Do we really need it?
                        dprint("I transformed into the same zone again, wtf, aborting the trace\n");
                        trace_ent = world;
                        break;
                }
                wz = trace_ent;
+               if(!WarpZone_trace_firstzone)
+                       WarpZone_trace_firstzone = wz;
+               WarpZone_trace_lastzone = wz;
                if(zone && wz != zone)
                        break;
                WarpZone_Trace_AddTransform(wz);
@@ -296,7 +304,7 @@ void WarpZone_TraceBox_ThroughZone(vector org, vector mi, vector ma, vector end,
        WarpZone_MakeAllOther();
 :fail
        if(contentshack)
-               forent.dphitcontentsmask &~= DPCONTENTS_SOLID;
+               BITCLR_ASSIGN(forent.dphitcontentsmask, DPCONTENTS_SOLID);
        trace_startsolid = sol;
        v_forward = vf;
        v_right = vr;
@@ -322,6 +330,8 @@ void WarpZone_TraceToss_ThroughZone(entity e, entity forent, entity zone, WarpZo
        o0 = e.origin;
        v0 = e.velocity;
 
+       WarpZone_trace_firstzone = world;
+       WarpZone_trace_lastzone = world;
        WarpZone_Trace_InitTransform();
        WarpZone_tracetoss_time = 0;
        if(!warpzone_warpzones_exist)
@@ -345,6 +355,8 @@ void WarpZone_TraceToss_ThroughZone(entity e, entity forent, entity zone, WarpZo
        wz = WarpZone_Find(e.origin + e.mins, e.origin + e.maxs);
        if(wz)
        {
+               WarpZone_trace_firstzone = wz;
+               WarpZone_trace_lastzone = wz;
                if(zone && wz != zone)
                {
                        // we are in ANOTHER warpzone. This is bad. Make a zero length trace and return.
@@ -381,11 +393,15 @@ void WarpZone_TraceToss_ThroughZone(entity e, entity forent, entity zone, WarpZo
                        break;
                if(trace_ent == wz)
                {
+                       // FIXME can this check be removed? Do we really need it?
                        dprint("I transformed into the same zone again, wtf, aborting the trace\n");
                        trace_ent = world;
                        break;
                }
                wz = trace_ent;
+               if(!WarpZone_trace_firstzone)
+                       WarpZone_trace_firstzone = wz;
+               WarpZone_trace_lastzone = wz;
                if(zone && wz != zone)
                        break;
                WarpZone_Trace_AddTransform(wz);
@@ -423,6 +439,24 @@ void WarpZone_TrailParticles(entity own, float eff, vector org, vector end)
        WarpZone_TraceBox_ThroughZone(org, '0 0 0', '0 0 0', end, MOVE_NOMONSTERS, world, world, WarpZone_TrailParticles_trace_callback);
 }
 
+#ifdef CSQC
+float WarpZone_TrailParticles_trace_callback_f;
+float WarpZone_TrailParticles_trace_callback_flags;
+void WarpZone_TrailParticles_WithMultiplier_trace_callback(vector from, vector endpos, vector to)
+{
+       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);
+}
+
+void WarpZone_TrailParticles_WithMultiplier(entity own, float eff, vector org, vector end, float f, float boxflags)
+{
+       WarpZone_TrailParticles_trace_callback_own = own;
+       WarpZone_TrailParticles_trace_callback_eff = eff;
+       WarpZone_TrailParticles_trace_callback_f = f;
+       WarpZone_TrailParticles_trace_callback_flags = boxflags;
+       WarpZone_TraceBox_ThroughZone(org, '0 0 0', '0 0 0', end, MOVE_NOMONSTERS, world, world, WarpZone_TrailParticles_WithMultiplier_trace_callback);
+}
+#endif
+
 float WarpZone_PlaneDist(entity wz, vector v)
 {
        return (v - wz.warpzone_origin) * wz.warpzone_forward;
@@ -629,7 +663,7 @@ void WarpZone_RefSys_AddIncrementally(entity me, entity ref)
        t = AnglesTransform_Invert(me.WarpZone_refsys_incremental_transform);
        s = AnglesTransform_PrePostShift_GetPostShift(me.WarpZone_refsys_incremental_shift, t, '0 0 0');
        WarpZone_Accumulator_AddTransform(me.WarpZone_refsys, t, s);
-       WarpZone_Accumulator_Add(me.WarpZone_refsys, ref);
+       WarpZone_Accumulator_Add(me.WarpZone_refsys, ref.WarpZone_refsys);
        me.WarpZone_refsys_incremental_shift = ref.WarpZone_refsys.warpzone_shift;
        me.WarpZone_refsys_incremental_transform = ref.WarpZone_refsys.warpzone_transform;
 }