From: terencehill Date: Thu, 12 Oct 2017 11:52:47 +0000 (+0200) Subject: Bot AI: also check if the goal item can be left to teammates while going to it X-Git-Tag: xonotic-v0.8.5~2378^2~44 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=3006ff064189933317bbc1ab03b38987733b41b0;p=xonotic%2Fxonotic-data.pk3dir.git Bot AI: also check if the goal item can be left to teammates while going to it --- diff --git a/qcsrc/server/bot/api.qh b/qcsrc/server/bot/api.qh index 89e9a84a8..1bab0b02b 100644 --- a/qcsrc/server/bot/api.qh +++ b/qcsrc/server/bot/api.qh @@ -71,6 +71,8 @@ void havocbot_goalrating_enemyplayers(entity this, float ratingscale, vector org void havocbot_goalrating_items(entity this, float ratingscale, vector org, float sradius); void havocbot_goalrating_waypoints(entity this, float ratingscale, vector org, float sradius); +bool havocbot_goalrating_item_pickable_check_players(entity this, vector org, entity item, vector item_org); + vector havocbot_middlepoint; float havocbot_middlepoint_radius; vector havocbot_symmetryaxis_equation; @@ -86,6 +88,7 @@ void navigation_goalrating_start(entity this); void navigation_goalrating_timeout_set(entity this); void navigation_goalrating_timeout_force(entity this); bool navigation_goalrating_timeout(entity this); +bool navigation_goalrating_timeout_can_be_anticipated(entity this); void navigation_markroutes(entity this, entity fixed_source_waypoint); void navigation_markroutes_inverted(entity fixed_source_waypoint); void navigation_routerating(entity this, entity e, float f, float rangebias); diff --git a/qcsrc/server/bot/default/havocbot/havocbot.qc b/qcsrc/server/bot/default/havocbot/havocbot.qc index a921a5bf9..b0772900c 100644 --- a/qcsrc/server/bot/default/havocbot/havocbot.qc +++ b/qcsrc/server/bot/default/havocbot/havocbot.qc @@ -759,8 +759,14 @@ void havocbot_movetogoal(entity this) } if(!locked_goal) { - if(navigation_poptouchedgoals(this) && time > this.bot_strategytime - (IS_MOVABLE(this.goalentity) ? 3 : 2)) - navigation_goalrating_timeout_force(this); + // 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_goalrating_timeout_can_be_anticipated(this)) + navigation_goalrating_timeout_force(this); + } } // if ran out of goals try to use an alternative goal or get a new strategy asap diff --git a/qcsrc/server/bot/default/navigation.qc b/qcsrc/server/bot/default/navigation.qc index 0f223142a..cfaec7f26 100644 --- a/qcsrc/server/bot/default/navigation.qc +++ b/qcsrc/server/bot/default/navigation.qc @@ -35,6 +35,24 @@ bool navigation_goalrating_timeout(entity this) return this.bot_strategytime < time; } +bool navigation_goalrating_timeout_can_be_anticipated(entity this) +{ + if(time > this.bot_strategytime - (IS_MOVABLE(this.goalentity) ? 3 : 2)) + return true; + + if (this.goalentity.bot_pickup && time > this.bot_strategytime - 5) + { + vector gco = (this.goalentity.absmin + this.goalentity.absmax) * 0.5; + if(!havocbot_goalrating_item_pickable_check_players(this, this.origin, this.goalentity, gco)) + { + this.ignoregoal = this.goalentity; + this.ignoregoaltime = time + autocvar_bot_ai_ignoregoal_timeout; + return true; + } + } + return false; +} + void navigation_dynamicgoal_init(entity this, bool initially_static) { this.navigation_dynamicgoal = true;