{
nwp = navigation_findnearestwaypoint(e, true);
if(nwp)
+ {
e.nearestwaypoint = nwp;
+
+ vector m1 = nwp.absmin, m2 = nwp.absmax;
+ m1.x = nwp.origin.x; m1.y = nwp.origin.y;
+ m2.x = nwp.origin.x; m2.y = nwp.origin.y;
+ vector ve = (e.absmin - e.absmax) * 0.5;
+ ve.x = bound(m1.x, ve.x, m2.x);
+ ve.y = bound(m1.y, ve.y, m2.y);
+ ve.z = bound(m1.z, ve.z, m2.z);
+
+ m1 = e.absmin; m2 = e.absmax;
+ m1.x = e.origin.x; m1.y = e.origin.y;
+ m2.x = e.origin.x; m2.y = e.origin.y;
+ vector vnwp = nwp.origin;
+ vnwp.x = bound(m1.x, vnwp.x, m2.x);
+ vnwp.y = bound(m1.y, vnwp.y, m2.y);
+ vnwp.z = bound(m1.z, vnwp.z, m2.z);
+ e.nearestwaypoint_dist = vlen(ve - vnwp);
+ }
else
{
LOG_DEBUG("FAILED to find a nearest waypoint to '", e.classname, "' #", etos(e));
if(nearest_wp && nearest_wp.enemy)
{
// often path can be optimized by not adding the nearest waypoint
- if(tracewalk(this, nearest_wp.enemy.origin, STAT(PL_MIN, this), STAT(PL_MAX, this), (this.goalentity.absmin + this.goalentity.absmax) * 0.5, bot_navigation_movemode))
+ if (this.goalentity.nearestwaypoint_dist < 8
+ || tracewalk(this, nearest_wp.enemy.origin, STAT(PL_MIN, this), STAT(PL_MAX, this), (this.goalentity.absmin + this.goalentity.absmax) * 0.5, bot_navigation_movemode))
e = nearest_wp.enemy;
}
.entity goalstack20, goalstack21, goalstack22, goalstack23;
.entity goalstack24, goalstack25, goalstack26, goalstack27;
.entity goalstack28, goalstack29, goalstack30, goalstack31;
+
.entity nearestwaypoint;
+.float nearestwaypoint_dist;
+.float nearestwaypointtimeout;
.entity wp_goal_prev0;
.entity wp_goal_prev1;
-.float nearestwaypointtimeout;
.float lastteleporttime;
.float blacklisted;