X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fbot%2Fnavigation.qc;h=95279d59fa062eede3377936b59f04e5f013dbca;hb=68d9a87b4cf6fe824c2fa9a21a284b56b666c522;hp=6aa6ea2a17f8a32b4f22df6d5c702df0ee591bd6;hpb=26ec33d6d19e627b43ac2cb51f83f890b5176293;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/bot/navigation.qc b/qcsrc/server/bot/navigation.qc index 6aa6ea2a1..95279d59f 100644 --- a/qcsrc/server/bot/navigation.qc +++ b/qcsrc/server/bot/navigation.qc @@ -27,6 +27,7 @@ float tracewalk(entity e, vector start, vector m1, vector m2, vector end, float dir = normalize(move); stepdist = 32; ignorehazards = FALSE; + swimming = FALSE; // Analyze starting point traceline(start, start, MOVE_NORMAL, e); @@ -332,12 +333,36 @@ void navigation_poproute() 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"); @@ -362,7 +387,6 @@ entity navigation_findnearestwaypoint(entity ent, float walkfromwp) te_plasmaburn(org); best = world; - bestdist = 1050; // box check failed, try walk w = waylist; @@ -382,36 +406,20 @@ entity navigation_findnearestwaypoint(entity ent, float walkfromwp) } 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) @@ -782,7 +790,7 @@ void navigation_routerating(entity e, float f, float rangebias) 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; @@ -794,7 +802,7 @@ void navigation_routerating(entity e, float f, float rangebias) 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; } } @@ -988,7 +996,7 @@ void navigation_goalrating_end() { 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; } @@ -1071,14 +1079,14 @@ void navigation_unstuck() { 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; @@ -1090,7 +1098,7 @@ void navigation_unstuck() 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; @@ -1118,7 +1126,7 @@ void navigation_unstuck() 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; } } @@ -1211,6 +1219,7 @@ void debuggoalstack() 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) {