Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Color;
- import java.awt.Container;
- import java.awt.Dimension;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.awt.Insets;
- import java.awt.Point;
- import java.awt.Rectangle;
- import java.awt.event.*;
- import java.text.DateFormat;
- import java.text.SimpleDateFormat;
- import java.util.Calendar;
- import java.util.List;
- import javax.swing.*;
- import javax.swing.DefaultComboBoxModel;
- import javax.swing.JButton;
- import javax.swing.JCheckBox;
- import javax.swing.JComboBox;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import org.osbot.script.Script;
- import org.osbot.script.ScriptManifest;
- import org.osbot.script.rs2.model.Entity;
- import org.osbot.script.rs2.model.GroundItem;
- import org.osbot.script.rs2.model.Item;
- import org.osbot.script.rs2.model.Player;
- import org.osbot.script.rs2.model.RS2Object;
- import org.osbot.script.rs2.skill.Skill;
- import org.osbot.script.rs2.ui.Tab;
- import org.osbot.script.rs2.utility.Area;
- @ScriptManifest(
- name = "Chop Everywhere",
- author = "Merccy",
- version = 1D,
- info = "Now you can chop every tree on any location! It will pick up birdnests and train your firemaking if you want."
- )
- public class ChopEverywhere extends Script{
- private Object treeToChop = null;
- // IDS
- public int[] trees = { 1276, 1278, 10041 };
- public int[] oak = { 1281 };
- public int[] willow = { 1307, 1308, 2467, 1309 };
- public int[] maple = { 2782 };
- public int[] yew = { 2468 };
- public int[] magictree = { 1306 };
- public int[] axes = { 1353, 1349, 1351, 1355, 1357, 1359, 1361, 6739 };
- public int[] nests = { 5073, 5070, 5074 };
- public int[][] logs = { { 1511, 1 }, { 2862, 1 }, { 1521, 15 }, { 1519, 30 }, { 6333, 35 }, { 10810, 42 }, { 1517, 45 }, { 6332, 50 }, { 1515, 60 }, { 1513, 75 } };
- public int[] dontDropElse = { 590 };
- public int tinderbox = 590;
- // Options
- public int[] toUse;
- public int[] dontDrop;
- public int aBanVal;
- public boolean birdsNest;
- public boolean willLight;
- // GUI Data
- public long startTime;
- public long runTime;
- public long startXP;
- public long startLevel;
- public long startFXP;
- public long startFLevel;
- public int cut = 0;
- public long seconds,minutes,hours;
- //GUI
- ChopEverywhereGUI g = new ChopEverywhereGUI();
- public boolean guiWait = true;
- public void onStart(){
- log("Chop Everywhere started.");
- g.setVisible(true);
- while(guiWait){
- }
- this.startXP = this.client.getSkills().getExperience(Skill.WOODCUTTING);
- this.startLevel = this.client.getSkills().getCurrentLevel(Skill.WOODCUTTING);
- this.startFXP = this.client.getSkills().getExperience(Skill.FIREMAKING);
- this.startFLevel = this.client.getSkills().getLevel(Skill.FIREMAKING);
- }
- public int onLoop(){
- try{
- ChopState now = getState();
- if(this.birdsNest){
- pickupNests();
- }
- handleState(now);
- if(random(aBanVal)==0){
- sleep(antiBan());
- }
- } catch(Exception e) {}
- return 50;
- }
- public void onMessage(String message){
- if(message.contains("logs.")){
- this.cut += 1;
- }
- if(message.contains("can't light a fire")){
- findEmptyTile();
- }
- }
- public void onPaint(Graphics g){
- this.runTime = (System.currentTimeMillis() - this.startTime);
- this.seconds = (this.runTime / 1000L);
- if (this.seconds >= 60L) {
- this.minutes = (this.seconds / 60L);
- this.seconds -= this.minutes * 60L;
- }
- if (this.minutes >= 60L) {
- this.hours = (this.minutes / 60L);
- this.minutes -= this.hours * 60L;
- }
- long XPGained = (this.client.getSkills().getExperience(Skill.WOODCUTTING) - this.startXP);
- long XPHour = ((int)(3600000.0D / this.runTime * XPGained));
- long LevelsGained = (this.client.getSkills().getLevel(Skill.WOODCUTTING) - this.startLevel);
- long LevelsPH = ((int)(3600000.0D / this.runTime * LevelsGained));
- long XPFGained = (this.client.getSkills().getExperience(Skill.FIREMAKING) - this.startFXP);
- long XPFHour = ((int)(3600000.0D / this.runTime * XPFGained));
- long LevelsFGained = (this.client.getSkills().getLevel(Skill.FIREMAKING) - this.startFLevel);
- long LevelsFPH = ((int)(3600000.0D / this.runTime * LevelsFGained));
- long cutph = ((int)(3600000.0D / this.runTime * this.cut));
- int widthAcross = this.client.getInterface(548).getChild(98).getWidth();
- int heightAcross = this.client.getInterface(548).getChild(98).getHeight();
- int paintWidth = widthAcross;
- g.setColor(new Color(0, 0, 0, 150));
- g.fill3DRect(547, 205, paintWidth, heightAcross, true);
- this.rowx = 559;
- this.rowy = 224;
- Color white = new Color(255,255,255);
- Font calibri = new Font("Arial", 0, 12);
- g.setColor(white);
- g.setFont(new Font("Arial", 0, 16));
- g.drawString("Chop Everywhere by Merccy", this.rowx, this.rowy);
- this.rowy += 25;
- writeText(g, calibri, white, "Logs chopped: " + this.cut);
- writeText(g, calibri, white, "Logs/hour: " + cutph);
- writeText(g, calibri, white, "XP Gained: " + XPGained);
- writeText(g, calibri, white, "XP/hour: " + XPHour);
- writeText(g, calibri, white, "Levels Gained: " + LevelsGained);
- writeText(g, calibri, white, "Levels/hour: " + LevelsPH);
- this.rowy += 25;
- writeText(g, calibri, white, "Fire XP Gained: " + XPFGained);
- writeText(g, calibri, white, "Fire XP/hour: " + XPFHour);
- writeText(g, calibri, white, "Fire Levels Gained: " + LevelsFGained);
- writeText(g, calibri, white, "Fire Levels/hour: " + LevelsFPH);
- this.rowy += 25;
- writeText(g, calibri, white, "Runtime: H:" + this.hours + " M:" + this.minutes + " S:" + this.seconds);
- }
- public int rowx;
- public int rowy;
- public void writeText(Graphics g, Font f, Color c, String t){
- g.setColor(c);
- g.setFont(f);
- g.drawString(t, this.rowx, this.rowy);
- this.rowy += 15;
- }
- public void pickupNests() throws InterruptedException{
- GroundItem nest = closestGroundItem(this.nests);
- if(nest != null){
- if(nest.isVisible()){
- nest.interact("Take");
- sleep(random(1000,2000));
- }else{
- this.client.moveCameraToEntity(nest);
- walkExact(nest.position);
- }
- }
- }
- public int antiBan() throws InterruptedException{
- log("Antiban...");
- int rnd = random(1,12);
- if(rnd == 1){
- this.client.setMouseSpeed(random(3,7));
- }else if(rnd == 2){
- this.client.rotateCameraPitch(random(30,100));
- }else if(rnd == 3){
- this.client.rotateCameraToAngle(random(30, 150));
- }else if(rnd == 4){
- if(currentTab() != Tab.SKILLS){
- openTab(Tab.SKILLS);
- sleep(1500 + random(1000));
- this.client.rotateCameraPitch(random(180));
- sleep(1250 + random(1250));
- openTab(Tab.INVENTORY);
- }
- }else if(rnd == 5){
- this.client.getInterface(548).getChild(89).hover();
- }else if(rnd == 6){
- this.client.getInterface(548).getChild(85).hover();
- }else if(rnd == 7){
- this.client.getInterface(548).getChild(109).hover();
- }else if(rnd == 8){
- this.client.getInterface(548).getChild(84).hover();
- }else if (rnd == 9){
- if (this.client.getInterface(320).getChild(144).isVisible()) {
- this.client.getInterface(548).getChild(50).interact();
- sleep(random(0, 600));
- }
- this.client.rotateCameraToAngle(random(60, 160));
- }else if (rnd == 10){
- this.client.getInterface(548).getChild(75).hover();
- }else if (rnd == 11){
- this.client.getInterface(548).getChild(100).hover();
- }else if (rnd == 12){
- this.client.getInterface(548).getChild(44).hover();
- }
- return random(1000,2500);
- }
- public void findEmptyTile(){
- int[] c = { this.client.getMyPlayer().getX(), this.client.getMyPlayer().getY() };
- Area a = null;
- int r = random(4);
- if (r == 0)
- a = new Area(c[0] + 1, c[1], c[0] + 1, c[1]);
- else if (r == 1)
- a = new Area(c[0] - 1, c[1], c[0] - 1, c[1]);
- else if (r == 2)
- a = new Area(c[0], c[1] + 1, c[0], c[1] + 1);
- else if (r == 3)
- a = new Area(c[0], c[1] - 1, c[0], c[1] + 1);
- List fires = this.closestObjectListForName(new String[] { "Fire" });
- for(int x = 0; x < fires.size(); x++){
- RS2Object f = (RS2Object)fires.get(x);
- if(a.contains(f.getX(), f.getY())){
- }
- }
- try{
- if(!a.contains(c[0], c[1])){
- walk(a);
- }
- }catch(Exception e){}
- }
- public ChopState getState() throws InterruptedException{
- Player player = this.client.getMyPlayer();
- this.treeToChop = closestObject(toUse);
- if(this.client.getInventory().isFull()){
- if(willLight){
- return ChopState.Lighting;
- }else{
- return ChopState.Dropping;
- }
- }
- if(!this.client.getInventory().isFull()){
- if((this.treeToChop != null) && (!player.isAnimating())){
- return ChopState.Chopping;
- }
- }
- return ChopState.Waiting;
- }
- public void handleState(ChopState state) throws InterruptedException{
- switch(state){
- case Waiting:
- break;
- case Dropping:
- this.client.getInventory().dropAllExcept(this.dontDrop);
- sleep(200 + random(400));
- break;
- case Lighting:
- for(int i = 0; i < this.logs.length; i++){
- if((this.client.getSkills().getLevel(Skill.FIREMAKING) > this.logs[i][1]) && (this.client.getInventory().contains(this.logs[i][0]))){
- for (Item it : this.client.getInventory().getItems()){
- if(it.getId() == this.logs[i][0]){
- Area a = new Area(this.client.getMyPlayer().getX(), this.client.getMyPlayer().getY(),this.client.getMyPlayer().getX(), this.client.getMyPlayer().getY());
- List fires = this.closestObjectListForName(new String[] { "Fire" });
- for(int x = 0; x < fires.size(); x++){
- RS2Object f = (RS2Object)fires.get(x);
- if(a.contains(f.getX(), f.getY())){
- findEmptyTile();
- sleep(random(250,750));
- }
- }
- selectInventoryOption(this.client.getInventory().getSlotForId(it.getId()), "Use");
- selectInventoryOption(this.client.getInventory().getSlotForId(this.tinderbox), "Use");
- sleep(random(500,1000));
- while((this.client.getMyPlayer().isAnimating() && this.client.getMyPlayer().getAnimation() == 733) || this.client.getMyPlayer().isMoving()){
- sleep(100);
- }
- }
- }
- }
- }
- break;
- case Chopping:
- if(this.client.getRunEnergy() > 25){
- setRunning(true);
- }
- Entity tree = (Entity)this.treeToChop;
- if(!tree.isVisible()){
- this.client.moveCameraToEntity(tree);
- this.client.rotateCameraPitch(60 + gRandom(7, 1.0D));
- }
- tree.interact("Chop down", false, true);
- sleep(750 + random(750));
- break;
- }
- }
- final static public int[] merge(final int[] ...arrays ) {
- int size = 0;
- for ( int[] a: arrays )
- size += a.length;
- int[] res = new int[size];
- int destPos = 0;
- for ( int i = 0; i < arrays.length; i++ ) {
- if ( i > 0 ) destPos += arrays[i-1].length;
- int length = arrays[i].length;
- System.arraycopy(arrays[i], 0, res, destPos, length);
- }
- return res;
- }
- public static String convertMilliSecondsToDate(long milliSeconds, String dateFormat)
- {
- // Create a DateFormatter object for displaying date in specified format.
- DateFormat formatter = new SimpleDateFormat(dateFormat);
- // Create a calendar object that will convert the date and time value in milliseconds to date.
- Calendar calendar = Calendar.getInstance();
- calendar.setTimeInMillis(milliSeconds);
- return formatter.format(calendar.getTime());
- }
- public static boolean isInteger(String s) {
- try {
- Integer.parseInt(s);
- } catch(NumberFormatException e) {
- return false;
- }
- // only got here if we didn't return false
- return true;
- }
- private enum ChopState{
- Waiting, Dropping, Lighting, Chopping
- }
- //GUI!!!
- public class ChopEverywhereGUI extends JFrame {
- public ChopEverywhereGUI() {
- initComponents();
- }
- private void startButtonActionPerformed(ActionEvent e) {
- String combo = comboBox1.getSelectedItem().toString();
- if(combo.equalsIgnoreCase("tree")){
- toUse = trees;
- }else if(combo.equalsIgnoreCase("oak")){
- toUse = oak;
- }else if(combo.equalsIgnoreCase("willow")){
- toUse = willow;
- }else if(combo.equalsIgnoreCase("maple")){
- toUse = maple;
- }else if(combo.equalsIgnoreCase("yew")){
- toUse = yew;
- }else if(combo.equalsIgnoreCase("magic")){
- toUse = magictree;
- }
- birdsNest = checkBNest.isSelected();
- willLight = checkLight.isSelected();
- dontDrop = merge(axes, dontDropElse);
- if(birdsNest){
- dontDrop = merge(axes, nests, dontDropElse);
- }
- if(isInteger(antibanVal.getText())){
- aBanVal = Integer.parseInt(antibanVal.getText());
- }else{
- aBanVal = 25;
- }
- startTime = System.currentTimeMillis();
- guiWait = false;
- g.dispose();
- }
- private void initComponents() {
- // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
- label1 = new JLabel();
- label2 = new JLabel();
- comboBox1 = new JComboBox<>();
- startButton = new JButton();
- label3 = new JLabel();
- checkBNest = new JCheckBox();
- label4 = new JLabel();
- checkLight = new JCheckBox();
- label5 = new JLabel();
- antibanVal = new JTextField();
- //======== this ========
- setTitle("Chop Everywhere Settings");
- Container contentPane = getContentPane();
- contentPane.setLayout(null);
- //---- label1 ----
- label1.setText("Chop Everywhere");
- label1.setFont(new Font("Segoe UI", Font.BOLD, 22));
- contentPane.add(label1);
- label1.setBounds(105, 5, 194, 35);
- //---- label2 ----
- label2.setText("Tree to chop: ");
- contentPane.add(label2);
- label2.setBounds(new Rectangle(new Point(10, 45), label2.getPreferredSize()));
- //---- comboBox1 ----
- comboBox1.setModel(new DefaultComboBoxModel<>(new String[] {
- "Tree",
- "Oak",
- "Willow",
- "Maple",
- "Yew",
- "Magic"
- }));
- contentPane.add(comboBox1);
- comboBox1.setBounds(125, 40, 252, comboBox1.getPreferredSize().height);
- //---- startButton ----
- startButton.setText("Start");
- startButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- startButtonActionPerformed(e);
- }
- });
- contentPane.add(startButton);
- startButton.setBounds(165, 145, startButton.getPreferredSize().width, 25);
- //---- label3 ----
- label3.setText("Pick up birdsnests: ");
- contentPane.add(label3);
- label3.setBounds(10, 70, 110, 15);
- contentPane.add(checkBNest);
- checkBNest.setBounds(new Rectangle(new Point(125, 65), checkBNest.getPreferredSize()));
- //---- label4 ----
- label4.setText("Light instead of drop");
- contentPane.add(label4);
- label4.setBounds(10, 95, 110, 15);
- contentPane.add(checkLight);
- checkLight.setBounds(125, 90, 21, 21);
- //---- label5 ----
- label5.setText("Antiban 1 in XX:");
- contentPane.add(label5);
- label5.setBounds(10, 120, 110, 15);
- //---- antibanVal ----
- antibanVal.setText("25");
- contentPane.add(antibanVal);
- antibanVal.setBounds(130, 120, 240, antibanVal.getPreferredSize().height);
- { // compute preferred size
- Dimension preferredSize = new Dimension();
- for(int i = 0; i < contentPane.getComponentCount(); i++) {
- Rectangle bounds = contentPane.getComponent(i).getBounds();
- preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
- preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
- }
- Insets insets = contentPane.getInsets();
- preferredSize.width += insets.right;
- preferredSize.height += insets.bottom;
- contentPane.setMinimumSize(preferredSize);
- contentPane.setPreferredSize(preferredSize);
- }
- pack();
- setLocationRelativeTo(getOwner());
- // JFormDesigner - End of component initialization //GEN-END:initComponents
- }
- // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
- // Generated using JFormDesigner Evaluation license - Henk Tenk
- private JLabel label1;
- private JLabel label2;
- private JComboBox<String> comboBox1;
- private JButton startButton;
- private JLabel label3;
- private JCheckBox checkBNest;
- private JLabel label4;
- private JCheckBox checkLight;
- private JLabel label5;
- private JTextField antibanVal;
- // JFormDesigner - End of variables declaration //GEN-END:variables
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment