NissanNut

Alcher V2.0

Feb 17th, 2012
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 7.91 KB | None | 0 0
  1. /*
  2.  * Nissan Nut
  3.  * Mouse credits to RsTra
  4.  */
  5.  
  6. import java.awt.*;
  7. import java.awt.event.MouseEvent;
  8. import java.awt.event.MouseListener;
  9. import java.awt.image.BufferedImage;
  10. import java.io.IOException;
  11. import java.net.MalformedURLException;
  12. import java.net.URL;
  13.  
  14. import javax.imageio.ImageIO;
  15.  
  16. import org.runedream.api.Script;
  17. import org.runedream.api.ScriptManifest;
  18. import org.runedream.api.methods.*;
  19. import org.runedream.api.util.Log;
  20. import org.runedream.api.util.Random;
  21.  
  22. @ScriptManifest(
  23.          authors = { "Nissan Nut" },
  24.          name = "Alcher",
  25.          version = 2.0,
  26.          description = "Simple Alcher Script",
  27.          keywords = { "magic", "jbot", "alcher", "Nissan Nut"},
  28.          language = { true, true, true, true })
  29.  
  30. public class Alcher extends Script implements MouseListener{
  31.  
  32.     public long millis = 0;
  33.     public long hours = 0;
  34.     public long minutes = 0;
  35.     public long seconds = 0;
  36.     private long startTime = 0;
  37.     private final Color silver = new Color(215, 215, 215);
  38.     private final Color red = new Color(238, 255, 0);
  39.     private final Color gray = new Color(52, 52, 52);
  40.     private final Color green = new Color(156, 255, 0);
  41.     private final BasicStroke stroke1 = new BasicStroke(1);
  42.     private final BasicStroke stroke3 = new BasicStroke(3);
  43.     private final Font font1 = new Font("Arial", 0, 9);
  44.     private final Font font2 = new Font("Arial", 1, 10);
  45.     private int xpGained = 0, alch = 0, alchHour = 0, xpHour = 0;
  46.     private Point book = new Point(Random.random(734, 759), Random.random(172, 201));
  47.     private Point Alch, Item, p1, p2;
  48.     private boolean SELECT1, SELECT2;
  49.     BufferedImage normal = null;
  50.     BufferedImage clicked = null;
  51.  
  52.    
  53.         public boolean onStart(){
  54.  
  55.             Mouse.click(book);
  56.             startTime = System.currentTimeMillis();
  57.            
  58.             try {
  59.                 final URL cursorURL = new URL(
  60.                         "http://www.upload.ee/image/2086209/n.png");
  61.                 final URL cursor80URL = new URL(
  62.                         "http://www.upload.ee/image/2086208/c.png");
  63.                 normal = ImageIO.read(cursorURL);
  64.                 clicked = ImageIO.read(cursor80URL);
  65.             } catch (MalformedURLException e) {
  66.                 Log.log("Unable to buffer cursor.");
  67.             } catch (IOException e) {
  68.                 Log.log("Unable to open cursor image.");
  69.             }
  70.             SELECT1 = true;
  71.             while(SELECT1){
  72.                 Script.sleep(1000);
  73.             }
  74.             Mouse.click(p1);
  75.             SELECT2 = true;
  76.             while(SELECT2){
  77.                 Script.sleep(1000);
  78.             }
  79.             Mouse.click(p2);
  80.             Script.sleep(1500, 1700);
  81.             alch++;
  82.             return true;
  83.         }
  84.  
  85.         @Override
  86.         public int loop() {
  87.             Mouse.setSpeed(Random.random(4, 7));
  88.             Alch = new Point(p1.x + Random.random(-7, 7), p1.y + Random.random(-7, 7));
  89.             Item = new Point(p2.x + Random.random(-10, 10), p2.y + Random.random(-10, 10));
  90.            
  91.             Mouse.click(Alch);
  92.             Script.sleep(210, 320);
  93.             Mouse.click(Item);
  94.             alch++;
  95.             Script.sleep(1510, 1720);
  96.             antiban();         
  97.             return 1;
  98.         }
  99.      
  100.         private boolean PointInRect(Point POINT, Rectangle RECT) {
  101.             if (POINT.x >= RECT.x && POINT.x <= (RECT.x + RECT.width) && POINT.y >= RECT.y && POINT.y <= (RECT.y + RECT.height)) {
  102.                 return true;
  103.             }
  104.             return false;
  105.         }// Credits to iBlink, he wrote this.
  106.        
  107.         @Override
  108.         public void onRepaint(Graphics g1) {
  109.             Graphics2D g = (Graphics2D) g1;
  110.             millis = System.currentTimeMillis() - startTime;
  111.             hours = millis / (1000 * 60 * 60);
  112.             millis -= hours * (1000 * 60 * 60);
  113.             minutes = millis / (1000 * 60);
  114.             millis -= minutes * (1000 * 60);
  115.             seconds = millis / 1000;
  116.            
  117.             xpGained = (int) (alch*65);
  118.             if (1200 < ((alch) * 3600000D / (System.currentTimeMillis() - startTime))){
  119.                 alchHour = 1200;
  120.             }else{
  121.                 alchHour = (int) ((alch) * 3600000D / (System.currentTimeMillis() - startTime));
  122.             }
  123.             xpHour = (int) (alchHour*65);
  124.  
  125.             if (SELECT1){
  126.                 g.setColor(silver);
  127.                 g.fillRect(551, 181, 181, 12);
  128.                 g.setColor(red);
  129.                 g.setStroke(stroke1);
  130.                 g.drawRect(551, 181, 181, 12);
  131.                 g.setFont(font1);
  132.                 g.setColor(gray);
  133.                 g.drawString("Click in the middle of the high alch button.", 553, 192);
  134.  
  135.             }else if (SELECT2){
  136.                 g.setColor(silver);
  137.                 g.fillRect(551, 181, 181, 12);
  138.                 g.setColor(red);
  139.                 g.setStroke(stroke1);
  140.                 g.drawRect(551, 181, 181, 12);
  141.                 g.setFont(font1);
  142.                 g.setColor(gray);
  143.                 g.drawString("Click in the middle of item to alch.", 571, 192);
  144.             }
  145.             g.setColor(green);
  146.             g.fillRoundRect(7, 260, 118, 71, 16, 16);
  147.             g.setColor(gray);
  148.             g.setStroke(stroke1);
  149.             g.drawRoundRect(7, 260, 118, 71, 16, 16);
  150.  
  151.             g.setFont(font2);
  152.             g.drawString("Alcher by Nissan Nut", 12, 270);
  153.             g.setFont(font2);
  154.             g.drawString("Runtime: "  + hours +":"+ minutes + ":" + seconds, 12, 282);
  155.             g.drawString("Alchs: "+ alch, 12, 294);
  156.             g.drawString("Alchs/Hour: "+ alchHour, 12, 306);
  157.             g.drawString("XP Gained: "+ xpGained, 12, 318);
  158.             g.drawString("XP/Hour: "+ xpHour, 12, 330);            
  159.  
  160.             if (p1 != null && p2 != null){
  161.                 g.setColor(silver);
  162.                 g.setStroke(stroke3);
  163.                
  164.                    g.drawLine(p1.x, p1.y - 4, p1.x, p1.y + 4);                 
  165.                    g.drawLine(p1.x - 4, p1.y, p1.x + 4, p1.y);
  166.                    
  167.                    g.drawLine(p2.x, p2.y - 4, p2.x, p2.y + 4);
  168.                    g.drawLine(p2.x - 4, p2.y, p2.x + 4, p2.y);
  169.  
  170.                
  171.             }
  172.             if (normal != null) {
  173.                 final int xPos = Mouse.getLocation().x;
  174.                 final int yPos = Mouse.getLocation().y;
  175.                 final int xPos2 = Mouse.getPressLocation().x;
  176.                 final int yPos2 = Mouse.getPressLocation().y;
  177.                 final long mpt = System.currentTimeMillis()
  178.                         - Mouse.getPressTime();
  179.                 if (Mouse.getPressTime() == -1 || mpt >= 1000) {
  180.                     g.drawImage(normal, xPos - 8, yPos - 8, null);
  181.                 }
  182.                 if (mpt < 1000) {
  183.                     g.drawImage(clicked, xPos2 - 8, yPos2 - 8, null);
  184.                     g.drawImage(normal, xPos - 8, yPos - 8, null);
  185.                 }
  186.             }//Credits to RsTra from powerbot.
  187.            
  188.        
  189.         }
  190.        
  191.         private void antiban() {
  192.             switch (Random.random(1, 100)){
  193.             case 1:
  194.                 Mouse.moveOffScreen();
  195.                 Script.sleep(1000, 3000);
  196.                 break;
  197.             case 2:
  198.                 Mouse.moveSlightly();
  199.                 break;
  200.             case 3:
  201.                 Camera.pitchDown(Random.random(0, 100));
  202.                 Camera.pitchUp(Random.random(0,  200));
  203.                 break;
  204.             case 4:
  205.                 Inventory.open();
  206.                 Script.sleep(100, 500);
  207.                 Mouse.moveSlightly();
  208.                 Script.sleep(1000, 3000);
  209.                 Mouse.click(book);
  210.                 Script.sleep(100, 500);
  211.                 break;
  212.             case 5:
  213.                 Script.sleep(1000, 3000);
  214.                 break;
  215.             }
  216.            
  217.         }
  218.        
  219.         @Override
  220.         public void onStop(){
  221.             Log.log("Runtime: "  + hours +":"+ minutes + ":" + seconds);
  222.             Log.log("Alchs: "+ alch);
  223.             Log.log("Alchs/Hour: "+ alchHour);
  224.             Log.log("XP Gained: "+ xpGained);
  225.             Log.log("XP/Hour: "+ xpHour);
  226.         }
  227.        
  228.         @Override
  229.         public void mouseClicked(MouseEvent e) {
  230.             if (PointInRect(e.getPoint(), Inventory.BOUNDS) && SELECT1) {
  231.                 p1 = e.getPoint();
  232.                 SELECT1 = false;
  233.                 Log.log("Selected Alch location");
  234.             }
  235.             if (PointInRect(e.getPoint(), Inventory.BOUNDS) && SELECT2) {
  236.                 p2 = e.getPoint();
  237.                 SELECT2 = false;
  238.                 Log.log("Selected Item location");
  239.             }
  240.         }
  241.         public void mouseEntered(MouseEvent e) {}
  242.         public void mouseExited(MouseEvent e) {}
  243.         public void mousePressed(MouseEvent e) {}
  244.         public void mouseReleased(MouseEvent e) {}
  245. }
Advertisement
Add Comment
Please, Sign In to add comment