Stormscythe 263 Posted March 9, 2015 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());
Chris 154 Posted March 9, 2015 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-
Stormscythe 263 Author Posted March 9, 2015 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- 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?
Nuclear Nezz 2094 Posted March 9, 2015 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())
Stormscythe 263 Author Posted March 9, 2015 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?
Chris 154 Posted March 9, 2015 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
Stormscythe 263 Author Posted March 9, 2015 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 Hello - that doesn't seem to work, when the GameObjects I declared are in an array.
Chris 154 Posted March 9, 2015 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.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.