]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Bot AI: anticipate search of a new goal when bot touches a waypoint and search time...
authorterencehill <piuntn@gmail.com>
Fri, 8 Sep 2017 13:27:18 +0000 (15:27 +0200)
committerterencehill <piuntn@gmail.com>
Fri, 8 Sep 2017 13:27:18 +0000 (15:27 +0200)
qcsrc/server/bot/default/havocbot/havocbot.qc
qcsrc/server/bot/default/navigation.qc
qcsrc/server/bot/default/navigation.qh

index 2f1f183cfc1fac016d33bcf96a2195680eedfda2..69549f8e356b6ece5b1fd5e145258887c34ed540 100644 (file)
@@ -758,7 +758,10 @@ void havocbot_movetogoal(entity this)
                }
        }
        if(!locked_goal)
-               navigation_poptouchedgoals(this);
+       {
+               if(navigation_poptouchedgoals(this) && this.bot_strategytime < time + 1)
+                       this.bot_strategytime = 0;
+       }
 
        // if ran out of goals try to use an alternative goal or get a new strategy asap
        if(this.goalcurrent == NULL)
index da87445b8f31b42e6b4d245b720fe001d3fce8fa..bdd20e179d4b1a1040b089ecf2b29dd4cae75aed 100644 (file)
@@ -1331,8 +1331,9 @@ bool navigation_routetogoal(entity this, entity e, vector startposition)
 
 // removes any currently touching waypoints from the goal stack
 // (this is how bots detect if they reached a goal)
-void navigation_poptouchedgoals(entity this)
+int navigation_poptouchedgoals(entity this)
 {
+       int removed_goals = 0;
        if(this.goalcurrent.wpflags & WAYPOINTFLAG_TELEPORT)
        {
                // make sure jumppad is really hit, don't rely on distance based checks
@@ -1347,9 +1348,10 @@ void navigation_poptouchedgoals(entity this)
                                this.aistatus |= AI_STATUS_WAYPOINT_PERSONAL_REACHED;
                        }
                        navigation_poproute(this);
+                       ++removed_goals;
                }
                else
-                       return;
+                       return removed_goals;
        }
 
        // If for some reason the bot is closer to the next goal, pop the current one
@@ -1364,8 +1366,9 @@ void navigation_poptouchedgoals(entity this)
                {
                        LOG_DEBUG("path optimized for ", this.netname, ", removed a goal from the queue");
                        navigation_poproute(this);
+                       ++removed_goals;
                        if(this.goalcurrent && this.goalcurrent.wpflags & WAYPOINTFLAG_TELEPORT)
-                               return;
+                               return removed_goals;
                        // TODO this may also be a nice idea to do "early" (e.g. by
                        // manipulating the vlen() comparisons) to shorten paths in
                        // general - this would make bots walk more "on rails" than
@@ -1394,8 +1397,9 @@ void navigation_poptouchedgoals(entity this)
                                }
 
                                navigation_poproute(this);
+                               ++removed_goals;
                                if(this.goalcurrent && this.goalcurrent.wpflags & WAYPOINTFLAG_TELEPORT)
-                                       return;
+                                       return removed_goals;
                        }
                }
        }
@@ -1421,9 +1425,11 @@ void navigation_poptouchedgoals(entity this)
                }
 
                navigation_poproute(this);
+               ++removed_goals;
                if(this.goalcurrent && this.goalcurrent.wpflags & WAYPOINTFLAG_TELEPORT)
-                       return;
+                       return removed_goals;
        }
+       return removed_goals;
 }
 
 entity navigation_get_really_close_waypoint(entity this)
index c88fd3397b23cfa1fea6a2fd776f4f188321a04e..1424b94c776af20629e7376506fad4d065a74b4a 100644 (file)
@@ -154,7 +154,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_poptouchedgoals(entity this);
+int navigation_poptouchedgoals(entity this);
 void navigation_goalrating_start(entity this);
 void navigation_goalrating_end(entity this);
 void navigation_unstuck(entity this);