]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
simplify trace owner logic for ballistic bullets, make more consistent with projectiles
authorRudolf Polzer <divverent@xonotic.org>
Wed, 19 Oct 2011 20:51:24 +0000 (22:51 +0200)
committerRudolf Polzer <divverent@xonotic.org>
Wed, 19 Oct 2011 20:51:24 +0000 (22:51 +0200)
qcsrc/server/w_common.qc
qcsrc/warpzonelib/common.qc
qcsrc/warpzonelib/common.qh

index 08c56121b5c6a110661fe6c6977bc90edee2d992..a61ec1067d98d13aef63398b820d3e9255c0f75c 100644 (file)
@@ -353,6 +353,7 @@ void fireBallisticBullet_trace_callback(vector start, vector hit, vector end)
 {
        if(vlen(trace_endpos - fireBallisticBullet_trace_callback_ent.origin) > 16)
                zcurveparticles_from_tracetoss(fireBallisticBullet_trace_callback_eff, fireBallisticBullet_trace_callback_ent.origin, trace_endpos, fireBallisticBullet_trace_callback_ent.velocity);
+       WarpZone_trace_forent = world;
 }
 
 void fireBallisticBullet(vector start, vector dir, float spread, float pSpeed, float lifetime, float damage, float headshotbonus, float force, float dtype, float tracereffects, float gravityfactor, float bulletconstant)
@@ -438,15 +439,6 @@ void fireBallisticBullet(vector start, vector dir, float spread, float pSpeed, f
                        trace_fraction = 0;
                        fireBallisticBullet_trace_callback_ent = self;
                        fireBallisticBullet_trace_callback_eff = eff;
-                       // FIXME can we somehow do this with just ONE trace?
-                       WarpZone_TraceToss(self, self.owner);
-                       if(self.owner && WarpZone_trace_firstzone)
-                       {
-                               self.owner = world;
-                               self.velocity = v0;
-                               self.gravity = g0;
-                               continue;
-                       }
                        WarpZone_TraceToss_ThroughZone(self, self.owner, world, fireBallisticBullet_trace_callback);
                        self.velocity = v0;
                        self.gravity = g0;
index 0f1337d18fb614c447e8efbac9be7d5fc6645040..f09f25bdcd13d320e5b9277da55795865d5c3e88 100644 (file)
@@ -191,6 +191,7 @@ void WarpZone_TraceBox_ThroughZone(vector org, vector mi, vector ma, vector end,
        entity wz;
        vector vf, vr, vu;
 
+       WarpZone_trace_forent = forent;
        WarpZone_trace_firstzone = world;
        WarpZone_trace_lastzone = world;
        WarpZone_Trace_InitTransform();
@@ -206,7 +207,7 @@ void WarpZone_TraceBox_ThroughZone(vector org, vector mi, vector ma, vector end,
                }
                else
                {
-                       tracebox(org, mi, ma, end, nomonsters, forent);
+                       tracebox(org, mi, ma, end, nomonsters, WarpZone_trace_forent);
                        if(cb)
                                cb(org, trace_endpos, end);
                        return;
@@ -229,8 +230,8 @@ void WarpZone_TraceBox_ThroughZone(vector org, vector mi, vector ma, vector end,
                        nomonsters_adjusted = nomonsters;
                        break;
        }
-       if((contentshack = (forent.dphitcontentsmask && !(forent.dphitcontentsmask & DPCONTENTS_SOLID))))
-               BITSET_ASSIGN(forent.dphitcontentsmask, DPCONTENTS_SOLID);
+       if((contentshack = (WarpZone_trace_forent.dphitcontentsmask && !(WarpZone_trace_forent.dphitcontentsmask & DPCONTENTS_SOLID))))
+               BITSET_ASSIGN(WarpZone_trace_forent.dphitcontentsmask, DPCONTENTS_SOLID);
 
        // if starting in warpzone, first transform
        wz = WarpZone_Find(org + mi, org + ma);
@@ -262,7 +263,7 @@ void WarpZone_TraceBox_ThroughZone(vector org, vector mi, vector ma, vector end,
                        trace_ent = world;
                        break;
                }
-               tracebox(org, mi, ma, end, nomonsters_adjusted, forent);
+               tracebox(org, mi, ma, end, nomonsters_adjusted, WarpZone_trace_forent);
                if(cb)
                        cb(org, trace_endpos, end);
                if(sol < 0)
@@ -273,7 +274,7 @@ void WarpZone_TraceBox_ThroughZone(vector org, vector mi, vector ma, vector end,
                        break;
                if(trace_ent.classname != "trigger_warpzone")
                {
-                       if((nomonsters == MOVE_NOTHING) || ((nomonsters == MOVE_WORLDONLY) && trace_ent) || (contentshack && (trace_dphitcontents & forent.dphitcontentsmask) == DPCONTENTS_SOLID))
+                       if((nomonsters == MOVE_NOTHING) || ((nomonsters == MOVE_WORLDONLY) && trace_ent) || (contentshack && (trace_dphitcontents & WarpZone_trace_forent.dphitcontentsmask) == DPCONTENTS_SOLID))
                        {
                                // continue the trace, ignoring this hit (we only care for warpzones)
                                org = trace_endpos + normalize(end - org);
@@ -302,13 +303,13 @@ void WarpZone_TraceBox_ThroughZone(vector org, vector mi, vector ma, vector end,
                end = WarpZone_TransformOrigin(wz, end);
 
                // we got warped, so let's step back a bit
-               tracebox(org, mi, ma, org + normalize(org - end) * 32, nomonsters_adjusted, forent);
+               tracebox(org, mi, ma, org + normalize(org - end) * 32, nomonsters_adjusted, WarpZone_trace_forent);
                org = trace_endpos;
        }
        WarpZone_MakeAllOther();
 :fail
        if(contentshack)
-               BITCLR_ASSIGN(forent.dphitcontentsmask, DPCONTENTS_SOLID);
+               BITCLR_ASSIGN(WarpZone_trace_forent.dphitcontentsmask, DPCONTENTS_SOLID);
        trace_startsolid = sol;
        v_forward = vf;
        v_right = vr;
@@ -334,13 +335,14 @@ void WarpZone_TraceToss_ThroughZone(entity e, entity forent, entity zone, WarpZo
        o0 = e.origin;
        v0 = e.velocity;
 
+       WarpZone_trace_forent = forent;
        WarpZone_trace_firstzone = world;
        WarpZone_trace_lastzone = world;
        WarpZone_Trace_InitTransform();
        WarpZone_tracetoss_time = 0;
        if(!warpzone_warpzones_exist)
        {
-               tracetoss(e, forent);
+               tracetoss(e, WarpZone_trace_forent);
                if(cb)
                        cb(e.origin, trace_endpos, trace_endpos);
                dt = vlen(e.origin - o0) / vlen(e.velocity);
@@ -384,7 +386,7 @@ void WarpZone_TraceToss_ThroughZone(entity e, entity forent, entity zone, WarpZo
                        trace_ent = world;
                        break;
                }
-               tracetoss(e, forent);
+               tracetoss(e, WarpZone_trace_forent);
                if(cb)
                        cb(e.origin, trace_endpos, trace_endpos);
                dt = vlen(trace_endpos - e.origin) / vlen(e.velocity);
@@ -415,7 +417,7 @@ void WarpZone_TraceToss_ThroughZone(entity e, entity forent, entity zone, WarpZo
 
                // we got warped, so let's step back a bit
                e.velocity = -e.velocity;
-               tracetoss(e, forent);
+               tracetoss(e, WarpZone_trace_forent);
                dt = vlen(trace_endpos - e.origin) / vlen(e.velocity);
                WarpZone_tracetoss_time -= dt;
                e.origin = trace_endpos;
index 1dc12b8cfe97f60bc75d5139bb653a04b1eacf3e..c2f36bea868d8baf7ad06c37294b3b7bb2316a24 100644 (file)
@@ -25,6 +25,7 @@ void WarpZone_MakeAllSolid();
 void WarpZone_MakeAllOther();
 
 #define MOVE_NOTHING -1
+entity WarpZone_trace_forent; // temp, callback is allowed to change it
 typedef void(vector start, vector hit, vector end) WarpZone_trace_callback_t; // called on every elementary trace
 const var WarpZone_trace_callback_t WarpZone_trace_callback_t_null;
 entity WarpZone_trace_transform; // transform accumulator during a trace