From f264dd1d6acb0893dd007ae669b435682e1c1293 Mon Sep 17 00:00:00 2001 From: terencehill Date: Sun, 2 Dec 2018 17:35:36 +0100 Subject: [PATCH] Bot AI: optimize removal of the first waypoint of the route when bot is really close to it --- qcsrc/server/bot/default/navigation.qc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/qcsrc/server/bot/default/navigation.qc b/qcsrc/server/bot/default/navigation.qc index 6c5e2769b..1a491530a 100644 --- a/qcsrc/server/bot/default/navigation.qc +++ b/qcsrc/server/bot/default/navigation.qc @@ -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) { -- 2.39.2