From 1769625e3f13a32117ac8d266524ea5684668cef Mon Sep 17 00:00:00 2001 From: terencehill Date: Tue, 25 Feb 2020 16:28:22 +0100 Subject: [PATCH] Bot AI: while bunnyhopping detect waypoints way under bots (up to 250 qu) for smoother runs --- qcsrc/server/bot/default/navigation.qc | 9 +++++---- qcsrc/server/bot/default/navigation.qh | 2 ++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/qcsrc/server/bot/default/navigation.qc b/qcsrc/server/bot/default/navigation.qc index dcf2f304cf..57cf690ada 100644 --- a/qcsrc/server/bot/default/navigation.qc +++ b/qcsrc/server/bot/default/navigation.qc @@ -1721,10 +1721,11 @@ int navigation_poptouchedgoals(entity this) && this.goalstack01 && !wasfreed(this.goalstack01) && vdist(vec2(this.velocity), >=, autocvar_sv_maxspeed)) { vector gco = this.goalcurrent.origin; - vector gno = this.goalstack01.origin; - float min_dist = 100; + float min_dist = BOT_BUNNYHOP_WP_DETECTION_RANGE; + // also detect waypoints when bot is way above them but with a narrower horizontal range + // so to increase chances bot ends up in the standard range (optimizes nearest waypoint finding) if(vdist(this.origin - gco, <, min_dist) - || (vdist(this.origin + eZ * 0.5 * min_dist - gco, <, min_dist) && vlen2(this.origin - gno) < vlen2(gco - gno))) + || (vdist(vec2(this.origin - gco), <, min_dist * 0.5) && vdist(this.origin - eZ * 1.5 * min_dist - gco, <, min_dist))) { traceline(this.origin + this.view_ofs , this.goalcurrent.origin, true, NULL); if(trace_fraction==1) @@ -1788,7 +1789,7 @@ entity navigation_get_really_close_waypoint(entity this) wp = this.goalcurrent_prev; if(!wp) return NULL; - float min_dist = ((this.aistatus & AI_STATUS_RUNNING) ? 100 : 50); + float min_dist = ((this.aistatus & AI_STATUS_RUNNING) ? BOT_BUNNYHOP_WP_DETECTION_RANGE : 50); if(wp != this.goalcurrent_prev && vdist(wp.origin - this.origin, >, min_dist)) { wp = this.goalcurrent_prev; diff --git a/qcsrc/server/bot/default/navigation.qh b/qcsrc/server/bot/default/navigation.qh index 073a98cf4e..07eacc1860 100644 --- a/qcsrc/server/bot/default/navigation.qh +++ b/qcsrc/server/bot/default/navigation.qh @@ -88,6 +88,8 @@ entity bot_waypoint_queue_goal; // Head of the temporary list of goals entity bot_waypoint_queue_bestgoal; float bot_waypoint_queue_bestgoalrating; +const float BOT_BUNNYHOP_WP_DETECTION_RANGE = 100; + .entity bot_basewaypoint; .bool navigation_dynamicgoal; void navigation_dynamicgoal_init(entity this, bool initially_static); -- 2.39.2