]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Allow bots to roam on the map even if there's no item to pick up (playing CA or with...
authorterencehill <piuntn@gmail.com>
Fri, 10 Feb 2017 15:26:10 +0000 (16:26 +0100)
committerterencehill <piuntn@gmail.com>
Fri, 10 Feb 2017 15:26:10 +0000 (16:26 +0100)
qcsrc/server/bot/api.qh
qcsrc/server/bot/default/havocbot/roles.qc
qcsrc/server/bot/default/navigation.qc
qcsrc/server/bot/default/navigation.qh
qcsrc/server/mutators/mutator/gamemode_domination.qc
qcsrc/server/mutators/mutator/gamemode_freezetag.qc
qcsrc/server/mutators/mutator/gamemode_keepaway.qc

index 97104ef3765908f46d29ad59368f325e3781d759..b0f457df4c37c496af39ef735bae1a64024b08f5 100644 (file)
@@ -66,6 +66,7 @@ entity find_bot_by_number(float number);
 
 void havocbot_goalrating_enemyplayers(entity this, float ratingscale, vector org, float sradius);
 void havocbot_goalrating_items(entity this, float ratingscale, vector org, float sradius);
+void havocbot_goalrating_waypoints(entity this, float ratingscale, vector org, float sradius);
 
 entity navigation_findnearestwaypoint(entity ent, float walkfromwp);
 void navigation_goalrating_end(entity this);
index 27710bf087f3e32118d8e13cd5445c14c145e523..6b9537651eb0a7ae7b931b30a8120425cf7b9fd2 100644 (file)
 .void(entity this) havocbot_previous_role;
 .void(entity this) havocbot_role;
 
+void havocbot_goalrating_waypoints(entity this, float ratingscale, vector org, float sradius)
+{
+       // rate waypoints only if there's no alternative goal
+       if(navigation_bestgoal)
+               return;
+
+       float f;
+       float range = 500;
+       sradius = max(range, (0.5 + random() * 0.5) * sradius);
+       while(sradius > 100)
+       {
+               IL_EACH(g_waypoints, vdist(it.origin - org, <, sradius)
+                       && vdist(it.origin - org, >, max(100, sradius - range)),
+               {
+                       if(vdist(it.origin - this.wp_goal_prev0.origin, <, range * 1.5))
+                               f = 0.1;
+                       else if(vdist(it.origin - this.wp_goal_prev1.origin, <, range * 1.5))
+                               f = 0.1;
+                       else
+                               f = 0.5 + random() * 0.5;
+                       navigation_routerating(this, it, ratingscale * f, 2000);
+               });
+               if(navigation_bestgoal)
+                       break;
+               sradius -= range;
+       }
+};
+
 void havocbot_goalrating_items(entity this, float ratingscale, vector org, float sradius)
 {
        float rating, d, discard, friend_distance, enemy_distance;
@@ -175,7 +203,7 @@ void havocbot_role_generic(entity this)
                navigation_goalrating_start(this);
                havocbot_goalrating_items(this, 10000, this.origin, 10000);
                havocbot_goalrating_enemyplayers(this, 20000, this.origin, 10000);
-               //havocbot_goalrating_waypoints(1, this.origin, 1000);
+               havocbot_goalrating_waypoints(this, 1, this.origin, 3000);
                navigation_goalrating_end(this);
        }
 }
index 742213a8977c897633c5868864dd31e89f95a423..2638958f5b43264368f6e65e88e318a341f56b6b 100644 (file)
@@ -875,6 +875,12 @@ bool navigation_routetogoal(entity this, entity e, vector startposition)
        //print("routetogoal ", etos(e), "\n");
        navigation_pushroute(this, e);
 
+       if(e.classname == "waypoint" && !(e.wpflags & WAYPOINTFLAG_PERSONAL))
+       {
+               this.wp_goal_prev1 = this.wp_goal_prev0;
+               this.wp_goal_prev0 = e;
+       }
+
        if(g_jetpack)
        if(e==this.navigation_jetpack_goal)
                return true;
index ad01776652b4de67098af9f77e5057d8df13e196..e5097563c65109ea6607c7e3ef7b3dc2eaf207c1 100644 (file)
@@ -24,6 +24,9 @@ entity navigation_bestgoal;
 .entity goalstack28, goalstack29, goalstack30, goalstack31;
 .entity nearestwaypoint;
 
+.entity wp_goal_prev0;
+.entity wp_goal_prev1;
+
 .float nearestwaypointtimeout;
 .float navigation_hasgoals;
 .float lastteleporttime;
index c236ab8a212cc52c4755eff8e44e29294617c9ce..cffb60cb122f51a7eb0ddb22a36c3c3e1bea742c 100644 (file)
@@ -409,7 +409,7 @@ void havocbot_role_dom(entity this)
                havocbot_goalrating_controlpoints(this, 10000, this.origin, 15000);
                havocbot_goalrating_items(this, 8000, this.origin, 8000);
                //havocbot_goalrating_enemyplayers(this, 3000, this.origin, 2000);
-               //havocbot_goalrating_waypoints(1, this.origin, 1000);
+               havocbot_goalrating_waypoints(this, 1, this.origin, 3000);
                navigation_goalrating_end(this);
        }
 }
index 2310ab4e6cdaa998a2999366790d89dbf7ee5f1e..515c9da943a7bd2778bcf5e5797cd182d47c8e3c 100644 (file)
@@ -270,7 +270,7 @@ void havocbot_role_ft_offense(entity this)
                havocbot_goalrating_items(this, 10000, this.origin, 10000);
                havocbot_goalrating_enemyplayers(this, 20000, this.origin, 10000);
                havocbot_goalrating_freeplayers(this, 9000, this.origin, 10000);
-               //havocbot_goalrating_waypoints(1, this.origin, 1000);
+               havocbot_goalrating_waypoints(this, 1, this.origin, 3000);
                navigation_goalrating_end(this);
        }
 }
@@ -299,7 +299,7 @@ void havocbot_role_ft_freeing(entity this)
                havocbot_goalrating_items(this, 8000, this.origin, 10000);
                havocbot_goalrating_enemyplayers(this, 10000, this.origin, 10000);
                havocbot_goalrating_freeplayers(this, 20000, this.origin, 10000);
-               //havocbot_goalrating_waypoints(1, this.origin, 1000);
+               havocbot_goalrating_waypoints(this, 1, this.origin, 3000);
                navigation_goalrating_end(this);
        }
 }
index 7677bdab5ce28224a74e682f00046cabe6c228b5..07c015f257e8175cd73cb74dc28e6a9186c5d95d 100644 (file)
@@ -231,7 +231,7 @@ void havocbot_role_ka_carrier(entity this)
                navigation_goalrating_start(this);
                havocbot_goalrating_items(this, 10000, this.origin, 10000);
                havocbot_goalrating_enemyplayers(this, 20000, this.origin, 10000);
-               //havocbot_goalrating_waypoints(1, this.origin, 1000);
+               havocbot_goalrating_waypoints(this, 1, this.origin, 3000);
                navigation_goalrating_end(this);
        }