Bot AI: optimize removal of the first waypoint of the route when bot is really close...
authorterencehill <piuntn@gmail.com>
Sun, 2 Dec 2018 16:35:36 +0000 (17:35 +0100)
committerterencehill <piuntn@gmail.com>
Sun, 2 Dec 2018 16:35:36 +0000 (17:35 +0100)
qcsrc/server/bot/default/navigation.qc

index 6c5e276..1a49153 100644 (file)
@@ -1796,6 +1796,7 @@ void navigation_goalrating_start(entity this)
        navigation_clearroute(this);
        navigation_bestgoal = NULL;
        navigation_markroutes(this, wp);
+       this.goalstack31 = wp; // temporarly save the really close waypoint
 }
 
 // ends a goal selection session (updates goal stack to the best goal)
@@ -1804,9 +1805,15 @@ void navigation_goalrating_end(entity this)
        if(this.aistatus & AI_STATUS_STUCK)
                return;
 
+       entity wp = this.goalstack31; // save to wp as this.goalstack31 is set by navigation_routetogoal
+       this.goalstack31 = NULL;
+
        navigation_routetogoal(this, navigation_bestgoal, this.origin);
        LOG_DEBUG("best goal ", this.goalcurrent.classname);
 
+       if (wp && this.goalcurrent == wp)
+               navigation_poproute(this);
+
        // If the bot got stuck then try to reach the farthest waypoint
        if (!this.goalentity)
        {