Advertisement
NissanNut

Alcher v2.1

Mar 28th, 2012
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 10.74 KB | None | 0 0
  1. /*
  2.  * RsTra, iBlink, Nissan Nut.
  3.  * 1.0 01/22/12 First user-made script for RuneDream
  4.  * 1.1 01/23/12 Script sets itself up now
  5.  * 1.2 01/24/12 Improved coordinate choosing
  6.  * 2.0 02/17/12 Added user input for alching coordinates
  7.  * 2.1 03/29/12 Added much more antiban and 2 failsafes
  8.  */
  9.  
  10. import java.awt.*;
  11. import java.awt.event.MouseEvent;
  12. import java.awt.event.MouseListener;
  13. import java.awt.image.BufferedImage;
  14. import java.io.IOException;
  15. import java.net.MalformedURLException;
  16. import java.net.URL;
  17.  
  18. import javax.imageio.ImageIO;
  19.  
  20. import org.runedream.api.Script;
  21. import org.runedream.api.ScriptManifest;
  22. import org.runedream.api.methods.*;
  23. import org.runedream.api.util.Log;
  24. import org.runedream.api.util.Random;
  25.  
  26. @ScriptManifest(
  27.          authors = { "Nissan Nut" },
  28.          name = "Alcher",
  29.          version = 2.1,
  30.          description = "Simple Alcher Script",
  31.          keywords = { "magic", "jbot", "alcher", "Nissan Nut"},
  32.          language = { true, true, true, true })
  33.  
  34. public class Alcher extends Script implements MouseListener{
  35.  
  36.     public long millis = 0;
  37.     public long hours = 0;
  38.     public long minutes = 0;
  39.     public long seconds = 0;
  40.     private long startTime = 0;
  41.     private final Color silver = new Color(215, 215, 215);
  42.     private final Color red = new Color(238, 255, 0);
  43.     private final Color gray = new Color(52, 52, 52);
  44.     private final Color green = new Color(156, 255, 0);
  45.     private final BasicStroke stroke1 = new BasicStroke(1);
  46.     private final Font font1 = new Font("Arial", 0, 9);
  47.     private final Font font2 = new Font("Arial", 1, 10);
  48.     private int xpGained = 0, alch = 0, alchHour = 0, xpHour = 0, FS1 = 0, FS2 = 0;
  49.     private Point Alch, Item, p1, p2;
  50.     private boolean SELECT1, SELECT2;
  51.     BufferedImage normal = null;
  52.     BufferedImage clicked = null;
  53.  
  54.    
  55.         public boolean onStart(){
  56.  
  57.             startTime = System.currentTimeMillis();
  58.             Inventory.open();
  59.             FS2 = Inventory.getCount();
  60.             Log.log("Inventory " + FS2 + "/28 full.");
  61.             Mouse.click(Random.random(734, 759), Random.random(172, 201));
  62.            
  63.             /* Custom Courser */
  64.             Log.log("Loading Custom Cursor...", red);
  65.             try {
  66.                 final URL cursorURL = new URL(
  67.                         "http://www.upload.ee/image/2086209/n.png");
  68.                 final URL cursor80URL = new URL(
  69.                         "http://www.upload.ee/image/2086208/c.png");
  70.                 normal = ImageIO.read(cursorURL);
  71.                 clicked = ImageIO.read(cursor80URL);
  72.             } catch (MalformedURLException e) {
  73.                 Log.log("Unable to buffer cursor.");
  74.             } catch (IOException e) {
  75.                 Log.log("Unable to open cursor image.");
  76.             }
  77.            
  78.             /* Alch Coordinates Setup */
  79.             SELECT1 = true;
  80.             Log.log("Please click in the middle of the high alch button.");
  81.             while(SELECT1){
  82.                 Script.sleep(1000);
  83.             }
  84.             Mouse.click(p1);
  85.             Log.log("Please click in the middle of the item you wish to alch.");
  86.             SELECT2 = true;
  87.             while(SELECT2){
  88.                 Script.sleep(1000);
  89.             }
  90.             Mouse.click(p2);
  91.             Script.sleep(1500, 1700);
  92.             alch++;
  93.             return true;
  94.         }
  95.  
  96.         @Override
  97.         public int loop() {
  98.             Mouse.setSpeed(Random.random(4, 7));
  99.             Alch = new Point(p1.x + Random.random(-7, 7), p1.y + Random.random(-7, 7));
  100.             Item = new Point(p2.x + Random.random(-10, 10), p2.y + Random.random(-10, 10));
  101.            
  102.             Mouse.click(Alch);
  103.             Script.sleep(210, 320);
  104.            
  105.             Mouse.click(Item);
  106.             alch++;
  107.             Script.sleep(1510, 1720);
  108.            
  109.             /* Failsafe */
  110.             if (Inventory.isOpen()){
  111.                 FS1++;
  112.                 alch--;
  113.             }else{
  114.                 FS1 = 0;
  115.             }
  116.            
  117.             if (FS1 == 3){
  118.                 Mouse.click(Random.random(734, 759), Random.random(172, 201));
  119.                 Log.log("Failsafe 1: Lag/Misclick", red);
  120.             }
  121.                
  122.             if (Inventory.isOpen() && Inventory.getCount() < FS2){
  123.                 Log.log("Failsafe 2: Out of runes/items, Script Stopped", green);
  124.                 return - 1;
  125.             }
  126.            
  127.             antiban();         
  128.             return (Random.random(100, 200));
  129.         }
  130.      
  131.         private boolean PointInRect(Point POINT, Rectangle RECT) {
  132.             if (POINT.x >= RECT.x && POINT.x <= (RECT.x + RECT.width) && POINT.y >= RECT.y && POINT.y <= (RECT.y + RECT.height)) {
  133.                 return true;
  134.             }
  135.             return false;
  136.         }// Credits to iBlink, he wrote this.
  137.        
  138.         @Override
  139.         public void onRepaint(Graphics g1) {
  140.             Graphics2D g = (Graphics2D) g1;
  141.             millis = System.currentTimeMillis() - startTime;
  142.             hours = millis / (1000 * 60 * 60);
  143.             millis -= hours * (1000 * 60 * 60);
  144.             minutes = millis / (1000 * 60);
  145.             millis -= minutes * (1000 * 60);
  146.             seconds = millis / 1000;
  147.            
  148.             xpGained = (int) (alch*65);
  149.             if (1200 < ((alch) * 3600000D / (System.currentTimeMillis() - startTime))){
  150.                 alchHour = 1200;
  151.             }else{
  152.                 alchHour = (int) ((alch) * 3600000D / (System.currentTimeMillis() - startTime));
  153.             }
  154.             xpHour = (int) (alchHour*65);
  155.  
  156.             if (SELECT1){
  157.                 g.setColor(silver);
  158.                 g.fillRect(551, 181, 181, 12);
  159.                 g.setColor(red);
  160.                 g.setStroke(stroke1);
  161.                 g.drawRect(551, 181, 181, 12);
  162.                 g.setFont(font1);
  163.                 g.setColor(gray);
  164.                 g.drawString("Click in the middle of the high alch button.", 553, 192);
  165.  
  166.             }else if (SELECT2){
  167.                 g.setColor(silver);
  168.                 g.fillRect(551, 181, 181, 12);
  169.                 g.setColor(red);
  170.                 g.setStroke(stroke1);
  171.                 g.drawRect(551, 181, 181, 12);
  172.                 g.setFont(font1);
  173.                 g.setColor(gray);
  174.                 g.drawString("Click in the middle of item to alch.", 571, 192);
  175.             }
  176.             g.setColor(green);
  177.             g.fillRoundRect(7, 260, 118, 71, 16, 16);
  178.             g.setColor(gray);
  179.             g.setStroke(stroke1);
  180.             g.drawRoundRect(7, 260, 118, 71, 16, 16);
  181.  
  182.             g.setFont(font2);
  183.             g.drawString("Alcher by Nissan Nut", 12, 270);
  184.             g.setFont(font2);
  185.             g.drawString("Runtime: "  + hours +":"+ minutes + ":" + seconds, 12, 282);
  186.             g.drawString("Alchs: " + alch + "±", 12, 294);
  187.             g.drawString("Alchs/Hour: " + alchHour, 12, 306);
  188.             g.drawString("XP Gained: " + xpGained + "±", 12, 318);
  189.             g.drawString("XP/Hour: " + xpHour, 12, 330);               
  190.  
  191.             if (normal != null) {
  192.                 final int xPos = Mouse.getLocation().x;
  193.                 final int yPos = Mouse.getLocation().y;
  194.                 final int xPos2 = Mouse.getPressLocation().x;
  195.                 final int yPos2 = Mouse.getPressLocation().y;
  196.                 final long mpt = System.currentTimeMillis()
  197.                         - Mouse.getPressTime();
  198.                 if (Mouse.getPressTime() == -1 || mpt >= 1000) {
  199.                     g.drawImage(normal, xPos - 8, yPos - 8, null);
  200.                 }
  201.                 if (mpt < 1000) {
  202.                     g.drawImage(clicked, xPos2 - 8, yPos2 - 8, null);
  203.                     g.drawImage(normal, xPos - 8, yPos - 8, null);
  204.                 }
  205.             }//Credits to RsTra from powerbot.
  206.            
  207.        
  208.         }
  209.        
  210.         private void antiban() {
  211.             switch (Random.random(1, 200)){
  212.             case 1:
  213.                 Mouse.moveOffScreen();
  214.                 Script.sleep(1000, 5000);
  215.                 if (Random.random(1, 3) == 1)
  216.                     Script.sleep(1000, 12000);
  217.                 Log.log("Antiban: 1");
  218.                 break;
  219.             case 2:
  220.                 Mouse.moveSlightly();
  221.                 Log.log("Antiban: 2");
  222.                 break;
  223.             case 3:
  224.                 Camera.pitchDown(Random.random(0, 400));
  225.                 Camera.pitchUp(Random.random(0,  500));
  226.                 Log.log("Antiban: 3");
  227.                 break;
  228.             case 4:
  229.                 Inventory.open();
  230.                 Script.sleep(100, 500);
  231.                 Mouse.moveSlightly();
  232.                 Script.sleep(1000, 5000);
  233.                 Mouse.click(Random.random(734, 759), Random.random(170, 203));//Magic tab
  234.                 Script.sleep(100, 500);
  235.                 Log.log("Antiban: 4");
  236.                 break;
  237.             case 5:
  238.                 Script.sleep(1000, 5000);
  239.                 Log.log("Antiban: 5");
  240.                 break;
  241.             case 6:
  242.                 Mouse.click(Random.random(582, 612), Random.random(170, 203));//Skills tab
  243.                 Script.sleep(100, 500);
  244.                 Mouse.move(Random.random(545, 737), Random.random(206, 466));
  245.                 Script.sleep(1000, 5000);
  246.                 Mouse.click(Random.random(734, 759), Random.random(170, 203));//Magic tab
  247.                 Log.log("Antiban: 6");
  248.                 break;
  249.             case 7:
  250.                 Mouse.click(Random.random(582, 612), Random.random(170, 203));//Skills tab
  251.                 Script.sleep(100, 500);
  252.                 Mouse.move(Random.random(545, 737), Random.random(206, 466));
  253.                 Script.sleep(1000, 5000);
  254.                 Mouse.moveSlightly();
  255.                 Script.sleep(1000, 5000);
  256.                 Mouse.click(Random.random(734, 759), Random.random(170, 203));//Magic tab
  257.                 Script.sleep(100, 500);
  258.                 Log.log("Antiban: 7");
  259.                 break;
  260.             case 8:
  261.                 for (int i=0; i<Random.random(1, 4); i++){
  262.                     if (Random.random(1, 10) == 1)
  263.                         Camera.rotateLeft(Random.random(100, 1000));
  264.                     if (Random.random(1, 10) == 1)
  265.                         Camera.rotateRight(Random.random(100, 1000));
  266.                     if (Random.random(1, 10) == 1)
  267.                         Camera.pitchDown(Random.random(100, 1000));
  268.                     if (Random.random(1, 10) == 1)
  269.                         Camera.pitchUp(Random.random(100,  1000));
  270.                     if (Random.random(1, 100) == 1)
  271.                         Game.clickCompass();
  272.                 }
  273.                 Log.log("Antiban: 8");
  274.                 break;
  275.             case 9:
  276.                 Mouse.moveSlightly();
  277.                 Script.sleep(1000, 5000);
  278.                 Mouse.moveSlightly();
  279.                 Log.log("Antiban: 9");
  280.                 break;
  281.             case 10:
  282.                 Mouse.click(Random.random(522, 761), Random.random(170, 203));//Random tab
  283.                 Script.sleep(100, 800);
  284.                 Mouse.move(Random.random(545, 737), Random.random(206, 466));
  285.                 Script.sleep(1000, 4000);
  286.                 Mouse.click(Random.random(734, 759), Random.random(170, 203));//Magic tab
  287.                 Script.sleep(0, 200);
  288.                 Log.log("Antiban: 10");
  289.                 break;
  290.             case 11:
  291.                 Script.sleep(0, 300);
  292.                 Log.log("Antiban: 11");
  293.                 break;
  294.             case 12:
  295.                 Script.sleep(0, 1000);
  296.                 Mouse.moveSlightly();
  297.                 Log.log("Antiban: 12");
  298.                 break;
  299.             }
  300.            
  301.         }
  302.        
  303.         @Override
  304.         public void onStop(){
  305.             Log.log("Runtime: "  + hours +":"+ minutes + ":" + seconds);
  306.             Log.log("Alchs: "+ alch + "±");
  307.             Log.log("Alchs/Hour: "+ alchHour);
  308.             Log.log("XP Gained: "+ xpGained + "±");
  309.             Log.log("XP/Hour: "+ xpHour);
  310.         }
  311.        
  312.         @Override
  313.         public void mouseClicked(MouseEvent e) {
  314.             if (PointInRect(e.getPoint(), Inventory.BOUNDS) && SELECT1) {
  315.                 p1 = e.getPoint();
  316.                 SELECT1 = false;
  317.                 Log.log("Selected Alch location");
  318.             }
  319.             if (PointInRect(e.getPoint(), Inventory.BOUNDS) && SELECT2) {
  320.                 p2 = e.getPoint();
  321.                 SELECT2 = false;
  322.                 Log.log("Selected Item location");
  323.             }
  324.         }
  325.         public void mouseEntered(MouseEvent e) {}
  326.         public void mouseExited(MouseEvent e) {}
  327.         public void mousePressed(MouseEvent e) {}
  328.         public void mouseReleased(MouseEvent e) {}
  329. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement