Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 18.30 KB | None | 0 0
  1. import java.awt.*;
  2. import java.awt.event.MouseEvent;
  3. import java.awt.event.MouseListener;
  4.  
  5. import javax.imageio.ImageIO;
  6. import javax.swing.DefaultComboBoxModel;
  7. import javax.swing.JButton;
  8. import javax.swing.JCheckBox;
  9. import javax.swing.JComboBox;
  10. import javax.swing.JFileChooser;
  11. import javax.swing.JFrame;
  12. import javax.swing.JLabel;
  13. import javax.swing.JOptionPane;
  14. import javax.swing.JPanel;
  15. import javax.swing.JTabbedPane;
  16. import javax.swing.JTextField;
  17.  
  18. import org.rsbot.event.events.ServerMessageEvent;
  19. import org.rsbot.event.listeners.PaintListener;
  20. import org.rsbot.event.listeners.ServerMessageListener;
  21. import org.rsbot.script.Script;
  22. import org.rsbot.script.ScriptManifest;
  23. import org.rsbot.script.methods.Skills;
  24. import org.rsbot.script.util.Filter;
  25. import org.rsbot.script.wrappers.RSTile;
  26. import org.rsbot.script.wrappers.RSObject;
  27. import org.rsbot.script.wrappers.RSNPC;
  28. import org.rsbot.script.wrappers.RSArea;
  29. import org.rsbot.script.wrappers.RSItem;
  30. import org.rsbot.script.wrappers.RSComponent;
  31.  
  32. @ScriptManifest(name = "konzy's Master Stealer", authors = "konzy", keywords = "Thieving",
  33.         version = 0.51, description = "Master Farmer Thieving by konzy")
  34.        
  35. public class konzyMasterStealer extends Script implements PaintListener, ServerMessageListener , MouseListener
  36. {
  37.  
  38.       final ScriptManifest properties = getClass().getAnnotation(ScriptManifest.class);
  39.  
  40.  
  41.     static final RSArea MARKET_AREA = new RSArea(new RSTile(3069, 3245), new RSTile(3086, 3258));
  42.     static final RSArea BANK_AREA = new RSArea(new RSTile(3092,3240),new RSTile(3097,3246));
  43.     static final RSArea WALK_AREA = new RSArea(new RSTile(3088,3247),new RSTile(3097,3250));
  44.     static final RSTile MARKET_TO_BANK[] = {new RSTile(3084,3249), new RSTile(3089,3249), new RSTile(3092,3248), new RSTile(3093,3245)};
  45.     static final RSTile MARKET_TILE = new RSTile(3080,3250);
  46.     static final RSTile BANK_TILE = new RSTile(3093,3244);
  47.     static final RSTile EXIT_TILE = new RSTile(3092,3249);
  48.     static final RSTile CENTRAL_TILE = new RSTile(3085,3249);
  49.     static final RSTile PATH_TO_BANK[] = {CENTRAL_TILE , BANK_TILE};
  50.     static final RSTile PATH_FROM_BANK[] = {EXIT_TILE , CENTRAL_TILE};
  51.     static final int[] KEEP_ID = {
  52.         5100, 5295, 5296, 5298, 5299, 5300, 5301, 5302, 5303, 5304,
  53.         5320, 5321, 5323};
  54.     static final String KEEP_NAME[] = {
  55.         "impwurt", "anarr", "oadflax", "vantoe", "wuarm",
  56.         "napdragon", "adantine", "antadyme", "warf", "orstol",
  57.         "weetcorn", "atermelon", "trawberry"};
  58.     static final int[] DONT_DROP_ID = {
  59.         617, 1733, 1734, 10115, 10075, 10076
  60.     };
  61.     static final int[] DROP_ID = {
  62.         5319, 5307, 5305, 5322, 5099, 5310, 5308, 5102, 5294, 5309,
  63.         5101, 5096, 5324, 5306, 5291, 5103, 5292, 5097, 5281, 5098,
  64.         5105, 5106, 5280, 5297, 5311, 5104, 5293, 5318, 5282, 1993,
  65.         1937};
  66.  
  67.     static final int KEEP_ID_COUNT = 13;
  68.     static final int DROP_ID_COUNT = 31;
  69.     static final int DONT_DROP_ID_COUNT = 6;
  70.     static final int FARMER_ID = 2234;
  71.     static final int BOOTH_ID = 2213;
  72.     static final int STUNNED_ID = 424;
  73.  
  74.  
  75.  
  76.    
  77.     //private boolean guiWait = true, guiExit;
  78.     private boolean dropSeeds = false;
  79.     private boolean failedPick = false;
  80.     private int profit = 0;
  81.     private int withdrawFood = 5;
  82.    
  83.     private int foodPrice = 0;
  84.     private int HP;
  85.     private int startLvl;
  86.     private int gainedLvls;
  87.     private int startXP = 0;
  88.     private int succeedPickpockets = 0;
  89.     private int failPickpockets = 0;
  90.     private int foodEaten = 0;
  91.     private long startTime;
  92.     private String status = "";
  93.     private boolean  showPaint;
  94.     private int completeIDs[][] = new int[3][KEEP_ID_COUNT];
  95.     private int totalComplete = 0;
  96.     private RSItem carriedFood;
  97.     private RSNPC masterFarmer;
  98.     private boolean justAttacked = false;
  99.    
  100.     public boolean onStart() {
  101.         if(!game.isLoggedIn()) {
  102.             log("Start logged in.");
  103.             return false;
  104.         }
  105.        
  106. /*     
  107.         startScript = false;
  108.         konzyMasterStealerGUI gui = new konzyMasterStealerGUI();
  109.         while(!startScript) {
  110.             if(!gui.isVisible())
  111.                 return false;
  112.             sleep(100);
  113.         }
  114. */
  115.        
  116.         carriedFood = getFood();
  117.        
  118.         if (carriedFood != null){
  119.             try {
  120.                 status = "Getting Prices";
  121.                 foodPrice = grandExchange.getMarketPrice(carriedFood.getID());
  122.             } catch (Exception e) {}
  123.         }else {
  124.             log("Please start with food in your inventory.");
  125.             return false;
  126.         }
  127.         log("The Item ID of your food is " + carriedFood.getID());
  128.         startTime = (int)System.currentTimeMillis();
  129.         startXP = skills.getCurrentExp(Skills.THIEVING);
  130.         startLvl = skills.getCurrentLevel(Skills.THIEVING);
  131.         showPaint = true;
  132.         return true;
  133.     }
  134.    
  135.     private RSItem getFood(){
  136.         for(RSItem i : inventory.getItems()) {
  137.             if(i == null || i.getID() == -1)
  138.                 continue;
  139.             if (i.getComponent().getActions() == null || i.getComponent().getActions()[0] == null)
  140.                 continue;
  141.             if (i.getComponent().getActions()[0].contains("Eat")){
  142.                 return i;
  143.             }  
  144.         }
  145.         return null;
  146.     }
  147.       private void hoverFarmer(){
  148.           if(npcs.getNearest("Master Farmer").isValid()){
  149.               if(npcs.getNearest("Master Farmer").isOnScreen()){
  150.                   Point farmerScreenLoc = npcs.getNearest("Master Farmer").getScreenLocation();
  151.                   int x = mouse.getLocation().x;
  152.                   int y =  mouse.getLocation().y;
  153.                   int x2 = farmerScreenLoc.x;
  154.                   int y2 = farmerScreenLoc.y;
  155.                   int xdiff;
  156.                   int ydiff;
  157.                   if(x > x2)
  158.                       xdiff = x - x2;
  159.                   else
  160.                   xdiff = x2 - x;
  161.                   if(y > y2)
  162.                       ydiff = y - y2;
  163.                   else
  164.                   ydiff = y2 - y;
  165.                  
  166.                   if(ydiff > 75 || xdiff > 75)
  167.                   try{
  168.                       mouse.move(farmerScreenLoc);
  169.                   }catch (Exception e){}
  170.               }
  171.           }
  172.     }
  173.    
  174.       private int getCurrentLifepoint() {
  175.           if (interfaces.get(748).getComponent(8).getText() != null && interfaces.get(748).getComponent(8).isValid()) {
  176.               HP = Integer.parseInt(interfaces.get(748).getComponent(8).getText());
  177.               }
  178.             return HP;
  179.           }
  180.      
  181.     public boolean isHealthLow() {
  182.         int CurrHP = getCurrentLifepoint() / 10;
  183.         int RealHP = skills.getRealLevel(Skills.CONSTITUTION);
  184.         if (CurrHP <= random(RealHP / 2, RealHP / 1.5)) {
  185.             status = "Eating Food";
  186.             return true;
  187.         }
  188.         if (getMyPlayer().getHPPercent() <= 10) {
  189.             log.warning("HP less than 10% Logging out.");
  190.             game.logout(true);
  191.             stopScript(true);
  192.           }    
  193.         return false;
  194.     }
  195.    
  196.     private final Filter<RSNPC> npcFilter = new Filter<RSNPC>() {
  197.         public boolean accept(RSNPC t) {
  198.                 if(t.getName().equals("Master Farmer"))
  199.                     return false;
  200.             return (t.isValid() && t.isInCombat() && t.isInteractingWithLocalPlayer() && t.getHPPercent() != 0);
  201.         }
  202.     };
  203.  
  204.  
  205.    
  206.     public boolean gettingAttacked(){
  207.         RSNPC mGuard[] = npcs.getAll(npcFilter);
  208.         if (mGuard != null && getMyPlayer().isInCombat())
  209.         return true;
  210.    
  211.     return false;
  212.     }
  213.    
  214.     private boolean eatFood() {
  215.         for(int i = 0; i < 3; i++) {
  216.             if(!inventory.contains(carriedFood.getID())){
  217.                 log("cant find food");
  218.                 break;
  219.             }
  220.             if(carriedFood.doAction("Eat")) {
  221.                 profit -= foodPrice;
  222.                 return true;
  223.             }
  224.         }
  225.         return false;
  226.     }
  227.    
  228.     public boolean openBank() {
  229.         status = "Opening Bank";
  230.         if(!bank.isOpen()){
  231.             if (objects.getNearest(BOOTH_ID).isOnScreen()) {
  232.                 final RSObject bankBooth = objects.getNearest(BOOTH_ID);
  233.                 if (bankBooth != null) {
  234.                     bankBooth.doAction("Use-Quickly");
  235.                     }
  236.                 }
  237.             return false;
  238.             }
  239.         return true;
  240.     }
  241.  
  242.  
  243.     public int loop(){
  244.         antiBan(false);
  245.         if(isHealthLow()){
  246.             carriedFood = getFood();
  247.             eatFood();
  248.             return random(25, 50);
  249.         }
  250.         if (justAttacked && !BANK_AREA.contains(getMyPlayer().getLocation())){
  251.             status = "RUN AWAY!!!";
  252.             walking.setRun(true);
  253.             walking.walkPathMM(PATH_TO_BANK , 1 , 1);
  254.             antiBan(true);
  255.             return random(3000, 5000);
  256.         }else
  257.             justAttacked = false;
  258.         if(!inventory.contains(carriedFood.getID()) || inventory.isFull()){
  259.             if(!BANK_AREA.contains(getMyPlayer().getLocation())){
  260.                 status = "Walking To Bank";
  261.                 walking.walkPathMM(PATH_TO_BANK , 1 , 1);
  262.             }
  263.             else if(!bank.isOpen())
  264.            
  265.                     openBank();
  266.                 else if(inventory.getCount() >= 1){
  267.                             status = "Depositing";
  268.                             bank.depositAll();
  269.                     } else if (bank.getCount(carriedFood.getID()) == 0 && game.isLoggedIn()) {
  270.                                 log("Out of food! logging out...");
  271.                                 sleep(random(4000, 5000));
  272.                                 bank.close();
  273.                                 game.logout(true);
  274.                                 stopScript(true);
  275.                               }else if (withdrawFood > inventory.getCount(carriedFood.getID()) ){
  276.                                       try{
  277.                                           if (withdrawFood - inventory.getCount(carriedFood.getID()) >= 10)
  278.                                               bank.getItem(carriedFood.getID()).doAction("Withdraw-10");
  279.                                           else
  280.                                               bank.getItem(carriedFood.getID()).doAction("Withdraw-5");
  281.                                       }catch (Exception e){}
  282.                                       if(bank.close()){
  283.                                           antiBan(true);
  284.                                           return random(100, 250);
  285.                                       }
  286.                                      
  287.                                   }
  288.             return random(1500, 2000);
  289.         }
  290.  
  291.         if (BANK_AREA.contains(getMyPlayer().getLocation())){
  292.             status = "Walking Back To Market";
  293.             walking.walkPathMM(PATH_FROM_BANK);
  294.             return random(1000 , 1500);
  295.         }
  296.         if (!MARKET_AREA.contains(getMyPlayer().getLocation())){
  297.             walking.walkTileMM(CENTRAL_TILE , 2 , 2);
  298.             return random(1000 , 1500);
  299.         }else if (failedPick){
  300.                     status = "failed";
  301.                     if(isHealthLow()){
  302.                         carriedFood = getFood();
  303.                         eatFood();
  304.                         antiBan(true);
  305.                     }
  306.                     if (inventory.containsOneOf(DROP_ID) && dropSeeds) {
  307.                         status = "Dropping Seeds";
  308.                         int dontDrop[] = {};
  309.                         int i;
  310.                         for (i = 0; i < KEEP_ID_COUNT ; i++)
  311.                             dontDrop[i] = KEEP_ID[i];
  312.                         while ((i - KEEP_ID_COUNT) < DONT_DROP_ID_COUNT){
  313.                             dontDrop[i] = DONT_DROP_ID[i - KEEP_ID_COUNT];
  314.                             i++;
  315.                         }
  316.                         dontDrop[i + 1] = carriedFood.getID();
  317.                           try {
  318.                             inventory.dropAllExcept(dontDrop);
  319.                           } catch (Exception e) {return 0;}
  320.                         }
  321.                     antiBan(true);
  322.                     hoverFarmer();
  323.                     failedPick = false;
  324.             }else if(getMyPlayer().isInCombat()){
  325.                 status = "Still Stunned";
  326.                 return random(100 , 250);
  327.             }
  328.        
  329.             else if(npcs.getNearest("Master Farmer").isValid()){
  330.                 try {
  331.                 masterFarmer = npcs.getNearest("Master Farmer");
  332.             if(masterFarmer.isOnScreen()){
  333.                 status = "Pickpocketing!";
  334.                
  335.                     masterFarmer.doAction("Pickpocket");
  336.                     antiBan(false);
  337.                     return random(250 , 400);
  338.             } else {
  339.                   status = "Walking to Farmer";
  340.                     walking.walkTo((walking.randomizeTile(masterFarmer.getLocation(),1, 1)));
  341.             }
  342.                 } catch (Exception e) {return 0;}
  343.                  
  344.             antiBan(true);
  345.                   return random(200, 500);
  346.                 }
  347.         return 0;
  348.     }
  349.    
  350.     private void antiBan(boolean overRide){
  351.         int randomNo = random(1, 20);
  352.         int r = random(1, 12);
  353.         if (randomNo == 3 || overRide) {
  354.                 if (r == 2) {
  355.                     status = "AB Open Random Tab";
  356.                         game.openTab(random(1, 14));
  357.                 }
  358.                 if (r == 3) {
  359.                     status = "AB Move Mouse Slightly";
  360.                         mouse.moveSlightly();
  361.                 }
  362.                 if (r == 4) {
  363.                     status = "AB Move Mouse";
  364.                         mouse.moveRandomly(70, 380);
  365.                 }
  366.                 if (r == 5) {
  367.                     status = "AB Move Off Screen";
  368.                     mouse.moveOffScreen();
  369.                 }
  370.                 if (r == 6) {
  371.                     status = "AB Rotate to Master Farmer";
  372.                     if(npcs.getNearest("Master Farmer") != null)
  373.                     camera.turnToCharacter(npcs.getNearest("Master Farmer"));                
  374.                 }
  375.                 if (r == 7) {
  376.                     status = "AB Rotate Camera";
  377.                         camera.setAngle(random(5, 120));
  378.                 }
  379.                 if (r == 8) {
  380.                     status = "AB Rotate Camera";
  381.                         camera.setAngle(random(80, 230));                    
  382.                 }
  383.                 if (r == 9) {
  384.                     status = "AB Rotate Camera";
  385.                         camera.setAngle(random(150, 180));
  386.                 }
  387.                 if (r == 10) {
  388.                     status = "AB Rotate Camera";
  389.                         camera.setAngle(random(250, 360));
  390.                 }
  391.                 if (r == 11) {
  392.                     status = "AB Open Skill Tab";
  393.                         if (game.getCurrentTab() != 4) {
  394.                                 game.openTab(4);
  395.                         } else return;
  396.                 }
  397.                 if (r == 12) {
  398.                     status = "AB Look AT Thieving Skill";
  399.                         if (game.getCurrentTab() != 1) {
  400.                                 game.openTab(1);
  401.                                 sleep(random(500, 700));
  402.                                 mouse.move(random(620 , 665), random(295, 315));
  403.                                 sleep(random(1000, 1500));
  404.                         }
  405.                 }
  406.         }
  407. }
  408.    
  409.    
  410.  
  411.    
  412.     int getItemID (String item){
  413.         int i;
  414.         for(i = 0 ; i < KEEP_ID_COUNT ; i++){
  415.             if(item.contains(KEEP_NAME[i])){
  416.                 return KEEP_ID[i];
  417.             }
  418.         }
  419.         return 0;
  420.     }
  421.    
  422.    
  423.     int itemPrice (int id){
  424.         int p;
  425.         for (int i = 0; i < totalComplete ; i ++ ){
  426.             if (completeIDs[0][i] == id)
  427.                 return completeIDs[1][i];
  428.         }
  429.        
  430.         try {
  431.             status = "Getting Prices";
  432.             p = grandExchange.getMarketPrice(id);
  433.         } catch (Exception e) {return 0;}
  434.         completeIDs[0][totalComplete] = id;
  435.         completeIDs[1][totalComplete] = p;
  436.         totalComplete++;
  437.         return p;
  438.    
  439.    
  440.     }
  441.    
  442.     public void serverMessageRecieved(ServerMessageEvent e) {
  443.  
  444.         String svrmsg = e.getMessage();
  445.         if (svrmsg.contains("combat")) {
  446.             justAttacked = true;
  447.         }
  448.         if (svrmsg.contains("stunned")){
  449.             failedPick = true;
  450.             failPickpockets++;
  451.         }
  452.         if (svrmsg.contains("restores"))
  453.             foodEaten++;
  454.  
  455.         if (svrmsg.contains("advanced")) {
  456.             sleep(random(1500, 2500));
  457.             if (interfaces.canContinue()) {
  458.               interfaces.clickContinue();
  459.             }
  460.             gainedLvls++;
  461.             sleep(random(50,100));
  462.         }
  463.         if (svrmsg.contains("You steal")){
  464.             succeedPickpockets++;
  465.             if (svrmsg.contains("seed")) {
  466.                 int seedCount = 1;
  467.                 String splitString[] = svrmsg.split(" " , 10);
  468.                 String seedName = "";
  469.                 if (!splitString[2].contains("a") && !splitString[2].contains("an"))
  470.                     seedCount = Integer.parseInt(splitString[2].trim());
  471.                     seedName = splitString[3];
  472.                 int seedID = getItemID(seedName);
  473.                 if (seedID != 0){
  474.                     if (foodPrice == 0){
  475.                         try {
  476.                             status = "Getting Prices";
  477.                             foodPrice = grandExchange.getMarketPrice(carriedFood.getID());
  478.                         } catch (Exception e1) {}
  479.                     }
  480.                     profit += (itemPrice(seedID) * seedCount);
  481.                 }
  482.             }
  483.         }
  484.     }
  485.  
  486.    
  487.    
  488.     //private class konzyMasterStealerGUI extends JFrame {}
  489.    
  490.     //START: Paint generated using Enfilade's Easel
  491.     private final Color color1 = new Color(0, 0, 0);
  492.     private final Color color2 = new Color(0, 204, 0);
  493.     private final Color color3 = new Color(255, 255, 255);
  494.  
  495.    
  496.     private final Font font1 = new Font("Razer Regular", 0, 13);
  497.    
  498.     public void onRepaint(Graphics g1) {
  499.        
  500.     if(!showPaint){
  501.         Graphics2D g = (Graphics2D)g1;
  502.         g.setFont(font1);
  503.         g.setColor(color3);
  504.         g.drawString("Click Chat To See Paint", 160, 335);
  505.         return;
  506.     }
  507.        
  508.         int runTime = (int) (System.currentTimeMillis() - startTime);
  509.         int hours = (int) runTime / (60 * 1000 * 60);
  510.         int minutes = (int) (runTime - (hours * 60 * 1000 * 60)) / (60 * 1000);
  511.         int seconds = (int) (runTime - (hours * 60 * 1000 * 60) - (minutes * 60 * 1000)) / 1000;
  512.        
  513.         int currentXP = skills.getCurrentExp(Skills.THIEVING);
  514.         int currentLVL = skills.getCurrentLevel(Skills.THIEVING);
  515.         int gainedXP = currentXP - startXP;
  516.         int gainedLVL = currentLVL - startLvl;
  517.         int xpPerHour = (int) ((3600000.0 / (double) runTime) * gainedXP);
  518.         int succeedPickpocketsHour = (int) ((3600000.0 / (double) runTime) * succeedPickpockets);
  519.         int profitPerHour = (int) ((3600000.0 / (double) runTime) * profit);
  520.        
  521.         String dispProfit = "" + profit;
  522.         String dispProfitPerHour = "" + profitPerHour;
  523.         if(profit < 0){
  524.             dispProfit = "(" + (-profit) + ")";
  525.             dispProfitPerHour = "(" + (-profitPerHour) + ")";
  526.         }
  527.         String normMinutes;
  528.         String normSeconds;
  529.        
  530.         if (minutes < 10)
  531.             normMinutes = "0" + minutes;
  532.         else normMinutes = "" + minutes;
  533.         if (seconds < 10)
  534.             normSeconds = "0" + seconds;
  535.         else normSeconds = "" + seconds;
  536.        
  537.         Graphics2D g = (Graphics2D)g1;
  538.         g.setColor(color1);
  539.         g.fillRect(8, 344, 502, 128);
  540.         g.setFont(font1);
  541.         g.setColor(color2);
  542.         g.drawString("konzy's Master Stealer V " + properties.version(), 10, 355);
  543.         g.drawString("XP Gained: " + gainedXP, 10, 370);
  544.         g.drawString("XP/hr: " + xpPerHour, 10, 385);
  545.         g.drawString("Current Level: " + currentLVL, 10, 400);
  546.         g.drawString("% Level Up: " + (100 - skills.getPercentToNextLevel(Skills.THIEVING)) + "%", 10, 415);
  547.         g.drawString("Levels Gained: " + gainedLVL, 10, 430);
  548.         g.drawString("Run Time: " + hours + ":" + normMinutes + ":" + normSeconds, 10, 445);
  549.         g.drawString("Number of Picks: " + succeedPickpockets, 250, 355);
  550.         g.drawString("Picks per Hour: " + succeedPickpocketsHour, 250, 370);
  551.         g.drawString("Picks Failed: " + failPickpockets, 250, 385);
  552.         g.drawString("Profit: " + dispProfit, 250, 400);
  553.         g.drawString("Profit Per Hour: " + dispProfitPerHour, 250, 415);
  554.         g.drawString("Status: " + status, 250, 430);
  555.         g.drawString("By konzy", 250, 445);
  556.         g.setColor(color3);
  557.         g.drawString("Click Paint To See Chat", 160, 335);
  558.  
  559.     }
  560.     //END: Paint generated using Enfilade's Easel
  561.  
  562.     @Override
  563.     public void mouseClicked(MouseEvent e) {
  564.         RSComponent inter = interfaces.get(137).getComponent(0);
  565.         if(inter.getArea().contains(e.getPoint())) {
  566.             showPaint = !showPaint;
  567.         }
  568.     }
  569.  
  570.     @Override
  571.     public void mousePressed(MouseEvent e) { }
  572.  
  573.     @Override
  574.     public void mouseReleased(MouseEvent e) { }
  575.  
  576.     @Override
  577.     public void mouseEntered(MouseEvent e) { }
  578.  
  579.     @Override
  580.     public void mouseExited(MouseEvent e) { }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement