move to nearest banker/booth/chest if one not within interaction range

This commit is contained in:
Danial
2021-11-05 21:54:30 +13:00
parent c34921742f
commit ef351ee545
2 changed files with 25 additions and 8 deletions
+21 -4
View File
@@ -4,6 +4,7 @@ import ParaScript.data.Variables;
import org.parabot.environment.api.utils.Time; import org.parabot.environment.api.utils.Time;
import org.parabot.environment.scripts.framework.Strategy; import org.parabot.environment.scripts.framework.Strategy;
import org.rev317.min.api.wrappers.Npc; import org.rev317.min.api.wrappers.Npc;
import org.rev317.min.api.wrappers.SceneObject;
import org.rev317.min.api.methods.*; import org.rev317.min.api.methods.*;
import org.rev317.min.api.wrappers.Item; import org.rev317.min.api.wrappers.Item;
@@ -32,17 +33,33 @@ public class Bank implements Strategy {
if (isBankOpen()) { if (isBankOpen()) {
return true; return true;
} }
Npc banker = Npcs.getClosest(494);
// Try find a nearby bank booth/chest
SceneObject bank_booth = SceneObjects.getClosest(11338, 2214, 3045, 5276, 6084, 11758, 14367, 4483, 3194, 10517, 2213);
if (bank_booth != null) {
bank_booth.interact(SceneObjects.Option.USE_QUICKLY);
Time.sleep(() -> isBankOpen(), 10000);
if (isBankOpen()) {
UpdateBank.saveBankFile();
return true;
}
}
// Try find a nearby banker
Npc banker = Npcs.getClosest(953, 166, 1702, 495, 496, 497, 498, 499, 567, 1036, 1360, 2163, 2164, 2354, 2355, 2568, 2569, 2570, 2271, 494, 2619);
if (banker != null) { if (banker != null) {
banker.interact(Npcs.Option.BANK); banker.interact(Npcs.Option.BANK);
Time.sleep(() -> isBankOpen(), 10000); Time.sleep(() -> isBankOpen(), 10000);
if (isBankOpen()) {
UpdateBank.saveBankFile();
return true; return true;
} else {
System.out.println("Unable to find a banker");
return false;
} }
} }
System.out.println("Unable to find a nearby bank booth or banker");
return false;
}
public static int getInventorySlot(int item_id){ public static int getInventorySlot(int item_id){
Item item = Inventory.getItem(item_id + 1); Item item = Inventory.getItem(item_id + 1);
if (item == null) return -1; if (item == null) return -1;
@@ -21,8 +21,6 @@ public class UpdateBank implements Strategy {
@Override @Override
public void execute() { public void execute() {
Variables.bank_items = Bank.getBankItemIDs();
Time.sleep(500);
saveBankFile(); saveBankFile();
// Variables.setStatus("none"); // Variables.setStatus("none");
} }
@@ -31,7 +29,9 @@ public class UpdateBank implements Strategy {
return "." + seperator + "bank" + seperator + Variables.getAccountUsername() + ".bank"; return "." + seperator + "bank" + seperator + Variables.getAccountUsername() + ".bank";
} }
public void saveBankFile(){ public static void saveBankFile(){
Variables.bank_items = Bank.getBankItemIDs();
Time.sleep(500);
String filePath = getfileName(); String filePath = getfileName();
checkOrCreateFile(filePath); checkOrCreateFile(filePath);
try { try {