From d62294ef4e097c38b6e1b1271fed8b6c72270dd0 Mon Sep 17 00:00:00 2001 From: RedSparr0w Date: Sat, 12 Oct 2019 10:07:14 +1300 Subject: [PATCH] Initial commit --- .gitattributes | 2 + .idea/misc.xml | 6 + .idea/modules.xml | 8 + .idea/uiDesigner.xml | 124 +++++++++++++++ .idea/vcs.xml | 6 + .idea/workspace.xml | 75 +++++++++ ParaScript.iml | 31 ++++ src/ParaScript/Main.java | 42 +++++ src/ParaScript/data/Variables.java | 23 +++ src/ParaScript/data/variables/Trees.java | 36 +++++ src/ParaScript/data/variables/Zone.java | 39 +++++ src/ParaScript/strategies/Bank.java | 19 +++ .../strategies/MakeArrowShafts.java | 47 ++++++ src/ParaScript/strategies/Mine.java | 32 ++++ src/ParaScript/strategies/ScriptState.java | 26 ++++ src/ParaScript/strategies/Thieving.java | 43 ++++++ src/ParaScript/strategies/WoodcutTree.java | 49 ++++++ src/ParaScript/ui/UI.java | 146 ++++++++++++++++++ 18 files changed, 754 insertions(+) create mode 100644 .gitattributes create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/uiDesigner.xml create mode 100644 .idea/vcs.xml create mode 100644 .idea/workspace.xml create mode 100644 ParaScript.iml create mode 100644 src/ParaScript/Main.java create mode 100644 src/ParaScript/data/Variables.java create mode 100644 src/ParaScript/data/variables/Trees.java create mode 100644 src/ParaScript/data/variables/Zone.java create mode 100644 src/ParaScript/strategies/Bank.java create mode 100644 src/ParaScript/strategies/MakeArrowShafts.java create mode 100644 src/ParaScript/strategies/Mine.java create mode 100644 src/ParaScript/strategies/ScriptState.java create mode 100644 src/ParaScript/strategies/Thieving.java create mode 100644 src/ParaScript/strategies/WoodcutTree.java create mode 100644 src/ParaScript/ui/UI.java diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..dfe0770 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Auto detect text files and perform LF normalization +* text=auto diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..0548357 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..9bc7e7b --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..e96534f --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..5c3aad7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..469504c --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1570572301532 + + + + \ No newline at end of file diff --git a/ParaScript.iml b/ParaScript.iml new file mode 100644 index 0000000..f40cab0 --- /dev/null +++ b/ParaScript.iml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/ParaScript/Main.java b/src/ParaScript/Main.java new file mode 100644 index 0000000..5019a25 --- /dev/null +++ b/src/ParaScript/Main.java @@ -0,0 +1,42 @@ +package ParaScript; + +import ParaScript.data.Variables; +import ParaScript.strategies.MakeArrowShafts; +import ParaScript.strategies.ScriptState; +import ParaScript.strategies.Thieving; +import ParaScript.strategies.WoodcutTree; +import ParaScript.ui.UI; +import org.parabot.environment.api.utils.Time; +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 java.util.ArrayList; + +@ScriptManifest(author = "RedSparr0w", category = Category.OTHER, description = "ParaScript", name = "Script", servers = { "2006rebotted" }, version = 1) +public class Main extends Script{ + + private final ArrayList strategies = new ArrayList(); + + @Override + public boolean onExecute() { + + UI ui = new UI(); + ui.setVisible(true); + while (!Variables.running) { + Time.sleep(300); + } + + strategies.add(new ScriptState()); + strategies.add(new MakeArrowShafts()); + strategies.add(new WoodcutTree()); + provide(strategies); + return true; + } + + @Override + public void onFinish() { + + } +} \ No newline at end of file diff --git a/src/ParaScript/data/Variables.java b/src/ParaScript/data/Variables.java new file mode 100644 index 0000000..511a9b6 --- /dev/null +++ b/src/ParaScript/data/Variables.java @@ -0,0 +1,23 @@ +package ParaScript.data; + +import ParaScript.data.variables.Trees; +import ParaScript.data.variables.Zone; +import org.rev317.min.api.wrappers.Tile; + +import java.util.List; + +public class Variables { + public static boolean running = false; + + private static String currentStatus = "none"; + + public static String getStatus() { + return currentStatus; + } + + public static void setStatus(String i) { + currentStatus = i; + } + + public final static Zone LUMBRIDGE_NORMAL_TREE_ZONE = new Zone(new Tile(3186, 3249), new Tile(3207, 3234)); +} diff --git a/src/ParaScript/data/variables/Trees.java b/src/ParaScript/data/variables/Trees.java new file mode 100644 index 0000000..5ab86ce --- /dev/null +++ b/src/ParaScript/data/variables/Trees.java @@ -0,0 +1,36 @@ +package ParaScript.data.variables; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public enum Trees { + NORMAL("normal", new int[]{1276, 1278}), + OAK("oak", new int[]{1281}), + WILLOW ("willow", new int[]{5551, 1308, 5553, 5552}), + MAPLE("maple", new int[]{1307}); + + private String name; + private int[] trees; + + Trees(String name, int[] trees) { + this.name = name; + this.trees = trees; + } + + public static String[] toStringArray() { + List enumList = Arrays.asList(Trees.values()); + List locationsArray = new ArrayList<>(); + for (Trees tree : enumList) { + locationsArray.add(tree.name); + } + + String[] simpleArray = new String[ locationsArray.size() ]; + locationsArray.toArray( simpleArray ); + return(simpleArray); + } + + public int[] getIDs() { + return this.trees; + } +} diff --git a/src/ParaScript/data/variables/Zone.java b/src/ParaScript/data/variables/Zone.java new file mode 100644 index 0000000..2b6dc50 --- /dev/null +++ b/src/ParaScript/data/variables/Zone.java @@ -0,0 +1,39 @@ +package ParaScript.data.variables; + +import org.rev317.min.api.methods.Players; +import org.rev317.min.api.wrappers.SceneObject; +import org.rev317.min.api.wrappers.Tile; + +public class Zone +{ + Tile topLeftTile; + Tile botRightTile; + + public Zone(Tile topLeftTile, Tile botRightTile) + { + this.topLeftTile = topLeftTile; + this.botRightTile = botRightTile; + } + + public boolean inTheZone() + { + if ((Players.getMyPlayer().getLocation().getX() > this.topLeftTile.getX()) && + (Players.getMyPlayer().getLocation().getY() < this.topLeftTile.getY()) && + (Players.getMyPlayer().getLocation().getX() < this.botRightTile.getX()) && + (Players.getMyPlayer().getLocation().getY() > this.botRightTile.getY())) { + return true; + } + return false; + } + + public boolean inTheZoneObject(SceneObject tree) + { + if ((tree.getLocation().getX() > this.topLeftTile.getX()) && + (tree.getLocation().getY() < this.topLeftTile.getY()) && + (tree.getLocation().getX() < this.botRightTile.getX()) && + (tree.getLocation().getY() > this.botRightTile.getY())) { + return true; + } + return false; + } +} \ No newline at end of file diff --git a/src/ParaScript/strategies/Bank.java b/src/ParaScript/strategies/Bank.java new file mode 100644 index 0000000..068a28d --- /dev/null +++ b/src/ParaScript/strategies/Bank.java @@ -0,0 +1,19 @@ +package ParaScript.strategies; + +import org.parabot.environment.scripts.framework.Strategy; +import org.rev317.min.api.methods.SceneObjects; +import org.rev317.min.api.wrappers.SceneObject; + +public class Bank implements Strategy { + @Override + public boolean activate() { + return true; + } + + @Override + public void execute() { + for (SceneObject i : SceneObjects.getNearest(100)) { + i.interact(SceneObjects.Option.MINE); + } + } +} \ No newline at end of file diff --git a/src/ParaScript/strategies/MakeArrowShafts.java b/src/ParaScript/strategies/MakeArrowShafts.java new file mode 100644 index 0000000..c181870 --- /dev/null +++ b/src/ParaScript/strategies/MakeArrowShafts.java @@ -0,0 +1,47 @@ +package ParaScript.strategies; + +import ParaScript.data.Variables; +import ParaScript.data.variables.Trees; +import org.parabot.environment.api.utils.Time; +import org.parabot.environment.scripts.framework.Strategy; +import org.rev317.min.api.methods.Menu; +import org.rev317.min.api.methods.Inventory; +import org.rev317.min.api.methods.Items; +import org.rev317.min.api.methods.Players; +import org.rev317.min.api.methods.SceneObjects; +import org.rev317.min.api.wrappers.SceneObject; + +import java.awt.*; + +public class MakeArrowShafts implements Strategy { + + @Override + public boolean activate() { + if (Variables.running + && hasLogs() + && (Variables.getStatus() == "none" || Variables.getStatus() == "making arrow shafts") + && !Players.getMyPlayer().isInCombat() + && Players.getMyPlayer().getAnimation() == -1) { + Variables.setStatus("making arrow shafts"); + return true; + } + Variables.setStatus("none"); + return false; + } + + @Override + public void execute() { + System.out.println("making arrow shafts"); + Inventory.getItem(947).interact(Items.Option.USE); + Inventory.getItem(1512).interact(Items.Option.USE_WITH); + + Menu.clickButton(8886); + Time.sleep(3000); + //Wait for the Player to chop the Tree + Time.sleep(() -> Players.getMyPlayer().getAnimation() == -1, 3000); + } + + private boolean hasLogs(){ + return Inventory.contains(1512); + } +} \ No newline at end of file diff --git a/src/ParaScript/strategies/Mine.java b/src/ParaScript/strategies/Mine.java new file mode 100644 index 0000000..595e839 --- /dev/null +++ b/src/ParaScript/strategies/Mine.java @@ -0,0 +1,32 @@ +package ParaScript.strategies; + +import ParaScript.data.Variables; +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 Mine implements Strategy { + @Override + public boolean activate() { + for (SceneObject i : SceneObjects.getNearest(100)) { + if (Variables.running + && i !=null + && i.distanceTo() <= 10 + && !Players.getMyPlayer().isInCombat() + && Players.getMyPlayer().getAnimation() == -1 + && !Inventory.isFull()) { + return true; + } + } + return false; + } + + @Override + public void execute() { + for (SceneObject i : SceneObjects.getNearest(100)) { + i.interact(SceneObjects.Option.MINE); + } + } +} \ No newline at end of file diff --git a/src/ParaScript/strategies/ScriptState.java b/src/ParaScript/strategies/ScriptState.java new file mode 100644 index 0000000..bb18b60 --- /dev/null +++ b/src/ParaScript/strategies/ScriptState.java @@ -0,0 +1,26 @@ +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 { + + @Override + public boolean activate() { + if (!Variables.running) { + return true; + } + return false; + } + + @Override + public void execute() { + //Wait for the Player to finish pickpocketing + Time.sleep(() -> !Variables.running, 1000); + } +} \ No newline at end of file diff --git a/src/ParaScript/strategies/Thieving.java b/src/ParaScript/strategies/Thieving.java new file mode 100644 index 0000000..8dc13bc --- /dev/null +++ b/src/ParaScript/strategies/Thieving.java @@ -0,0 +1,43 @@ +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 Thieving implements Strategy { + private SceneObject victim; + + @Override + public boolean activate() { + victim = victim(); // set the local Variable + if (Variables.running + && victim != null + && !Players.getMyPlayer().isInCombat() + && Players.getMyPlayer().getAnimation() == -1 + && !Inventory.isFull()) { + return true; + } + return false; + } + + @Override + public void execute() { + victim.interact(SceneObjects.Option.STEAL_FROM); + Time.sleep(1000); + //Wait for the Player to finish pickpocketing + Time.sleep(() -> Players.getMyPlayer().getAnimation() == -1, 500); + } + + private SceneObject victim(){ + for(SceneObject victim : SceneObjects.getNearest(1, 2, 3, 4)){ + if(victim != null){ + return victim; + } + } + return null; + } +} \ No newline at end of file diff --git a/src/ParaScript/strategies/WoodcutTree.java b/src/ParaScript/strategies/WoodcutTree.java new file mode 100644 index 0000000..f9f4551 --- /dev/null +++ b/src/ParaScript/strategies/WoodcutTree.java @@ -0,0 +1,49 @@ +package ParaScript.strategies; + +import ParaScript.data.Variables; +import ParaScript.data.variables.Trees; +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 WoodcutTree implements Strategy { + private SceneObject tree; + + @Override + public boolean activate() { + tree = tree(); // set the local Variable + if (Variables.running + && tree != null + && (Variables.getStatus() == "none" || Variables.getStatus() == "woodcutting") + && !Players.getMyPlayer().isInCombat() + && Players.getMyPlayer().getAnimation() == -1 + && !Inventory.isFull()) { + Variables.setStatus("woodcutting"); + return true; + } + Variables.setStatus("none"); + return false; + } + + @Override + public void execute() { + tree.interact(SceneObjects.Option.CHOP_DOWN); + Time.sleep(1000); + //Wait for the Player to chop the Tree + Time.sleep(() -> Players.getMyPlayer().getAnimation() == -1, 3000); + } + + private SceneObject tree(){ + for(SceneObject tree : SceneObjects.getNearest(Trees.NORMAL.getIDs())){ + if(tree != null){ + if(Variables.LUMBRIDGE_NORMAL_TREE_ZONE.inTheZoneObject(tree)) { + return tree; + } + } + } + return null; + } +} \ No newline at end of file diff --git a/src/ParaScript/ui/UI.java b/src/ParaScript/ui/UI.java new file mode 100644 index 0000000..ee59941 --- /dev/null +++ b/src/ParaScript/ui/UI.java @@ -0,0 +1,146 @@ +package ParaScript.ui; + +import ParaScript.data.variables.Trees; +import ParaScript.data.Variables; + +import javax.swing.*; +import javax.swing.border.EmptyBorder; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class UI extends JFrame { + private final ButtonGroup woodcutOptionButtonGroup = new ButtonGroup(); + private JPanel contentPane; + private JComboBox location = new JComboBox(); + private JComboBox treeSelect = new JComboBox(); + private JRadioButton bank = new JRadioButton("Bank"); + private JRadioButton drop = new JRadioButton("Drop"); + private JTextField username = new JTextField(); + private JPasswordField password = new JPasswordField(); + private JCheckBox birdsNest = new JCheckBox(); + + public UI() { + setTitle("AIO Woodcutter"); + setResizable(false); + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + setBounds(100, 100, 400, 280); + contentPane = new JPanel(); + contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); + setContentPane(contentPane); + contentPane.setLayout(null); + + JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP); + tabbedPane.setBounds(0, 0, 395, 220); + contentPane.add(tabbedPane); + + JPanel fletchPanel = new JPanel(); + tabbedPane.addTab("Woodcutting", null, fletchPanel, null); + fletchPanel.setLayout(null); + + JLabel lblUsername = new JLabel("Username:"); + lblUsername.setBounds(20, 20, 73, 20); + fletchPanel.add(lblUsername); + username.setBounds(20, 40, 150, 20); + fletchPanel.add(username); + + JLabel lblPassword = new JLabel("Password:"); + lblPassword.setBounds(20, 60, 73, 20); + fletchPanel.add(lblPassword); + password.setBounds(20, 80, 150, 20); + fletchPanel.add(password); + + JLabel lblLocation = new JLabel("Location"); + lblLocation.setBounds(200, 20, 73, 20); + fletchPanel.add(lblLocation); + + /* + location.setModel( + new DefaultComboBoxModel(Methods.locationToStringArray())); + location.setBounds(200, 40, 150, 20); + fletchPanel.add(location); + */ + + JLabel lblTree = new JLabel("Tree"); + lblTree.setBounds(200, 60, 73, 20); + fletchPanel.add(lblTree); + + treeSelect.setModel(new DefaultComboBoxModel(Trees.toStringArray())); + treeSelect.setBounds(200, 80, 150, 20); + fletchPanel.add(treeSelect); + + JLabel lblMethod = new JLabel("Method"); + lblMethod.setBounds(20, 120, 73, 20); + fletchPanel.add(lblMethod); + + /* + woodcutOptionButtonGroup.add(bank); + bank.setSelected(true); + bank.setBounds(20, 140, 80, 20); + fletchPanel.add(bank); + + woodcutOptionButtonGroup.add(drop); + drop.setBounds(20, 160, 80, 20); + fletchPanel.add(drop); + + JLabel lblBirdsNest = new JLabel("Bird nests"); + lblBirdsNest.setBounds(200, 120, 150, 20); + fletchPanel.add(lblBirdsNest); + + birdsNest.setBounds(195, 140, 20, 20); + birdsNest.setSelected(true); + fletchPanel.add(birdsNest); + + JLabel lblBirdsNestCheckBox = new JLabel("Pickup"); + lblBirdsNestCheckBox.setBounds(215, 140, 150, 20); + fletchPanel.add(lblBirdsNestCheckBox); + + location.addActionListener (new ActionListener () { + public void actionPerformed(ActionEvent e) { + for (Location loc : Location.values()) { + if (loc.getName().equalsIgnoreCase(location.getSelectedItem().toString())) { + treeSelect.setModel( + new DefaultComboBoxModel(Methods.treeToStringArray(loc))); + } + } + } + }); + */ + + JButton start = new JButton("Start"); + start.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent arg0) { + /* + 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(!password.getText().equals("") && !username.getText().equals("")) { + Variables.setAccountUsername(username.getText()); + Variables.setAccountPassword(password.getText()); + } + if (drop.isSelected()) { + Variables.setDrop(true); + } + if (bank.isSelected()) { + Variables.setBanking(true); + } + if (birdsNest.isSelected()) { + Variables.setPickupBirdNests(true); + } + dispose(); + */ + Variables.running = !Variables.running; + start.setText(Variables.running ? "pause" : "start"); + } + }); + start.setBounds(0, 220, 400, 20); + contentPane.add(start); + } +} \ No newline at end of file