]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Bot AI: also check if the goal item can be left to teammates while going to it
authorterencehill <piuntn@gmail.com>
Thu, 12 Oct 2017 11:52:47 +0000 (13:52 +0200)
committerterencehill <piuntn@gmail.com>
Thu, 12 Oct 2017 11:52:47 +0000 (13:52 +0200)
qcsrc/server/bot/api.qh
qcsrc/server/bot/default/havocbot/havocbot.qc
qcsrc/server/bot/default/navigation.qc

index 89e9a84a8c0902dc944f865d7ae3c11d02a36dd5..1bab0b02b7b4afcf6eb8ee57ee5741c4de0a2e78 100644 (file)
@@ -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);
index a921a5bf9e3ddc018987c5ff10d07b3c355ccd15..b0772900cf5d88dcda18fdaaa4b7ea11a761d70f 100644 (file)
@@ -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
index 0f223142a1c04e95d9a8ab36337d62436616de2c..cfaec7f2669957068c58c41b5116e6b08008a72a 100644 (file)
@@ -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;