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))
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)
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);
));
}
// 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");
}
}
+ entity nwp;
//te_wizspike(e.origin);
//bprint(etos(e));
//bprint("\n");