]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/bot/default/havocbot/havocbot.qc
Bot AI: anticipate search of a new goal when bot touches a waypoint and search time...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / bot / default / havocbot / havocbot.qc
index 439ef5471525c4486e99221fc8d6fb9921e27410..69549f8e356b6ece5b1fd5e145258887c34ed540 100644 (file)
@@ -430,7 +430,8 @@ void havocbot_bunnyhop(entity this, vector dir)
 bool havocbot_checkgoaldistance(entity this, vector gco)
 {
        float curr_dist = vlen(this.origin - gco);
-       if(curr_dist > this.goalcurrent_distance)
+       float curr_dist_2d = vlen(vec2(this.origin - gco));
+       if(curr_dist > this.goalcurrent_distance && curr_dist_2d > this.goalcurrent_distance_2d)
        {
                if(!this.goalcurrent_distance_time)
                        this.goalcurrent_distance_time = time;
@@ -440,7 +441,8 @@ bool havocbot_checkgoaldistance(entity this, vector gco)
        else
        {
                // reduce it a little bit so it works even with very small approaches to the goal
-               this.goalcurrent_distance = max(20, curr_dist - 15);
+               this.goalcurrent_distance = max(20, curr_dist - 10);
+               this.goalcurrent_distance_2d = max(20, curr_dist_2d - 10);
                this.goalcurrent_distance_time = 0;
        }
        return false;
@@ -734,23 +736,32 @@ void havocbot_movetogoal(entity this)
                                this.goalentity.bot_pickup_respawning = false;
                        else if(time < this.goalentity.scheduledrespawntime - 10) // item already taken (by someone else)
                        {
-                               this.goalentity.bot_pickup_respawning = false;
-                               navigation_clearroute(this);
-                               this.bot_strategytime = 0;
-                               return;
+                               if(checkpvs(this.origin, this.goalentity))
+                               {
+                                       this.goalentity.bot_pickup_respawning = false;
+                                       navigation_clearroute(this);
+                                       this.bot_strategytime = 0;
+                                       return;
+                               }
                        }
                        else if(this.goalentity == this.goalcurrent)
                                locked_goal = true; // wait for item to respawn
                }
-               else if(!this.goalentity.solid)
+               else if(!this.goalentity.solid && !boxesoverlap(this.goalentity.absmin, this.goalentity.absmax, this.absmin, this.absmax))
                {
-                       navigation_clearroute(this);
-                       this.bot_strategytime = 0;
-                       return;
+                       if(checkpvs(this.origin, this.goalentity))
+                       {
+                               navigation_clearroute(this);
+                               this.bot_strategytime = 0;
+                               return;
+                       }
                }
        }
        if(!locked_goal)
-               navigation_poptouchedgoals(this);
+       {
+               if(navigation_poptouchedgoals(this) && this.bot_strategytime < time + 1)
+                       this.bot_strategytime = 0;
+       }
 
        // if ran out of goals try to use an alternative goal or get a new strategy asap
        if(this.goalcurrent == NULL)