May 29, 20187 yr 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.
May 29, 20187 yr 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
May 29, 20187 yr 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);
May 29, 20187 yr Author 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.
May 29, 20187 yr 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) { // .. } ?
May 29, 20187 yr Author 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!
Create an account or sign in to comment