From: terencehill Date: Sat, 4 Mar 2017 14:10:16 +0000 (+0100) Subject: Bot path finding: when possible (often) optimize path by not adding the nearest waypo... X-Git-Tag: xonotic-v0.8.2~148 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=5d3b698d64dc4cbd9c17d77c271e31f8e359543e;p=xonotic%2Fxonotic-data.pk3dir.git Bot path finding: when possible (often) optimize path by not adding the nearest waypoint of the goal --- diff --git a/qcsrc/server/bot/default/navigation.qc b/qcsrc/server/bot/default/navigation.qc index 20a3a9149..65ba4d00b 100644 --- a/qcsrc/server/bot/default/navigation.qc +++ b/qcsrc/server/bot/default/navigation.qc @@ -895,15 +895,26 @@ bool navigation_routetogoal(entity this, entity e, vector startposition) if (tracewalk(this, startposition, STAT(PL_MIN, this), STAT(PL_MAX, this), (e.absmin + e.absmax) * 0.5, bot_navigation_movemode)) return true; + entity nearest_wp = NULL; // see if there are waypoints describing a path to the item if(e.classname != "waypoint" || (e.wpflags & WAYPOINTFLAG_PERSONAL)) + { e = e.nearestwaypoint; + nearest_wp = e; + } else e = e.enemy; // we already have added it, so... if(e == NULL) return false; + if(nearest_wp && nearest_wp.enemy) + { + // often path can be optimized by not adding the nearest waypoint + if(tracewalk(this, nearest_wp.enemy.origin, STAT(PL_MIN, this), STAT(PL_MAX, this), (this.goalentity.absmin + this.goalentity.absmax) * 0.5, bot_navigation_movemode)) + e = nearest_wp.enemy; + } + for (;;) { // add the spawnfunc_waypoint to the path