From: terencehill Date: Tue, 25 Feb 2020 15:28:22 +0000 (+0100) Subject: Bot AI: while bunnyhopping detect waypoints way under bots (up to 250 qu) for smoothe... X-Git-Tag: xonotic-v0.8.5~1151 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=1769625e3f13a32117ac8d266524ea5684668cef;p=xonotic%2Fxonotic-data.pk3dir.git Bot AI: while bunnyhopping detect waypoints way under bots (up to 250 qu) for smoother runs --- diff --git a/qcsrc/server/bot/default/navigation.qc b/qcsrc/server/bot/default/navigation.qc index dcf2f304c..57cf690ad 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 073a98cf4..07eacc186 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);