Advertisement
Guest User

Untitled

a guest
Sep 15th, 2015
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.77 KB | None | 0 0
  1. package scripts.genchant;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Font;
  5. import java.awt.Graphics;
  6. import java.awt.Graphics2D;
  7. import java.awt.Image;
  8. import java.io.IOException;
  9. import java.net.URL;
  10.  
  11. import javax.imageio.ImageIO;
  12.  
  13. import org.tribot.api.Timing;
  14. import org.tribot.api.input.Mouse;
  15. import org.tribot.api.util.ABCUtil;
  16. import org.tribot.api2007.Banking;
  17. import org.tribot.api2007.Inventory;
  18. import org.tribot.api2007.Login;
  19. import org.tribot.api2007.Magic;
  20. import org.tribot.api2007.Skills;
  21. import org.tribot.api2007.Login.STATE;
  22. import org.tribot.api2007.Skills.SKILLS;
  23. import org.tribot.api2007.types.RSItem;
  24. import org.tribot.script.Script;
  25. import org.tribot.script.ScriptManifest;
  26. import org.tribot.script.interfaces.Painting;
  27.  
  28. @ScriptManifest(authors = { "Genka" }, category = "Magic", name = "GEnchant")
  29. public class main extends Script implements Painting{
  30.     ABCUtil abc = new ABCUtil();
  31.     private boolean alive = true;
  32.     private int startXp = Skills.getXP(SKILLS.MAGIC);
  33.     private long lastBusyTime = System.currentTimeMillis();
  34.     static String spell = "";
  35.     static int itemToEnchant = 1639;
  36.     int cosmicID = 564;
  37.     GUI gui = new GUI();
  38.    
  39.     @Override
  40.     public void run() {
  41.         gui.setVisible(true);
  42.         while(gui.isVisible()){
  43.             sleep(300);
  44.         }
  45.         while(alive){
  46.             if(!Banking.isBankScreenOpen()){
  47.                 abc.performTimedActions(SKILLS.MAGIC);
  48.             }
  49.             if(Inventory.find(itemToEnchant).length > 0 && Inventory.find(cosmicID).length > 0){
  50.                 if(Banking.isBankScreenOpen()){
  51.                     Banking.close();
  52.                 }
  53.                 if(!Magic.isSpellSelected()){
  54.                     Magic.selectSpell(spell);
  55.                 }
  56.                 if(Magic.isSpellSelected()){
  57.                     if(!Magic.getSelectedSpellName().equals(spell)){
  58.                         println(Magic.getSelectedSpellName());
  59.                         Mouse.click(1);
  60.                     }
  61.                     if(Inventory.find(itemToEnchant).length > 0){
  62.                         if(Inventory.getAll().length > 1 && Inventory.getAll()[Inventory.getAll().length - 1].getID() == itemToEnchant && Inventory.getAll()[Inventory.getAll().length -2 ].getID() == 2552){
  63.                         Inventory.find(itemToEnchant)[0].click("Cast");
  64.                         sleep(1000, 2000);
  65.                         } else {
  66.                             Inventory.find(itemToEnchant)[0].click("Cast");
  67.                             abc.waitNewOrSwitchDelay(lastBusyTime, false);
  68.                         }
  69.                     }
  70.                 }
  71.             } else {
  72.                 if(Banking.isBankScreenOpen()){
  73.                     if(Inventory.getAll().length > 1){
  74.                         Banking.depositAllExcept(cosmicID);
  75.                         long t = System.currentTimeMillis();
  76.                         while(Inventory.getAll().length > 1 && Timing.timeFromMark(t) < 2000){
  77.                             sleep(10,300);
  78.                         }
  79.                     } else {
  80.                         if(Magic.isSpellSelected()){
  81.                             Mouse.click(1);
  82.                         }
  83.                         if(Inventory.find(cosmicID).length == 0){
  84.                             RSItem[] cosmics = Banking.find(cosmicID);
  85.                             RSItem[] enchant = Banking.find(itemToEnchant);
  86.                             if((cosmics.length == 0 || enchant.length == 0) && Banking.getAll().length > 0){
  87.                                 println("Out of supplies");
  88.                                 long t = System.currentTimeMillis();
  89.                                 while(Login.getLoginState() == STATE.INGAME && Timing.timeFromMark(t) < 20000){
  90.                                     sleep(100,500);
  91.                                     Banking.close();
  92.                                     Login.logout();
  93.                                 }
  94.                                 if(Login.getLoginState() == STATE.LOGINSCREEN){
  95.                                     alive = false;
  96.                                 }
  97.                             }
  98.                             Banking.withdraw(1000, cosmicID);
  99.                         }
  100.                         Banking.withdraw(0, itemToEnchant);
  101.                         long t = System.currentTimeMillis();
  102.                         while(Inventory.find(itemToEnchant).length == 0 && Timing.timeFromMark(t) < 3000){
  103.                             sleep(10,300);
  104.                         }
  105.                     }
  106.                 } else if(!Banking.isBankScreenOpen()){
  107.                     Banking.openBank();
  108.                     long t = System.currentTimeMillis();
  109.                     while(!Banking.isBankScreenOpen() && Timing.timeFromMark(t) < 2000){
  110.                         sleep(10,300);
  111.                     }
  112.                 }              
  113.             }
  114.             sleep(10, 50);
  115.         }
  116.        
  117.     }
  118.    
  119.     //START: Code generated using Enfilade's Easel
  120.     private Image getImage(String url) {
  121.         try {
  122.             return ImageIO.read(new URL(url));
  123.         } catch(IOException e) {
  124.             return null;
  125.         }
  126.     }
  127.  
  128.     private final Color color1 = new Color(255, 255, 255);
  129.  
  130.     private final Font font1 = new Font("Arial", 0, 10);
  131.  
  132.     private final Image img1 = getImage("http://i.imgur.com/zwBUJ0i.png");
  133.  
  134.     public void onPaint(Graphics g1) {
  135.         double multiplier = getRunningTime() / 3600000.0D;
  136.         int xpPerHour = (int) ((Skills.getXP(SKILLS.MAGIC) - startXp) / multiplier);       
  137.         Graphics2D g = (Graphics2D)g1;
  138.         g.drawImage(img1, 277, 345, null);
  139.         g.setFont(font1);
  140.         g.setColor(color1);
  141.         g.drawString("Runtime: " + Timing.msToString(getRunningTime()), 366, 409);
  142.         g.drawString("RC level: " + Skills.getActualLevel(SKILLS.MAGIC), 366, 421);
  143.         g.drawString("XP: "  + (Skills.getXP(SKILLS.MAGIC) - startXp) + " (" + xpPerHour + ")", 366, 433);
  144.     }
  145.     //END: Code generated using Enfilade's Easel
  146.  
  147. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement