]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Bot AI: check if path is walkable while chasing a player
authorterencehill <piuntn@gmail.com>
Fri, 10 Nov 2017 14:47:36 +0000 (15:47 +0100)
committerterencehill <piuntn@gmail.com>
Mon, 13 Nov 2017 18:16:36 +0000 (19:16 +0100)
qcsrc/server/bot/default/havocbot/havocbot.qc
qcsrc/server/bot/default/havocbot/havocbot.qh
qcsrc/server/bot/default/navigation.qc

index a383dd87cb5393143da5eea9be2b843f368f724f..608429aa8c09357e7fb6acae5ab8106166ab5ebf 100644 (file)
@@ -768,14 +768,42 @@ void havocbot_movetogoal(entity this)
        if (this.goalcurrent == this.goalentity && this.goalentity_lock_timeout > time)
                locked_goal = true;
 
+       if (IS_MOVABLE(this.goalcurrent))
+       {
+               if (IS_DEAD(this.goalcurrent))
+               {
+                       if (checkpvs(this.origin + this.view_ofs, this.goalcurrent))
+                       {
+                               navigation_goalrating_timeout_force(this);
+                               return;
+                       }
+               }
+               else if (this.bot_tracewalk_time < time)
+               {
+                       set_tracewalk_dest(this.goalcurrent, this.origin, true);
+                       if (!(trace_ent == this || tracewalk(this, this.origin, this.mins, this.maxs,
+                               tracewalk_dest, tracewalk_dest_height, bot_navigation_movemode)))
+                       {
+                               navigation_goalrating_timeout_force(this);
+                               return;
+                       }
+                       this.bot_tracewalk_time = max(time, this.bot_tracewalk_time) + 0.25;
+               }
+       }
        if(!locked_goal)
        {
                // optimize path finding by anticipating goalrating when bot is near a waypoint;
                // in this case path finding can start directly from a waypoint instead of
                // looking for all the reachable waypoints up to a certain distance
-               if(navigation_poptouchedgoals(this) && this.goalcurrent)
+               if (navigation_poptouchedgoals(this) && this.goalcurrent)
                {
-                       if(navigation_goalrating_timeout_can_be_anticipated(this))
+                       if (IS_MOVABLE(this.goalcurrent) && IS_DEAD(this.goalcurrent))
+                       {
+                               // remove even if not visible
+                               navigation_goalrating_timeout_force(this);
+                               return;
+                       }
+                       else if (navigation_goalrating_timeout_can_be_anticipated(this))
                                navigation_goalrating_timeout_force(this);
                }
        }
index 88ba407a2d68aca2dd10f96bbe028c79de4987a9..2f987f674ec8719503137e05452abe5e7701fd1e 100644 (file)
@@ -23,6 +23,7 @@
 .float havocbot_stickenemy;
 .float havocbot_role_timeout;
 
+.float bot_tracewalk_time;
 .entity ignoregoal;
 .entity bot_lastseengoal;
 .entity havocbot_personal_waypoint;
index 36e5843f64824a278fe818ea4fbe84b25caac471..c9ebc07550408ea28704823bdbc27304fd9ec09a 100644 (file)
@@ -1503,11 +1503,8 @@ int navigation_poptouchedgoals(entity this)
 {
        int removed_goals = 0;
 
-       if(IS_PLAYER(this.goalcurrent) && IS_DEAD(this.goalcurrent) && checkpvs(this.origin + this.view_ofs, this.goalcurrent))
-       {
-               navigation_poproute(this);
-               ++removed_goals;
-       }
+       if(!this.goalcurrent)
+               return removed_goals;
 
        if(this.goalcurrent.wpflags & WAYPOINTFLAG_TELEPORT)
        {