From: mand1nga Date: Sat, 13 Aug 2011 03:27:38 +0000 (-0300) Subject: Avoid searching the nearest wapoint for items that remain always on the same place... X-Git-Tag: xonotic-v0.5.0~140^2~2^2^2~2 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=37a1ac728faf4509acb9d5da80bc43b82556451f;p=xonotic%2Fxonotic-data.pk3dir.git Avoid searching the nearest wapoint for items that remain always on the same place. Added blacklisting of unreachable items. --- diff --git a/qcsrc/server/bot/navigation.qc b/qcsrc/server/bot/navigation.qc index 258d3d177..ee1d60ffa 100644 --- a/qcsrc/server/bot/navigation.qc +++ b/qcsrc/server/bot/navigation.qc @@ -644,6 +644,9 @@ void navigation_routerating(entity e, float f, float rangebias) if (!e) return; + if(e.blacklisted) + return; + //print("routerating ", etos(e), " = ", ftos(f), " - ", ftos(rangebias), "\n"); // Evaluate path using jetpack @@ -745,14 +748,48 @@ void navigation_routerating(entity e, float f, float rangebias) } else { + float search; + + search = TRUE; + + if(e.flags & FL_ITEM) + { + if not(e.flags & FL_WEAPON) + if(e.nearestwaypoint) + search = FALSE; + } + else if (e.flags & FL_WEAPON) + { + if(e.classname != "droppedweapon") + if(e.nearestwaypoint) + search = FALSE; + } + + if(search) if (time > e.nearestwaypointtimeout) { nwp = navigation_findnearestwaypoint(e, TRUE); if(nwp) e.nearestwaypoint = nwp; else + { dprint("FAILED to find a nearest waypoint to '", e.classname, "' #", etos(e), "\n"); + if(e.flags & FL_ITEM) + e.blacklisted = TRUE; + else if (e.flags & FL_WEAPON) + { + if(e.classname != "droppedweapon") + e.blacklisted = TRUE; + } + + if(e.blacklisted) + { + dprint("The entity '", e.classname, "' is going to be excluded from path finding during this match\n"); + return; + } + } + // TODO: Cleaner solution, probably handling this timeout from ctf.qc if(e.classname=="item_flag_team") e.nearestwaypointtimeout = time + 2; diff --git a/qcsrc/server/bot/navigation.qh b/qcsrc/server/bot/navigation.qh index 0a9bf1401..8b227afd9 100644 --- a/qcsrc/server/bot/navigation.qh +++ b/qcsrc/server/bot/navigation.qh @@ -27,6 +27,8 @@ entity navigation_bestgoal; .float navigation_hasgoals; .float lastteleporttime; +.float blacklisted; + .entity navigation_jetpack_goal; .vector navigation_jetpack_point;