{
entity theEnemy = e;
entity best_wp = NULL;
- float best_dist = 10000;
- IL_EACH(g_waypoints, vdist(it.origin - theEnemy.origin, <, 500)
+ float best_dist = FLOAT_MAX;
+ IL_EACH(g_waypoints, !(it.wpflags & WAYPOINTFLAG_TELEPORT)
+ && vdist(it.origin - theEnemy.origin, <, 500)
&& vdist(it.origin - this.origin, >, 100)
- && !(it.wpflags & WAYPOINTFLAG_TELEPORT),
+ && vdist(it.origin - this.origin, <, 10000),
{
- float dist = vlen(it.origin - theEnemy.origin);
+ float dist = vlen2(it.origin - theEnemy.origin);
if (dist < best_dist)
{
best_wp = it;