1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Question QueryBuilder for Coordinates?

Discussion in 'Developer Support' started by dungeonqueer, Dec 5, 2017.

  1. dungeonqueer

    Joined:
    Nov 29, 2017
    Messages:
    3
    Likes Received:
    0
    Is there a way of invoking a QueryBuilder? In the docs, it wasn't apparent that this was feasible.

    The context in which I'd be using this would be to find a specific "safe" tile within a region that is furthest from monsters with a propensity to attack. This would allow for a user to retreat to this local tile, and the process of finding the next safest local tile in the updated region would continue until the monster no longer focuses on the user.

    If there is a simpler way of going about doing this without the use of a QueryBuilder, I'm all ears.

    Thanks
     
  2. Savior

    Savior Java Warlord

    Joined:
    Nov 17, 2014
    Messages:
    4,906
    Likes Received:
    2,748
    There are more than 10000 coordinates loaded at once, it‘s basically impossible to frequently iterate over them checking for distances and reachability and what not
     
  3. dungeonqueer

    Joined:
    Nov 29, 2017
    Messages:
    3
    Likes Received:
    0
    What about within a specified distance, eg. the coordinates displayed on a player's minimap?
     
  4. Derk

    Derk 12 year old normie

    Joined:
    Jan 8, 2015
    Messages:
    2,766
    Likes Received:
    1,339
    You can create a circular area around the player and get all coordinates form that area if you really want to pursue this.
     
  5. Jux7apose

    Joined:
    Mar 28, 2017
    Messages:
    286
    Likes Received:
    58
    I don't think there's a set method getSafeTile or something of those sorts, or even npc.getSafeDistance, so you'd have to manually define a monsters wandering radius, and walk away that amount of tiles.

    Then again, I don't know if it becomes slightly difficult if the npcs are ranged. Also, it becomes more difficult to do the method above because that monsters attack region is already pre defined, and based on where they spawn. Unless the npc is stationary, it's going to be hard to know what is that npc's spawn point, unless we have a method that defines that
     
  6. auxi

    Joined:
    May 24, 2016
    Messages:
    1,113
    Likes Received:
    990
    What you are trying to do sounds achievable using
    Code (Text):
    1. Players.getLocal().getPostion().getReachableCoordinates()
    which returns all reachable coordinates in the current region.
     
    #6 auxi, Dec 19, 2017
    Last edited: Dec 19, 2017
  7. tyb51

    tyb51 Niche bots at your disposal

    Joined:
    Dec 23, 2015
    Messages:
    1,098
    Likes Received:
    439
    I needed a coordinate query builder myself just recently. What I did now is getReachableCoordinates (like auxi just said) and then use a GameObjects query with the .on(coordinates) filter to do what I want. This allows you to use thing like nearest(), nearestTo() (without making your own comparator) and parallel compute (?) of the regular stream filters.
    Just remember to use providers where applicable, so you don't query your CPU to hell.

    So what you could do is something like this:
    (do note you can optimize this query by using other parameters)
    Code (Javascript):
    1. Npc target;
    2. GameObjects.newQuery().on(reachableCoordinates).within(optionalArea).fitler(monster->Distance.between (target, monster)>getWanderignDistance(monster)).results().nearest();
     
    #7 tyb51, Dec 19, 2017
    Last edited: Dec 19, 2017
    LucasSousa likes this.

Share This Page

Loading...