Advertisement
asciicat

GateStones.java

Jun 5th, 2011
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 14.87 KB | None | 0 0
  1. import java.awt.Color;
  2. import java.awt.Graphics;
  3. import java.awt.Graphics2D;
  4. import java.awt.Image;
  5. import java.awt.RenderingHints;
  6. import org.rsbot.script.Script;
  7. import org.rsbot.script.ScriptManifest;
  8.  
  9. import org.rsbot.script.methods.Skills;
  10. import org.rsbot.script.wrappers.RSObject;
  11. import org.rsbot.script.wrappers.RSTile;
  12. import org.rsbot.script.wrappers.RSArea;
  13.  
  14. import java.awt.event.KeyEvent;
  15. import java.io.IOException;
  16. import java.net.URL;
  17. import javax.imageio.ImageIO;
  18. import javax.swing.JOptionPane;
  19. import org.rsbot.event.listeners.PaintListener;
  20. import org.rsbot.script.methods.Game;
  21.  
  22. @ScriptManifest(authors = "Maze2234", name = "GateStone Maker", version = 2.5, description = "Creates gatestones within daemonheim for magic experience.")
  23.  
  24.  
  25. public class GateStones extends Script implements PaintListener {
  26.  
  27.  
  28. //Variables_______________________________________________________________________
  29.  
  30. private int startExp;
  31. private int gainedExp;
  32. private int startLvl;
  33. private int gainedLvls;
  34. private int currentLevel;
  35. private int percentLevel;
  36. private int mouseSpeed = 1;
  37. private int[] dungLadderID = {51156, 50604, 51704, 54675};
  38. private int ExpHour = 0;
  39. private long startTime;
  40. private long runTime;
  41. private long expLevel;
  42. private boolean checkedSkill = false;
  43.  
  44. private final Image gateStone = getImage("http://rs2basic.webs.com/Images/Gatestone%20(Main).PNG");
  45.  
  46. //Voids & Booleans________________________________________________________________
  47.  
  48. //Locations and Walking
  49. private boolean outSide(){
  50.     RSArea area = new RSArea(new RSTile(3445, 3718), new RSTile(3472, 3729));
  51.     return area.contains(getMyPlayer().getLocation());
  52. }
  53.  
  54. //Clicking Objects
  55. private void clickDoor() {
  56.         antiBan();
  57.     if (objects.getNearest(48496) != null) {
  58.             if (!interfaces.get(236).isValid() && !interfaces.get(210).isValid()) {
  59.                 if (!interfaces.get(947).isValid() && !interfaces.get(938).isValid()) {
  60.                     RSObject dungDoor = objects.getNearest(48496);
  61.                     RSTile doorLocation = objects.getNearest(48496).getLocation();
  62.                     if (!dungDoor.isOnScreen() && doorLocation != null) {
  63.                         walking.walkTileOnScreen(doorLocation);
  64.                         camera.turnTo(dungDoor);
  65.                         //web.getWeb(getMyPlayer().getLocation(), doorLocation).step();
  66.                         sleep(random(1200, 1400));
  67.                     }
  68.                     if (dungDoor.isOnScreen()) {
  69.                         dungDoor.doHover();
  70.                         sleep(random(50, 100));
  71.                         if (menu.contains("Climb-down")) {
  72.                             mouse.click(true);
  73.                             sleep(random(1200, 1600));
  74.                         }
  75.                     }
  76.                 }
  77.             }
  78.     }
  79. }
  80.  
  81. private void clickLadder() {
  82.         antiBan();
  83.     if (objects.getNearest(dungLadderID) != null) {
  84.             if (!interfaces.get(236).isValid() && !interfaces.get(211).isValid()) {
  85.                 RSObject dungLadder = objects.getNearest(dungLadderID);
  86.                 RSTile ladderLocation = objects.getNearest(dungLadderID).getLocation();
  87.                 if (!dungLadder.isOnScreen() && ladderLocation != null) {
  88.                     walking.walkTileOnScreen(ladderLocation);
  89.                     camera.turnTo(dungLadder);
  90.                     //web.getWeb(getMyPlayer().getLocation(), ladderLocation).step();
  91.                     sleep(random(1200, 1400));
  92.                 }
  93.                 if (dungLadder.isOnScreen()) {
  94.                     dungLadder.doHover();
  95.                     sleep(random(50, 100));
  96.                     if (menu.contains("Climb-up")) {
  97.                         mouse.click(true);
  98.                         sleep(random(1500, 1800));
  99.                     }
  100.                 }
  101.             }
  102.         }
  103. }
  104.  
  105. private void clickStairs() {
  106.         antiBan();
  107.     if (objects.getNearest(50552) != null && getMyPlayer().getAnimation() != 13760) {
  108.             RSObject dungStairs = objects.getNearest(50552);
  109.             RSTile stairLocation = objects.getNearest(50552).getLocation();
  110.             if  (!dungStairs.isOnScreen() && stairLocation != null) {
  111.                 walking.walkTileOnScreen(stairLocation);
  112.                 camera.turnTo(dungStairs);
  113.                 //web.getWeb(getMyPlayer().getLocation(), stairLocation).step();
  114.                 sleep(random(1200, 1400));
  115.             }
  116.             if (dungStairs.isOnScreen()) {
  117.                 dungStairs.doHover();
  118.                 sleep(random(50, 100));
  119.                 if (menu.contains("Jump-down")) {
  120.                     mouse.click(true);
  121.                     sleep(random(500, 800));
  122.                 }
  123.             }
  124.     }
  125. }
  126.  
  127. //Exploring Interfaces
  128.  
  129. private void formParty() {
  130.     antiBan();
  131.     if (interfaces.get(210).getComponent(2).isValid()) {
  132.         mouse.setSpeed(mouseSpeed + random(0, 5));
  133.         interfaces.get(210).getComponent(2).doClick();
  134.         sleep(random(300, 400));
  135.     }
  136.     if (interfaces.get(236).getComponent(1).isValid()) {
  137.         mouse.setSpeed(mouseSpeed + random(0, 5));
  138.         interfaces.get(236).getComponent(1).doClick();
  139.         sleep(random(300, 400));
  140.     }
  141. }
  142.  
  143. private void setDifficulty() {
  144.     antiBan();
  145.     if (interfaces.get(947).getComponent(761).isValid()) {
  146.         mouse.setSpeed(mouseSpeed + random(0, 5));
  147.         interfaces.get(947).getComponent(761).doClick();//change floor (finish)
  148.         sleep(random(200, 400));
  149.     }
  150.     if (interfaces.get(938).getComponent(39).isValid()) {
  151.         mouse.setSpeed(mouseSpeed + random(0, 5));
  152.         interfaces.get(938).getComponent(39).doClick();//change complexity (finish)
  153.         sleep(random(200, 400));
  154.     }
  155. }
  156.  
  157. private void setSize() {
  158.     if (interfaces.get(236).getComponent(1).isValid()) {
  159.                 mouse.setSpeed(mouseSpeed + random(0, 5));
  160.                 interfaces.get(236).getComponent(1).doClick();//size (small)
  161.     }
  162. }
  163.  
  164. private void makeStones() {
  165.     if (inventory.contains(17489)) {
  166.                 antiBan();
  167.         mouse.setSpeed(mouseSpeed + random(0, 3));
  168.             inventory.getItem(17489).doAction("Drop");
  169.         keyboard.pressKey((char) KeyEvent.VK_F4);
  170.         sleep(random(75, 100));
  171.         keyboard.releaseKey((char) KeyEvent.VK_F4);
  172.         mouse.setSpeed(mouseSpeed + random(0, 3));
  173.             interfaces.get(950).getComponent(38).doAction("Quick-cast");//make gatestone
  174.         sleep(random(650, 750));
  175.         keyboard.pressKey((char) KeyEvent.VK_F1);
  176.         sleep(random(75, 100));
  177.         keyboard.releaseKey((char) KeyEvent.VK_F1);
  178.     } else if (!inventory.contains(17489)) {
  179.         keyboard.pressKey((char) KeyEvent.VK_F4);
  180.         sleep(random(75, 100));
  181.         keyboard.releaseKey((char) KeyEvent.VK_F4);
  182.         mouse.setSpeed(mouseSpeed + random(0, 3));
  183.             interfaces.get(950).getComponent(38).doAction("Quick-cast");//make gatestone
  184.         keyboard.pressKey((char) KeyEvent.VK_F1);
  185.         sleep(random(75, 100));
  186.         keyboard.releaseKey((char) KeyEvent.VK_F1);
  187.         sleep(random(650, 750));
  188.         }
  189. }
  190.  
  191. private void leaveDung() {
  192.         clickLadder();
  193.         antiBan();
  194.         if (interfaces.get(211).getComponent(3).isValid()) {
  195.         mouse.setSpeed(mouseSpeed + random(0, 5));
  196.             interfaces.get(211).getComponent(3).doClick();//Leave party (Continue)
  197.         sleep(random(800, 1000));
  198.     }
  199.         if (interfaces.get(236).getComponent(1).isValid()) {
  200.         mouse.setSpeed(mouseSpeed + random(0, 5));
  201.             interfaces.get(236).getComponent(1).doClick();//Leave party (Yes)
  202.     }
  203. }
  204.  
  205. //Other
  206.     @Override
  207. public boolean onStart(){
  208.     startExp = skills.getCurrentExp(Skills.MAGIC);
  209.     startLvl = skills.getRealLevel(Skills.MAGIC);
  210.     startTime = System.currentTimeMillis();
  211.     log("Welcome to Maze's GateStone maker.");
  212.         Object[] options = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10"};
  213.         mouseSpeed = (int)JOptionPane.showOptionDialog(null, "Choose the mouse speed for the script: \n" + "(1 being the fastest)", "GateStones",JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, 1);
  214.     return true;
  215. }
  216.  
  217.     @Override
  218. public void onFinish(){
  219.     log("Thanks for using Maze's Gatestone maker.");
  220.     log("You gained "+ (gainedExp) +" experiance and "+ gainedLvls +" magic levels.");
  221.     env.saveScreenshot(true);
  222.     sleep(500);
  223. }
  224.    
  225.    
  226. private String formatTime(final long time) {
  227.     final int sec = (int) (time / 1000), h = sec / 3600, m = sec / 60 % 60, s = sec % 60;
  228.     return (h < 10 ? "0" + h : h) + ":" + (m < 10 ? "0" + m : m) + ":"
  229.             + (s < 10 ? "0" + s : s);
  230. }
  231.  
  232. private Image getImage(String url) {
  233.     try {
  234.         return ImageIO.read(new URL(url));
  235.     } catch (IOException e) {
  236.         return null;
  237.     }
  238. }
  239.  
  240. private void antiBan() {
  241.     int antiBan = random(1, 80);
  242.     mouse.setSpeed(mouseSpeed + random(3, 7));
  243.     switch (antiBan) {
  244.         case 3:
  245.             camera.moveRandomly(1000);
  246.             sleep(random(300, 500));
  247.             break;
  248.         case 5:
  249.             camera.setPitch(random(1, 100));
  250.             sleep(random(300, 500));
  251.             break;
  252.         case 7:
  253.             camera.setAngle(random(50, 500));
  254.             sleep(random(300, 500));
  255.             break;
  256.         case 10:
  257.             RSTile turnTo = new RSTile(getMyPlayer().getLocation().getX() + random(-5, 5), getMyPlayer().getLocation().getY() + random(1, 5), getMyPlayer().getLocation().getZ());
  258.             if (turnTo != null) {
  259.                 camera.turnTo(turnTo, random(0, 10));
  260.                 sleep(random(300, 500));
  261.             }
  262.             break;
  263.         case 15:
  264.             mouse.moveSlightly();
  265.             sleep(random(50, 300));
  266.             break;
  267.         case 20:
  268.             if (random(1, 8) == 2) {
  269.                 mouse.moveOffScreen();
  270.                 sleep(random(1000, 10000));
  271.             }
  272.             break;
  273.         case 25:
  274.             if (random(1, 6) == 3) {
  275.                 game.openTab(Game.TAB_STATS);
  276.                 sleep(random(3000, 5000));
  277.             }
  278.             break;
  279.         case 30:
  280.             if (random(1, 10) == 4) {
  281.                 RSTile walkTo = new RSTile(getMyPlayer().getLocation().getX() + random(-5, 5), getMyPlayer().getLocation().getY() + random(1, 5), getMyPlayer().getLocation().getZ());
  282.                 if (walkTo != null){
  283.                     walking.walkTileOnScreen(walkTo);
  284.                     sleep(random(1000, 3000));
  285.                 }
  286.             }
  287.             break;
  288.         default:
  289.             break;
  290.     }
  291. }
  292.  
  293. //LOOP____________________________________________________________
  294.  
  295. @Override
  296. public int loop() {
  297.  
  298.     if(game.isLoggedIn() && getMyPlayer().isOnScreen()) {
  299.            
  300. //Starting a party
  301.         if(game.getPlane() == 0 && outSide()) {
  302.                    clickDoor();
  303.                    formParty();
  304.                    clickDoor();
  305.                    setDifficulty();
  306.                    setSize();
  307.                 }
  308.  
  309.                 if (!outSide() && game.getPlane() == 0) {
  310. //Making gatestones
  311.                     if (inventory.getCount(true, 16100) >= 3) {
  312.                     makeStones();
  313.                     }
  314. //Leaving Dungeon
  315.                     if (inventory.getCount(true, 16100) <=2 && inventory.getCount(true, 16100) != -1 || inventory.getCount(true, 16100) == -1) {
  316.                     leaveDung();
  317.                     }
  318.                 }
  319.  
  320.         if (game.getPlane() == 1) {
  321.                     mouse.setSpeed(mouseSpeed + random(0, 6));
  322.                     clickStairs(); 
  323.         }
  324.                
  325.     }
  326.  
  327.     return 0;
  328.  
  329. }
  330.  
  331.  
  332.  
  333. //Paint____________________________________________________
  334.  
  335.     @Override
  336.     public void onRepaint(Graphics g1) {
  337.  if(game.isLoggedIn()) {
  338.         final Graphics2D g2 = (Graphics2D) g1;
  339.         g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
  340.         RenderingHints.VALUE_ANTIALIAS_ON);
  341.         currentLevel = skills.getRealLevel(Skills.MAGIC);
  342.         gainedLvls = skills.getRealLevel(Skills.MAGIC) - startLvl;
  343.         gainedExp = skills.getCurrentExp(Skills.MAGIC) - startExp;
  344.         expLevel = skills.getExpToNextLevel(Skills.MAGIC);
  345.         ExpHour = (int) ((3600000.0 / (double) runTime) * gainedExp);
  346.         runTime = System.currentTimeMillis() - startTime;
  347.         percentLevel = skills.getPercentToNextLevel(Skills.MAGIC);
  348.         g2.setColor(Color.BLUE);
  349.                 g2.drawImage(gateStone, 2, 138, null);
  350.         g2.drawString("By: Maze2234", 77, 215);
  351.                 g2.setColor(Color.BLACK);
  352.         g2.drawString("Level: " + currentLevel + " (" + gainedLvls + ")", 80, 245);
  353.                 if (gainedExp /1000 <= 0) {
  354.                     g2.drawString("Gained: " + (gainedExp) + " (" + (ExpHour / 1000) + "K Xp/h)", 57, 260);
  355.                 } else if (gainedExp / 1000 >= 1) {
  356.                     g2.drawString("Gained: " + (gainedExp) / 1000 + "K " + " (" + (ExpHour / 1000) + "K Xp/h)", 57, 260);
  357.                 } else if (gainedExp / 1000000 >= 1) {
  358.                     g2.drawString("Gained: " + (gainedExp) / 1000000 + "M (WOW, Post a prog)" + " (" + (ExpHour / 1000) + "K Xp/h)", 57, 260);
  359.                 }
  360.                 if (expLevel /1000 <= 0) {
  361.         g2.drawString("To Level: " + expLevel, 70, 275);
  362.                 } else if (expLevel /1000 >= 1) {
  363.         g2.drawString("To Level: " + expLevel / 1000 + "K", 70, 275);
  364.                 } else if (expLevel /1000000 >= 1) {
  365.         g2.drawString("To Level: " + expLevel / 1000000 + "M", 70, 275);
  366.                 }
  367.                 if(ExpHour != 0 && gainedExp >= 2000){
  368.                     float timeTNLhour = 0;
  369.                     timeTNLhour = (float) expLevel/(float)ExpHour;
  370.                     float timeTNLmin = timeTNLhour*60;
  371.                     float timeTNLsec = timeTNLmin*60;  
  372.                     int estimatedHour = (int) (timeTNLsec/3600);
  373.                     float tempminutes = timeTNLsec%3600;
  374.                     int estimatedMinutes = (int) (tempminutes/60);
  375.                     int estimatedSeconds = (int) (tempminutes%60);
  376.                     if (estimatedMinutes < 10 && estimatedSeconds < 10) {
  377.                         g2.drawString("Time to Level: " + estimatedHour + ":0" + estimatedMinutes + ":0" + estimatedSeconds, 55, 290);  
  378.                     } else if (estimatedMinutes > 10 && estimatedSeconds < 10) {
  379.                         g2.drawString("Time to Level: " + estimatedHour + ":" + estimatedMinutes + ":0" + estimatedSeconds, 55, 290);  
  380.                     } else if (estimatedMinutes < 10 && estimatedSeconds > 10) {
  381.                         g2.drawString("Time to Level: " + estimatedHour + ":0" + estimatedMinutes + ":" + estimatedSeconds, 55, 290);  
  382.                     } else {
  383.                     g2.drawString("Time to Level: " + estimatedHour + ":" + estimatedMinutes + ":" + estimatedSeconds, 55, 290);
  384.                     }
  385.         } else if (ExpHour == 0 || gainedExp <= 5000) {
  386.                     g2.drawString("Time to Level: N/A", 62, 290);
  387.                 }
  388.             g2.drawString("Run Time: " + formatTime(runTime), 60, 320);
  389.         g2.setColor(Color.BLACK);
  390.         g2.fillRect(65, 330, 100, 4);
  391.         g2.setColor(Color.GREEN);
  392.         g2.fillRect(63, 330, percentLevel, 4);
  393.                
  394.     }
  395.                    
  396.     }
  397.  
  398.  
  399. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement