entity best = NULL;
vector v;
+ if(!autocvar_g_waypointeditor && !ent.navigation_dynamicgoal)
+ {
+ waypoint_clearlinks(ent); // initialize wpXXmincost fields
+ IL_EACH(g_waypoints, it != ent,
+ {
+ if(it.wpisbox)
+ {
+ vector wm1 = it.absmin;
+ vector wm2 = it.absmax;
+ v.x = bound(wm1_x, org.x, wm2_x);
+ v.y = bound(wm1_y, org.y, wm2_y);
+ v.z = bound(wm1_z, org.z, wm2_z);
+ }
+ else
+ v = it.origin;
+ if(navigation_waypoint_will_link(v, org, ent, walkfromwp, 1050))
+ navigation_item_addlink(it, ent);
+ });
+ }
+
// box check failed, try walk
IL_EACH(g_waypoints, it != ent,
{
{
// often path can be optimized by not adding the nearest waypoint
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))
+ || (!this.goalentity.navigation_dynamicgoal && navigation_item_islinked(nearest_wp.enemy, this.goalentity))
+ || (this.goalentity.navigation_dynamicgoal && 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;
}
.float nearestwaypoint_dist;
.float nearestwaypointtimeout;
+/*
+// item it is linked from waypoint it.wpXX (INCOMING link)
+// links are sorted by their cost (wpXXmincost)
+.entity wp00, wp01, wp02, wp03, wp04, wp05, wp06, wp07, wp08, wp09, wp10, wp11, wp12, wp13, wp14, wp15;
+.entity wp16, wp17, wp18, wp19, wp20, wp21, wp22, wp23, wp24, wp25, wp26, wp27, wp28, wp29, wp30, wp31;
+
+.float wp00mincost, wp01mincost, wp02mincost, wp03mincost, wp04mincost, wp05mincost, wp06mincost, wp07mincost;
+.float wp08mincost, wp09mincost, wp10mincost, wp11mincost, wp12mincost, wp13mincost, wp14mincost, wp15mincost;
+.float wp16mincost, wp17mincost, wp18mincost, wp19mincost, wp20mincost, wp21mincost, wp22mincost, wp23mincost;
+.float wp24mincost, wp25mincost, wp26mincost, wp27mincost, wp28mincost, wp29mincost, wp30mincost, wp31mincost;
+*/
+
+#define navigation_item_islinked(from_wp, to_item) waypoint_islinked(to_item, from_wp)
+#define navigation_item_addlink(from_wp, to_item) \
+ waypoint_addlink_customcost(to_item, from_wp, waypoint_getlinkcost(from_wp, to_item))
+
+
.entity wp_goal_prev0;
.entity wp_goal_prev1;
{
vector v1 = from.origin;
vector v2 = to.origin;
- if (to.wpisbox || from.wpisbox)
+ if (from.wpisbox)
{
- // if either is a box we have to find the nearest points on them to
- // calculate the distance properly
- vector m1, m2;
- m1 = to.absmin;
- m2 = to.absmax;
+ vector m1 = to.absmin, m2 = to.absmax;
v1_x = bound(m1_x, v1_x, m2_x);
v1_y = bound(m1_y, v1_y, m2_y);
v1_z = bound(m1_z, v1_z, m2_z);
- m1 = from.absmin;
- m2 = from.absmax;
+ }
+ if (to.wpisbox)
+ {
+ vector m1 = from.absmin, m2 = from.absmax;
v2_x = bound(m1_x, v2_x, m2_x);
v2_y = bound(m1_y, v2_y, m2_y);
v2_z = bound(m1_z, v2_z, m2_z);
float botframe_loadedforcedlinks;
float botframe_cachedwaypointlinks;
+// waypoint wp links to waypoint wp.wpXX (OUTGOING link)
+// links are sorted by their cost (wpXXmincost)
.entity wp00, wp01, wp02, wp03, wp04, wp05, wp06, wp07, wp08, wp09, wp10, wp11, wp12, wp13, wp14, wp15;
.entity wp16, wp17, wp18, wp19, wp20, wp21, wp22, wp23, wp24, wp25, wp26, wp27, wp28, wp29, wp30, wp31;
-// itemscore = (howmuchmoreIwant / howmuchIcanwant) / itemdistance
.float wp00mincost, wp01mincost, wp02mincost, wp03mincost, wp04mincost, wp05mincost, wp06mincost, wp07mincost;
.float wp08mincost, wp09mincost, wp10mincost, wp11mincost, wp12mincost, wp13mincost, wp14mincost, wp15mincost;
.float wp16mincost, wp17mincost, wp18mincost, wp19mincost, wp20mincost, wp21mincost, wp22mincost, wp23mincost;
void waypoint_clearlinks(entity wp);
void waypoint_schedulerelink(entity wp);
+float waypoint_getlinkcost(entity from, entity to);
float waypoint_getdistancecost(vector v1, vector v2);
float waypoint_getdistancecost_simple(float dist);