Add general Run task
This commit is contained in:
41
Util/src/io/reisub/dreambot/util/tasks/Run.java
Normal file
41
Util/src/io/reisub/dreambot/util/tasks/Run.java
Normal file
@ -0,0 +1,41 @@
|
||||
package io.reisub.dreambot.util.tasks;
|
||||
|
||||
import org.dreambot.api.methods.Calculations;
|
||||
import org.dreambot.api.methods.MethodContext;
|
||||
import org.dreambot.api.methods.walking.impl.Walking;
|
||||
import org.dreambot.api.script.TaskNode;
|
||||
|
||||
public class Run extends TaskNode {
|
||||
private final int min, max;
|
||||
private int threshold;
|
||||
|
||||
public Run() {
|
||||
this(75, 100);
|
||||
}
|
||||
|
||||
public Run(int threshold) {
|
||||
this(threshold, threshold+1);
|
||||
}
|
||||
|
||||
public Run(int min, int max) {
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
this.threshold = Calculations.random(min, max);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accept() {
|
||||
return !Walking.isRunEnabled() && Walking.getRunEnergy() >= threshold;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int execute() {
|
||||
Walking.toggleRun();
|
||||
|
||||
if (MethodContext.sleepUntil(Walking::isRunEnabled, Calculations.random(1500, 2000))) {
|
||||
threshold = Calculations.random(min, max);
|
||||
}
|
||||
|
||||
return Calculations.random(200, 400);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user