diff --git a/src/main/java/ParaScript/DesktopTray.java b/src/main/java/ParaScript/DesktopTray.java new file mode 100644 index 0000000..e444d6d --- /dev/null +++ b/src/main/java/ParaScript/DesktopTray.java @@ -0,0 +1,41 @@ +package ParaScript; + +import ParaScript.data.Variables; + +import java.awt.*; +import java.awt.TrayIcon.MessageType; + +public class DesktopTray { + private TrayIcon trayIcon = null; + private SystemTray tray = null; + + public DesktopTray() { + if (SystemTray.isSupported()) { + //Obtain only one instance of the SystemTray object + tray = SystemTray.getSystemTray(); + + Image image = Toolkit.getDefaultToolkit().createImage("icon.png"); + String name = "2006 AIO | " + Variables.getAccountUsername(); + trayIcon = new TrayIcon(image, name); + //Let the system resize the image if needed + trayIcon.setImageAutoSize(true); + //Set tooltip text for the tray icon + trayIcon.setToolTip(name); + try { + tray.add(trayIcon); + } catch (AWTException e) { + e.printStackTrace(); + } + } else { + System.err.println("System tray not supported!"); + } + } + + public void displayNotification(String title, String message){ + trayIcon.displayMessage(title, message, MessageType.NONE); + } + + public void removeTray(){ + tray.remove(trayIcon); + } +} \ No newline at end of file diff --git a/src/main/java/ParaScript/Main.java b/src/main/java/ParaScript/Main.java index da6627c..5c8c582 100644 --- a/src/main/java/ParaScript/Main.java +++ b/src/main/java/ParaScript/Main.java @@ -3,16 +3,13 @@ package ParaScript; import ParaScript.data.Variables; import ParaScript.strategies.*; import ParaScript.ui.UI; -import org.parabot.core.ui.Logger; import org.parabot.environment.api.interfaces.Paintable; import org.parabot.environment.api.utils.Time; import org.parabot.environment.api.utils.Timer; -import org.parabot.environment.input.Keyboard; import org.parabot.environment.scripts.Script; import org.parabot.environment.scripts.framework.Strategy; import org.parabot.environment.scripts.Category; import org.parabot.environment.scripts.ScriptManifest; -import org.rev317.min.accessors.Client; import org.rev317.min.api.events.MessageEvent; import org.rev317.min.api.events.listeners.MessageListener; import org.rev317.min.api.methods.Skill; @@ -20,7 +17,7 @@ import org.rev317.min.api.methods.Skill; import java.awt.*; import java.util.ArrayList; -@ScriptManifest(author = "RedSparr0w & Dark98", category = Category.OTHER, description = "2006 AIO Script", name = "2006 AIO", servers = { "2006rebotted" }, version = 1.2) +@ScriptManifest(author = "RedSparr0w & Dark98", category = Category.OTHER, description = "2006 AIO Script", name = "2006 AIO", servers = { "2006rebotted" }, version = 1.3) public class Main extends Script implements MessageListener, Paintable { private final ArrayList strategies = new ArrayList(); @@ -38,8 +35,12 @@ public class Main extends Script implements MessageListener, Paintable { Variables.setBaseExp(); + strategies.add(new UpdateBank()); strategies.add(new UpdateExperience()); strategies.add(new ScriptState()); + if(Variables.skill_to_train == Skill.CRAFTING) { + strategies.add(new Crafting()); + } if(Variables.skill_to_train == Skill.WOODCUTTING) { strategies.add(new MakeArrowShafts()); strategies.add(new WoodcutTree()); @@ -55,8 +56,12 @@ public class Main extends Script implements MessageListener, Paintable { if(Variables.skill_to_train == Skill.ATTACK) { // Activate auto retaliate org.rev317.min.api.methods.Menu.clickButton(150); + strategies.add(new Eat()); + strategies.add(new PickupClues()); strategies.add(new PickupItems()); strategies.add(new BuryBones()); + strategies.add(new FightingReturnToCoords()); + strategies.add(new LoadCannon()); strategies.add(new Fighting()); } if(Variables.skill_to_train == Skill.FISHING) { @@ -77,8 +82,9 @@ public class Main extends Script implements MessageListener, Paintable { @Override public void onFinish() { + Variables.desktopTray.removeTray(); ui.dispose(); - System.out.println("Script Stopped"); + System.out.println("2006 AIO Script Stopped"); } @Override @@ -104,25 +110,30 @@ public class Main extends Script implements MessageListener, Paintable { g.drawString("Items(P/H): " + Methods.formatNumber(Variables.items_gained) + "(" + Methods.formatNumber(SCRIPT_TIMER.getPerHour(Variables.items_gained)) + ")", 360, 290); g.drawString("EXP(P/H): " + Methods.formatNumber((int) Variables.exp_gained) + "(" + Methods.formatNumber(SCRIPT_TIMER.getPerHour((int) Variables.exp_gained)) + ")", 360, 310); g.drawString("Runtime: " + SCRIPT_TIMER.toString(), 360, 330); - } public void messageReceived(MessageEvent message) { switch (message.getType()) { case 0: - if (message.getMessage().startsWith("You manage to") || // woodcutting, mining - message.getMessage().startsWith("You catch some") || // fishing - message.getMessage().startsWith("You pick the")) { // pickpockets + if (message.getMessage().startsWith("You manage to ") // Woodcutting, Mining + || message.getMessage().startsWith("You catch ") // Fishing + || message.getMessage().startsWith("You receive a") // Smelting + || message.getMessage().startsWith("You pick the ") // Pickpocketing + ) { Variables.addItemGained(1); Variables.updateExpGained(); } - if (message.getMessage().startsWith("Congratulations, you advanced a")) { + if (message.getMessage().startsWith("Congratulations, you've advanced a level")) { + Variables.desktopTray.displayNotification(Variables.getAccountUsername() + " | Level up!", message.getMessage()); // add in level up to paint } + if (message.getMessage().startsWith("You completed your slayer task")) { + Variables.desktopTray.displayNotification(Variables.getAccountUsername() + " | Slayer task complete!", message.getMessage()); + } break; case 4: if(Variables.skill_to_train == null) { - if (message.getMessage().startsWith(Variables.slaveMaster.toLowerCase() + " wishes to trade with you")) { + if (message.getMessage().startsWith(Variables.slave_master.toLowerCase() + " wishes to trade with you")) { // accept trade // take items, give items if smithing or similar // goto bank, deposit/withdraw items diff --git a/src/main/java/ParaScript/data/Variables.java b/src/main/java/ParaScript/data/Variables.java index a3b23aa..622ceca 100644 --- a/src/main/java/ParaScript/data/Variables.java +++ b/src/main/java/ParaScript/data/Variables.java @@ -1,49 +1,62 @@ package ParaScript.data; +import ParaScript.DesktopTray; import ParaScript.data.variables.*; -import org.rev317.min.api.methods.Npcs; import org.rev317.min.api.methods.Skill; import org.rev317.min.api.wrappers.Tile; import org.rev317.min.api.wrappers.TilePath; public class Variables { public static boolean running = false; - private static String current_status = "none"; + private static String current_status = "-----"; public static int items_gained = 0; public static double base_experience = 0; public static double exp_gained = 0; public static int update_experience_tick = 0; + public static DesktopTray desktopTray = new DesktopTray(); + // Login Panel private static String username = ""; private static String password = ""; // Settings Panel - public static Skill skill_to_train = Skill.WOODCUTTING; + public static Skill skill_to_train = Skill.ATTACK; // Woodcutting public static Trees woodcutting_tree_selected = Trees.NORMAL; public static String woodcutting_method = "Fletch"; // Mining - public static Ores mining_ore_selected = Ores.ESSENCE; + public static Rocks mining_rock_selected = Rocks.ESSENCE; public static String mining_method = "Bank"; + // Smithing + public static Bars smithing_bar_selected = Bars.BRONZE; + public static String smithing_method = "Bank"; + // Fighting public static FightingNpcs fighting_npc_selected = FightingNpcs.CHICKEN; public static boolean fighting_bury_bones = true; + public static boolean load_cannon = false; + public static int[] return_to_coords = new int[]{}; public static int[] fighting_item_ids = new int[]{}; - public static int fighting_minimum_hitpoints = 0; + public static int fighting_minimum_hitpoints = -1; + public static int fighting_food_to_eat = -1; + public static int fighting_food_heals_amount = 20; // Thieving public static ThievingNpcs thieving_npc_selected = ThievingNpcs.MAN_WOMAN; //public static String thieving_method = "None"; // Fishing - public static Npcs.Option fishing_type_selected = Npcs.Option.NET; + public static FishingSpots fishing_spot_selected = FishingSpots.NET; + + // Banking + public static int[] bank_items = new int[]{}; // Used for slave accounts - public static String slaveMaster = ""; + public static String slave_master = ""; // Used to walk places public static TilePath pathToWalk; @@ -59,7 +72,6 @@ public class Variables { public final static Zone LUMBRIDGE_NORMAL_TREE_ZONE = new Zone(new Tile(3140, 3260), new Tile(3206, 3206)); // Mining Varrock - public final static Zone VARROCK_EAST_BANK_ZONE = new Zone(new Tile(3250, 3424), new Tile(3257, 3416)); public final static Zone VARROCK_EAST_MINE_ZONE = new Zone(new Tile(3276, 3375), new Tile(3298, 3354)); @@ -162,9 +174,11 @@ public class Variables { if (skill_to_train == null) return new int[]{-1}; switch (skill_to_train.getName()){ case "Woodcutting": - return woodcutting_tree_selected.getIDs(); + return new int[]{woodcutting_tree_selected.getItemID()}; case "Mining": - return mining_ore_selected.getIDs(); + return mining_rock_selected.getItemID(); + case "Attack": + return fighting_item_ids; default: return new int[]{-1}; } @@ -177,6 +191,8 @@ public class Variables { return woodcutting_method.equalsIgnoreCase("Bank"); case "Mining": return mining_method.equalsIgnoreCase("Bank"); + case "Smithing": + return smithing_method.equalsIgnoreCase("Bank"); default: return true; } diff --git a/src/main/java/ParaScript/data/variables/Bars.java b/src/main/java/ParaScript/data/variables/Bars.java new file mode 100644 index 0000000..006a20c --- /dev/null +++ b/src/main/java/ParaScript/data/variables/Bars.java @@ -0,0 +1,47 @@ +package ParaScript.data.variables; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public enum Bars { + BRONZE("Bronze", 2350, new int[]{437, 439}, 2414), + IRON ("Iron", 2352, new int[]{441}, 3988), + STEEL("Steel", 2354, new int[]{441, 454, 454}, 3996), + SILVER("Silver", 2356, new int[]{443}, 3992), + GOLD("Gold", 2358, new int[]{445}, 4000), + MITHRIL("Mithril", 2360, new int[]{448, 454, 454, 454, 454}, 4158), + ADAMANT("Adamant", 2362, new int[]{450, 454, 454, 454, 454, 454, 454}, 7442), + RUNITE("Runite", 2364, new int[]{452, 454, 454, 454, 454, 454, 454, 454, 454}, 7447); + + private String name; + private int id; + private int[] ores; + private int button_id; + + Bars(String name, int id, int[] ores, int button_id) { + this.name = name; + this.id = id; + this.ores = ores; + this.button_id = button_id; + } + + public static String[] toStringArray() { + List enumList = Arrays.asList(Bars.values()); + List locationsArray = new ArrayList<>(); + for (Bars obj : enumList) { + locationsArray.add(obj.name); + } + + String[] simpleArray = new String[ locationsArray.size() ]; + locationsArray.toArray( simpleArray ); + return(simpleArray); + } + + public String getName() { return this.name; } + + public int getID() { return this.id; } + public int getButtonID() { return this.button_id; } + + public int[] getOres() { return this.ores; } +} diff --git a/src/main/java/ParaScript/data/variables/FishingSpots.java b/src/main/java/ParaScript/data/variables/FishingSpots.java new file mode 100644 index 0000000..8f90d94 --- /dev/null +++ b/src/main/java/ParaScript/data/variables/FishingSpots.java @@ -0,0 +1,58 @@ +package ParaScript.data.variables; + +import org.rev317.min.api.methods.Npcs; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public enum FishingSpots { + NET("Net", new int[] { 319, 329, 323, 325, 326, 327, 330, 332, 404, 316, 334, 313, 322, 1191 }, 1, 5, 3, Npcs.Option.NET, new int[] { 317, 321, 327, 345, 353, 335, 331, 341, 363, 349, 359, 371, 377, 7944, 383 }), + BAIT("Bait", new int[] { 319, 329, 323, 325, 326, 327, 330, 332, 404, 316 }, 1, 5, 1, Npcs.Option.BAIT, new int[] { 317, 321, 327, 345, 353, 335, 331, 341, 363, 349, 359, 371, 377, 7944, 383 }), + HARPOON("Harpoon", new int[] { 334, 313, 322, 312, 321, 405, 324 }, 1, 18, 1, Npcs.Option.HARPOON, new int[] { 317, 321, 327, 345, 353, 335, 331, 341, 363, 349, 359, 371, 377, 7944, 383 }), + LURE("Lure", new int[] { 309, 310, 403, 311, 314, 315, 317, 318, 328, 331 }, 1, 18, 1, Npcs.Option.BAIT, new int[] { 317, 321, 327, 345, 353, 335, 331, 341, 363, 349, 359, 371, 377, 7944, 383 }), + CAGE("Cage", new int[] { 312, 321, 405, 324 }, 1, 18, 1, Npcs.Option.CAGE, new int[] { 317, 321, 327, 345, 353, 335, 331, 341, 363, 349, 359, 371, 377, 7944, 383 }); + + private final String name; + private final int levelReq, mineTimer, xp; + public Npcs.Option actionType; + private final int[] fishIDs; + private final int[] objectIDs; + public int hash = 0; + public int x = 0; + public int y = 0; + + FishingSpots(final String name, final int[] objectIDs, final int levelReq, final int xp, final int mineTimer, final Npcs.Option actionType, final int[] fishIDs) { + this.name = name; + this.objectIDs = objectIDs; + this.levelReq = levelReq; + this.xp = xp; + this.mineTimer = mineTimer; + this.actionType = actionType; + this.fishIDs = fishIDs; + } + + public static String[] toStringArray() { + List enumList = Arrays.asList(FishingSpots.values()); + List locationsArray = new ArrayList<>(); + for (FishingSpots obj : enumList) { + locationsArray.add(obj.name); + } + + String[] simpleArray = new String[ locationsArray.size() ]; + locationsArray.toArray( simpleArray ); + return(simpleArray); + } + + public String getName() { return this.name; } + + public int[] getIDs() { return this.objectIDs; } + + public int[] getItemIDs() { return this.fishIDs; } + + public void reset(){ + this.hash = 0; + this.x = 0; + this.y = 0; + } +} diff --git a/src/main/java/ParaScript/data/variables/Rocks.java b/src/main/java/ParaScript/data/variables/Rocks.java new file mode 100644 index 0000000..c316da4 --- /dev/null +++ b/src/main/java/ParaScript/data/variables/Rocks.java @@ -0,0 +1,65 @@ +package ParaScript.data.variables; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public enum Rocks { + ESSENCE("Essence", new int[] { 2491 }, 1, 5, 3, 1, new int[] { 1436, 7936 }), + CLAY("Clay", new int[] { 2108, 2109, 11189, 11190, 11191, 9713, 9711, 14905, 14904 }, 1, 5, 1, 5, new int[] { 434 }), + COPPER("Copper", new int[] { 3042, 2091, 2090, 9708, 9709, 9710, 11960, 14906, 14907 }, 1, 18, 1, 8, new int[] { 436 }), + TIN("Tin", new int[] { 2094, 2095, 3043, 9716, 9714, 11958, 11957, 11959, 11933, 11934, 11935, 14903, 14902 }, 1, 18, 1, 8, new int[] { 438 }), + BLURITE("Blurite", new int[] { 10574, 10583, 2110 }, 10, 20, 1, 8, new int[] { 668 }), + IRON("Iron", new int[] { 2093, 2092, 9717, 9718, 9719, 11962, 11956, 11954, 14856, 14857, 14858, 14914, 14913 }, 15, 35, 2, 5, new int[] { 440 }), + SILVER("Silver", new int[] { 2101, 11186, 11187, 11188, 2100 }, 20, 40, 3, 20, new int[] { 442 }), + COAL("Coal", new int[] { 2096, 2097, 11963, 11964, 14850, 14851, 14852, 11930, 11931 }, 30, 50, 4, 25, new int[] { 453 }), + GOLD("Gold", new int[] { 2099, 2098, 11183, 11184, 11185, 9720, 9722 }, 40, 65, 6, 33, new int[] { 444 }), + MITHRIL("Mithril", new int[] { 2103, 2102, 14853, 14854, 14855 }, 55, 80, 8, 50, new int[] { 447 }), + ADAMANT("Adamant", new int[] { 2104, 2105, 14862, 14863, 14864 }, 70, 95, 10, 83, new int[] { 449 }), + RUNE("Rune", new int[] { 14859, 14860, 2106, 2107 }, 85, 125, 20, 166, new int[] { 451 }), + GRANITE("Granite", new int[] { 10947 }, 45, 75, 10, 10, new int[] { 6979, 6981, 6983 }), + SANDSTONE("Sandstone", new int[] { 10946 }, 35, 60, 5, 5, new int[] { 6971, 6973, 6975, 6977 }), + GEM("Gem", new int[] {2111}, 40, 65, 6, 120, new int[] {1625, 1627, 1629, 1623, 1621, 1619, 1617}); + + private final String name; + private final int levelReq, mineTimer, respawnTimer, xp; + private final int[] oreIds; + private final int[] objectId; + public int hash = 0; + public int x = 0; + public int y = 0; + + Rocks(final String name, final int[] objectId, final int levelReq, final int xp, final int mineTimer, final int respawnTimer, final int... oreIds) { + this.name = name; + this.objectId = objectId; + this.levelReq = levelReq; + this.xp = xp; + this.mineTimer = mineTimer; + this.respawnTimer = respawnTimer; + this.oreIds = oreIds; + } + + public static String[] toStringArray() { + List enumList = Arrays.asList(Rocks.values()); + List locationsArray = new ArrayList<>(); + for (Rocks obj : enumList) { + locationsArray.add(obj.name); + } + + String[] simpleArray = new String[ locationsArray.size() ]; + locationsArray.toArray( simpleArray ); + return(simpleArray); + } + + public String getName() { return this.name; } + + public int[] getIDs() { return this.objectId; } + + public int[] getItemID() { return this.oreIds; } + + public void reset(){ + this.hash = 0; + this.x = 0; + this.y = 0; + } +} diff --git a/src/main/java/ParaScript/icon.png b/src/main/java/ParaScript/icon.png new file mode 100644 index 0000000..0c93980 Binary files /dev/null and b/src/main/java/ParaScript/icon.png differ diff --git a/src/main/java/ParaScript/strategies/BuryBones.java b/src/main/java/ParaScript/strategies/BuryBones.java index 366452e..b32b905 100644 --- a/src/main/java/ParaScript/strategies/BuryBones.java +++ b/src/main/java/ParaScript/strategies/BuryBones.java @@ -29,7 +29,7 @@ public class BuryBones implements Strategy { private void buryBones(){ try { - Inventory.getItem(527).interact(Items.Option.SECOND); + getBones().interact(Items.Option.SECOND); Time.sleep(500); if (Game.isLoggedIn() && hasBones()) buryBones(); } catch (Exception ಠ_ಠ) { @@ -39,6 +39,20 @@ public class BuryBones implements Strategy { private boolean hasBones(){ // Make sure we have bones - return Inventory.getItem(527) != null; // TODO: need to add the other bones too + return getBones() != null; + } + + private Item getBones(){ + // Make sure we have bones + for (int bone_id : getBoneIds()) { + if (Inventory.getItem(bone_id + 1) != null) { + return Inventory.getItem(bone_id + 1); + } + } + return null; + } + + public static int[] getBoneIds(){ + return new int[]{526, 528, 530, 532, 534, 536, 2859, 3125, 3127, 3179, 3180, 3181, 3182, 3183, 3185, 3186, 3187, 4812, 6729, 6812}; // TODO: need to check if all are bones } } diff --git a/src/main/java/ParaScript/strategies/Eat.java b/src/main/java/ParaScript/strategies/Eat.java new file mode 100644 index 0000000..7cf2dc6 --- /dev/null +++ b/src/main/java/ParaScript/strategies/Eat.java @@ -0,0 +1,41 @@ +package ParaScript.strategies; + +import ParaScript.data.Variables; +import org.parabot.environment.api.utils.Time; +import org.parabot.environment.scripts.framework.Strategy; +import org.rev317.min.api.methods.*; + +public class Eat implements Strategy { + private int currentHealth = 0; + + @Override + public boolean activate() { + currentHealth = Players.getMyPlayer().getHealth(); + if (Variables.running + && hasRequiredItems() + && currentHealth > 0 + && Players.getMyPlayer().isInCombat() + && currentHealth <= (Skill.HITPOINTS.getRealLevel() - Variables.fighting_food_heals_amount) + ) { + Variables.setStatus("eating food"); + return true; + } + Variables.setStatus("none"); + return false; + } + + @Override + public void execute() { + try { + Inventory.getItem(Variables.fighting_food_to_eat + 1).interact(Items.Option.CONSUME); + Time.sleep(() -> Players.getMyPlayer().getHealth() != currentHealth || !Players.getMyPlayer().isInCombat(), 8000); + Variables.setStatus("none"); + } catch (Exception ಠ_ಠ) { + System.out.println("Eating error: ¯\\_(ツ)_/¯"); + } + } + + private boolean hasRequiredItems(){ + return Inventory.getItem(Variables.fighting_food_to_eat + 1) != null; + } +} \ No newline at end of file diff --git a/src/main/java/ParaScript/strategies/Fighting.java b/src/main/java/ParaScript/strategies/Fighting.java index 561986b..e17dc11 100644 --- a/src/main/java/ParaScript/strategies/Fighting.java +++ b/src/main/java/ParaScript/strategies/Fighting.java @@ -6,24 +6,27 @@ import org.parabot.environment.scripts.framework.Strategy; import org.rev317.min.api.methods.Inventory; import org.rev317.min.api.methods.Npcs; import org.rev317.min.api.methods.Players; +import org.rev317.min.api.wrappers.Character; import org.rev317.min.api.wrappers.Npc; import org.rev317.min.api.wrappers.Player; public class Fighting implements Strategy { private Npc victim; + private Player myPlayer; @Override public boolean activate() { - victim = victim(); // set the local Variable - Player myPlayer = Players.getMyPlayer(); + myPlayer = Players.getMyPlayer(); if (Variables.running - && victim != null && !myPlayer.isInCombat() - && myPlayer.getAnimation() == -1 + //&& (myPlayer.getInteractingCharacter() == null || myPlayer.getInteractingCharacter().getIndex() <= 0) && !Inventory.isFull() - && myPlayer.getHealth() > Variables.fighting_minimum_hitpoints) { - Variables.setStatus("fighting"); - return true; + && (myPlayer.getHealth() <= 0 || myPlayer.getHealth() > Variables.fighting_minimum_hitpoints)) { + victim = victim(); // set the local Variable + if (victim != null) { + Variables.setStatus("fighting"); + return true; + } } Variables.setStatus("none"); return false; @@ -33,8 +36,8 @@ public class Fighting implements Strategy { public void execute() { victim.interact(Npcs.Option.ATTACK); Time.sleep(2000); - // Wait for the Player to finish attacking (max 30 seconds) - Time.sleep(() -> !Players.getMyPlayer().isInCombat(), 30000); + // Wait for the Player to finish attacking (max 3 seconds) + Time.sleep(() -> !Players.getMyPlayer().isInCombat(), 3000); Variables.updateExpGained(); } @@ -42,8 +45,10 @@ public class Fighting implements Strategy { try { int[] npc_to_thieve = Variables.fighting_npc_selected.getIDs(); for (Npc victim : Npcs.getNearest(npc_to_thieve)) { - if (victim != null) { - return victim; + Character interactingPlayer = victim.getInteractingCharacter(); + if (victim != null && (interactingPlayer == null || interactingPlayer.getIndex() <= 0 || interactingPlayer.getIndex() == myPlayer.getIndex())) { + if (!Variables.load_cannon || victim.distanceTo() <= 1) + return victim; } } } catch (Exception ಠ_ಠ){} diff --git a/src/main/java/ParaScript/strategies/FightingReturnToCoords.java b/src/main/java/ParaScript/strategies/FightingReturnToCoords.java new file mode 100644 index 0000000..3b2e68a --- /dev/null +++ b/src/main/java/ParaScript/strategies/FightingReturnToCoords.java @@ -0,0 +1,41 @@ +package ParaScript.strategies; + +import ParaScript.data.Variables; +import org.parabot.environment.api.utils.Time; +import org.parabot.environment.scripts.framework.Strategy; +import org.rev317.min.api.methods.Game; +import org.rev317.min.api.methods.Inventory; +import org.rev317.min.api.methods.Players; +import org.rev317.min.api.wrappers.Player; +import org.rev317.min.api.wrappers.Tile; +import org.rev317.min.api.wrappers.TilePath; + +import javax.swing.plaf.synth.SynthTextAreaUI; + +public class FightingReturnToCoords implements Strategy { + @Override + public boolean activate() { + return Variables.running + && Game.isLoggedIn() + && Variables.return_to_coords.length == 2 + && getTile().distanceTo() > 0 + && getTile().distanceTo() <= 20; + } + + @Override + public void execute() { + Variables.setStatus("Walking to spot"); + Tile tile = getTile(); + tile.walkTo(); + Time.sleep(1000); + int timeout = (int) Math.min(1e4, tile.distanceTo() * 500); + Time.sleep(() -> tile.distanceTo() < 1, timeout); + Time.sleep(500); + tile.walkTo(); + Variables.setStatus("none"); + } + + public Tile getTile(){ + return new Tile(Variables.return_to_coords[0], Variables.return_to_coords[1]); + } +} \ No newline at end of file diff --git a/src/main/java/ParaScript/strategies/LoadCannon.java b/src/main/java/ParaScript/strategies/LoadCannon.java new file mode 100644 index 0000000..c078cf6 --- /dev/null +++ b/src/main/java/ParaScript/strategies/LoadCannon.java @@ -0,0 +1,51 @@ +package ParaScript.strategies; + +import ParaScript.data.Variables; +import org.parabot.environment.api.utils.Time; +import org.parabot.environment.scripts.framework.Strategy; +import org.rev317.min.api.methods.Game; +import org.rev317.min.api.methods.Inventory; +import org.rev317.min.api.methods.Items; +import org.rev317.min.api.methods.SceneObjects; +import org.rev317.min.api.wrappers.Item; +import org.rev317.min.api.wrappers.SceneObject; + +import java.util.Date; + +public class LoadCannon implements Strategy { + private SceneObject cannon; + private long nextFill = System.currentTimeMillis() + 20000; + private long lastFilled = System.currentTimeMillis(); + + @Override + public boolean activate() { + cannon = getCannon(); + if (Variables.running + && Variables.load_cannon + && cannon != null + && nextFill <= System.currentTimeMillis() + ) { + Variables.setStatus("filling cannon"); + return true; + } + Variables.setStatus("none"); + return false; + } + + @Override + public void execute() { + cannon.interact(SceneObjects.Option.SECOND); + int Timeout = (int) Math.max(500, Math.min(5e3, cannon.distanceTo() * 500)); + Time.sleep(Timeout); + cannon.interact(SceneObjects.Option.FIRST); + nextFill = System.currentTimeMillis() + 20000; + } + + private SceneObject getCannon(){ + for(SceneObject _cannon : SceneObjects.getNearest(6)){ + if (_cannon.distanceTo() <= 10) + return _cannon; + } + return null; + } +} diff --git a/src/main/java/ParaScript/strategies/PickupClues.java b/src/main/java/ParaScript/strategies/PickupClues.java new file mode 100644 index 0000000..3f82750 --- /dev/null +++ b/src/main/java/ParaScript/strategies/PickupClues.java @@ -0,0 +1,59 @@ +package ParaScript.strategies; + +import ParaScript.Methods; +import ParaScript.data.Variables; +import org.parabot.environment.api.utils.Time; +import org.parabot.environment.scripts.framework.Strategy; +import org.rev317.min.api.methods.GroundItems; +import org.rev317.min.api.methods.Inventory; +import org.rev317.min.api.methods.Players; +import org.rev317.min.api.methods.Skill; +import org.rev317.min.api.wrappers.GroundItem; + +import java.util.ArrayList; + +public class PickupClues implements Strategy { + ArrayList items; + + @Override + public boolean activate() { + items = getItems(); + if (Variables.running + && items.size() > 0 + && !Inventory.isFull() + ) { + Variables.setStatus("picking up cluescrolls"); + return true; + } + Variables.setStatus("none"); + return false; + } + + @Override + public void execute() { + int currentItemAmount = Inventory.getCount(true); + try { + for (GroundItem item : items) { + item.take(); + Time.sleep(500); + int timeout = Math.min(10000, item.distanceTo() * 1000); + Time.sleep(() -> item.distanceTo() < 1, timeout); + if (Inventory.isFull()){ + break; + } + } + } catch (Exception ಠ_ಠ){ + System.out.println("Pickup clue scrolls error: ¯\\_(ツ)_/¯"); + } + Variables.addItemGained(Inventory.getCount(true) - currentItemAmount); + } + + private ArrayList getItems(){ + ArrayList groundItems = new ArrayList(); + for (GroundItem item : GroundItems.getNearest(2677, 2678, 2679)){ + if (item.distanceTo() < 12) + groundItems.add(item); + } + return groundItems; + } +} diff --git a/src/main/java/ParaScript/strategies/PickupItems.java b/src/main/java/ParaScript/strategies/PickupItems.java index a6f4e2c..e53b2ce 100644 --- a/src/main/java/ParaScript/strategies/PickupItems.java +++ b/src/main/java/ParaScript/strategies/PickupItems.java @@ -6,17 +6,22 @@ import org.parabot.environment.api.utils.Time; import org.parabot.environment.scripts.framework.Strategy; import org.rev317.min.api.methods.*; import org.rev317.min.api.wrappers.GroundItem; +import org.rev317.min.api.wrappers.Item; +import org.rev317.min.api.wrappers.Player; +import org.rev317.min.api.wrappers.Tile; + +import java.util.ArrayList; public class PickupItems implements Strategy { - GroundItem[] items; + ArrayList items; @Override public boolean activate() { items = getItems(); + Player myPlayer = Players.getMyPlayer(); if (Variables.running - && items.length > 0 - && !Players.getMyPlayer().isInCombat() - && Players.getMyPlayer().getAnimation() == -1 + && items.size() > 0 + && (myPlayer.getInteractingCharacter() == null || myPlayer.getInteractingCharacter().getIndex() <= 0) && !Inventory.isFull()) { Variables.setStatus("picking up items"); return true; @@ -27,12 +32,13 @@ public class PickupItems implements Strategy { @Override public void execute() { - int currentItemAmount = Inventory.getCount(true); try { for (GroundItem item : items) { + int currentItemAmount = Inventory.getCount(true); item.take(); Time.sleep(500); Time.sleep(() -> item.distanceTo() < 1, 2000); + Variables.addItemGained(Inventory.getCount(true) - currentItemAmount); if (Inventory.isFull()){ break; } @@ -40,18 +46,22 @@ public class PickupItems implements Strategy { } catch (Exception ಠ_ಠ){ System.out.println("Pickup items error: ¯\\_(ツ)_/¯"); } - Variables.addItemGained(Inventory.getCount(true) - currentItemAmount); } - private GroundItem[] getItems(){ - return GroundItems.getNearest(getItemIDs()); + private ArrayList getItems(){ + ArrayList groundItems = new ArrayList(); + for (GroundItem item : GroundItems.getNearest(getItemIDs())){ + if (item.distanceTo() < 16) + groundItems.add(item); + } + return groundItems; } private int[] getItemIDs(){ int[] itemIDs = new int[]{}; if (Variables.skill_to_train == Skill.ATTACK){ if (Variables.fighting_bury_bones) - itemIDs = new int[]{526}; // TODO: need to add all the other bones + itemIDs = BuryBones.getBoneIds(); } itemIDs = Methods.combineIntArrays(Variables.fighting_item_ids, itemIDs); return itemIDs; diff --git a/src/main/java/ParaScript/strategies/ScriptState.java b/src/main/java/ParaScript/strategies/ScriptState.java index e2ab555..bb18b60 100644 --- a/src/main/java/ParaScript/strategies/ScriptState.java +++ b/src/main/java/ParaScript/strategies/ScriptState.java @@ -3,6 +3,10 @@ package ParaScript.strategies; import ParaScript.data.Variables; import org.parabot.environment.api.utils.Time; import org.parabot.environment.scripts.framework.Strategy; +import org.rev317.min.api.methods.Inventory; +import org.rev317.min.api.methods.Players; +import org.rev317.min.api.methods.SceneObjects; +import org.rev317.min.api.wrappers.SceneObject; public class ScriptState implements Strategy { diff --git a/src/main/java/ParaScript/strategies/Thieving.java b/src/main/java/ParaScript/strategies/Thieving.java index 9978152..f1642f5 100644 --- a/src/main/java/ParaScript/strategies/Thieving.java +++ b/src/main/java/ParaScript/strategies/Thieving.java @@ -6,7 +6,9 @@ import org.parabot.environment.scripts.framework.Strategy; import org.rev317.min.api.methods.Inventory; import org.rev317.min.api.methods.Npcs; import org.rev317.min.api.methods.Players; +import org.rev317.min.api.methods.SceneObjects; import org.rev317.min.api.wrappers.Npc; +import org.rev317.min.api.wrappers.SceneObject; public class Thieving implements Strategy { private Npc victim; diff --git a/src/main/java/ParaScript/strategies/UpdateBank.java b/src/main/java/ParaScript/strategies/UpdateBank.java new file mode 100644 index 0000000..23f87e9 --- /dev/null +++ b/src/main/java/ParaScript/strategies/UpdateBank.java @@ -0,0 +1,77 @@ +package ParaScript.strategies; + +import ParaScript.data.Variables; +import org.parabot.environment.api.utils.Time; +import org.parabot.environment.scripts.framework.Strategy; +import org.rev317.min.api.methods.Bank; + +import java.io.*; + +public class UpdateBank implements Strategy { + private static String seperator = System.getProperty("file.separator"); + + @Override + public boolean activate() { + if (Bank.isOpen()) { + Variables.setStatus("Saving Bank"); + return true; + } + return false; + } + + @Override + public void execute() { + Variables.bank_items = Bank.getBankItemIDs(); + Time.sleep(500); + saveBankFile(); + } + + private static String getfileName(){ + return "." + seperator + "bank" + seperator + Variables.getAccountUsername() + ".bank"; + } + + public void saveBankFile(){ + String filePath = getfileName(); + checkOrCreateFile(filePath); + try { + ObjectOutputStream out = new ObjectOutputStream( + new FileOutputStream(filePath) + ); + out.writeObject(Variables.bank_items); + out.flush(); + out.close(); + } catch(Exception O_o){ + System.out.println("Save file error"); + } + } + + public static int[] loadBankFile(){ + if (Variables.getAccountUsername().length() <= 0) + return new int[]{}; + + String filePath = getfileName(); + checkOrCreateFile(filePath); + try { + ObjectInputStream in = new ObjectInputStream( + new FileInputStream(filePath) + ); + int[] array = (int[]) in.readObject(); + in.close(); + return array; + } catch(Exception O_o){ + System.out.println("Load file error"); + } + return new int[]{}; + } + + private static void checkOrCreateFile(String filename){ + try { + File file = new File(filename); + File directory = new File(file.getParentFile().getPath()); + directory.mkdirs(); + file.createNewFile(); + } catch(Exception O_o){ + System.out.println("Create file error"); + } + } +} \ No newline at end of file diff --git a/src/main/java/ParaScript/ui/UI.java b/src/main/java/ParaScript/ui/UI.java index 5da4693..278242f 100644 --- a/src/main/java/ParaScript/ui/UI.java +++ b/src/main/java/ParaScript/ui/UI.java @@ -2,10 +2,9 @@ package ParaScript.ui; import ParaScript.data.variables.*; import ParaScript.data.Variables; -import org.rev317.min.api.methods.Game; -import org.rev317.min.api.methods.Npcs; -import org.rev317.min.api.methods.Players; -import org.rev317.min.api.methods.Skill; +import ParaScript.strategies.UpdateBank; +import org.rev317.min.api.methods.*; +import org.rev317.min.api.methods.Menu; import javax.swing.*; import javax.swing.border.EmptyBorder; @@ -31,16 +30,23 @@ public class UI extends JFrame { private JCheckBox birdsNest = new JCheckBox(); // Mining - private JComboBox oreSelect = new JComboBox(); + private JComboBox rockSelect = new JComboBox(); private JComboBox miningMethod = new JComboBox(); + // Smithing + private JComboBox barSelect = new JComboBox(); + // Fighting private JComboBox fightingNpcSelect = new JComboBox(); private JLabel lblFightingNpcCustomID = new JLabel("Custom NPC IDs"); private JTextField fightingNpcCustomID = new JTextField(); private JCheckBox fightingBuryBones = new JCheckBox(); + private JCheckBox fightingLoadCannon = new JCheckBox(); + private JTextField returnPositionCoords = new JTextField(); private JTextField fightingItemCustomID = new JTextField(); private JTextField fightingMinimumHitpoints = new JTextField(); + private JTextField fightingFoodToEat = new JTextField(); + private JTextField fightingFoodHealsAmount = new JTextField(); // Thieving private JComboBox thievingNpcSelect = new JComboBox(); @@ -56,6 +62,7 @@ public class UI extends JFrame { private Color Color_WhiteSmoke = new Color(245, 245, 245); private Color Color_Emerald = new Color(46, 204, 113); private Color Color_Alizarin = new Color(231, 76, 60); + private Color Color_BelizeHole = new Color(41, 128, 185); public UI() { setTitle("2006 AIO"); @@ -125,11 +132,13 @@ public class UI extends JFrame { lblSkillToTrain.setBounds(20, 20, 73, 20); settingsPanel.add(lblSkillToTrain); skillSelect.setModel(new DefaultComboBoxModel(new String[]{ + Skill.ATTACK.getName(), Skill.WOODCUTTING.getName(), Skill.MINING.getName(), - Skill.ATTACK.getName(), + Skill.SMITHING.getName(), Skill.THIEVING.getName(), Skill.FISHING.getName(), + Skill.CRAFTING.getName(), "Bank Runner", })); skillSelect.setBounds(20, 40, 150, 20); @@ -168,6 +177,7 @@ public class UI extends JFrame { for (Trees tree : Trees.values()) { if (tree.getName().equalsIgnoreCase(treeSelect.getSelectedItem().toString())) { Variables.woodcutting_tree_selected = tree; + Variables.woodcutting_tree_selected.reset(); } } } @@ -238,22 +248,23 @@ public class UI extends JFrame { miningPanel.setLayout(null); // Select which ore to mine - JLabel lblOre = new JLabel("Ore"); - lblOre.setForeground(Color_WhiteSmoke); - lblOre.setBounds(20, 20, 73, 20); - miningPanel.add(lblOre); - oreSelect.setModel(new DefaultComboBoxModel(Ores.toStringArray())); - oreSelect.setBounds(20, 40, 150, 20); - oreSelect.addActionListener (new ActionListener () { + JLabel lblRock = new JLabel("Rock"); + lblRock.setForeground(Color_WhiteSmoke); + lblRock.setBounds(20, 20, 73, 20); + miningPanel.add(lblRock); + rockSelect.setModel(new DefaultComboBoxModel(Rocks.toStringArray())); + rockSelect.setBounds(20, 40, 150, 20); + rockSelect.addActionListener (new ActionListener () { public void actionPerformed(ActionEvent e) { - for (Ores ore : Ores.values()) { - if (ore.getName().equalsIgnoreCase(oreSelect.getSelectedItem().toString())) { - Variables.mining_ore_selected = ore; + for (Rocks rock : Rocks.values()) { + if (rock.getName().equalsIgnoreCase(rockSelect.getSelectedItem().toString())) { + Variables.mining_rock_selected = rock; + Variables.mining_rock_selected.reset(); } } } }); - miningPanel.add(oreSelect); + miningPanel.add(rockSelect); // What should we do with our ores JLabel lblMiningMethod = new JLabel("Method"); @@ -272,6 +283,34 @@ public class UI extends JFrame { }); miningPanel.add(miningMethod); + /* + * Smithing Panel + */ + + JPanel smithingPanel = new JPanel(); + smithingPanel.setForeground(Color_WhiteSmoke); + smithingPanel.setBackground(Color_WetAsphalt); + tabbedPane.addTab("Smithing", null, smithingPanel, null); + smithingPanel.setLayout(null); + + // Select which ore to mine + JLabel lblBar = new JLabel("Bar"); + lblBar.setForeground(Color_WhiteSmoke); + lblBar.setBounds(20, 20, 73, 20); + smithingPanel.add(lblBar); + barSelect.setModel(new DefaultComboBoxModel(Bars.toStringArray())); + barSelect.setBounds(20, 40, 150, 20); + barSelect.addActionListener (new ActionListener () { + public void actionPerformed(ActionEvent e) { + for (Bars bar : Bars.values()) { + if (bar.getName().equalsIgnoreCase(barSelect.getSelectedItem().toString())) { + Variables.smithing_bar_selected = bar; + } + } + } + }); + smithingPanel.add(barSelect); + /* * Fighting Panel */ @@ -285,10 +324,10 @@ public class UI extends JFrame { // Select which npc should be our victim JLabel lblFightingNpc = new JLabel("NPC"); lblFightingNpc.setForeground(Color_WhiteSmoke); - lblFightingNpc.setBounds(20, 20, 73, 20); + lblFightingNpc.setBounds(20, 0, 73, 20); fightingPanel.add(lblFightingNpc); fightingNpcSelect.setModel(new DefaultComboBoxModel(FightingNpcs.toStringArray())); - fightingNpcSelect.setBounds(20, 40, 150, 20); + fightingNpcSelect.setBounds(20, 20, 150, 20); fightingNpcSelect.addActionListener (new ActionListener () { public void actionPerformed(ActionEvent e) { for (FightingNpcs npc : FightingNpcs.values()) { @@ -311,9 +350,9 @@ public class UI extends JFrame { // Custom npc id to attack lblFightingNpcCustomID.setForeground(Color_WhiteSmoke); - lblFightingNpcCustomID.setBounds(200, 20, 150, 20); + lblFightingNpcCustomID.setBounds(200, 0, 150, 20); fightingPanel.add(lblFightingNpcCustomID); - fightingNpcCustomID.setBounds(200, 40, 150, 20); + fightingNpcCustomID.setBounds(200, 20, 150, 20); fightingNpcCustomID.addFocusListener(new FocusListener() { @Override public void focusGained(FocusEvent e) { @@ -328,9 +367,9 @@ public class UI extends JFrame { for (int i = 0; i < sample.length; i++) customIDs[i] = Integer.parseInt(sample[i]); - Variables.fighting_npc_selected.setIDs(customIDs); + FightingNpcs.CUSTOM.setIDs(customIDs); } catch (Exception ಠ_ಠ) { - FightingNpcs.CUSTOM.setIDs(new int[]{0}); + FightingNpcs.CUSTOM.setIDs(new int[]{}); } } }); @@ -338,13 +377,30 @@ public class UI extends JFrame { lblFightingNpcCustomID.setVisible(false); fightingNpcCustomID.setVisible(false); + // Should we collect and bury our bones + JLabel lblFightingLoadCannon = new JLabel("Load cannon"); + lblFightingLoadCannon.setForeground(Color_WhiteSmoke); + lblFightingLoadCannon.setBounds(40, 40, 130, 20); + fightingPanel.add(lblFightingLoadCannon); + fightingLoadCannon.setBackground(Color_WetAsphalt); + fightingLoadCannon.setForeground(Color_WhiteSmoke); + fightingLoadCannon.setBounds(15, 40, 20, 20); + fightingLoadCannon.setSelected(false); + fightingLoadCannon.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent e) { + Variables.load_cannon = fightingLoadCannon.isSelected(); + } + }); + fightingPanel.add(fightingLoadCannon); + + // Should we collect and bury our bones JLabel lblFightingBuryBones = new JLabel("Collect and bury bones"); lblFightingBuryBones.setForeground(Color_WhiteSmoke); - lblFightingBuryBones.setBounds(40, 80, 130, 20); + lblFightingBuryBones.setBounds(40, 60, 130, 20); fightingPanel.add(lblFightingBuryBones); fightingBuryBones.setBackground(Color_WetAsphalt); fightingBuryBones.setForeground(Color_WhiteSmoke); - fightingBuryBones.setBounds(15, 80, 20, 20); + fightingBuryBones.setBounds(15, 60, 20, 20); fightingBuryBones.setSelected(true); fightingBuryBones.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { @@ -353,12 +409,40 @@ public class UI extends JFrame { }); fightingPanel.add(fightingBuryBones); + // Should we hold a position (aggressive npcs) return after collecting items + JLabel lblReturnPosition = new JLabel("Return Position"); + lblReturnPosition.setForeground(Color_WhiteSmoke); + lblReturnPosition.setBounds(200, 40, 150, 20); + fightingPanel.add(lblReturnPosition); + returnPositionCoords.setBounds(200, 60, 150, 20); + returnPositionCoords.addFocusListener(new FocusListener() { + @Override + public void focusGained(FocusEvent e) { + // we don't need to do anything here + } + + @Override + public void focusLost(FocusEvent e) { + try { + String[] sample = returnPositionCoords.getText().split("(,|;)\\s*"); + int[] coords = new int[sample.length]; + + for (int i = 0; i < sample.length; i++) + coords[i] = Integer.parseInt(sample[i]); + Variables.return_to_coords = coords; + } catch (Exception ಠ_ಠ) { + Variables.return_to_coords = new int[]{}; + } + } + }); + fightingPanel.add(returnPositionCoords); + // Custom items to pickup JLabel lblFightingItemCustomID = new JLabel("Pickup Item IDs"); lblFightingItemCustomID.setForeground(Color_WhiteSmoke); - lblFightingItemCustomID.setBounds(20, 120, 150, 20); + lblFightingItemCustomID.setBounds(20, 80, 150, 20); fightingPanel.add(lblFightingItemCustomID); - fightingItemCustomID.setBounds(20, 140, 150, 20); + fightingItemCustomID.setBounds(20, 100, 150, 20); fightingItemCustomID.addFocusListener(new FocusListener() { @Override public void focusGained(FocusEvent e) { @@ -382,11 +466,11 @@ public class UI extends JFrame { fightingPanel.add(fightingItemCustomID); // Minimum hitpoints to start fighting - JLabel lblFightingMinimumHitpoints = new JLabel("Minimum hitpoints"); + JLabel lblFightingMinimumHitpoints = new JLabel("Minimum hitpoints to fight"); lblFightingMinimumHitpoints.setForeground(Color_WhiteSmoke); - lblFightingMinimumHitpoints.setBounds(200, 120, 150, 20); + lblFightingMinimumHitpoints.setBounds(200, 80, 150, 20); fightingPanel.add(lblFightingMinimumHitpoints); - fightingMinimumHitpoints.setBounds(200, 140, 150, 20); + fightingMinimumHitpoints.setBounds(200, 100, 150, 20); fightingMinimumHitpoints.addFocusListener(new FocusListener() { @Override public void focusGained(FocusEvent e) { @@ -398,12 +482,58 @@ public class UI extends JFrame { try { Variables.fighting_minimum_hitpoints = Integer.parseInt(fightingMinimumHitpoints.getText()); } catch (Exception ಠ_ಠ) { - Variables.fighting_minimum_hitpoints = 0; + Variables.fighting_minimum_hitpoints = -1; } } }); fightingPanel.add(fightingMinimumHitpoints); + // Food to eat when health is low + JLabel lblFightingFoodToEat = new JLabel("Food ID to eat"); + lblFightingFoodToEat.setForeground(Color_WhiteSmoke); + lblFightingFoodToEat.setBounds(20, 120, 150, 20); + fightingPanel.add(lblFightingFoodToEat); + fightingFoodToEat.setBounds(20, 140, 150, 20); + fightingFoodToEat.addFocusListener(new FocusListener() { + @Override + public void focusGained(FocusEvent e) { + // we don't need to do anything here + } + + @Override + public void focusLost(FocusEvent e) { + try { + Variables.fighting_food_to_eat = Integer.parseInt(fightingFoodToEat.getText()); + } catch (Exception ಠ_ಠ) { + Variables.fighting_food_to_eat = -1; + } + } + }); + fightingPanel.add(fightingFoodToEat); + + // How much the food heals for + JLabel lblFightingFoodHealsAmount = new JLabel("Food heals amount"); + lblFightingFoodHealsAmount.setForeground(Color_WhiteSmoke); + lblFightingFoodHealsAmount.setBounds(200, 120, 150, 20); + fightingPanel.add(lblFightingFoodHealsAmount); + fightingFoodHealsAmount.setBounds(200, 140, 150, 20); + fightingFoodHealsAmount.addFocusListener(new FocusListener() { + @Override + public void focusGained(FocusEvent e) { + // we don't need to do anything here + } + + @Override + public void focusLost(FocusEvent e) { + try { + Variables.fighting_food_heals_amount = Integer.parseInt(fightingFoodHealsAmount.getText()); + } catch (Exception ಠ_ಠ) { + Variables.fighting_food_heals_amount = 20; + } + } + }); + fightingPanel.add(fightingFoodHealsAmount); + /* * Thieving Panel */ @@ -480,23 +610,18 @@ public class UI extends JFrame { tabbedPane.addTab("Fishing", fishingPanel); fishingPanel.setLayout(null); - // Select which npc should be our victim + // Select our fishing type JLabel lblFishingTypeSelect = new JLabel("Fishing Type"); lblFishingTypeSelect.setForeground(Color_WhiteSmoke); lblFishingTypeSelect.setBounds(20, 20, 73, 20); fishingPanel.add(lblFishingTypeSelect); - fishingTypeSelect.setModel(new DefaultComboBoxModel(new String[]{ - Npcs.Option.NET.name(), - Npcs.Option.BAIT.name(), - Npcs.Option.CAGE.name(), - Npcs.Option.HARPOON.name(), - })); + fishingTypeSelect.setModel(new DefaultComboBoxModel(FishingSpots.toStringArray())); fishingTypeSelect.setBounds(20, 40, 150, 20); fishingTypeSelect.addActionListener (new ActionListener () { public void actionPerformed(ActionEvent e) { - for (Npcs.Option option : Npcs.Option.values()) { - if (option.name().equalsIgnoreCase(fishingTypeSelect.getSelectedItem().toString())) { - Variables.fishing_type_selected = option; + for (FishingSpots fishingSpot : FishingSpots.values()) { + if (fishingSpot.name().equalsIgnoreCase(fishingTypeSelect.getSelectedItem().toString())) { + Variables.fishing_spot_selected = fishingSpot; } } } @@ -524,7 +649,7 @@ public class UI extends JFrame { slavePanel.add(slaveMaster); slaveMaster.addActionListener (new ActionListener () { public void actionPerformed(ActionEvent e) { - Variables.slaveMaster = slaveMaster.getText(); + Variables.slave_master = slaveMaster.getText(); } }); */ @@ -536,29 +661,7 @@ public class UI extends JFrame { Variables.setAccountUsername(username.getText()); Variables.setAccountPassword(password.getText()); } - /* - for (Location loc : Location.values()) { - if (loc.getName().equalsIgnoreCase(location.getSelectedItem().toString())) { - Variables.setLocation(loc); - } - } - for (Tree selectedTree : Tree.values()) { - if (selectedTree.getName().equalsIgnoreCase(treeSelect.getSelectedItem().toString())) { - Variables.setTree(selectedTree); - System.out.println(selectedTree.getName()); - } - } - if (drop.isSelected()) { - Variables.setDrop(true); - } - if (bank.isSelected()) { - Variables.setBanking(true); - } - if (birdsNest.isSelected()) { - Variables.setPickupBirdNests(true); - } - dispose(); - */ + Variables.bank_items = UpdateBank.loadBankFile(); Variables.running = !Variables.running; start.setText(Variables.running ? "PAUSE" : "START"); start.setBackground(Variables.running ? Color_Alizarin : Color_Emerald); @@ -566,7 +669,6 @@ public class UI extends JFrame { }); start.setBackground(Color_Emerald); start.setForeground(Color_MidnightBlue); - // these next two lines do the magic.. start.setContentAreaFilled(false); start.setOpaque(true); start.setBounds(20, 220, 360, 40);