digitaltoaster Posted May 29, 2018 Share Posted May 29, 2018 Im trying to move away my player of another player is standing next to it, but it does not seem to do anything. I have tried alot of different methods, but none seem to work. Here is what I have now: private void moveAway(Player player) throws InterruptedException { try { if (isRanger) { if (!(abs(myPlayer().getPosition().getX() - player.getPosition().getX()) > 1) && !(abs(myPlayer().getPosition().getY() - player.getPosition().getY()) > 1)) { log("Trying to move"); WalkingEvent event = new WalkingEvent(player).setMinDistanceThreshold(3); execute(event); } } }catch (RuntimeException ex) { log(ex); } } Best would be if it clicked on the screen and not he minimap. Thanks in advance. Quote Link to comment Share on other sites More sharing options...
Apaec Posted May 29, 2018 Share Posted May 29, 2018 Couple of things. Firstly, it might be worth taking a look at the WalkingEvent API https://osbot.org/api/org/osbot/rs07/event/WalkingEvent.html (specifically setMinDistanceThreshold, which presumably doesn't do what you think it does) Secondly, it is worth noting that a Position (https://osbot.org/api/org/osbot/rs07/api/map/Position.html) represents an in-game tile. You might find your 'same tile' check can be simplified: if (myPlayer().getPosition().equals(player.getPosition())) { // .. } Best of luck Apa Quote Link to comment Share on other sites More sharing options...
d0zza Posted May 29, 2018 Share Posted May 29, 2018 Instead of calculating the distance like that what you can do is if (myPosition().equals(player.getPosition()) And the reason why you're not moving is because your walking event is trying to walk to the player itself. WalkingEvent event = new WalkingEvent(player).setMinDistanceThreshold(3); should be WalkingEvent event = new WalkingEvent(the position you want to walk to); Quote Link to comment Share on other sites More sharing options...
digitaltoaster Posted May 29, 2018 Author Share Posted May 29, 2018 7 minutes ago, d0zza said: Instead of calculating the distance like that what you can do is if (myPosition().equals(player.getPosition()) And the reason why you're not moving is because your walking event is trying to walk to the player itself. WalkingEvent event = new WalkingEvent(player).setMinDistanceThreshold(3); should be WalkingEvent event = new WalkingEvent(the position you want to walk to); I got it working now thanks. And yes I know I can use if (myPosition().equals(player.getPosition()) But that only checks if iets the exact same position. And I also need to know if it is next to him. So I need to absolute difference between player and use X and Y. Quote Link to comment Share on other sites More sharing options...
Apaec Posted May 29, 2018 Share Posted May 29, 2018 6 minutes ago, digitaltoaster said: I got it working now thanks. And yes I know I can use if (myPosition().equals(player.getPosition()) But that only checks if iets the exact same position. And I also need to know if it is next to him. So I need to absolute difference between player and use X and Y. Have you considered: if (getMap().distance(player) <= 1) { // .. } ? Quote Link to comment Share on other sites More sharing options...
digitaltoaster Posted May 29, 2018 Author Share Posted May 29, 2018 1 minute ago, Apaec said: Have you considered: if (getMap().distance(player) <= 1) { // .. } ? Oh I did not, thanks! Will use that instead of what I used. Thank you! 1 Quote Link to comment Share on other sites More sharing options...