]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Adapt code to support better bigger teleport and jumppad waypoints; it fixes creation...
authorterencehill <piuntn@gmail.com>
Thu, 8 Jun 2017 23:56:32 +0000 (01:56 +0200)
committerterencehill <piuntn@gmail.com>
Thu, 8 Jun 2017 23:56:32 +0000 (01:56 +0200)
qcsrc/server/bot/default/navigation.qc
qcsrc/server/bot/default/waypoints.qc

index 7bed55737dc8922eea58c2f07b907fdabe2a90a3..e7afb5f27481aae89f45031deb935ed34142ec30 100644 (file)
@@ -115,7 +115,7 @@ bool tracewalk(entity e, vector start, vector m1, vector m2, vector end, float e
        // Movement loop
        for (;;)
        {
-               if (boxesoverlap(end, end2, org + m1 + '-1 -1 -1', org + m2 + '1 1 1'))
+               if (boxesoverlap(end, end2, org + '-1 -1 -1', org + '1 1 1'))
                {
                        // Succeeded
                        if(autocvar_bot_debug_tracewalk)
index 74df45583fededaf0afc2969eff412d647f2bd08..05133bb762d47399d636b308f5d2af0b73e7ec3d 100644 (file)
@@ -562,16 +562,49 @@ void waypoint_think(entity this)
                                ++relink_pvsculled;
                                continue;
                        }
-                       sv = it.origin;
-                       sv.x = bound(sm1_x, sv.x, sm2_x);
-                       sv.y = bound(sm1_y, sv.y, sm2_y);
-                       sv.z = bound(sm1_z, sv.z, sm2_z);
-                       ev = this.origin;
-                       em1 = it.origin + it.mins;
-                       em2 = it.origin + it.maxs;
-                       ev.x = bound(em1_x, ev.x, em2_x);
-                       ev.y = bound(em1_y, ev.y, em2_y);
-                       ev.z = bound(em1_z, ev.z, em2_z);
+
+                       vector sv2;
+                       float sv2_height;
+                       if (this.wpisbox)
+                       {
+                               sv = it.origin;
+                               sv.x = bound(sm1.x, sv.x, sm2.x);
+                               sv.y = bound(sm1.y, sv.y, sm2.y);
+                               sv.z = bound(sm1.z, sv.z, sm2.z);
+                               sv2.x = sv.x;
+                               sv2.y = sv.y;
+                               sv2.z = sm1.z;
+                               sv2_height = sm2.z - sm1.z;
+                       }
+                       else
+                       {
+                               sv = this.origin;
+                               sv2 = sv;
+                               sv2_height = 0;
+                       }
+
+                       vector ev2;
+                       float ev2_height;
+                       if (it.wpisbox)
+                       {
+                               ev = this.origin;
+                               em1 = it.origin + it.mins;
+                               em2 = it.origin + it.maxs;
+                               ev.x = bound(em1.x, ev.x, em2.x);
+                               ev.y = bound(em1.y, ev.y, em2.y);
+                               ev.z = bound(em1.z, ev.z, em2.z);
+                               ev2.x = ev.x;
+                               ev2.y = ev.y;
+                               ev2.z = em1.z;
+                               ev2_height = em2.z - em1.z;
+                       }
+                       else
+                       {
+                               ev = it.origin;
+                               ev2 = ev;
+                               ev2_height = 0;
+                       }
+
                        dv = ev - sv;
                        dv.z = 0;
                        if(vdist(dv, >=, 1050)) // max search distance in XY
@@ -579,39 +612,16 @@ void waypoint_think(entity this)
                                ++relink_lengthculled;
                                continue;
                        }
-                       float sv_deviation = 0;
-                       float ev_deviation = 0;
+
                        navigation_testtracewalk = 0;
-                       if (!this.wpisbox)
-                       {
-                               tracebox(sv - PL_MIN_CONST.z * '0 0 1', PL_MIN_CONST, PL_MAX_CONST, sv, false, this);
-                               if (!trace_startsolid)
-                               {
-                                       //dprint("sv deviation", vtos(trace_endpos - sv), "\n");
-                                       sv_deviation = trace_endpos.z + 1 - sv.z;
-                                       sv = trace_endpos + '0 0 1';
-                               }
-                       }
-                       if (!it.wpisbox)
-                       {
-                               tracebox(ev - PL_MIN_CONST.z * '0 0 1', PL_MIN_CONST, PL_MAX_CONST, ev, false, it);
-                               if (!trace_startsolid)
-                               {
-                                       //dprint("ev deviation", vtos(trace_endpos - ev), "\n");
-                                       ev_deviation = trace_endpos.z + 1 - ev.z;
-                                       ev = trace_endpos + '0 0 1';
-                               }
-                       }
+
                        //traceline(this.origin, it.origin, false, NULL);
                        //if (trace_fraction == 1)
                        if (this.wpisbox)
                                relink_walkculled += 0.5;
                        else
                        {
-                               vector dest = ev;
-                               dest.z = em1.z + ev_deviation;
-                               float dest_height = em2.z - em1.z;
-                               if(tracewalk(this, sv, PL_MIN_CONST, PL_MAX_CONST, dest, dest_height, MOVE_NOMONSTERS))
+                               if (tracewalk(this, sv, PL_MIN_CONST, PL_MAX_CONST, ev2, ev2_height, MOVE_NOMONSTERS))
                                        waypoint_addlink(this, it);
                                else
                                        relink_walkculled += 0.5;
@@ -621,10 +631,7 @@ void waypoint_think(entity this)
                                relink_walkculled += 0.5;
                        else
                        {
-                               vector dest = sv;
-                               dest.z = sm1.z + sv_deviation;
-                               float dest_height = sm2.z - sm1.z;
-                               if(tracewalk(it, ev, PL_MIN_CONST, PL_MAX_CONST, dest, dest_height, MOVE_NOMONSTERS))
+                               if (tracewalk(it, ev, PL_MIN_CONST, PL_MAX_CONST, sv2, sv2_height, MOVE_NOMONSTERS))
                                        waypoint_addlink(it, this);
                                else
                                        relink_walkculled += 0.5;