• Visit Rebornbuddy
  • CanFullyNavigateTo

    Discussion in 'Community Developer Forum' started by kaihaider, Nov 12, 2014.

    1. kaihaider

      kaihaider Community Developer

      Joined:
      May 18, 2010
      Messages:
      1,325
      Likes Received:
      5
      Trophy Points:
      38
      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?
       
      Last edited: Nov 12, 2014
    2. mastahg

      mastahg Administrator Staff Member

      Joined:
      Feb 27, 2011
      Messages:
      5,232
      Likes Received:
      364
      Trophy Points:
      83
      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.
       
    3. kaihaider

      kaihaider Community Developer

      Joined:
      May 18, 2010
      Messages:
      1,325
      Likes Received:
      5
      Trophy Points:
      38
      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.
       
    4. mastahg

      mastahg Administrator Staff Member

      Joined:
      Feb 27, 2011
      Messages:
      5,232
      Likes Received:
      364
      Trophy Points:
      83
      Just use linq.

      Code:
      var result = resultsarray.Where(r=>r.CanNavigate == 1).FirstOrDefault();
      if (result != null)
      {
      return targets.FirstOrDefault(z=>z.ObjectId == result.Id);
      }
      
       
    5. kaihaider

      kaihaider Community Developer

      Joined:
      May 18, 2010
      Messages:
      1,325
      Likes Received:
      5
      Trophy Points:
      38
      beautiful thanks ^_^
       
    6. kaihaider

      kaihaider Community Developer

      Joined:
      May 18, 2010
      Messages:
      1,325
      Likes Received:
      5
      Trophy Points:
      38
      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;
      }
       
      Last edited: Nov 15, 2014
    7. mastahg

      mastahg Administrator Staff Member

      Joined:
      Feb 27, 2011
      Messages:
      5,232
      Likes Received:
      364
      Trophy Points:
      83
      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)
       

    Share This Page