]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Bot AI: while bunnyhopping detect waypoints way under bots (up to 250 qu) for smoothe...
authorterencehill <piuntn@gmail.com>
Tue, 25 Feb 2020 15:28:22 +0000 (16:28 +0100)
committerterencehill <piuntn@gmail.com>
Tue, 25 Feb 2020 15:28:22 +0000 (16:28 +0100)
qcsrc/server/bot/default/navigation.qc
qcsrc/server/bot/default/navigation.qh

index dcf2f304cf3a5c4f7d28a05eefa25f31a1cd14cc..57cf690ada1ae354cd3ba6e066bd0c4a16ce097c 100644 (file)
@@ -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;
index 073a98cf4e725544eab16f9e84a2f180285f30a2..07eacc1860f4d4176a77f2a8bfaf07df1ada6e9d 100644 (file)
@@ -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);