From: terencehill Date: Fri, 8 Sep 2017 13:27:18 +0000 (+0200) Subject: Bot AI: anticipate search of a new goal when bot touches a waypoint and search time... X-Git-Tag: xonotic-v0.8.5~2378^2~67 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=b327ff4ca57aae20768dedf4f5b7b27076391563;p=xonotic%2Fxonotic-data.pk3dir.git Bot AI: anticipate search of a new goal when bot touches a waypoint and search time is close; it avoids finding nearest waypoints many times --- diff --git a/qcsrc/server/bot/default/havocbot/havocbot.qc b/qcsrc/server/bot/default/havocbot/havocbot.qc index 2f1f183cf..69549f8e3 100644 --- a/qcsrc/server/bot/default/havocbot/havocbot.qc +++ b/qcsrc/server/bot/default/havocbot/havocbot.qc @@ -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) diff --git a/qcsrc/server/bot/default/navigation.qc b/qcsrc/server/bot/default/navigation.qc index da87445b8..bdd20e179 100644 --- a/qcsrc/server/bot/default/navigation.qc +++ b/qcsrc/server/bot/default/navigation.qc @@ -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) diff --git a/qcsrc/server/bot/default/navigation.qh b/qcsrc/server/bot/default/navigation.qh index c88fd3397..1424b94c7 100644 --- a/qcsrc/server/bot/default/navigation.qh +++ b/qcsrc/server/bot/default/navigation.qh @@ -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);