2021-10-28 00:01:08 +02:00

43 lines
1.4 KiB
Java

package io.reisub.dreambot.csmelter.tasks;
import io.reisub.dreambot.csmelter.CSmelter;
import io.reisub.dreambot.util.Util;
import org.dreambot.api.methods.Calculations;
import org.dreambot.api.methods.MethodProvider;
import org.dreambot.api.methods.container.impl.Inventory;
import org.dreambot.api.methods.container.impl.bank.Bank;
import org.dreambot.api.methods.interactive.GameObjects;
import org.dreambot.api.methods.walking.impl.Walking;
import org.dreambot.api.script.TaskNode;
import org.dreambot.api.wrappers.interactive.GameObject;
public class OpenBank extends TaskNode {
@Override
public boolean accept() {
return !Bank.isOpen()
&& !Inventory.containsAll(CSmelter.smeltingOption.getIngredientsNames())
&& Util.playerIsIdle();
}
@Override
public int execute() {
GameObject bank = GameObjects.closest("Bank booth");
if (bank == null) return Calculations.random(250, 400);
if (!bank.isOnScreen()) {
while (bank.distance() > Calculations.random(6, 9)) {
if (Walking.shouldWalk(Calculations.random(4, 6))) {
Walking.walk(bank);
}
}
}
bank.interactForceLeft("Bank");
if (!Util.sleepUntilMoving()) return Calculations.random(250, 400);
MethodProvider.sleepUntil(Bank::isOpen, Calculations.random(10000, 11000));
return Calculations.random(250, 400);
}
}