Advertisement
deww1

tabMakerFree.java

May 30th, 2011
883
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 18.43 KB | None | 0 0
  1. import org.rsbot.script.*;
  2. import org.rsbot.script.wrappers.*;
  3. import org.rsbot.script.methods.*;
  4. import org.rsbot.event.listeners.PaintListener;
  5.  
  6. import java.awt.image.BufferedImage;
  7. import java.awt.*;
  8.  
  9. import javax.imageio.ImageIO;
  10.  
  11. import java.io.IOException;
  12.  
  13. import java.net.MalformedURLException;
  14. import java.net.URL;
  15.  
  16.  
  17. @ScriptManifest(authors = {"Dew"}, keywords = {"Home", "Construction", "Moneymaking"}, name = "Tab Maker Premium", description = "start with Demon Butler following and by your lectern", version = 0.83)
  18.  
  19. public class tabMakerFree extends Script implements PaintListener {
  20.    
  21.     public static final int AIR_STAFF = 1381;
  22.     public static final int SOFT_CLAY = 1761;  
  23.     public static final int LAW_RUNE = 563;
  24.     public static final int GP = 995;
  25.     public int tabID = 0;    
  26.     public int tabPrice = 0;
  27.     private Double ver = tabMakerFree.class.getAnnotation(ScriptManifest.class).version();
  28.     //public int lumbtele = 8008;
  29.     //public int ardotele = 8011;
  30.     //public int cametele = 8010;
  31.     //public int falatele = 8009;
  32.     //public int houstele = 8013;
  33.     public int varrtele = 8007;
  34.     //public int btbtele = 8014;
  35.     //public int btptele = 8015;
  36.     //public int enditele = 8019;
  37.     //public int endrtele = 8020;
  38.     //public int enemtele = 8017;
  39.     //public int enontele = 8021;
  40.     //public int enrutele = 8018;
  41.     //public int ensatele = 8016;
  42.     //public int watctele = 8012;
  43.     public boolean paying = false;
  44.     public boolean useAirStaff;
  45.     public boolean moneyInBank;
  46.     public boolean enterAmount = false;
  47.     public boolean sleeper = true;
  48.     public int studyAnim = 3652;
  49.  
  50.     public int startTabs = 0;
  51.     public int nowTabs = 0;
  52.     public int tabHr = 0;
  53.     public int lvlsGained = 0;
  54.  
  55.     public long startTime = 0;
  56.     public long millis = 0;
  57.     public long hours = 0;
  58.     public long minutes = 0;
  59.     public long seconds = 0;
  60.  
  61.     private String status = "Setting up";
  62.  
  63.     BufferedImage normal = null;
  64.     BufferedImage clicked = null;
  65.     public String cursorU;//Cursor unclicked
  66.     public String cursorC;//Cursor clicked
  67.  
  68.     public int check1 = 0;
  69.     public int check2 = 0;
  70.  
  71.     private org.rsbot.script.util.Timer checkTimer = new org.rsbot.script.util.Timer(15000);
  72.     private org.rsbot.script.util.Timer interTimer = new org.rsbot.script.util.Timer(10000); //10 sec
  73.    
  74.     ///////
  75.     ///AntibanStuff
  76.     ///////
  77.     int antiMisClick = 0;
  78.    
  79.    
  80.     public static final int[] LECTERN_IDS = new int[] { 13642, 13643,
  81.                                    13644, 13645, 13646, 13647, 13648 };
  82.    
  83.     public static final int[] BUTLER_IDS = new int[] { 4241, 4243 };
  84.    
  85.     public static final int TAB_INTERFACE = 400;
  86.    
  87.    
  88.  
  89.  
  90.     public boolean checkLaws() {
  91.         if (inventory.contains(LAW_RUNE)) {
  92.             return true;
  93.         }
  94.         return false;
  95.     }
  96.     public int invCheck() {
  97.         check1 = inventory.getCount(SOFT_CLAY);
  98.         return check1;
  99.     }
  100.    
  101.  
  102.  
  103.     // <editor-fold defaultstate="collapsed" desc="making the tabs">
  104. //this checks if the tab interface is open or not.
  105.     //true if it is false if not
  106.     public boolean checkTabInterface() {
  107.         RSInterface inter = interfaces.get(TAB_INTERFACE);
  108.         RSComponent com = inter.getComponent(tabID);
  109.         if (inter.isValid() && inter != null) {
  110.             return true;
  111.         }
  112.  
  113.         return false;
  114.     }
  115.     //this opens the tab making interface
  116.  
  117.     public void openTabInterface() {
  118.         RSObject lect = objects.getNearest(LECTERN_IDS);
  119.         RSInterface inter = interfaces.get(TAB_INTERFACE);
  120.         if (!checkTabInterface()) {
  121.             if (lect != null) {
  122.                 if (lect.isOnScreen()) {
  123.                     lect.doAction("Study");
  124.                     sleep(2000, 5000);
  125.                 } else {
  126.                     walking.walkTo(lect.getLocation());
  127.                 }
  128.             } else {
  129.                 sleep(1000, 1250);
  130.             }
  131.         } else {
  132.             makeTabs();
  133.         }
  134.     }
  135.     //this makes the tabs
  136.  
  137.     public void makeTabs() {
  138.         RSComponent com = interfaces.get(TAB_INTERFACE).getComponent(tabID);
  139.         if (checkTabInterface()) {
  140.             if (com.isValid()) {
  141.                 if (com.isValid()) {
  142.                     com.doAction("Make-all");
  143.                     sleeper = true;
  144.                     sleep(5000, 6000);
  145.                 }
  146.             }
  147.         }
  148.     }// </editor-fold>
  149.     // <editor-fold defaultstate="collapsed" desc="onStart Checks">
  150. //checks if inventory contains any clay at all
  151.     //true if contains clay, false if not
  152.     public boolean checkClays() {
  153.         if (inventory.contains(SOFT_CLAY)) {
  154.             check2 = inventory.getCount(SOFT_CLAY);
  155.             return true;
  156.         }
  157.         return false;
  158.     }
  159.  
  160.     public boolean checkLectOnScreen() {
  161.         RSObject lect = objects.getNearest(LECTERN_IDS);
  162.         if (lect.isOnScreen()) {
  163.             return true;
  164.         }
  165.         return false;
  166.     }
  167.     //checks if inventory contains money
  168.     //true if does, false if doesn't
  169.     public boolean moneyInBank() {
  170.         if (inventory.contains(GP)) {
  171.             return false;
  172.         }
  173.         return true;
  174.     }
  175.     //checks if inventory contains an air staff
  176.     //true if contains one, if true equips false if doesn't contain one
  177.     public boolean useAirStaff() {
  178.         if (inventory.contains(AIR_STAFF)) {
  179.             inventory.getItem(AIR_STAFF).doClick(true);
  180.             return true;
  181.         }
  182.         return false;
  183.     }// </editor-fold>
  184.     public int checkItem(int item) {
  185.         if (inventory.contains(item)) {
  186.             inventory.getCount(item);
  187.         }
  188.         return item;
  189.     }
  190.  
  191.     @Override
  192.     public boolean onStart() {
  193.         cursorU = "http://i360.photobucket.com/albums/oo47/perez048/mouseReg.png";
  194.         cursorC = "http://i360.photobucket.com/albums/oo47/perez048/mouseClicked.png";
  195.  
  196.         while (game.isLoginScreen() || game.isWelcomeScreen()) {
  197.             log("Waiting to be logged in...");
  198.             sleep(1000);
  199.         }
  200.         /*if (!checkLectOnScreen()) {
  201.             log("Please go to your study room and start this script!");
  202.             return false;
  203.         }*/
  204.         log("If you are using an air staff, leave it unequipped!");
  205.         if (!moneyInBank()) {
  206.             log("We have money in inventory. we will use this money!");
  207.         } else {
  208.             log("No money in our inventory! We will use money from the bank.");
  209.         }
  210.         if (useAirStaff()) {
  211.             log("using Air Staff!");
  212.         } else {
  213.             log("Using Air Runes!");
  214.         }
  215.         tabID = 15;
  216.         useAirStaff = useAirStaff();
  217.         moneyInBank = moneyInBank();
  218.         startTabs = checkItem(varrtele);
  219.         log("");
  220.         log("Thank you for choosing Deww1's Tab Maker!");
  221.         log("Make sure to start with demon butler following and by your lectern!");
  222.         log("This bot has not had much testing, so I need feedback! ");
  223.         try {
  224.               final URL cursorURL = new URL(cursorU);
  225.               final URL cursor80URL = new URL(cursorC);
  226.             normal = ImageIO.read(cursorURL);
  227.             clicked = ImageIO.read(cursor80URL);
  228.         } catch (MalformedURLException e) {
  229.             log("Unable to buffer cursor.");
  230.         } catch (IOException e) {
  231.             log("Unable to open cursor image.");
  232.         }
  233.         startTime = System.currentTimeMillis();
  234.  
  235.         return true;
  236.     }
  237.  
  238.     public int loop() {
  239.         checkLevelUp();
  240.         nowTabs = startTabs - checkItem(varrtele);
  241.         checkLaws();
  242.         if (!checkLaws()) {
  243.             status = "Stopping Script.";
  244.             log("out of laws.. Stopping Script.");
  245.             onFinish();
  246.         }
  247.         log("check1 ="+ check1 + " : check2 = " +check2);
  248.         invCheck();
  249.         while (sleeper) {
  250.             status = "Sleeping...(zzz)";
  251.             if (!inventory.contains(SOFT_CLAY)) {
  252.                 sleeper = false;
  253.             } else {
  254.                 if (invCheck() != check2) {
  255.                     checkTimer.reset();
  256.                 } else {
  257.                     sleeper = false;
  258.                 }
  259.                 sleep(500, 1250);
  260.             }
  261.         }
  262.         //test();
  263.         if (checkIfPayButler()) {
  264.             status = "Paying Butler.";
  265.             paying = true;
  266.             payButler();
  267.         }
  268.         if (!paying)
  269.         if (!checkClays()) {
  270.             if (!fetchClayInterface()) {
  271.                 clickButlerToFetch();
  272.             } else {
  273.                 status = "Fetching Clay From Bank.";
  274.                 fetchClays();
  275.             }
  276.         } else {
  277.             if (checkTabInterface()) {
  278.                 status = "Making Tabs.";
  279.                 makeTabs();
  280.             } else {
  281.                 status = "Opening Tab Interface.";
  282.                 openTabInterface();
  283.             }
  284.         }
  285.         return random(500,800);
  286.     }
  287.  
  288.     // <editor-fold defaultstate="collapsed" desc="onFinish">
  289.     @Override
  290.     public void onFinish() {
  291.         log("Thank you for using Tab Maker Free! By Deww1.");
  292.         log("Visit my thread and post some feedback!");
  293.         env.saveScreenshot(false);
  294.     }// </editor-fold>
  295.  
  296.     // <editor-fold defaultstate="collapsed" desc="paying butler stuff">
  297.     public void payButler() {
  298.         RSInterface inter = interfaces.get(243); //butler interface
  299.         RSComponent com = inter.getComponent(4); //contains text my services
  300.         RSComponent cont = inter.getComponent(7); //continue button
  301.  
  302.         RSInterface inter2 = interfaces.get(232); //butler pay interface
  303.         RSComponent pay1 = inter2.getComponent(2); //pay from inventory
  304.         RSComponent pay2 = inter2.getComponent(3); //pay from bank
  305.         if (inter != null && inter.isValid()) {
  306.             if (com != null && com.isValid()) {
  307.                 if (com.containsText("my continued service")) {
  308.                     if (cont != null && cont.isValid()) {
  309.                         cont.doClick(true);
  310.                     }
  311.                 }
  312.             }
  313.         } else if (inter2 != null && inter2.isValid()) {
  314.             if (!moneyInBank()) {
  315.                 if (pay1 != null && pay1.isValid()) {
  316.                     if (pay1.containsText("coins")) {
  317.                         pay1.doClick(true);
  318.                 log("We are paying our butler 10k!");
  319.                 paying = false;
  320.                 sleep(1000, 1250);
  321.                     }
  322.                 }
  323.             } else {
  324.                 if (pay2 != null && pay2.isValid()) {
  325.                     if (pay2.containsText("bank")) {
  326.                         pay2.doClick(true);
  327.                 log("We are paying our butler 10k!");
  328.                 paying = false;
  329.                 sleep(1000, 1250);
  330.                     }
  331.                 }
  332.             }
  333.         }
  334.     }
  335.  
  336.     public boolean checkIfPayButler() {
  337.         RSInterface inter = interfaces.get(243); //butler interface
  338.         RSInterface inter2 = interfaces.get(232); //butler pay interface
  339.        
  340.         RSComponent com = inter.getComponent(4); //contains text my services
  341.         RSComponent pay1 = inter2.getComponent(2); //pay from inventory
  342.         RSComponent pay2 = inter2.getComponent(3); //pay from bank
  343.         if (inter != null && inter.isValid()
  344.                 || inter2 != null && inter2.isValid()) {
  345.             if (com.containsText("my continued service")
  346.                     || pay1.containsText("coins")
  347.                     || pay2.containsText("bank")) {
  348.                 return true;
  349.             }
  350.         }
  351.         return false;
  352.     }// </editor-fold>
  353.    
  354.     public void test() {
  355.         RSInterface inter = interfaces.get(232); //fetch interface
  356.         RSInterface inter2 = interfaces.get(234); //clay page
  357.         RSInterface inter3 = interfaces.get(752); //enter amount page
  358.        
  359.         RSComponent com1 = inter.getComponent(5); //MORE component
  360.         RSComponent com2 = inter2.getComponent(3); //SOFT_CLAY component
  361.         RSComponent com3 = inter3.getComponent(4); //ENTER AMOUNT: component
  362.        
  363.        
  364.         if (!inter.isValid() && inter2.isValid()) {
  365.             log("test1");
  366.         }
  367.         if (inter.isValid() && !inter2.isValid()) {
  368.             log("test2");
  369.         }
  370.         if (!com3.containsText("amount")) {
  371.             log("test3");
  372.         }
  373.         stopScript();
  374.     }
  375.    
  376.    
  377.     // <editor-fold defaultstate="collapsed" desc="fetching methods">
  378.     public boolean fetchClayInterface() {
  379.         RSInterface inter = interfaces.get(232); //fetch interface
  380.         RSInterface inter2 = interfaces.get(234); //clay page
  381.         RSInterface inter3 = interfaces.get(752); //enter amount page
  382.        
  383.         RSComponent com1 = inter.getComponent(5); //MORE component
  384.         RSComponent com2 = inter2.getComponent(3); //SOFT_CLAY component
  385.         RSComponent com3 = inter3.getComponent(4); //ENTER AMOUNT: component
  386.        
  387.         if (!inter.isValid() && !inter2.isValid()) {
  388.             return false;
  389.         }
  390.         return true;
  391.     }
  392.  
  393.     public void clickButlerToFetch() {
  394.         RSNPC butler = npcs.getNearest(BUTLER_IDS);
  395.         if (butler != null) {
  396.             if (butler.isOnScreen()) {
  397.                 butler.doAction("Fetch-from-bank");
  398.                 sleep(1500, 2000);
  399.             } else {
  400.                 walking.walkTo(butler.getLocation());
  401.             }
  402.         }
  403.     }
  404.  
  405.     public void fetchClays() {
  406.         RSInterface inter = interfaces.get(232); //fetch interface
  407.         RSInterface inter2 = interfaces.get(234); //clay page
  408.         RSInterface inter3 = interfaces.get(752); //enter amount page
  409.        
  410.         RSComponent com1 = inter.getComponent(5); //MORE component
  411.         RSComponent com2 = inter2.getComponent(3); //SOFT_CLAY component
  412.         RSComponent com3 = inter3.getComponent(4); //ENTER AMOUNT: component
  413.         RSComponent com4 = inter2.getComponent(2); //GET MORE
  414.             if (inter2 != null && inter2.isValid() &&
  415.                 com4 != null && com4.isValid()) {
  416.                     if (com4.containsText("another 24")) {
  417.                         com4.doClick(true);
  418.                         sleep(1000, 1250);
  419.                         check2 = 24;
  420.                     } else {
  421.                     }
  422.             } else {
  423.             if (inter != null && inter.isValid()) {
  424.                 if (com1 != null && com1.isValid()) {
  425.                     if (com1.containsText("ore")) {
  426.                         com1.doClick(true);
  427.                         sleep(800, 1400);
  428.                     }
  429.                 }
  430.             }
  431.             if (inter2 != null && inter2.isValid()) {
  432.                 if (com2 != null && com2.isValid()) {
  433.                     if (com2.containsText("clay")) {
  434.                         com2.doClick(true);
  435.                         enterAmount = true;
  436.                         sleep(800, 1400);
  437.                     }
  438.                 }
  439.             }
  440.             if (inter3 != null && inter3.isValid()) {
  441.                 if (com3 != null && com3.isValid()) {
  442.                     if (com3.containsText("amount") && enterAmount) {
  443.                         keyboard.sendText("24", true);
  444.                         check2 = 24;
  445.                         enterAmount = false;
  446.                         sleep(1000, 1400);
  447.                     }
  448.                 }
  449.             }
  450.         }
  451.     }// </editor-fold>
  452.  
  453.     public void checkLevelUp() {
  454.         RSInterface inter = interfaces.get(740);
  455.         RSComponent com1 = inter.getComponent(0);
  456.         RSComponent com2 = inter.getComponent(3);
  457.  
  458.         if (inter != null && inter.isValid()) {
  459.             if (com1 != null && com1.isValid()) {
  460.                 if (com2 != null && com2.isValid()) {
  461.                     log("You Leveled up!");
  462.                     walking.walkTileOnScreen(getMyPlayer().getLocation());
  463.                     lvlsGained++;
  464.                 }
  465.             }
  466.         }
  467.     }
  468.  
  469.  
  470.         //START: Code generated using Enfilade's Easel
  471.     private final Color color1 = new Color(0, 153, 0, 155);
  472.     private final Color color2 = new Color(0, 0, 0);
  473.     private final Color color3 = new Color(255, 255, 255);
  474.  
  475.     private final BasicStroke stroke1 = new BasicStroke(1);
  476.  
  477.     private final Font font1 = new Font("Calibri", 0, 15);
  478.  
  479.     public void onRepaint(Graphics g1) {
  480.         Graphics2D g = (Graphics2D)g1;
  481.         if (normal != null) {
  482.  
  483.             final int mouse_x = mouse.getLocation().x;
  484.             final int mouse_y = mouse.getLocation().y;
  485.             final int mouse_x2 = mouse.getPressLocation().x;
  486.             final int mouse_y2 = mouse.getPressLocation().y;
  487.             final long mpt = System.currentTimeMillis()
  488.                     - mouse.getPressTime();
  489.             if (mouse.getPressTime() == -1 || mpt >= 1000) {
  490.                 g.drawImage(normal, mouse_x - 8, mouse_y - 8, null); //this show the mouse when its not clicked
  491.             }
  492.             if (mpt < 1000) {
  493.                 g.drawImage(clicked, mouse_x2 - 8, mouse_y2 - 8, null); //this show the four squares where you clicked.
  494.                 g.drawImage(normal, mouse_x - 8, mouse_y - 8, null); //this show the mouse as normal when its/just clicked
  495.             }
  496.         }
  497.         tabHr = (int) ((nowTabs) * 3600000D / (System.currentTimeMillis() - startTime));
  498.         millis = System.currentTimeMillis() - startTime;
  499.         hours = millis / (1000 * 60 * 60);
  500.         millis -= hours * (1000 * 60 * 60);
  501.         minutes = millis / (1000 * 60);
  502.         millis -= minutes * (1000 * 60);
  503.         seconds = millis / 1000;
  504.         g.setColor(color1);
  505.         g.fillRect(2, 290, 514, 48);
  506.         g.setColor(color2);
  507.         g.setStroke(stroke1);
  508.         g.drawRect(2, 290, 514, 48);
  509.         g.setColor(color1);
  510.         g.fillRect(298, 339, 218, 140);
  511.         g.setColor(color2);
  512.         g.drawRect(298, 339, 218, 140);
  513.         g.setFont(font1);
  514.         g.setColor(color3);
  515.         g.drawString("Run Time: "+ hours + ":" + minutes + ":" + seconds, 301, 366);
  516.         g.drawString("Total Tabs Made: "+nowTabs, 301, 396);
  517.         g.drawString("Tabs Per Hour: "+tabHr, 301, 426);
  518.         g.drawString("Total Money Made:", 301, 456);
  519.         g.drawString("Script Status: "+status, 4, 335);
  520.         g.drawString("Script Written by : Deww1", 5, 311);
  521.         g.drawString("Script Version: "+ver, 381, 337);
  522.         g.drawString("Automatic Tablet Maker FREE", 333, 311);
  523.     }
  524.     //END: Code generated using Enfilade's Easel
  525. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement