Advertisement
Guest User

Untitled

a guest
Sep 17th, 2015
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 23.81 KB | None | 0 0
  1. package scripts.GSpinner;
  2.  
  3. import java.awt.Point;
  4. import java.io.File;
  5. import java.io.FileNotFoundException;
  6. import java.util.Scanner;
  7.  
  8. import org.tribot.api.General;
  9. import org.tribot.api.Timing;
  10. import org.tribot.api.input.Keyboard;
  11. import org.tribot.api.input.Mouse;
  12. import org.tribot.api2007.Banking;
  13. import org.tribot.api2007.Camera;
  14. import org.tribot.api2007.ChooseOption;
  15. import org.tribot.api2007.Game;
  16. import org.tribot.api2007.GameTab;
  17. import org.tribot.api2007.GameTab.TABS;
  18. import org.tribot.api2007.Interfaces;
  19. import org.tribot.api2007.Inventory;
  20. import org.tribot.api2007.Login;
  21. import org.tribot.api2007.Magic;
  22. import org.tribot.api2007.Objects;
  23. import org.tribot.api2007.Options;
  24. import org.tribot.api2007.Player;
  25. import org.tribot.api2007.Players;
  26. import org.tribot.api2007.Skills;
  27. import org.tribot.api2007.Skills.SKILLS;
  28. import org.tribot.api2007.Walking;
  29. import org.tribot.api2007.types.RSItem;
  30. import org.tribot.api2007.types.RSObject;
  31. import org.tribot.api2007.types.RSPlayer;
  32. import org.tribot.api2007.types.RSTile;
  33. import org.tribot.script.Script;
  34. import org.tribot.script.ScriptManifest;
  35. import org.tribot.script.interfaces.Ending;
  36. import org.tribot.script.interfaces.MessageListening07;
  37. import org.tribot.util.Util;
  38.  
  39. @ScriptManifest(authors = { "Genka" }, category = "Crafting", name = "GSpinner")
  40. public class GSpinner extends Script implements Ending, MessageListening07 {
  41.     static final RSTile BANKTILE = new RSTile(3208, 3218);
  42.     static final RSTile DOORTILE = new RSTile(3207, 3214);
  43.     static final RSTile STAIRTILE = new RSTile(3205, 3208);
  44.     static final RSTile WHEELTILE = new RSTile(3209, 3212);
  45.     static final int NEEDLE = 1733;
  46.     static final int THREAD = 1734;
  47.     static final int LEATHER = 1741;
  48.     static final int FLAX = 1779;
  49.     static final int BOWSTRING = 1777;
  50.     static final int NOTEDBOWSTRING = 1778;
  51.     public boolean alive = true;
  52.     long animationtime = System.currentTimeMillis();
  53.     long antibantime = System.currentTimeMillis();
  54.     int nextantiban = 60000;
  55.     long lastprint = System.currentTimeMillis();
  56.     long lastsaid = System.currentTimeMillis();
  57.     int startxp = 0;
  58.     int botworld = 0;
  59.     int muleworld = 0;
  60.     String mulename = "null";
  61.     String state = "Spin";
  62.     String filelocation = Util.getWorkingDirectory() + "\\GSpinner\\lines.txt";
  63.     File file = new File(filelocation);
  64.    
  65.     @Override
  66.     public void run() {
  67.         setRandomSolverState(RANDOM_SOLVERS.COMBATRANDOM, false);
  68.         while(Game.getGameState() != 30){
  69.             sleep(10);         
  70.         }
  71.         Camera.setCameraAngle(100);
  72.         Camera.setCameraRotation(0);
  73.         Mouse.setSpeed(General.random(140,150));
  74.         startxp = Skills.getXP(SKILLS.CRAFTING);
  75.         while(alive){
  76.             if(Player.getPosition().distanceTo(BANKTILE) > 25){
  77.                 Magic.selectSpell("Lumbridge Home Teleport");
  78.                 long t = System.currentTimeMillis();
  79.                 while(Player.getPosition().distanceTo(BANKTILE) > 25 && Timing.timeFromMark(t) < 20000){
  80.                     sleep(10);
  81.                 }
  82.             } else {           
  83.                 if(state.equals("Spin")){
  84.                     if(Game.getGameState() != 30){         
  85.                         sleep(10);
  86.                     } else {
  87.                         if(!Game.isRunOn() && Game.getRunEnergy() > 50){
  88.                             Options.setRunOn(true);
  89.                         }
  90.                         if(Skills.getActualLevel(SKILLS.CRAFTING) < 10){
  91.                             oneToTen();
  92.                             deathWalk();
  93.                         } else {
  94.                             spinLoop();
  95.                         }
  96.                         if(Timing.timeFromMark(lastprint) > 1800000){
  97.                             double multiplier = getRunningTime() / 3600000D;
  98.                             int strHour = (int) (((Skills.getXP(SKILLS.CRAFTING) - startxp) / 15) / multiplier) ;  
  99.                             println("Runtime: " + Timing.msToString(getRunningTime()) + " Bowstrings made: " + ((Skills.getXP(SKILLS.CRAFTING) - startxp) / 15) + "(" + strHour + "/HR)");
  100.                             lastprint = System.currentTimeMillis();
  101.                         }
  102.                     }
  103.                 } else if (state.equals("Trademule")){
  104.                     handleMule();
  105.                 }
  106.             }          
  107.             sleep(10, 50);
  108.             }
  109.        
  110.     }
  111.    
  112.     private void spinLoop(){
  113.         if(Timing.timeFromMark(animationtime) < 3000){
  114.             antiBan();
  115.         } else {
  116.             if(Player.getRSPlayer().isInCombat()){
  117.                 toBank();
  118.             } else {
  119.             bank();
  120.             toWheel(); 
  121.             spin();
  122.             toBank();
  123.             deathWalk();
  124.             }
  125.         }
  126.     }
  127.    
  128.     private void deathWalk(){
  129.         if(Player.getPosition().distanceTo(BANKTILE) < 25 && Player.getPosition().getPlane() == 0){
  130.             if(!Player.isMoving() && Player.getPosition().distanceTo(STAIRTILE) > 3){
  131.                 Walking.blindWalkTo(STAIRTILE);
  132.             } else if (Player.getPosition().distanceTo(STAIRTILE) <= 3){
  133.                 RSObject[] stairs = Objects.find(5, "Staircase");
  134.                 if(stairs.length > 0){
  135.                     if(stairs[0] != null){
  136.                         clickObject(stairs[0], "Climb-up", 3, 3);
  137.                         long t = System.currentTimeMillis();
  138.                         while(Player.getPosition().getPlane() == 0 && Timing.timeFromMark(t) < 5000){
  139.                             sleep(10);
  140.                         }
  141.                     }
  142.                 }
  143.             }
  144.         }
  145.     }
  146.    
  147.     private void handleMule(){
  148.         while(state.equals("Trademule")){
  149.                 if(muleworld != getWorld()){
  150.                     setLoginBotState(false);
  151.                     Hopping.hop(muleworld);
  152.                     setLoginBotState(true);
  153.                 } else {
  154.                     if(Player.getPosition().getPlane() == 1){
  155.                         if(Player.getPosition().getX() > 3207){
  156.                             if(openDoor()){
  157.                                 if(Player.getPosition().distanceTo(STAIRTILE) > 2 && !Player.isMoving()){
  158.                                     Walking.clickTileMM(randomTile(STAIRTILE), 1);
  159.                                     sleep(500, 1600);
  160.                                     Mouse.moveBox(168, 317, 346, 227);
  161.                                 }
  162.                             } else if (!openDoor()){
  163.                                 RSObject[] door = Objects.getAt(DOORTILE);
  164.                                 if(door.length > 0){
  165.                                     door[0].click("Open");
  166.                                     long t = System.currentTimeMillis();
  167.                                     while(!openDoor() && Timing.timeFromMark(t) < 2000){
  168.                                         sleep(10);
  169.                                     }
  170.                                 }      
  171.                             }
  172.                         } else if (Player.getPosition().distanceTo(STAIRTILE) <= 2){
  173.                             RSObject[] stairs = Objects.getAt(STAIRTILE);
  174.                             if(stairs.length > 0){
  175.                                 if(clickObject(stairs[0], "Climb-up", 2, 2)){
  176.                                     long t = System.currentTimeMillis();
  177.                                     while(Player.getPosition().getPlane() == 1 && Timing.timeFromMark(t) < 3000){
  178.                                         sleep(10);
  179.                                     }
  180.                                 }
  181.                             }
  182.                         }
  183.                     } else if (Player.getPosition().getPlane() == 2){
  184.                         RSObject[] bankbooth = Objects.find(20, "Bank booth");
  185.                         if (bankbooth.length > 0){
  186.                             if(Player.getPosition().distanceTo(BANKTILE) > 2 && !Player.isMoving()){
  187.                                 Walking.clickTileMM(randomTile(BANKTILE), 1);
  188.                                 sleep(300);
  189.                             } else {
  190.                                 if(Inventory.find(NOTEDBOWSTRING).length > 0 || isTradeScreenOpen() || isSecondTradeScreenOpen()){
  191.                                     if(Banking.isBankScreenOpen()){
  192.                                     Banking.close();
  193.                                     } else {
  194.                                         RSPlayer[] mule = Players.find(mulename);
  195.                                         if(mule.length > 0){
  196.                                             if(!isTradeScreenOpen() && !isSecondTradeScreenOpen()){
  197.                                                 if(GameTab.getOpen() != TABS.INVENTORY){
  198.                                                     GameTab.open(TABS.INVENTORY);
  199.                                                 } else if(clickPlayer(mule[0], "Trade with " +  mulename)){
  200.                                                     long t = System.currentTimeMillis();
  201.                                                     while(!isTradeScreenOpen() && Timing.timeFromMark(t) < 5000){
  202.                                                         sleep(10);
  203.                                                     }
  204.                                                 }
  205.                                             } else if (isTradeScreenOpen()){
  206.                                                 RSItem[] nstring = Inventory.find(NOTEDBOWSTRING);
  207.                                                 if(nstring.length > 0){
  208.                                                     nstring[0].click("Offer-All");
  209.                                                     long t = System.currentTimeMillis();
  210.                                                     while(Inventory.find(NOTEDBOWSTRING).length > 0 && Timing.timeFromMark(t) < 4000){
  211.                                                         sleep(10);
  212.                                                     }
  213.                                                 } else {
  214.                                                     if(Interfaces.get(335, 50) != null){
  215.                                                         if(Interfaces.get(335, 50).getChild(0).getComponentItem() == 1780){
  216.                                                             if(!Interfaces.get(335, 56).getText().contains("Waiting for other player...")){
  217.                                                             Interfaces.get(335, 17).click("Accept");
  218.                                                             }
  219.                                                         }
  220.                                                     }
  221.                                                 }                                          
  222.                                             } else if (isSecondTradeScreenOpen()){
  223.                                                 if(Interfaces.get(334, 20) != null){
  224.                                                     if(!Interfaces.get(334, 33).getText().contains("Waiting for other player...")){
  225.                                                         Interfaces.get(334, 20).click("Accept");
  226.                                                     }
  227.                                                 }
  228.                                             }
  229.                                         } else {
  230.                                             state = "Wait";
  231.                                             setLoginBotState(false);
  232.                                             if(getWorld() != botworld){
  233.                                             Hopping.hop(botworld);
  234.                                             }
  235.                                             state = "Spin";
  236.                                             setLoginBotState(true);
  237.                                         }
  238.                                     }
  239.                                 } else if (Inventory.find(NOTEDBOWSTRING).length == 0 && !isTradeScreenOpen() && !isSecondTradeScreenOpen()){
  240.                                     if(!Banking.isBankScreenOpen()){
  241.                                         if(bankbooth.length > 0){
  242.                                             if(clickObject(bankbooth[0], "Bank", 3, 3)){
  243.                                                 long t = System.currentTimeMillis();
  244.                                                 while(!Banking.isBankScreenOpen() && Timing.timeFromMark(t) < 3000){
  245.                                                     sleep(10);
  246.                                                 }
  247.                                             }
  248.                                         }
  249.                                     } else if(Banking.isBankScreenOpen()) {
  250.                                         Banking.depositAllExcept(NOTEDBOWSTRING);
  251.                                         if (Interfaces.get(12, 18) != null){
  252.                                             Interfaces.get(12, 18).click("Note");
  253.                                         }
  254.                                         Banking.withdraw(0, BOWSTRING);
  255.                                         long t = System.currentTimeMillis();
  256.                                         while(Inventory.find(NOTEDBOWSTRING).length == 0 && Timing.timeFromMark(t) < 3000){
  257.                                             sleep(10);
  258.                                         }
  259.                                     }
  260.                                 }  
  261.                             }
  262.                         }              
  263.                     }              
  264.                 }          
  265.             }  
  266.         }
  267.    
  268.     private boolean isTradeScreenOpen(){
  269.         return Interfaces.get(335) != null;    
  270.     }
  271.    
  272.     private boolean isSecondTradeScreenOpen(){
  273.         return Interfaces.get(334) != null;
  274.     }
  275.    
  276.     private int getWorld(){
  277.         String world = "" + Game.getCurrentWorld();
  278.         return Integer.parseInt(world.substring(1));
  279.     }
  280.    
  281.     private int getMuleWorld(){
  282.         if(!GameTab.getOpen().equals(TABS.FRIENDS)){
  283.             GameTab.open(TABS.FRIENDS);
  284.         }
  285.         if(Interfaces.get(550, 1).getChild(1) != null && !Interfaces.get(550, 1).getChild(1).getText().equals("Offline")){
  286.             int length = Interfaces.get(550, 1).getChild(1).getText().length();
  287.             return Integer.parseInt(Interfaces.get(550, 1).getChild(1).getText().substring(length -2));
  288.         }      
  289.         return 0;
  290.     }
  291.    
  292.     private String getMuleName(){
  293.         if(!GameTab.getOpen().equals(TABS.FRIENDS)){
  294.             GameTab.open(TABS.FRIENDS);
  295.         }
  296.         if(Interfaces.get(550, 1).getChild(1) != null){
  297.             return Interfaces.get(550, 1).getChild(0).getText();
  298.         }              
  299.         return null;
  300.     }
  301.    
  302.     private void bank(){
  303.         if((Inventory.find(FLAX).length == 0 && Player.getPosition().distanceTo(BANKTILE) < 3 && Player.getPosition().getPlane() == 2) || Player.getRSPlayer().isInCombat()){
  304.             if(!Banking.isBankScreenOpen() && !Player.isMoving()){
  305.                 RSObject[] bankbooth = Objects.findNearest(10, "Bank booth");
  306.                 if(bankbooth.length > 0){
  307.                     if(clickObject(bankbooth[0], "Bank", 3, 3)){
  308.                         long t = System.currentTimeMillis();
  309.                         while(!Banking.isBankScreenOpen() && Timing.timeFromMark(t) < 3000){
  310.                             sleep(10);
  311.                         }
  312.                     }
  313.                 }
  314.             } else if(Banking.isBankScreenOpen()){
  315.                 if(Inventory.getAll().length > 0){
  316.                     Banking.depositAll();
  317.                 } else {
  318.                     if(Banking.find(FLAX).length > 0){
  319.                     Banking.withdraw(0, FLAX);
  320.                     } else {
  321.                         if(state.equals("Spin")){
  322.                             int tries = 0;
  323.                             while(Banking.find(FLAX).length == 0 && tries < 50){
  324.                                 tries++;
  325.                                 if(tries > 40){
  326.                                     setLoginBotState(false);
  327.                                     while(Game.getGameState() == 30){
  328.                                     Login.logout();
  329.                                     }
  330.                                     alive = false;
  331.                                 }
  332.                             }
  333.                         }
  334.                     }
  335.                     long t = System.currentTimeMillis();
  336.                     while(Inventory.find(FLAX).length == 0 && Timing.timeFromMark(t) < 2000){
  337.                         sleep(10);
  338.                     }
  339.                     sleep(10,25);
  340.                 }              
  341.             }
  342.         }
  343.     }
  344.    
  345.     private void antiBan(){
  346.         if(Timing.timeFromMark(antibantime) > nextantiban){
  347.             antibantime = System.currentTimeMillis();
  348.             nextantiban = General.random(60000, 300000);
  349.             int key = General.random(1, 5);
  350.             try{
  351.                 switch (key){
  352.    
  353.                 case 1:
  354.                     if(GameTab.getOpen() != GameTab.TABS.STATS){
  355.                         GameTab.open(TABS.STATS);
  356.                     }
  357.                     sleep(10, 100);
  358.                     Mouse.moveBox(613, 333, 667, 355);
  359.                     sleep(1000,3500);
  360.                     GameTab.open(TABS.INVENTORY);
  361.                     break;
  362.                 case 2:
  363.                     Mouse.move((int)Mouse.getPos().getX() + General.random(-150, 150), (int)Mouse.getPos().getY() + General.random(-150, 150));
  364.                     break;
  365.                 case 3:
  366.                     RSPlayer[] players = Players.getAll();
  367.                     if(players.length > 0){
  368.                         for (RSPlayer i : players){
  369.                             if(i != null && i.isOnScreen()){
  370.                                 if(i.getModel() != null && i.getModel().getCentrePoint() != null){
  371.                                 Mouse.click(i.getModel().getCentrePoint(), 3);
  372.                                 } else {
  373.                                     Mouse.click(Player.getRSPlayer().getModel().getCentrePoint(), 3);
  374.                                 }
  375.                                 sleep(1000, 2000);
  376.                                 Mouse.move((int)Mouse.getPos().getX() + General.random(15, 25),(int) Mouse.getPos().getY() + General.random(-60, -80));
  377.                                 break;
  378.                             }
  379.                         }
  380.                     }
  381.                     break;
  382.                 case 4:
  383.                     RSObject[] all = Objects.getAll(6);
  384.                     for (int i = 0; i < 50 ; i++){
  385.                         int random = General.random(0, all.length -1);
  386.                             if(all != null && all.length >= random && all[random] != null && all[random].getDefinition() != null){
  387.                                 Camera.turnToTile(new RSTile(all[random].getPosition().getX() + General.random(-1, 1), all[random].getPosition().getY() + General.random(-1, 1)));
  388.                                 sleep(500, 5000);
  389.                                 Camera.setCameraAngle(100);
  390.                                 Camera.setCameraRotation(0);   
  391.                                 break;
  392.                             }
  393.                     }
  394.                     break;
  395.                 case 5:                
  396.                      int randomint = General.random(1, 3000);
  397.                              try {
  398.                                  Scanner scanner = new Scanner(file);
  399.                                  for(int i = 0; i <= randomint; i++) {                
  400.  
  401.                                      String line = scanner.nextLine();
  402.                                      if(i == randomint && !line.equals("")){
  403.                                          Keyboard.typeSend("/" + line);
  404.                                      }
  405.                            
  406.                                  }
  407.                                  scanner.close();
  408.                              } catch (FileNotFoundException e) {
  409.                                  println("fle lines.txt was not found");
  410.                              }
  411.                     break;
  412.                
  413.                
  414.                 }
  415.             } catch (NullPointerException e){
  416.                
  417.             }
  418.         }
  419.     }
  420.    
  421.     private boolean clickObject(RSObject object, String option, int randomx, int randomy){
  422.         try{
  423.         if(object != null && object.isOnScreen() && object.getModel() != null){
  424.             Point x = object.getModel().getCentrePoint();
  425.             int x1 = (int) x.getX() + General.random(randomx, -randomx);
  426.             int x2 = (int) x.getY() + General.random(randomy, -randomy);
  427.             int tries = 0;
  428.             while((int)Mouse.getPos().getX() != x1 && (int)Mouse.getPos().getY() != x2 && tries < 30) {
  429.                 Mouse.move(x1, x2);
  430.                 tries++;
  431.             }
  432.             Mouse.click(x1, x2, 3);
  433.             if(ChooseOption.isOpen()){
  434.                 if(ChooseOption.isOptionValid(option)){
  435.                     ChooseOption.select(option);
  436.                     return true;
  437.                 } else {
  438.                     Mouse.move((int)Mouse.getPos().getX() + General.random(15, 25),(int) Mouse.getPos().getY() + General.random(-60, -80));
  439.                 }
  440.             }  
  441.         }
  442.         } catch (NullPointerException e){
  443.             System.out.print("Your computer sux, recovered from nullpointer");
  444.         }
  445.         return false;
  446.     }
  447.    
  448.     private boolean clickPlayer(RSPlayer object, String option){
  449.         try{
  450.         if(object != null && object.isOnScreen() && object.getModel() != null){
  451.             Point x = object.getModel().getCentrePoint();
  452.             int x1 = (int) x.getX();
  453.             int x2 = (int) x.getY();
  454.             int tries = 0;
  455.             while((int)Mouse.getPos().getX() != x1 && (int)Mouse.getPos().getY() != x2 && tries < 30) {
  456.                 Mouse.move(x1, x2);
  457.                 tries++;
  458.             }
  459.             Mouse.click(x1, x2, 3);
  460.             if(ChooseOption.isOpen()){
  461.                 if(ChooseOption.isOptionValid(option)){
  462.                     ChooseOption.select(option);
  463.                     return true;
  464.                 } else {
  465.                     Mouse.move((int)Mouse.getPos().getX() + General.random(15, 25),(int) Mouse.getPos().getY() + General.random(-60, -80));
  466.                 }
  467.             }  
  468.         }
  469.         } catch (NullPointerException e){
  470.             System.out.print("Your computer sux, recovered from nullpointer");
  471.         }
  472.         return false;
  473.     }
  474.    
  475.     private void toWheel(){
  476.         if(Inventory.find(FLAX).length > 0 && Player.getPosition().getPlane() == 2){
  477.             if(Player.getPosition().distanceTo(STAIRTILE) > 2 && !Player.isMoving()){
  478.                 Walking.clickTileMM(randomTile(STAIRTILE), 1);
  479.                 sleep(500, 1600);
  480.                 Mouse.moveBox(168, 317, 346, 227);
  481.             } else if (Player.getPosition().distanceTo(STAIRTILE) <= 2){
  482.                 RSObject[] stairs = Objects.getAt(STAIRTILE);
  483.                 if(stairs.length > 0){
  484.                     if(stairs[0] != null && stairs[0].isOnScreen()){
  485.                         sleep(200);                
  486.                             if(clickObject(stairs[0], "Climb-down", 2, 7)){
  487.                                 long t = System.currentTimeMillis();
  488.                                 while(Player.getPosition().getPlane() == 2 && Timing.timeFromMark(t) < 3000){
  489.                                     sleep(10);
  490.                                 }
  491.                                 sleep(200,500);
  492.                             }
  493.                     }
  494.                 }
  495.             }
  496.         } else if (Inventory.find(FLAX).length > 0 && Player.getPosition().getPlane() == 1){
  497.             if(Player.getPosition().getX() < 3208){
  498.                 if(openDoor() && !Player.isMoving()){
  499.                     RSObject[] wheel = Objects.getAt(WHEELTILE);
  500.                     if(wheel.length > 0){
  501.                         if(wheel[0] != null){
  502.                             if(clickObject(wheel[0], "Spin", 2, 2)){
  503.                                 long t = System.currentTimeMillis();
  504.                                 while(!Player.isMoving() && Timing.timeFromMark(t) < 3000){
  505.                                     sleep(10);
  506.                                 }
  507.                             }
  508.                         }
  509.                     }
  510.                 } else if (!openDoor()){
  511.                     if(Player.getPosition().distanceTo(DOORTILE) > 2){
  512.                         Walking.walkScreenPath(Walking.generateStraightScreenPath(new RSTile(3207, 3214)));
  513.                         sleep(1000);
  514.                     } else {
  515.                         RSObject[] door = Objects.getAt(DOORTILE);
  516.                         if(door.length > 0 && !Player.isMoving()){
  517.                             if(clickObject(door[0], "Open", 1, 1)){
  518.                                 long t = System.currentTimeMillis();
  519.                                 while(!openDoor() && Timing.timeFromMark(t) < 2000){
  520.                                     sleep(10);
  521.                                 }
  522.                             }
  523.                         }      
  524.                     }                  
  525.                 }
  526.             }
  527.         }
  528.     }
  529.    
  530.     private void spin(){
  531.         if(Player.getAnimation() == 894){
  532.             animationtime = System.currentTimeMillis();
  533.         } else if (Player.getPosition().distanceTo(WHEELTILE) > 1 && Inventory.find(FLAX).length > 1 && Player.getPosition().getX() > 3207 && !Player.isMoving() && Player.getPosition().getPlane() == 1){
  534.             Walking.clickTileMS(new RSTile(3209, 3213), "Walk here");
  535.             sleep(200);
  536.         } else if(Player.getPosition().distanceTo(WHEELTILE) < 2 && Inventory.find(FLAX).length > 0 && Timing.timeFromMark(animationtime) > 5000){
  537.             if((Interfaces.get(459,91) == null || Interfaces.get(459, 91).getParentID() == -1) && Interfaces.get(548, 117).isHidden()){
  538.                 RSObject[] wheel = Objects.getAt(WHEELTILE);
  539.                 if(wheel.length > 0 && !Player.isMoving()){
  540.                     if(wheel[0] != null){
  541.                         if(clickObject(wheel[0], "Spin", 3, 10)){
  542.                             long t = System.currentTimeMillis();
  543.                             while((Interfaces.get(459, 91) == null || Interfaces.get(459, 91).getParentID() != -1) && Timing.timeFromMark(t) < 2000){
  544.                                 sleep(10);
  545.                             }
  546.                         }
  547.                     }
  548.                 }
  549.            
  550.             } else if (Interfaces.get(459, 91) != null && Interfaces.get(459).isValid() && Interfaces.get(459, 91).getParentID() != -1){
  551.                 Interfaces.get(459,91).click("Make X");
  552.                 long t = System.currentTimeMillis();
  553.                 while(Interfaces.get(548, 117).isHidden() && Timing.timeFromMark(t) < 2000){
  554.                     sleep(10);
  555.                 }
  556.             } else if (!Interfaces.get(548, 117).isHidden()){
  557.                 Keyboard.typeSend("" + randomInt(General.random(1, 50)));
  558.                 sleep(500);
  559.             }
  560.         }
  561.     }
  562.    
  563.     private int randomInt(int key){
  564.         switch (key){
  565.         case 1:
  566.             return 77;
  567.         case 2:
  568.             return 88;
  569.         case 3:
  570.             return 78;
  571.         case 4:
  572.             return 89;
  573.         case 5:
  574.             return 98;
  575.         case 6:
  576.             return 87;
  577.         default:
  578.             return 99;
  579.         }
  580.     }
  581.    
  582.     private void toBank(){
  583.         if(Inventory.find(FLAX).length == 0 || Player.getRSPlayer().isInCombat()){
  584.             if(Player.getPosition().getPlane() == 1){
  585.                 if(Player.getPosition().getX() > 3207){
  586.                     if(openDoor()){
  587.                         if(Player.getPosition().distanceTo(STAIRTILE) > 2 && !Player.isMoving()){
  588.                             Walking.clickTileMM(randomTile(STAIRTILE), 1);
  589.                             sleep(500, 1600);
  590.                             Mouse.moveBox(168, 317, 346, 227);
  591.                         }
  592.                     } else if (!openDoor()){
  593.                         RSObject[] door = Objects.getAt(DOORTILE);
  594.                         if(door.length > 0){
  595.                             door[0].click("Open");
  596.                             long t = System.currentTimeMillis();
  597.                             while(!openDoor() && Timing.timeFromMark(t) < 2000){
  598.                                 sleep(10);
  599.                             }
  600.                         }      
  601.                     }
  602.                 } else if (Player.getPosition().distanceTo(STAIRTILE) <= 2){
  603.                     RSObject[] stairs = Objects.getAt(STAIRTILE);
  604.                     if(stairs.length > 0){
  605.                         if(clickObject(stairs[0], "Climb-up", 2, 2)){
  606.                             long t = System.currentTimeMillis();
  607.                             while(Player.getPosition().getPlane() == 1 && Timing.timeFromMark(t) < 3000){
  608.                                 sleep(10);
  609.                             }
  610.                         }
  611.                     }
  612.                 }
  613.             } else if (Player.getPosition().getPlane() == 2){
  614.                 RSObject[] bankbooth = Objects.find(20, "Bank booth");
  615.                 if (bankbooth.length > 0){
  616.                     if(Player.getPosition().distanceTo(BANKTILE) > 2 && !Player.isMoving()){
  617.                         Walking.clickTileMM(randomTile(BANKTILE), 1);
  618.                         sleep(300);
  619.                     }
  620.                 }              
  621.             }
  622.         }
  623.     }
  624.    
  625.     private boolean openDoor(){
  626.         RSObject[] door = Objects.getAt(DOORTILE);
  627.         if(door.length > 0){
  628.             return false;
  629.         }      
  630.         return true;
  631.     }
  632.    
  633.     private void oneToTen(){
  634.         if(Player.getPosition().distanceTo(BANKTILE) <= 5 && Player.getPosition().getPlane() == 2){
  635.             if(Inventory.find(NEEDLE).length == 0 || Inventory.find(THREAD).length == 0 || Inventory.find(LEATHER).length == 0){
  636.                 if(!Banking.isBankScreenOpen()){
  637.                     Banking.openBank();
  638.                 } else {
  639.                     Banking.depositAllExcept(NEEDLE, THREAD, LEATHER);
  640.                     if(Inventory.find(NEEDLE).length == 0){
  641.                         Banking.withdraw(1, NEEDLE);
  642.                     }
  643.                     if(Inventory.find(THREAD).length == 0){
  644.                         Banking.withdraw(0, THREAD);
  645.                     }
  646.                     if(Inventory.find(LEATHER).length == 0){
  647.                         Banking.withdraw(0, LEATHER);
  648.                         long t = System.currentTimeMillis();
  649.                         while(Inventory.find(LEATHER).length == 0 && Timing.timeFromMark(t) < 2000){
  650.                             sleep(10,40);
  651.                         }
  652.                     }
  653.                 }
  654.             } else {
  655.                 if(Banking.isBankScreenOpen()){
  656.                     Banking.close();
  657.                 } else {
  658.                     if(Player.getAnimation() == 1249){
  659.                         animationtime = System.currentTimeMillis();
  660.                     }
  661.                     if(Interfaces.get(154, 108) == null && Timing.timeFromMark(animationtime) > 3000){
  662.                         RSItem[] needle = Inventory.find(NEEDLE);
  663.                         if(needle.length > 0){
  664.                             needle[0].click("Use Needle");
  665.                             RSItem[] leather = Inventory.find(LEATHER);
  666.                             if(leather.length > 0){
  667.                                 leather[0].click("Use Needle");
  668.                                 sleep(600,800);
  669.                             }
  670.                         }
  671.                     } else if(Interfaces.get(154, 108) != null) {
  672.                         Interfaces.get(154, 108).click("Make All");
  673.                         sleep(800, 1200);
  674.                     }
  675.                 }
  676.             }
  677.         }
  678.     }
  679.    
  680.     private RSTile randomTile(RSTile torand){
  681.             int x = torand.getX();
  682.             int y = torand.getY();
  683.         return new RSTile(x + General.random(-1, 1), y + General.random(-1, 1));
  684.     }
  685.    
  686.    
  687.     @Override
  688.     public void onEnd() {
  689.         double multiplier = getRunningTime() / 3600000D;
  690.         int strHour = (int) (((Skills.getXP(SKILLS.CRAFTING) - startxp) / 15) / multiplier) ;      
  691.         println("Script ended. Runtime: " + Timing.msToString(getRunningTime()) + " Bowstrings made: " + ((Skills.getXP(SKILLS.CRAFTING) - startxp) / 15) + "(" + strHour + "/HR)");
  692.     }
  693.  
  694.     @Override
  695.     public void clanMessageReceived(String arg0, String arg1) {
  696.         if(arg1.equals("Bs")){
  697.             state = "Wait";
  698.             if(Banking.isBankScreenOpen()){
  699.                 Banking.close();
  700.             }
  701.             mulename = getMuleName();
  702.             muleworld = getMuleWorld();
  703.             botworld = getWorld();
  704.             state = "Trademule";
  705.         }
  706.     }
  707.  
  708.     @Override
  709.     public void personalMessageReceived(String arg0, String arg1) {
  710.        
  711.     }
  712.  
  713.     @Override
  714.     public void playerMessageReceived(String arg0, String arg1) {
  715.        
  716.     }
  717.  
  718.     @Override
  719.     public void serverMessageReceived(String arg0) {
  720.          if (arg0.contains("Accepted trade")){
  721.             state = "Wait";
  722.             setLoginBotState(false);
  723.             if(getWorld() != botworld){
  724.             Hopping.hop(botworld);
  725.             }
  726.             state = "Spin";
  727.             setLoginBotState(true);
  728.            
  729.         }
  730.        
  731.     }
  732.  
  733.     @Override
  734.     public void tradeRequestReceived(String arg0) {
  735.  
  736.     }
  737.  
  738.     @Override
  739.     public void duelRequestReceived(String arg0, String arg1) {
  740.         // TODO Auto-generated method stub
  741.        
  742.     }
  743.  
  744. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement