From: terencehill Date: Fri, 10 Nov 2017 14:47:36 +0000 (+0100) Subject: Bot AI: check if path is walkable while chasing a player X-Git-Tag: xonotic-v0.8.5~2378^2~21 X-Git-Url: http://de.git.xonotic.org/?a=commitdiff_plain;h=1f178e9e99364ebbb3398d9de8b5a13aca01e2f8;p=xonotic%2Fxonotic-data.pk3dir.git Bot AI: check if path is walkable while chasing a player --- diff --git a/qcsrc/server/bot/default/havocbot/havocbot.qc b/qcsrc/server/bot/default/havocbot/havocbot.qc index a383dd87c..608429aa8 100644 --- a/qcsrc/server/bot/default/havocbot/havocbot.qc +++ b/qcsrc/server/bot/default/havocbot/havocbot.qc @@ -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); } } diff --git a/qcsrc/server/bot/default/havocbot/havocbot.qh b/qcsrc/server/bot/default/havocbot/havocbot.qh index 88ba407a2..2f987f674 100644 --- a/qcsrc/server/bot/default/havocbot/havocbot.qh +++ b/qcsrc/server/bot/default/havocbot/havocbot.qh @@ -23,6 +23,7 @@ .float havocbot_stickenemy; .float havocbot_role_timeout; +.float bot_tracewalk_time; .entity ignoregoal; .entity bot_lastseengoal; .entity havocbot_personal_waypoint; diff --git a/qcsrc/server/bot/default/navigation.qc b/qcsrc/server/bot/default/navigation.qc index 36e5843f6..c9ebc0755 100644 --- a/qcsrc/server/bot/default/navigation.qc +++ b/qcsrc/server/bot/default/navigation.qc @@ -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) {