Add general Run task

This commit is contained in:
2021-10-20 13:54:35 +02:00
parent a9ef578e50
commit 17f2a005ca
3 changed files with 21 additions and 9 deletions

View 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);
}
}