]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Bot AI: allow to find nearest waypoint of players in the air so that they can be...
authorterencehill <piuntn@gmail.com>
Fri, 10 Nov 2017 09:51:51 +0000 (10:51 +0100)
committerterencehill <piuntn@gmail.com>
Fri, 10 Nov 2017 09:51:51 +0000 (10:51 +0100)
qcsrc/server/bot/default/navigation.qc

index b61939499aba8e85c17badd7eae81fa6cb41ca38..98403bc4d34535e4f5c53dc46a4cad72eefa1fa3 100644 (file)
@@ -948,15 +948,28 @@ entity navigation_findnearestwaypoint_withdist_except(entity ent, float walkfrom
                if(walkfromwp && (it.wpflags & WAYPOINTFLAG_NORELINK))
                        continue;
                v = it.origin;
-               if(walkfromwp)
-                       set_tracewalk_dest(ent, v, false);
+
+               if (walkfromwp)
+               {
+                       set_tracewalk_dest(ent, v, true);
+                       if (trace_ent == ent)
+                       {
+                               bestdist = 0;
+                               best = it;
+                               break;
+                       }
+               }
                else
                        set_tracewalk_dest(it, org, false);
+
                if (navigation_waypoint_will_link(v, org, ent,
                        tracewalk_dest, tracewalk_dest_height,
                        tracewalk_dest, tracewalk_dest_height, walkfromwp, bestdist))
                {
-                       bestdist = vlen(v - org);
+                       if (walkfromwp)
+                               bestdist = vlen(tracewalk_dest - org);
+                       else
+                               bestdist = vlen(v - org);
                        best = it;
                }
        });