import org.dreambot.api.methods.Calculations;
import org.dreambot.api.methods.input.Mouse;
import org.dreambot.api.script.AbstractScript;
import org.dreambot.api.script.ScriptManifest;
import org.dreambot.api.script.Category;
import org.dreambot.api.utilities.Timer;
import org.dreambot.api.wrappers.interactive.GameObject;
@ScriptManifest(author = "You", name = "Improved Tea Thiever", version = 1.0, description = "Advanced Tea Thieving Script", category = Category.THIEVING)
public class Main extends AbstractScript {
private static final int MIN_WAIT = 300;
private static final int MAX_WAIT = 800;
private static final int MOUSE_MOVE_RANGE = 20;
private static final int LOOT_THRESHOLD = 100;
private Timer antiBanTimer = new Timer();
private boolean antiBanActive = false;
public void onStart() {
log("Welcome to Improved Tea Thiever by Apaec.");
log("If you experience any issues while running this script please report them to me on the forums.");
log("Enjoy the script, gain some thieving levels!.");
}
private enum State {
STEAL, DROP, WAIT
};
private State getState() {
GameObject stall = getGameObjects().getClosest("Tea stall");
if (!getInventory().isEmpty())
return State.DROP;
if (stall != null)
return State.STEAL;
return State.WAIT;
}
public void onExit() {
}
@Override
public int onLoop() {
switch (getState()) {
case STEAL:
GameObject stall = getGameObjects().getClosest("Tea stall");
if (stall != null) {
if (antiBanActive) {
if (antiBanTimer.elapsed() >= MIN_WAIT) {
Mouse.moveRandomly(MOUSE_MOVE_RANGE);
antiBanTimer.reset();
}
} else {
stall.interact("Steal-from");
antiBanTimer.reset();
antiBanActive = true;
}
}
break;
case DROP:
getInventory().getItems(item -> item.getName().equals("Cup of tea") && item.getValue() <= LOOT_THRESHOLD).forEach(item -> item.interact("Drop"));
break;
case WAIT:
sleep(Calculations.random(MIN_WAIT, MAX_WAIT));
antiBanActive = false;
break;
}
return Calculations.random(500, 600);
}
}