]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/bot/default/havocbot/roles.qc
Merge branch 'master' into martin-t/damagetext
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / bot / default / havocbot / roles.qc
index 27710bf087f3e32118d8e13cd5445c14c145e523..5ddb0f74b576ab0bcd8107dad86e1af96a5f6a27 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))
+                       && !(it.wpflags & WAYPOINTFLAG_TELEPORT),
+               {
+                       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,8 +204,11 @@ 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);
+
+               if(IS_PLAYER(this.goalentity))
+                       this.bot_strategytime = time + min(2, autocvar_bot_ai_strategyinterval);
        }
 }