Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Try asking for help in the chatbox
  • Get location of an object


    Stormscythe
     Share

    Recommended Posts

    Hello

     

    I am trying to get the position of gameobjects, so I could walk to them - how do I do this?

     

    This is how I would think it worked:

     

    getWalking.walk(object.getLocation());

    Edited by jannikl
    Link to comment
    Share on other sites

    Hello

     

    I am trying to get the position of gameobjects, so I could walk to them - how do I do this?

     

    This is how I would think it worked:

     

    getWalking.walk(object.getLocation());

    You're looking for GameObject#getTile()

     

    http://dreambot.org/javadocs/org/dreambot/api/methods/walking/impl/Walking.html#walk-org.dreambot.api.methods.map.Tile-

    Link to comment
    Share on other sites

    Thanks Chris

     

    While I have you, is there a way to check which of the 4 different gameobjects in an array, that are closer to you?

    You'd have to loop through the array and check the distance of each gameobject to you, and return the one that is closest. You can check distance with

    gameObject.getTile().distance(getLocalPlayer().getTile())

    Link to comment
    Share on other sites

    You'd have to loop through the array and check the distance of each gameobject to you, and return the one that is closest. You can check distance with

    gameObject.getTile().distance(getLocalPlayer().getTile())

     

    Thanks Nezz, but it appears to throw an error: Cannot convert from double to boolean

     

    EDIT: Ah, got it to work eventually, thank you :-D Although, I have another question (lol) - How would I return the object closest to me?

    Edited by jannikl
    Link to comment
    Share on other sites

    Thanks Nezz, but it appears to throw an error: Cannot convert from double to boolean

     

    EDIT: Ah, got it to work eventually, thank you :-D Although, I have another question (lol) - How would I return the object closest to me?

    You can use the method GameObjects#closest(Filter<GameObject> f)

     

    http://dreambot.org/javadocs/org/dreambot/api/methods/interactive/GameObjects.html#closest-org.dreambot.api.methods.filter.Filter-

     

    http://dreambot.org/javadocs/org/dreambot/api/methods/filter/impl/NameFilter.html

    Link to comment
    Share on other sites

     

    Hello - that doesn't seem to work, when the GameObjects I declared are in an array.

    Link to comment
    Share on other sites

    Hello - that doesn't seem to work, when the GameObjects I declared are in an array.

    You can manually do it then

    private GameObject getClosestGameObjectFromList(List<GameObject> gameObjectList) {
        double distance = 100D;
        GameObject closestObject = null;
        for (GameOject temp : gameObjectList) {
            if (temp != null && temp.distance(getMyPlayer().getTile()) < distance) {
                distance = temp.distance(getMyPlayer().getTile());
                closestObject = temp;
                if (distance <= 1) break;
            }
        }
        return closestObject;
    }
    
    This is untested.
    Link to comment
    Share on other sites

     Share

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.