My First Bot

Discussion in 'Programming General' started by agiledice, Sep 28, 2012.

My First Bot
  1. Unread #1 - Sep 28, 2012 at 3:01 PM
  2. agiledice
    Joined:
    Sep 25, 2011
    Posts:
    140
    Referrals:
    0
    Sythe Gold:
    0

    agiledice Active Member
    Banned

    My First Bot

    Since botany bay just came out I thought it would be good to get into the botting industry now that fewer people do it. I have never used a bot (made my me or not) until two days ago. With very little java programming knowledge (zero experience with robot class) I wrote this superheating bot that seems like a success. I ran it last night successfully for 6 hours. It simply clicks in the right place at the right time. It doesn't use color except to check if a certain spot on the minimap is mostly red. This is meant to run at north west varrock west bank and it is making sure it is there by looking for the red arrow that goes down the bank stairs. If this is the wrong place, feel free to move, just wanted to share what I created. I haven't seen anything similar on here, but if there is I would like to see look at it and maybe learn more.

    Code:
    package one;
    import java.awt.AWTException;
    import java.awt.Color;
    import java.awt.Robot;
    import java.awt.event.InputEvent;
    import java.util.Random;
    public class Action {
    	public static void main(String[] args) throws AWTException {
    	Robot robot=new Robot();
    	int x=20;
    	int y=20;
    	int count=0;
    	int count2=0;
    	int antiban=0;
    	int antiban2=10;
    	int red=0;
    	int pixelx=0;
    	int blue=0;
    	int blue2=0;
    	int bluecount=0;
    	int t=0;
    	Random ranban= new Random();
    	Random rant= new Random();
    	Random ranx= new Random();
    	Random rany= new Random();
    	robot.delay(10000);
    	//waits 10 seconds to start
    	for(count2=0;count2<2000;count2+=1){
    		Color color = robot.getPixelColor(712, 328);
    		red=color.getRed();
    		if(red<200){
    		t=1000;
    		robot.delay(t);
    		robot.mouseMove(860, 260);
    		robot.mousePress(InputEvent.BUTTON1_MASK);
            robot.mouseRelease(InputEvent.BUTTON1_MASK);
            robot.delay(t);
    		}
    		//checks to see if on magic tab
    	x=ranx.nextInt(7)+346;
    	y=rany.nextInt(7)+231;
    	robot.mouseMove(x,y);
    	t=rant.nextInt(100)+500;
        robot.delay(t);
    		for(pixelx=220;pixelx<250;pixelx+=1){
    		Color color2=robot.getPixelColor(pixelx, 90);
    		blue=color2.getBlue();
    			if(blue>200){
    			bluecount+=1;
    			}
    		}
    		//checks if bank is one west
    	if(bluecount<1){
    		x=ranx.nextInt(5)+870;
    		y=rany.nextInt(5)+75;
        	robot.mouseMove(x,y);
    		robot.mousePress(InputEvent.BUTTON1_MASK);
            robot.mouseRelease(InputEvent.BUTTON1_MASK);
            x=ranx.nextInt(10)+755;
        	y=rany.nextInt(20)+460;
    		robot.mouseMove(755,460);
    		robot.mousePress(InputEvent.BUTTON1_MASK);
            robot.mouseRelease(InputEvent.BUTTON1_MASK);
            System.exit(0); 
    		}
    	bluecount=0;
    	robot.mousePress(InputEvent.BUTTON1_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
        //clicks on bank
        t=rant.nextInt(200)+1500;
        robot.delay(t);
        x=ranx.nextInt(15)+480;
    	y=rany.nextInt(10)+370;
    	robot.mouseMove(x,y);
    	t=rant.nextInt(100)+400;
        robot.delay(t);
        Color color3=robot.getPixelColor(490, 375);
    	blue2=color3.getBlue();
    		if(blue2>160){
    			t=rant.nextInt(2000)+3000;
    		    robot.delay(t);
    		}
    		//sees if blue rug is showing due to lagg
    		//if so, waits a bit
    	robot.mousePress(InputEvent.BUTTON1_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
        //clicks bank all
        t=rant.nextInt(100)+500;
        robot.delay(t);
        x=ranx.nextInt(20)+560;
    	y=rany.nextInt(15)+165;
    	robot.mouseMove(x,y);
    	t=rant.nextInt(50)+200;
        robot.delay(t);
    	robot.mousePress(InputEvent.BUTTON3_MASK);
        robot.mouseRelease(InputEvent.BUTTON3_MASK);
        //rightclicks ore
        t=rant.nextInt(100)+500;
        robot.delay(t);
        x=ranx.nextInt(25)+555;
    	y+=78+rany.nextInt(3);
    	robot.mouseMove(x,y);
    	t=rant.nextInt(100)+500;
        robot.delay(t);
    	robot.mousePress(InputEvent.BUTTON1_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
        //withdraws ore
        t=rant.nextInt(100)+500;
        robot.delay(t);
        x=ranx.nextInt(25)+515;
    	y=rany.nextInt(15)+170;
    	robot.mouseMove(x,y);
    	t=rant.nextInt(100)+500;
        robot.delay(t);
    	robot.mousePress(InputEvent.BUTTON3_MASK);
        robot.mouseRelease(InputEvent.BUTTON3_MASK);
        //right clicks coal
        t=rant.nextInt(100)+500;
        robot.delay(t);
        x=ranx.nextInt(20)+515;
    	y=rany.nextInt(7)+290;
    	robot.mouseMove(x,y);
    	robot.mousePress(InputEvent.BUTTON1_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
        t=rant.nextInt(100)+500;
        robot.delay(t);
        //clicks withdraw all coal
        t=rant.nextInt(100)+200;
        robot.delay(t);
        x=ranx.nextInt(10)+605;
    	y=rany.nextInt(12)+100;
    	robot.mouseMove(x,y);
    	t=rant.nextInt(100)+500;
        robot.delay(t);
    	robot.mousePress(InputEvent.BUTTON1_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
        //closes bank
        x=ranx.nextInt(5)+713;
    	y=rany.nextInt(5)+325;
    	robot.mouseMove(x,y);
    	//moves to superheat
    	t=rant.nextInt(200)+700;
        robot.delay(t);
    	count=0;
        for(count=0;count<5;count+=1){
        	x=ranx.nextInt(5)+713;
        	y=rany.nextInt(5)+325;
        	robot.mouseMove(x,y);
        	robot.mousePress(InputEvent.BUTTON1_MASK);
            robot.mouseRelease(InputEvent.BUTTON1_MASK);
            t=rant.nextInt(200);
            robot.delay(t);
            robot.mousePress(InputEvent.BUTTON1_MASK);
            robot.mouseRelease(InputEvent.BUTTON1_MASK);
            t=rant.nextInt(200)+1200;
            robot.delay(t);
            //clicks superheat 5 times
        	}
        antiban+=1;
        	if(antiban>antiban2){
        	x=ranx.nextInt(15)+710;
            y=rany.nextInt(15)+245;
            robot.mouseMove(x,y);
            t=rant.nextInt(100)+500;
            robot.delay(t);
            robot.mousePress(InputEvent.BUTTON1_MASK);
            robot.mouseRelease(InputEvent.BUTTON1_MASK);
            t=rant.nextInt(100)+500;
            robot.delay(t);
            x=ranx.nextInt(15)+800;
            y=rany.nextInt(15)+310;
            robot.mouseMove(x,y);
            t=rant.nextInt(2000)+3000;
            robot.delay(t);
            x=ranx.nextInt(15)+855;
            y=rany.nextInt(15)+250;
            robot.mouseMove(x,y);
            t=rant.nextInt(100)+500;
            robot.delay(t);
            robot.mousePress(InputEvent.BUTTON1_MASK);
            robot.mouseRelease(InputEvent.BUTTON1_MASK);
            t=rant.nextInt(200)+500;
            robot.delay(t);
            antiban2=ranban.nextInt(10)+15;
            antiban=0;
        	}
        	//occasionally looks at smithing xp
        }	
    }
    }
     
  3. Unread #2 - Sep 28, 2012 at 5:59 PM
  4. RuneScapeJJ
    Joined:
    Aug 14, 2011
    Posts:
    1,522
    Referrals:
    1
    Sythe Gold:
    0
    Potamus

    RuneScapeJJ Guru
    $25 USD Donor New

    My First Bot

    Looks good for your first script, but you can still improve loads even if you are just using your own Robot stuff and not an actual client. You should add a picture of your bank setup and player setup as this wouldn't work otherwise as far as I can judge from quickly looking over the code.
     
  5. Unread #3 - Sep 28, 2012 at 6:36 PM
  6. agiledice
    Joined:
    Sep 25, 2011
    Posts:
    140
    Referrals:
    0
    Sythe Gold:
    0

    agiledice Active Member
    Banned

    My First Bot

    It works great, just may not work on another screen size. Also I'm not using chrome/firefox/ect, I am using rs linux client.
     
  7. Unread #4 - Sep 30, 2012 at 11:59 AM
  8. wackywamba
    Joined:
    Jul 14, 2005
    Posts:
    1,358
    Referrals:
    0
    Sythe Gold:
    1

    wackywamba Guru

    My First Bot

    You might want to randomize coordinates and delays, just in case.
     
  9. Unread #5 - Sep 30, 2012 at 1:38 PM
  10. agiledice
    Joined:
    Sep 25, 2011
    Posts:
    140
    Referrals:
    0
    Sythe Gold:
    0

    agiledice Active Member
    Banned

    My First Bot

    If you look at it, it does do that.
     
  11. Unread #6 - Sep 30, 2012 at 5:14 PM
  12. wackywamba
    Joined:
    Jul 14, 2005
    Posts:
    1,358
    Referrals:
    0
    Sythe Gold:
    1

    wackywamba Guru

    My First Bot

    Code:
    robot.mouseMove(662, 90);
    
    t=2000;
    robot.delay(t);
    oh sorry, I didn't see these lines which are clearly very random.
     
  13. Unread #7 - Sep 30, 2012 at 6:36 PM
  14. iJava
    Joined:
    Nov 21, 2011
    Posts:
    1,197
    Referrals:
    11
    Sythe Gold:
    485
    Discord Unique ID:
    220055593568829441

    iJava .Previously known as RSGoldRush
    $200 USD Donor New

    My First Bot

    Nice work, however if something were to happen that shouldn't normally then your program wouldn't correct itself, you should look into scripting for a client as this uses your mouse.
     
  15. Unread #8 - Oct 3, 2012 at 7:56 PM
  16. Bubbi
    Joined:
    Jun 9, 2009
    Posts:
    482
    Referrals:
    0
    Sythe Gold:
    14

    Bubbi Forum Addict

    My First Bot

    Saw some flaws here and there. Overall, the whole script was pretty good.
    I made my first one back in 09 I think.
     
< Simplicity | Batch, How do you make a random out come? >

Users viewing this thread
1 guest


 
 
Adblock breaks this site