Don't like ads? PRO users don't see any ads ;-)
Guest

Zammy Telekinetic - ccman32

By: a guest on Jun 9th, 2012  |  syntax: JavaScript  |  size: 12.91 KB  |  hits: 31  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import java.awt.BasicStroke;
  2. import java.awt.Color;
  3. import java.awt.Font;
  4. import java.awt.Graphics;
  5. import java.awt.Graphics2D;
  6. import java.awt.Image;
  7. import java.awt.Point;
  8. import java.awt.event.KeyEvent;
  9. import java.io.IOException;
  10. import java.net.URL;
  11.  
  12. import javax.imageio.ImageIO;
  13.  
  14. import com.rarebot.event.listeners.PaintListener;
  15. import com.rarebot.script.Random;
  16. import com.rarebot.script.Script;
  17. import com.rarebot.script.ScriptManifest;
  18. import com.rarebot.script.methods.Game.Tab;
  19. import com.rarebot.script.methods.Magic;
  20. import com.rarebot.script.methods.Skills;
  21. import com.rarebot.script.util.Timer;
  22. import com.rarebot.script.wrappers.RSArea;
  23. import com.rarebot.script.wrappers.RSGroundItem;
  24. import com.rarebot.script.wrappers.RSObject;
  25. import com.rarebot.script.wrappers.RSTile;
  26. import com.rarebot.script.wrappers.RSTilePath;
  27.  
  28.  
  29. @ScriptManifest(authors = {"ccman32"}, keywords = {"MoneyMaking"}, name = "Zammy Telekinetic", description = "Telegrabs zamorak wine at the Zamorak Altar.", version = 1.0)
  30. public class ZammyTelekinetic extends Script implements PaintListener {
  31.        
  32.         public long startTime;
  33.         private int InvCount = 0;
  34.         public int experiencePerHour;
  35.         private int WineTaken = 0;
  36.         private int WaterRuneID = 555, LawRuneID = 563, ZamorakWineID = 245;
  37.         private int startExperience, experienceGained = 0;
  38.         public String STATUS;
  39.         RSTile[] ToAltar = { new RSTile(3012, 3359), new RSTile(3007, 3362), new RSTile(3001, 3364), new RSTile(2995, 3367), new RSTile(2989, 3371), new RSTile(2984, 3375), new RSTile(2979, 3378), new RSTile(2969, 3380), new RSTile(2966, 3386), new RSTile(2965, 3392), new RSTile(2965, 3398), new RSTile(2965, 3404), new RSTile(2962, 3414), new RSTile(2954, 3420), new RSTile(2948, 3425), new RSTile(2948, 3431), new RSTile(2948, 3438), new RSTile(2947, 3447), new RSTile(2947, 3455), new RSTile(3948, 3461), new RSTile(2950, 3467), new RSTile(2948, 3473) };
  40.         RSTilePath ToAltar1;
  41.         RSTile[] ToBank = { new RSTile(2970, 3379), new RSTile(2976, 3379), new RSTile(2983, 3376), new RSTile(2988, 3372), new RSTile(2994, 3367), new RSTile(3000, 3363), new RSTile(3007, 3363), new RSTile(3012, 3356)};
  42.         RSTilePath ToBank1;
  43.         RSTile TelegrabTile = new RSTile(2947, 3473);
  44.         RSTile WineTile = new RSTile(2946, 3473);
  45.         public RSArea FaladorBankArea = new RSArea(new RSTile(3009, 3355, 0),new RSTile(3018, 3358, 0));
  46.         public RSArea AltarArea = new RSArea(new RSTile(2946, 3472, 0),new RSTile(2952, 3475, 0));
  47.        
  48.         public boolean onStart() {
  49.                 mouse.setSpeed(2);
  50.                 startTime = System.currentTimeMillis();
  51.                 startExperience = skills.getCurrentExp(Skills.MAGIC);
  52.                 ToAltar1 = walking.newTilePath(ToAltar);
  53.                 ToBank1 = walking.newTilePath(ToBank);
  54.                 if (!game.isLoggedIn()) {
  55.                         log.severe("Please start the script logged in!");
  56.                         stopScript();
  57.                         return false;
  58.                 }
  59.                 log(Color.RED, "Script successfully started.");
  60.                 log(Color.RED, "You must have an Air staff equipped or the script will not work!");
  61.                 camera.setNorth();
  62.                 camera.setPitch(100);
  63.                
  64.                 return true;
  65.         }
  66.        
  67.         public void WaitForMove() {
  68.         Timer timer = new Timer(Random.random(1700, 2000));
  69.         while (!getMyPlayer().isMoving()) {
  70.             sleep(Random.random(10, 50));
  71.             if (!timer.isRunning()) {
  72.                 break;
  73.             }
  74.         }
  75.         while (getMyPlayer().isMoving()) {
  76.             sleep(Random.random(40, 100));
  77.         }
  78.     }
  79.        
  80.         public int loop() {
  81.                 if(game.isLoginScreen()) {
  82.                         game.login();
  83.                 }
  84.                 RSObject Table = objects.getNearest(15573);
  85.                 if(atAltar() && !Table.isOnScreen()){
  86.                         camera.turnTo(Table);
  87.                        
  88.                 }
  89.                  turnRunOn();
  90.                  antiBan();
  91.                  if (walking.getEnergy() < Random.random(1, 80)) {
  92.                          walking.rest();
  93.              sleep(Random.random(100, 1000));
  94.                  }
  95.                  if (game.getTab() == Tab.INVENTORY) {
  96.                                 if (InvCount < inventory.getCount(ZamorakWineID)) {
  97.                                         WineTaken++;
  98.                                         InvCount = inventory.getCount(ZamorakWineID);
  99.                                 } else if (inventory.getCount(ZamorakWineID) == 0) {
  100.                                         InvCount = 0;
  101.                                 }
  102.                         }
  103.                 experienceGained = skills.getCurrentExp(Skills.MAGIC) - startExperience;
  104.                 if (!atAltar() && !atBank()) {
  105.                         if(inventory.contains(LawRuneID) && inventory.contains(WaterRuneID) && !inventory.isFull()) {
  106.                                 walkToAltar();
  107.                         } else {
  108.                                 if(inventory.isFull()){
  109.                                 STATUS = "Walking to bank";
  110.                                 ToBank1.traverse();
  111.                                 WaitForMove();
  112.                                 }
  113.                                 if((!inventory.contains(LawRuneID) || !inventory.contains(WaterRuneID)) && !atBank())  {
  114.                                         log.severe("No law or water runes left! Stopping script...");
  115.                                         stopScript();
  116.                                 }
  117.                                 }
  118.                         }
  119.                
  120.  
  121.                         if(atBank()) {
  122.                                 if(inventory.isFull()) {
  123.                                         bankItems();
  124.                                 } else {
  125.                                         walkToAltar();
  126.                                 }
  127.                 }
  128.                 if (!hasTeleportRunes()) {
  129.                         if (inventory.isFull() && !atBank()) {
  130.                                 log.severe("No teleport runes left! Stopping script...");
  131.                                 stopScript();
  132.                         }
  133.                 }
  134.                 if (atAltar() && inventory.isFull()) {
  135.                         FaladorTeleport();     
  136.                 }
  137.         if (atAltar() && !inventory.isFull()) {
  138.                 telegrabWine();
  139.         }
  140.        
  141.         return 0;
  142.     }
  143.        
  144.          public void turnRunOn() {
  145.                 if (!walking.isRunEnabled() && walking.getEnergy() > 30) {
  146.                     walking.setRun(true);
  147.                     sleep(1000);
  148.                 }
  149.             }
  150.        
  151.         private void FaladorTeleport() {
  152.                 STATUS = "Teleporting to Falador";
  153.                 magic.castSpell(Magic.SPELL_FALADOR_TELEPORT);
  154.                 sleep(500, 800);
  155.                 while (!getMyPlayer().isIdle()) {
  156.                         sleep(200, 300);
  157.                 }
  158.         }
  159.        
  160.         private void bankItems() {
  161.                
  162.                 if (bank.isOpen()) {
  163.             Timer timer = new Timer(2000);
  164.             while (inventory.getCount() > 2) {
  165.                 if (!timer.isRunning()) {
  166.                     return;
  167.                 }
  168.                 STATUS = "Depositing wine";
  169.                 bank.depositAllExcept(LawRuneID, WaterRuneID);
  170.                 sleep(1000);
  171.             }
  172.         } else {
  173.                 STATUS = "Opening bank";
  174.             bank.open();
  175.         }
  176.     }
  177.                
  178.          public void f(int i){
  179.          char k = (i == 1 ? (char)KeyEvent.VK_F1 :  (char)KeyEvent.VK_F4);
  180.          keyboard.pressKey(k);
  181.          sleep(random(25,150));
  182.          keyboard.releaseKey(k);
  183.  }
  184.        
  185.         private void telegrabWine() {
  186.                 RSGroundItem Wine = groundItems.getNearest(ZamorakWineID);
  187.  
  188.                 if (calc.distanceTo(TelegrabTile) > 0)
  189.                         walking.walkTileOnScreen(TelegrabTile);
  190.                 if (Wine == null && !magic.isSpellSelected()){
  191.                         STATUS = "Opening Spell book";
  192.                         game.openTab(Tab.MAGIC);
  193.                         magic.hoverSpell(Magic.SPELL_TELEKINETIC_GRAB);
  194.                         STATUS = "Selecting spell";
  195.                         mouse.click(true);
  196.                         sleep(Random.random(10, 1000));
  197.                         f(1);
  198.                         STATUS = "Moving mouse over table";
  199.                         mouse.move(calc.tileToScreen(WineTile));
  200.                         Point currentPos = mouse.getLocation();
  201.                         int currentPosx = currentPos.x;
  202.                         int currentPosy = currentPos.y;
  203.                         mouse.move(currentPosx, (currentPosy + (Random.random(2, 8))));
  204.                         mouse.moveRandomly(0, 4);
  205.             STATUS = "Waiting for wine to spawn";
  206.                 }
  207.  
  208.                 if (Wine != null) {
  209.                         if(!magic.isSpellSelected()) {
  210.                                 STATUS = "Opening Spell book";
  211.                                 game.openTab(Tab.MAGIC);
  212.                                 magic.hoverSpell(Magic.SPELL_TELEKINETIC_GRAB);
  213.                                 STATUS = "Selecting spell";
  214.                                 mouse.click(true);
  215.                                 sleep(Random.random(10, 300));
  216.                                 f(1);
  217.                         }
  218.                         if(magic.isSpellSelected()) {
  219.                                 if (Wine.isOnScreen()) {
  220.                                         InvCount = inventory.getCount(ZamorakWineID);
  221.                                         Wine.interact("Cast");
  222.                                         STATUS = "Telegrabbing wine";
  223.                                         sleep(1000, 1500);
  224.                                                 while (!getMyPlayer().isIdle()) {
  225.                                                 sleep(100, 300);
  226.                                 }
  227.                                
  228.                         } else {
  229.                                 sleep(50, 100);
  230.                         }
  231.                 } else {
  232.                         sleep(50, 100);
  233.                 }
  234.                 }
  235.         }
  236.        
  237.         private void walkToAltar() {
  238.                 STATUS = "Walking to altar";
  239.                 ToAltar1.traverse();
  240.                 WaitForMove();
  241.         }
  242.        
  243.  
  244.         private boolean hasTeleportRunes() {
  245.                 return inventory.getCount(WaterRuneID) > 0
  246.                                 && inventory.getCount(LawRuneID) > 0;
  247.         }
  248.        
  249.          public boolean atAltar() {
  250.                 return AltarArea.contains(getMyPlayer().getLocation());
  251.             }
  252.          
  253.          public boolean atBank() {
  254.                 return FaladorBankArea.contains(getMyPlayer().getLocation());
  255.             }
  256.  
  257.         private Image getImage(String url) {
  258.         try {
  259.             return ImageIO.read(new URL(url));
  260.         } catch(IOException e) {
  261.             return null;
  262.         }
  263.     }
  264.        
  265.         private void antiBan() {
  266.                 int num = random(0,10000);
  267.                         switch(num) {
  268.                                
  269.                                 case 5:
  270.                                         STATUS = "Antiban";
  271.                                         mouse.moveOffScreen();
  272.                                         if (atAltar() && !inventory.isFull()) {
  273.                                                 mouse.move(calc.tileToScreen(WineTile));
  274.                                                 Point currentPos = mouse.getLocation();
  275.                                                 int currentPosx = currentPos.x;
  276.                                                 int currentPosy = currentPos.y;
  277.                                                 mouse.move(currentPosx, (currentPosy + (Random.random(2, 8))));
  278.                                                 mouse.moveRandomly(0, 4);
  279.                                         }
  280.                                         break;
  281.                                 case 10:
  282.                                         STATUS = "Antiban";
  283.                                         mouse.moveSlightly();
  284.                                         sleep(random(300, 500));
  285.                                         if (atAltar() && !inventory.isFull()) {
  286.                                                 mouse.move(calc.tileToScreen(WineTile));
  287.                                                 Point currentPos = mouse.getLocation();
  288.                                                 int currentPosx = currentPos.x;
  289.                                                 int currentPosy = currentPos.y;
  290.                                                 mouse.move(currentPosx, (currentPosy + (Random.random(2, 8))));
  291.                                                 mouse.moveRandomly(0, 4);
  292.                                         }
  293.                                         break;
  294.                                 case 15:
  295.                                         STATUS = "Antiban";
  296.                                         skills.doHover(Skills.INTERFACE_MAGIC);
  297.                                         sleep(random(2100, 3200));
  298.                                         if (atAltar() && !inventory.isFull()) {
  299.                                                 mouse.move(calc.tileToScreen(WineTile));
  300.                                                 Point currentPos = mouse.getLocation();
  301.                                                 int currentPosx = currentPos.x;
  302.                                                 int currentPosy = currentPos.y;
  303.                                                 mouse.move(currentPosx, (currentPosy + (Random.random(2, 8))));
  304.                                                 mouse.moveRandomly(0, 4);
  305.                                         }
  306.                                         break;
  307.                                 case 20:
  308.                                         STATUS = "Antiban";
  309.                                         mouse.moveRandomly(Random.random(1, 1000));
  310.                                         if (atAltar() && !inventory.isFull()) {
  311.                                                 mouse.move(calc.tileToScreen(WineTile));
  312.                                                 Point currentPos = mouse.getLocation();
  313.                                                 int currentPosx = currentPos.x;
  314.                                                 int currentPosy = currentPos.y;
  315.                                                 mouse.move(currentPosx, (currentPosy + (Random.random(2, 8))));
  316.                                                 mouse.moveRandomly(0, 4);
  317.                                         }
  318.                                         break;
  319.                    default:
  320.                         break;
  321.                 }
  322.             }
  323.  
  324.     private final Color color1 = new Color(0, 102, 102);
  325.     private final Color color2 = new Color(0, 0, 0);
  326.     private final Color color3 = new Color(111, 110, 110);
  327.     private final Color color4 = new Color(204, 51, 0);
  328.     private final Color color5 = new Color(255, 255, 255);
  329.  
  330.     private final BasicStroke stroke1 = new BasicStroke(1);
  331.  
  332.     private final Font font1 = new Font("MV Boli", 0, 28);
  333.     private final Font font2 = new Font("Calibri", 0, 15);
  334.  
  335.     private final Image img1 = getImage("http://ccman32web.webs.com/Zammy%20Telekinetic%20for%20rarebot/WineOfZamorak.png");
  336.     private final Image img2 = getImage("http://ccman32web.webs.com/Zammy%20Telekinetic%20for%20rarebot/coins.gif");
  337.     private final Image img3 = getImage("http://ccman32web.webs.com/Zammy%20Telekinetic%20for%20rarebot/Law_Rune_Detail.png");
  338.  
  339.     public void onRepaint(Graphics g1) {
  340.         Long runtime = System.currentTimeMillis() - startTime;
  341.         int hours = 0;
  342.         while (runtime > 3600000) {
  343.             hours++;
  344.             runtime -= 3600000;
  345.         }
  346.         int minutes = 0;
  347.         while (runtime > 60000) {
  348.             minutes++;
  349.             runtime -= 60000;
  350.         }
  351.         int seconds = 0;
  352.         while (runtime > 1000) {
  353.             seconds++;
  354.             runtime -= 1000;
  355.         }
  356.         float WinesPerSec = 0;
  357.         if ((minutes > 0 || hours > 0 || seconds > 0) && (WineTaken) > 0) {
  358.                         WinesPerSec = ((float) (WineTaken)) / (float) (seconds + (minutes * 60) + (hours * 60 * 60));
  359.         }
  360.         int WinesPerHour = (int) (WinesPerSec * 3600);
  361.         Graphics2D g = (Graphics2D)g1;
  362.         g.setColor(Color.WHITE);
  363.         g.drawLine(0, (int) mouse.getLocation().getY(), game.getWidth(), (int) mouse.getLocation().getY());
  364.         g.drawLine((int) mouse.getLocation().getX(), 0, (int) mouse.getLocation().getX(), game.getHeight());
  365.         g.setColor(color1);
  366.         g.fillRect(6, 344, 506, 129);
  367.         g.setColor(color2);
  368.         g.setStroke(stroke1);
  369.         g.drawRect(6, 344, 506, 129);
  370.         g.setColor(color3);
  371.         g.fillRoundRect(19, 357, 481, 104, 16, 16);
  372.         g.setColor(color2);
  373.         g.drawRoundRect(19, 357, 481, 104, 16, 16);
  374.         g.setFont(font1);
  375.         g.setColor(color4);
  376.         g.drawString("Zammy Telekinetic", 130, 380);
  377.         g.drawImage(img1, 433, 378, null);
  378.         g.drawImage(img2, -1, 339, null);
  379.         g.drawImage(img2, 471, 339, null);
  380.         g.drawImage(img2, 471, 435, null);
  381.         g.drawImage(img2, -1, 435, null);
  382.         g.drawImage(img3, 36, 374, null);
  383.         g.setFont(font2);
  384.         g.setColor(color5);
  385.         g.drawString("Runtime: " + hours + ":" + minutes + ":" + seconds , 110, 405);
  386.         g.drawString("Wine collected: " + WineTaken, 110, 430);
  387.         g.drawString("Wines/Hour: " + WinesPerHour, 295, 405);
  388.         g.drawString("XP Gained: " + experienceGained, 295, 430);
  389.         g.drawString("Status: " + STATUS, 4, 335);
  390.    
  391.                
  392.         }
  393.  
  394.  
  395. }