dir = normalize(move);
stepdist = 32;
ignorehazards = FALSE;
+ swimming = FALSE;
// Analyze starting point
traceline(start, start, MOVE_NORMAL, e);
self.goalstack31 = world;
}
+float navigation_waypoint_will_link(vector v, vector org, entity ent, float walkfromwp, float bestdist)
+{
+ float dist;
+ dist = vlen(v - org);
+ if (bestdist > dist)
+ {
+ traceline(v, org, TRUE, ent);
+ if (trace_fraction == 1)
+ {
+ if (walkfromwp)
+ {
+ if (tracewalk(ent, v, PL_MIN, PL_MAX, org, bot_navigation_movemode))
+ return TRUE;
+ }
+ else
+ {
+ if (tracewalk(ent, org, PL_MIN, PL_MAX, v, bot_navigation_movemode))
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
+}
+
// find the spawnfunc_waypoint near a dynamic goal such as a dropped weapon
-entity navigation_findnearestwaypoint(entity ent, float walkfromwp)
+entity navigation_findnearestwaypoint_withdist(entity ent, float walkfromwp, float bestdist)
{
entity waylist, w, best;
- float dist, bestdist;
vector v, org, pm1, pm2;
+
pm1 = ent.origin + ent.mins;
pm2 = ent.origin + ent.maxs;
waylist = findchain(classname, "waypoint");
te_plasmaburn(org);
best = world;
- bestdist = 1050;
// box check failed, try walk
w = waylist;
}
else
v = w.origin;
- dist = vlen(v - org);
- if (bestdist > dist)
+ if(navigation_waypoint_will_link(v, org, ent, walkfromwp, bestdist))
{
- traceline(v, org, TRUE, ent);
- if (trace_fraction == 1)
- {
- if (walkfromwp)
- {
- //print("^1can I reach ", vtos(org), " from ", vtos(v), "?\n");
- if (tracewalk(ent, v, PL_MIN, PL_MAX, org, bot_navigation_movemode))
- {
- bestdist = dist;
- best = w;
- }
- }
- else
- {
- if (tracewalk(ent, org, PL_MIN, PL_MAX, v, bot_navigation_movemode))
- {
- bestdist = dist;
- best = w;
- }
- }
- }
+ bestdist = vlen(v - org);
+ best = w;
}
}
w = w.chain;
}
return best;
}
+entity navigation_findnearestwaypoint(entity ent, float walkfromwp)
+{
+ return navigation_findnearestwaypoint_withdist(ent, walkfromwp, 1050);
+}
// finds the waypoints near the bot initiating a navigation query
float navigation_markroutes_nearestwaypoints(entity waylist, float maxdist)
e.nearestwaypoint = nwp;
else
{
- dprint("FAILED to find a nearest waypoint to '", e.classname, "' #", etos(e), "\n");
+ //dprint("FAILED to find a nearest waypoint to '", e.classname, "' #", etos(e), "\n");
if(e.flags & FL_ITEM)
e.blacklisted = TRUE;
if(e.blacklisted)
{
- dprint("The entity '", e.classname, "' is going to be excluded from path finding during this match\n");
+ //dprint("The entity '", e.classname, "' is going to be excluded from path finding during this match\n");
return;
}
}
{
if not(self.aistatus & AI_STATUS_STUCK)
{
- dprint(self.netname, " cannot walk to any goal\n");
+ //dprint(self.netname, " cannot walk to any goal\n");
self.aistatus |= AI_STATUS_STUCK;
}
{
if (bot_waypoint_queue_bestgoal)
{
- dprint(self.netname, " stuck, reachable waypoint found, heading to it\n");
+ //dprint(self.netname, " stuck, reachable waypoint found, heading to it\n");
navigation_routetogoal(bot_waypoint_queue_bestgoal, self.origin);
self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
self.aistatus &~= AI_STATUS_STUCK;
}
else
{
- dprint(self.netname, " stuck, cannot walk to any waypoint at all\n");
+ //dprint(self.netname, " stuck, cannot walk to any waypoint at all\n");
}
bot_waypoint_queue_owner = world;
return;
// build a new queue
- dprint(self.netname, " stuck, scanning reachable waypoints within ", ftos(search_radius)," qu\n");
+ //dprint(self.netname, " stuck, scanning reachable waypoints within ", ftos(search_radius)," qu\n");
entity head, first;
bot_waypoint_queue_goal = first;
else
{
- dprint(self.netname, " stuck, cannot walk to any waypoint at all\n");
+ //dprint(self.netname, " stuck, cannot walk to any waypoint at all\n");
bot_waypoint_queue_owner = world;
}
}
else if(self.goalcounter==29)goal=self.goalstack29;
else if(self.goalcounter==30)goal=self.goalstack30;
else if(self.goalcounter==31)goal=self.goalstack31;
+ else goal=world;
if(goal==world)
{