This forum is in archive mode. You will not be able to post new content.

Author Topic: [Java] Rsbot (runescape)  (Read 6008 times)

0 Members and 1 Guest are viewing this topic.

Offline hanorotu

  • Dj Rapture
  • VIP
  • Majesty
  • *
  • Posts: 1173
  • Cookies: 98
  • ( ͡° ʖ ͡°)
    • View Profile
    • Rapture
[Java] Rsbot (runescape)
« on: March 28, 2011, 03:35:19 PM »
I have never been really big into coding but for a while now I have been playing around with Java and making rsbot scripts. For those that don't know rsbot is a runescape automation bot that does the shit for you so you don't have to be there.

Any who, this is my first script. anyone want to help me clean it up a bit, maybe show me some methods to coding that is a little less... well sloppy?

Code: [Select]
import org.rsbot.script.Script;
import org.rsbot.script.methods.Inventory;
import org.rsbot.script.methods.Mouse;
import org.rsbot.script.methods.MethodProvider;
import org.rsbot.script.ScriptManifest;
import org.rsbot.script.wrappers.RSObject;
import org.rsbot.script.wrappers.RSItem;
import org.rsbot.script.wrappers.RSTile;
import org.rsbot.script.methods.Walking;
import org.rsbot.script.methods.Calculations;
import java.awt.*;
import java.awt.event.KeyEvent;
import org.rsbot.script.Script;
import org.rsbot.script.ScriptManifest;
import org.rsbot.script.methods.*;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import org.rsbot.script.wrappers.*;
import org.rsbot.script.methods.*;
import org.rsbot.script.methods.Game.CHAT_MODE;
import org.rsbot.script.methods.Skills;
import org.rsbot.event.events.ServerMessageEvent;
import org.rsbot.event.listeners.ServerMessageListener;
import org.rsbot.event.listeners.PaintListener;
import javax.imageio.ImageIO;
import java.io.IOException;
import java.net.URL;
@ScriptManifest(authors = "Hanorotu", name = "Power Fletcher", version = 1.2, description = "Chops normal trees and fletches them into arrow shafts.")
public class HPowerFletcher extends Script implements PaintListener,
   ServerMessageListener {
        int[] TreeID = {1276, 1277, 1278, 1315, 1316};
        int[] KnifeID = {946};
        int[] LogsID = {1511};
        int[] ShaftID = {52};
        int[] BadTreeID = {0};
        int[] Square = {0,0,0,0};
        int switch1 = 0;
      public long startTime = 0;
      public long millis = 0;
      public long hours = 0;
      public long minutes = 0;
      public long seconds = 0;
      public long last = 0;
      public int expGained = 0;
      public int startLevel;
      public int lvlsGained;
      public int currLevel;
      private int startExp;
      public int expForShaft = 5;
      private int made;
               public void antiban() {
               int b = random(0, 10);
               switch (b) {
               case 1:
               if (random(0, 10) == 5) {
               log("Antiban- move mouse");
               mouse.moveSlightly();
               sleep(200, 600);
               mouse.moveRandomly(150, 350);
               }
               break;
               case 2:
               if (random(0, 13) == 2) {
               log("Antiban- Turn screen");
               camera.setAngle(random(30, 70));
               sleep(400, 1200);
               }
               break;
               case 3:
               if (random(0, 24) == 6) {
               log("Antiban- mouse off screen");
               mouse.moveOffScreen();
               sleep(random(600, random(1200, 2000)));
               }
               break;
               case 4:
               if (random(0, 18) == 3) {
               log("Antiban- Checking Xp.");
               game.openTab(1);
               skills.doHover(Skills.INTERFACE_FLETCHING);
               sleep(random(2100, 3400));
               }
               break;
               default:
               break;
               }
               }
       public boolean onStart(){
            log("Welcome to Hanorotu's PowerFletcher.");
         startTime = System.currentTimeMillis();
         int expForShaft = 5;
         startExp = skills.getCurrentExp(skills.FLETCHING);
         startLevel = skills.getCurrentLevel(skills.FLETCHING);
         return true;
        }
        public void onFinish() {
            log("Thanks for using Hanorotu's PowerFletcher, exclusive to Powerbot.org");
        }
     
          //START PAINT
    private Image getImage(String url) {
        try {
            return ImageIO.read(new URL(url));
        } catch(IOException e) {
            return null;
        }
    }
    private final Color color1 = new Color(255, 255, 255);
    private final Color color2 = new Color(0, 0, 0);
    private final BasicStroke stroke1 = new BasicStroke(1);
    private final Font font1 = new Font("Comic Sans MS", 0, 12);
    private final Font font2 = new Font("Comic Sans MS", 0, 10);
    private final Image img1 = getImage("http://images1.wikia.nocookie.net/runescape/images/8/87/Flecthing.PNG");
    public void onRepaint(Graphics g1) {
        Graphics2D g = (Graphics2D)g1;
      millis = System.currentTimeMillis() - startTime;
      hours = millis / (1000 * 60 * 60);
      millis -= hours * (1000 * 60 * 60);
      minutes = millis / (1000 * 60);
      millis -= minutes * (1000 * 60);
      seconds = millis / 1000;
      expGained = skills.getCurrentExp(skills.FLETCHING) - startExp;
      currLevel = skills.getCurrentLevel(skills.FLETCHING);
      lvlsGained = currLevel - startLevel;
     
        g.setColor(color1);
        g.fillRoundRect(289, 234, 226, 98, 16, 16);
        g.setColor(color2);
        g.setStroke(stroke1);
        g.drawRoundRect(289, 234, 226, 98, 16, 16);
        g.setFont(font1);
        g.drawString("Hanorotu's PowerFletcher", 365, 247);
        g.setFont(font2);
        g.drawString("Time Ran: " + hours +":"+ minutes + ":" + seconds, 309, 269);
        g.drawString("EXP Gained: " + expGained, 302, 283);
      g.drawString("Arrowshafts Made: " + made * 15, 293, 299);
        g.drawString("Current Level: " + currLevel + " (" + lvlsGained + ")", 293, 318);
        g.drawImage(img1, 466, 280, null);
    }
    //END Paint
   
   public void serverMessageRecieved(ServerMessageEvent arg0) {
        final String serverString = arg0.getMessage();
        if (serverString.contains("You carefully cut the wood into 15 arrow shafts")) {
            made++;
        }
    }
   
       public void Chop() {
            RSObject tree = objects.getNearest(TreeID);
            if (tree != null && getMyPlayer().getAnimation() == -1 ) {
                RSTile treetochop = tree.getLocation();
                if (calc.canReach( treetochop, true))    {
                if (tree != null && getMyPlayer().getAnimation() == -1 && !calc.tileOnScreen(treetochop)) {
                    walking.walkTileMM(treetochop);
                }
            antiban();
                if (tree != null && getMyPlayer().getAnimation() == -1 && calc.tileOnScreen(treetochop)) {
                    tree.doAction("Chop");
                }
            }
                else {
                    log("Finding alternative tree..");
                    mouse.click( 656, 40, 10, 10, true);
                }
                    sleep(random(500,800));
        }
        }
      public void checkRun() {
      if(!walking.isRunEnabled()) {
         if(walking.getEnergy() < random(66,90)) {
            walking.rest(random(78,100));
         } else
            walking.setRun(true);
      }
   }
        public void Fletch() {
            while (inventory.contains(1521))  {
                RSItem Oak = inventory.getItem(1521);
                Oak.doAction("Drop");
                sleep(random(500,800));
            }
                RSItem Log = inventory.getItem(LogsID);
                RSItem Knife = inventory.getItem(KnifeID);
                 inventory.useItem(Knife, Log);
                 sleep(random(3000,4000));
                 mouse.click(100, 419, 10, 10, true);
                 sleep(random(500,800));

        }
     
        @Override
        public int loop(){

        if (inventory.isFull()) {
            Fletch();
            }else{
                if (!inventory.isFull()) {
                    Chop();
                    }
                }
            checkRun();
            antiban();
        return (random(1000, 1500));
        }
             
}
« Last Edit: March 28, 2011, 05:30:43 PM by ande »


Life is hard, then you get buried.
If you want to use my work all of my music is licensed under GNU General Public License v3 (GPL-3) - http://bit.ly/TfUOBA

Offline ande

  • Owner
  • Titan
  • *
  • Posts: 2664
  • Cookies: 256
    • View Profile
Re: [JavaScript] Rsbot
« Reply #1 on: March 28, 2011, 05:22:50 PM »
This is Java, not javascript. Moved
if($statement) { unless(!$statement) { // Very sure } }
https://evilzone.org/?hack=true

Offline hanorotu

  • Dj Rapture
  • VIP
  • Majesty
  • *
  • Posts: 1173
  • Cookies: 98
  • ( ͡° ʖ ͡°)
    • View Profile
    • Rapture
Re: [Java] Rsbot (runescape)
« Reply #2 on: March 28, 2011, 05:36:50 PM »
This is Java, not javascript. Moved
oops, soz bro


Life is hard, then you get buried.
If you want to use my work all of my music is licensed under GNU General Public License v3 (GPL-3) - http://bit.ly/TfUOBA

Offline blk.Sith0

  • Serf
  • *
  • Posts: 27
  • Cookies: 0
    • View Profile
Re: [Java] Rsbot (runescape)
« Reply #3 on: March 29, 2011, 12:50:04 AM »
i copyed that and put it into microsoft word. then i saved it as runescapebot.JAVA
but then it didnt work for me so ur code is broken i think, are u sure it works for Microsoft Windows Vista Home Basic?

Offline Stackprotector

  • Administrator
  • Titan
  • *
  • Posts: 2515
  • Cookies: 205
    • View Profile
Re: [Java] Rsbot (runescape)
« Reply #4 on: March 29, 2011, 09:32:52 AM »
i copyed that and put it into microsoft word. then i saved it as runescapebot.JAVA
but then it didnt work for me so ur code is broken i think, are u sure it works for Microsoft Windows Vista Home Basic?
Windows vista home basic,   (get something like windows 7 instead or windows xp :P)

Anywayyy,
Dont use microsoft word, use notepad or notepad++, and ofcourse compiling.
You know what compiling means :P
~Factionwars

Offline hanorotu

  • Dj Rapture
  • VIP
  • Majesty
  • *
  • Posts: 1173
  • Cookies: 98
  • ( ͡° ʖ ͡°)
    • View Profile
    • Rapture
Re: [Java] Rsbot (runescape)
« Reply #5 on: March 29, 2011, 11:14:13 AM »
Besides it is for use with the powerbot(rsbot) client.

public class HPowerFletcher extends Script implements PaintListener,
You save it as HPowerFletcher.java

I just need some help cleaning it up, with like tabs and stuff. I need some tips lol


Life is hard, then you get buried.
If you want to use my work all of my music is licensed under GNU General Public License v3 (GPL-3) - http://bit.ly/TfUOBA

Offline I_Learning_I

  • Knight
  • **
  • Posts: 267
  • Cookies: 26
  • Nor black or white, not even grey. What hat am I?
    • View Profile
    • Hacking F0r Fr33
Re: [Java] Rsbot (runescape)
« Reply #6 on: March 29, 2011, 04:50:25 PM »
Sounds like a nice spacing to me.
Anyways for RsBot doubts I think you're better in RsBot forum as they code with this all day, I've made a little script for my account and I have leveled some strength levels, I think I'm 96 now or so, so yea, it isn't that bad xD
Thanks for reading,
I_Learning_I

 



Want to be here? Contact Ande, Factionwars or Kulverstukas on the forum or at IRC.