domp Posted October 31, 2016 Share Posted October 31, 2016 (edited) I am trying to get my player to walk back to ONE specific coord(x, y, z), I am using getWalking().walk(coord) and the bot always seems to click one tile off of the coordinate I have it set to move to. I need to be on a specific tile to aggro all the monsters and efficiently run my script Also on tips/ideas/logic about having myPlayer reset aggro? I'm using a not so good check because If I kill all the crabs my script thinks I have to reset aggro if (!myPlayer().isHitBarVisible()) { if (!RESET_AREA.contains(myPlayer())) { return State.Reset; } } Is there a efficient way to set a timer so after a certain amount of time the script returns a state? By the way, trying to make a simple Sandcrab killer with resetting Thank you so much ! Edited October 31, 2016 by domp Quote Link to comment Share on other sites More sharing options...
Explv Posted October 31, 2016 Share Posted October 31, 2016 I am trying to get my player to walk back to ONE specific coord(x, y, z), I am using getWalking().walk(coord) and the bot always seems to click one tile off of the coordinate I have it set to move to. I need to be on a specific tile to aggro all the monsters and efficiently run my script Also on tips/ideas/logic about having myPlayer reset aggro? I'm using a not so good check because If I kill all the crabs my script thinks I have to reset aggro if (!myPlayer().isHitBarVisible()) { if (!RESET_AREA.contains(myPlayer())) { return State.Reset; } } Is there a efficient way to set a timer so after a certain amount of time the script returns a state? By the way, trying to make a simple Sandcrab killer with resetting Thank you so much ! Use the WalkingEvent: WalkingEvent walkingEvent = new WalkingEvent(position); walkingEvent.setMinDistanceThreshold(0); execute(walkingEvent); 2 Quote Link to comment Share on other sites More sharing options...
Manner Posted October 31, 2016 Share Posted October 31, 2016 For a timer you could do something like this: //Class variable private long timer; //when you want to start/reset the timer timer = System.currentTimeMillis(); //to check if the timer is past a certain amount of time, ex. 1 min. System.currentTimeMillis() - timer >= 60000; 1 Quote Link to comment Share on other sites More sharing options...
domp Posted November 1, 2016 Author Share Posted November 1, 2016 Use the WalkingEvent: WalkingEvent walkingEvent = new WalkingEvent(position); walkingEvent.setMinDistanceThreshold(0); execute(walkingEvent); Thankyou, I implemented this and I will let you know how it works, currently laying low..did alot of testing that was faulty For a timer you could do something like this: //Class variable private long timer; //when you want to start/reset the timer timer = System.currentTimeMillis(); //to check if the timer is past a certain amount of time, ex. 1 min. System.currentTimeMillis() - timer >= 60000; Thank you for this idea! I will be using this for my reset state! Quote Link to comment Share on other sites More sharing options...
Chris Posted November 1, 2016 Share Posted November 1, 2016 public class Timer { private final long start; private final long period; private long end; public Timer(long period) { this.period = period; this.start = System.currentTimeMillis(); this.end = (this.start + period); } public long getElapsed() { return System.currentTimeMillis() - this.start; } public long getRemaining() { if (isRunning()) { return this.end - System.currentTimeMillis(); } return 0L; } public boolean isRunning() { return System.currentTimeMillis() < this.end; } public void reset() { this.end = (System.currentTimeMillis() + this.period); } public long setEndIn(long ms) { this.end = (System.currentTimeMillis() + ms); return this.end; } public String toElapsedString() { return Time.format(getElapsed()); } public String toRemainingString() { return Time.format(getRemaining()); } } public class Time { public static String format(long time) { StringBuilder t = new StringBuilder(); long total_secs = time / 1000L; long total_mins = total_secs / 60L; long total_hrs = total_mins / 60L; long total_days = total_hrs / 24L; int secs = (int)total_secs % 60; int mins = (int)total_mins % 60; int hrs = (int)total_hrs % 24; int days = (int)total_days; if (days > 0) { if (days < 10) { t.append("0"); } t.append(days); t.append(":"); } if (hrs < 10) { t.append("0"); } t.append(hrs); t.append(":"); if (mins < 10) { t.append("0"); } t.append(mins); t.append(":"); if (secs < 10) { t.append("0"); } t.append(secs); return t.toString(); } } Quote Link to comment Share on other sites More sharing options...