Code: public static GameObject FindNavigableTarget(IEnumerable<GameObject> targets) { GameObject target = null; foreach (var item in targets) { if (target != null) continue; var navtarget = Yield(item).Select(unit => new CanFullyNavigateTarget { Id = unit.ObjectId, Position = unit.Location }); var paths = ff14bot.Navigation.Navigator.NavigationProvider.CanFullyNavigateTo(navtarget); if (paths!=null) target = item; } return target; } Can you please enlighten me on why this breaks the bot and how I can use it to check navigation to objects or vectors? :S and even though it calls it once and I don't see errors...it seems to cause weird things >_> edit: maybe I just needed to restart arr, after 4 screwed up tests in a row, everything seems to be running fine? T_T Can you tell me if I'm using this correctly though?
if you looked at CanFullyNavigateTo you'd see that it returns a List<CanFullyNavigateResult> which says which objects you can navigate to and which you cant and how long the path would be. Also, you send one request with multiple items in it, if you do it like you are you are locking up the game client for several seconds.
I've only noticed a fraction of a second freeze (probably cause the first check returns true) and since I only search once after every grind fight, I figured it was fine. I was mostly worried that my usage of it wasn't actually getting a correct response. Thanks for the idea though, I guess I can .toarray the objects to check list position of the results? I wasn't sure how to get the object back out of the list.
Just use linq. Code: var result = resultsarray.Where(r=>r.CanNavigate == 1).FirstOrDefault(); if (result != null) { return targets.FirstOrDefault(z=>z.ObjectId == result.Id); }
I'm guessing this is the right way? Code: public static GameObject FindNavigableTarget(IEnumerable<GameObject> targets) { if (targets == null) return null; var targetsArray = targets as GameObject[] ?? targets.ToArray(); var navtarget = targetsArray.Select(unit => new CanFullyNavigateTarget { Id = unit.ObjectId, Position = unit.Location }); var resultsArray = Navigator.NavigationProvider.CanFullyNavigateTo(navtarget); var result = resultsArray.FirstOrDefault(r => r.CanNavigate == 1); return result != null ? targetsArray.FirstOrDefault(z => z.ObjectId == result.Id) : null; }
Yes, but I'd limit the amount of things you request to like the closest 8 or so targets. something like targetsArray.OrderBy(r=>r.DistanceSqr(Core.Player.Location)).Take(8)