]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Check if rating a waypoint is better than the enemy himself in navigation_routerating...
authorterencehill <piuntn@gmail.com>
Mon, 30 Jan 2017 16:45:35 +0000 (17:45 +0100)
committerterencehill <piuntn@gmail.com>
Mon, 30 Jan 2017 16:45:35 +0000 (17:45 +0100)
qcsrc/server/bot/default/havocbot/roles.qc
qcsrc/server/bot/default/navigation.qc

index dfa2f4540617580d5c5dc0b821734ca355c3b835..27710bf087f3e32118d8e13cd5445c14c145e523 100644 (file)
@@ -135,7 +135,7 @@ void havocbot_goalrating_enemyplayers(entity this, float ratingscale, vector org
 
        ratingscale = ratingscale * 0.00005; // enemies are rated around 20000 already
 
-       int t;
+       float t;
        FOREACH_CLIENT(IS_PLAYER(it) && bot_shouldattack(this, it), LAMBDA(
                // TODO: Merge this logic with the bot_shouldattack function
                if(vdist(it.origin - org, <, 100) || vdist(it.origin - org, >, sradius))
@@ -148,24 +148,6 @@ void havocbot_goalrating_enemyplayers(entity this, float ratingscale, vector org
                        continue;
                */
 
-               bool rate_wps = false;
-               if((it.flags & FL_INWATER) || (it.flags & FL_PARTIALGROUND))
-                       rate_wps = true;
-
-               // not falling
-               if(!IS_ONGROUND(it))
-               {
-                       traceline(it.origin, it.origin + '0 0 -1500', true, NULL);
-                       t = pointcontents(trace_endpos + '0 0 1');
-                       if(t != CONTENT_SOLID )
-                       {
-                               if(t == CONTENT_WATER || t == CONTENT_SLIME || t == CONTENT_LAVA)
-                                       rate_wps = true;
-                               else if(tracebox_hits_trigger_hurt(it.origin, it.mins, it.maxs, trace_endpos))
-                                       continue;
-                       }
-               }
-
                t = ((this.health + this.armorvalue) - (it.health + it.armorvalue)) / 150;
                t = bound(0, 1 + t, 3);
                if (skill > 3)
@@ -176,27 +158,7 @@ void havocbot_goalrating_enemyplayers(entity this, float ratingscale, vector org
                t += max(0, 8 - skill) * 0.05; // less skilled bots attack more mindlessly
                ratingscale *= t;
                if (ratingscale > 0)
-               {
-                       if(rate_wps)
-                       {
-                               entity theEnemy = it;
-                               entity best_wp = NULL;
-                               float best_dist = 10000;
-                               IL_EACH(g_waypoints, vdist(it.origin - theEnemy.origin, <, 500) && vdist(it.origin - this.origin, >, 100),
-                               {
-                                       float dist = vlen(it.origin - theEnemy.origin);
-                                       if (dist < best_dist)
-                                       {
-                                               best_wp = it;
-                                               best_dist = dist;
-                                       }
-                               });
-                               if (best_wp)
-                                       navigation_routerating(this, best_wp, ratingscale * BOT_RATING_ENEMY, 2000);
-                       }
-                       else
-                               navigation_routerating(this, it, ratingscale * BOT_RATING_ENEMY, 2000);
-               }
+                       navigation_routerating(this, it, ratingscale * BOT_RATING_ENEMY, 2000);
        ));
 }
 
index eb869601a3f4e59f862ea8b4d944a37808639d2d..fd8a521d1de2c8dd7a084e2f98351b863e5029f8 100644 (file)
@@ -643,15 +643,52 @@ void navigation_markroutes_inverted(entity fixed_source_waypoint)
 // updates the best goal according to a weighted calculation of travel cost and item value of a new proposed item
 void navigation_routerating(entity this, entity e, float f, float rangebias)
 {
-       entity nwp;
-       vector o;
        if (!e)
                return;
 
        if(e.blacklisted)
                return;
 
-       o = (e.absmin + e.absmax) * 0.5;
+       if (IS_PLAYER(e))
+       {
+               bool rate_wps = false;
+               if((e.flags & FL_INWATER) || (e.flags & FL_PARTIALGROUND))
+                       rate_wps = true;
+
+               if(!IS_ONGROUND(e))
+               {
+                       traceline(e.origin, e.origin + '0 0 -1500', true, NULL);
+                       int t = pointcontents(trace_endpos + '0 0 1');
+                       if(t != CONTENT_SOLID )
+                       {
+                               if(t == CONTENT_WATER || t == CONTENT_SLIME || t == CONTENT_LAVA)
+                                       rate_wps = true;
+                               else if(tracebox_hits_trigger_hurt(e.origin, e.mins, e.maxs, trace_endpos))
+                                       return;
+                       }
+               }
+
+               if(rate_wps)
+               {
+                       entity theEnemy = e;
+                       entity best_wp = NULL;
+                       float best_dist = 10000;
+                       IL_EACH(g_waypoints, vdist(it.origin - theEnemy.origin, <, 500) && vdist(it.origin - this.origin, >, 100),
+                       {
+                               float dist = vlen(it.origin - theEnemy.origin);
+                               if (dist < best_dist)
+                               {
+                                       best_wp = it;
+                                       best_dist = dist;
+                               }
+                       });
+                       if (!best_wp)
+                               return;
+                       e = best_wp;
+               }
+       }
+
+       vector o = (e.absmin + e.absmax) * 0.5;
 
        //print("routerating ", etos(e), " = ", ftos(f), " - ", ftos(rangebias), "\n");
 
@@ -744,6 +781,7 @@ void navigation_routerating(entity this, entity e, float f, float rangebias)
                }
        }
 
+       entity nwp;
        //te_wizspike(e.origin);
        //bprint(etos(e));
        //bprint("\n");