mirror of
https://github.com/2006Scape-Scripts/ParaScript.git
synced 2026-07-03 08:39:12 +00:00
Initial commit
This commit is contained in:
@@ -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<Strategy> strategies = new ArrayList<Strategy>();
|
||||
|
||||
@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() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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));
|
||||
}
|
||||
@@ -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<Trees> enumList = Arrays.asList(Trees.values());
|
||||
List<String> 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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user