]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Bot AI: try to anticipate (and optimize) path finding when path gets shortened too
authorterencehill <piuntn@gmail.com>
Wed, 13 Jun 2018 17:29:37 +0000 (19:29 +0200)
committerterencehill <piuntn@gmail.com>
Wed, 13 Jun 2018 17:29:37 +0000 (19:29 +0200)
qcsrc/server/bot/default/havocbot/havocbot.qc
qcsrc/server/bot/default/navigation.qc
qcsrc/server/bot/default/navigation.qh

index 429254a5ef60d39631b7cebae03a91b4b301c7ee..40cff2753cedf652390ac71045e115e58e9073fa 100644 (file)
@@ -772,7 +772,12 @@ void havocbot_movetogoal(entity this)
        if (this.goalcurrent == this.goalentity && this.goalentity_lock_timeout > time)
                locked_goal = true;
 
-       navigation_shortenpath(this);
+       if (navigation_shortenpath(this))
+       {
+               if (vdist(this.origin - this.goalcurrent_prev.origin, <, 50)
+                       && navigation_goalrating_timeout_can_be_anticipated(this))
+                       navigation_goalrating_timeout_force(this);
+       }
 
        bool goalcurrent_can_be_removed = false;
        if (IS_MOVABLE(this.goalcurrent))
index 228ec30dee699916cde0bf24925716f436ee20fe..7ece113e6a858b6ff4d7263b74b6da2ba33ba13e 100644 (file)
@@ -1507,12 +1507,12 @@ bool navigation_routetogoal(entity this, entity e, vector startposition)
 }
 
 // shorten path by removing intermediate goals
-void navigation_shortenpath(entity this)
+bool navigation_shortenpath(entity this)
 {
        if (!this.goalstack01 || wasfreed(this.goalstack01))
-               return;
+               return false;
        if (this.bot_tracewalk_time > time)
-               return;
+               return false;
        this.bot_tracewalk_time = max(time, this.bot_tracewalk_time) + 0.25;
 
        bool cut_allowed = false;
@@ -1551,8 +1551,9 @@ void navigation_shortenpath(entity this)
                                        navigation_poproute(this);
                                }
                                while (this.goalcurrent != next);
+                               return true;
                        }
-                       return;
+                       return false;
                }
        }
 
@@ -1573,8 +1574,10 @@ void navigation_shortenpath(entity this)
                {
                        LOG_DEBUG("path optimized for ", this.netname, ", removed a goal from the queue");
                        navigation_poproute(this);
+                       return true;
                }
        }
+       return false;
 }
 
 // removes any currently touching waypoints from the goal stack
index 80498b691f8f2ddc4efcf7f4be0af0aeb4e7988e..233ae9ae77459c4f144921e65b7a56f890199102 100644 (file)
@@ -115,7 +115,7 @@ void navigation_markroutes_checkwaypoint(entity w, entity wp, float cost2, vecto
 void navigation_markroutes(entity this, entity fixed_source_waypoint);
 void navigation_markroutes_inverted(entity fixed_source_waypoint);
 void navigation_routerating(entity this, entity e, float f, float rangebias);
-void navigation_shortenpath(entity this);
+bool navigation_shortenpath(entity this);
 int navigation_poptouchedgoals(entity this);
 void navigation_goalrating_start(entity this);
 void navigation_goalrating_end(entity this);