Update Bank.java

This commit is contained in:
Danial
2021-10-07 12:50:18 +13:00
parent 419f7212db
commit c8f2521e64
+94 -26
View File
@@ -2,11 +2,9 @@ package ParaScript.strategies;
import ParaScript.data.Variables;
import org.parabot.environment.api.utils.Time;
import org.parabot.environment.input.Keyboard;
import org.parabot.environment.scripts.framework.Strategy;
import org.rev317.min.api.methods.*;
import org.rev317.min.api.wrappers.Npc;
import org.rev317.min.api.wrappers.TilePath;
import org.rev317.min.api.methods.*;
import org.rev317.min.api.wrappers.Item;
public class Bank implements Strategy {
@@ -17,40 +15,110 @@ public class Bank implements Strategy {
&& Game.isLoggedIn()
&& Variables.shouldBankItems()
&& (Variables.getStatus() == "none" || Variables.getStatus() == "banking items")
&& Inventory.isFull();
&& Inventory.isFull()
&& openBank();
}
@Override
public void execute() {
Variables.pathToWalk = new TilePath(Variables.VARROCK_EAST_MINE_PATH_TO_BANK);
Variables.setStatus("banking items");
while (Variables.pathToWalk != null && !Variables.pathToWalk.hasReached()) {
if (!Game.isLoggedIn()) new HandleLogin().execute();
Variables.pathToWalk.traverse();
Time.sleep(2500);
}
depositItems();
bankAll();
}
public void depositItems() {
public static boolean isBankOpen() {
return Game.getOpenInterfaceId() == 5292;
}
public static boolean openBank() {
if (isBankOpen()) {
return true;
}
Npc banker = Npcs.getClosest(494);
if (banker != null)
{
if (banker != null) {
banker.interact(Npcs.Option.BANK);
Time.sleep(() -> isBankOpen(), 10000);
return true;
} else {
Keyboard.getInstance().sendKeys("I can't find the banker!");
System.out.println("Unable to find a banker");
return false;
}
Time.sleep(3000);
if (Game.getOpenInterfaceId() == 5292) {
if (Variables.skill_to_train == Skill.MINING)
org.rev317.min.api.methods.Bank.depositAllExcept(1266, 1268, 1270, 1272, 1274, 1276);
else if (Variables.skill_to_train == Skill.WOODCUTTING)
org.rev317.min.api.methods.Bank.depositAllExcept(1350, 1352, 1354, 1356, 1358, 1360, 6740);
else {
org.rev317.min.api.methods.Bank.depositAllExcept(1);
Variables.addItemGained(28);
}
Variables.setStatus("none");
public static int getInventorySlot(int item_id){
Item item = Inventory.getItem(item_id + 1);
if (item == null) return -1;
return item.getSlot();
}
public static int getBankSlot(int item_id){
item_id++;
int slot = 0;
for (int bank_item_id : Variables.bank_items){
if (bank_item_id == item_id) return slot;
slot++;
}
return -1;
}
public static void bankAll(){
if (!openBank()) return;
Variables.setStatus("Banking items");
try {
for (int item_id : Variables.getItemIDs()) {
int inventory_slot = getInventorySlot(item_id);
if (inventory_slot >= 0) {
Menu.sendAction(431, item_id, inventory_slot, 5064, 3);
Time.sleep(50);
}
Time.sleep(200);
}
} catch (Exception err){
System.out.println("Banking error: ¯\\_(ツ)_/¯");
}
}
public static void withdrawItem(int item_id, int amount){
if (!openBank()) return;
int slot = getBankSlot(item_id);
if (slot < 0) return;
switch(amount){
case 1:
Menu.sendAction(632, item_id, slot, 5382, 6);
return;
case 5:
Menu.sendAction(78, item_id, slot, 5382, 5);
return;
case 10:
Menu.sendAction(867, item_id, slot, 5382, 4);
return;
case -1: // all
Menu.sendAction(431, item_id, slot, 5382, 3);
return;
default: // x
Menu.sendAction(53, item_id, slot, 5382, 2);
return;
}
}
public static void depositItem(int item_id, int amount){
if (!openBank()) return;
int slot = Bank.getInventorySlot(item_id);
if (slot < 0) return;
switch(amount){
case 1:
Menu.sendAction(632, item_id, slot, 5064, 6);
return;
case 5:
Menu.sendAction(78, item_id, slot, 5064, 5);
return;
case 10:
Menu.sendAction(867, item_id, slot, 5064, 4);
return;
case -1: // all
Menu.sendAction(431, item_id, slot, 5064, 3);
return;
default: // x
Menu.sendAction(53, item_id, slot, 5064, 2);
return;
}
}
}