]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/bot/default/navigation.qc
Fix some cases of missing parenthesis in bitflag checks
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / bot / default / navigation.qc
index 5ee889d169605d4f0c373b6d331682a903595563..ebc18a6875353a2306ea07c6304d989860b76cac 100644 (file)
@@ -47,6 +47,7 @@ bool navigation_goalrating_timeout(entity this)
        return this.bot_strategytime < time;
 }
 
+ERASEABLE
 void navigation_goalrating_timeout_extend_if_needed(entity this, float seconds)
 {
        this.bot_strategytime = max(this.bot_strategytime, time + seconds);
@@ -1653,7 +1654,7 @@ int navigation_poptouchedgoals(entity this)
                if(this.lastteleporttime > 0 && TELEPORT_USED(this, this.goalcurrent))
                {
                        if(this.aistatus & AI_STATUS_WAYPOINT_PERSONAL_GOING)
-                       if(this.goalcurrent.wpflags & WAYPOINTFLAG_PERSONAL && this.goalcurrent.owner==this)
+                       if((this.goalcurrent.wpflags & WAYPOINTFLAG_PERSONAL) && this.goalcurrent.owner==this)
                        {
                                this.aistatus &= ~AI_STATUS_WAYPOINT_PERSONAL_GOING;
                                this.aistatus |= AI_STATUS_WAYPOINT_PERSONAL_REACHED;
@@ -1695,7 +1696,7 @@ int navigation_poptouchedgoals(entity this)
                if (tele_ent && TELEPORT_USED(this, tele_ent))
                {
                        if (this.aistatus & AI_STATUS_WAYPOINT_PERSONAL_GOING)
-                       if (tele_ent.wpflags & WAYPOINTFLAG_PERSONAL && tele_ent.owner == this)
+                       if ((tele_ent.wpflags & WAYPOINTFLAG_PERSONAL) && tele_ent.owner == this)
                        {
                                this.aistatus &= ~AI_STATUS_WAYPOINT_PERSONAL_GOING;
                                this.aistatus |= AI_STATUS_WAYPOINT_PERSONAL_REACHED;
@@ -1716,18 +1717,23 @@ int navigation_poptouchedgoals(entity this)
        }
 
        // Loose goal touching check when running
-       if(this.aistatus & AI_STATUS_RUNNING)
-       if(this.goalcurrent.classname=="waypoint")
-       if(vdist(vec2(this.velocity), >=, autocvar_sv_maxspeed)) // if -really- running
-       {
-               if(vdist(this.origin - this.goalcurrent.origin, <, 150))
+       // check goalstack01 to make sure waypoint isn't the final goal
+       if((this.aistatus & AI_STATUS_RUNNING) && this.goalcurrent.classname == "waypoint" && !(this.goalcurrent.wpflags & WAYPOINTFLAG_JUMP)
+               && this.goalstack01 && !wasfreed(this.goalstack01) && vdist(vec2(this.velocity), >=, autocvar_sv_maxspeed))
+       {
+               vector gco = this.goalcurrent.origin;
+               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(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)
                        {
                                // Detect personal waypoints
                                if(this.aistatus & AI_STATUS_WAYPOINT_PERSONAL_GOING)
-                               if(this.goalcurrent.wpflags & WAYPOINTFLAG_PERSONAL && this.goalcurrent.owner==this)
+                               if((this.goalcurrent.wpflags & WAYPOINTFLAG_PERSONAL) && this.goalcurrent.owner==this)
                                {
                                        this.aistatus &= ~AI_STATUS_WAYPOINT_PERSONAL_GOING;
                                        this.aistatus |= AI_STATUS_WAYPOINT_PERSONAL_REACHED;
@@ -1748,7 +1754,7 @@ int navigation_poptouchedgoals(entity this)
                if(this.goalcurrent.classname == "waypoint" && !this.goalcurrent.wpisbox)
                {
                        gc_min = this.goalcurrent.origin - '1 1 1' * 12;
-                       gc_max = this.goalcurrent.origin + '1 1 1' * 12;
+                       gc_max = this.goalcurrent.origin + '1 1 1' * 12 + eZ * (jumpheight_vec.z + STAT(PL_MIN, this).z);
                }
                if (time < this.ladder_time)
                {
@@ -1763,7 +1769,7 @@ int navigation_poptouchedgoals(entity this)
 
                // Detect personal waypoints
                if(this.aistatus & AI_STATUS_WAYPOINT_PERSONAL_GOING)
-               if(this.goalcurrent.wpflags & WAYPOINTFLAG_PERSONAL && this.goalcurrent.owner==this)
+               if((this.goalcurrent.wpflags & WAYPOINTFLAG_PERSONAL) && this.goalcurrent.owner==this)
                {
                        this.aistatus &= ~AI_STATUS_WAYPOINT_PERSONAL_GOING;
                        this.aistatus |= AI_STATUS_WAYPOINT_PERSONAL_REACHED;
@@ -1784,7 +1790,8 @@ entity navigation_get_really_close_waypoint(entity this)
                wp = this.goalcurrent_prev;
        if(!wp)
                return NULL;
-       if(wp != this.goalcurrent_prev && vdist(wp.origin - this.origin, >, 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;
                if(!wp)
@@ -1796,12 +1803,12 @@ entity navigation_get_really_close_waypoint(entity this)
                if(!wp)
                        return NULL;
        }
-       if(vdist(wp.origin - this.origin, >, 50))
+       if(vdist(wp.origin - this.origin, >, min_dist))
        {
                wp = NULL;
                IL_EACH(g_waypoints, !(it.wpflags & (WAYPOINTFLAG_TELEPORT | WAYPOINTFLAG_JUMP)),
                {
-                       if(vdist(it.origin - this.origin, <, 50))
+                       if(vdist(it.origin - this.origin, <, min_dist))
                        {
                                wp = it;
                                break;