Advertisement
Guest User

Untitled

a guest
Sep 8th, 2017
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 44.86 KB | None | 0 0
  1.  
  2. /**
  3.  *
  4.  * @author Frederick
  5.  */
  6. import java.awt.Graphics;
  7. import java.awt.Color;
  8.  
  9. import org.rsbot.script.ScriptManifest;
  10. import org.rsbot.event.listeners.PaintListener;
  11. import org.rsbot.script.Script;
  12. import org.rsbot.script.methods.Game;
  13. import org.rsbot.script.methods.Skills;
  14. import org.rsbot.script.wrappers.RSInterface;
  15. import org.rsbot.script.wrappers.RSComponent;
  16. import org.rsbot.script.wrappers.RSGroundItem;
  17. import org.rsbot.script.wrappers.RSObject;
  18. import org.rsbot.script.wrappers.RSTile;
  19. import org.rsbot.script.wrappers.RSNPC;
  20.  
  21. @ScriptManifest(name = "TISolver", authors = {"Fred"}, version = 1.08, description = "Solves the Tutorial Quest for you")
  22. public class TISolver extends Script implements PaintListener {
  23.  
  24.     boolean autoCreate = false, usernameTaken = false, passwordDunMatch = false;
  25.     String prefix, password, username;
  26.     int[] interfaceID;
  27.     int suffix = -1;
  28.     RSTile referenceTile;
  29.     RSObject hole, plank, bag;
  30.     RSNPC Vant, Goblin, Vant2, Roddeck;
  31.     int[] NPCIDs = {8850, 8862, 8848, 8867};
  32.     int[] armoursonfloor = {1117, 1173, 1277};
  33.     int accountsCreated = 0;
  34.     int height = 1;
  35.     long startTime = 0;
  36.     long totalTime = 0;
  37.     long averageTime = 0;
  38.     boolean mining = true;
  39.     String blabla = "random stuff";
  40.  
  41.     @Override
  42.     public boolean onStart() {
  43.         env.disableRandom("Login");
  44.         env.enableRandom("InterfaceCloser");
  45.         TISolverGUI gui = new TISolverGUI();
  46.         gui.setVisible(true);
  47.         while (gui.isVisible()) {
  48.             sleep(500);
  49.         }
  50.         if (gui.autoCheck.isSelected()) {
  51.             autoCreate = true;
  52.             prefix = gui.prefixText.getText();
  53.             password = gui.passwordText.getText();
  54.         }
  55.         if (gui.skillCombo.getSelectedItem() == "Woodcutting") {
  56.             mining = false;
  57.         }
  58.         return true;
  59.     }
  60.  
  61.     @Override
  62.     public void onFinish() {
  63.         env.enableRandom("LoginBot");
  64.     }
  65.  
  66.     @Override
  67.     public int loop() {
  68.         if (!game.isLoggedIn()) {
  69.             if (autoCreate) {
  70.                 startTime = System.currentTimeMillis();
  71.                 if (interfaceThatContains("Create a Free") == null) {
  72.                     if (!interfaces.getComponent(596, 85).isValid()) {
  73.                         return random(250, 300);
  74.                     }
  75.                     interfaces.getComponent(596, 85).doClick();
  76.                     sleep(random(1000, 1500));
  77.                 }
  78.                 interfaces.getComponent(673, 81).doClick();
  79.                 sleep(random(1000, 1500));
  80.                 do {
  81.                     if (usernameTaken) {
  82.                         interfaceThatContains("close").doClick();
  83.                         int numberOfCharToDelete = (suffix - 1 == -1) ? 0 : ("" + suffix).length();
  84.                         for (int i = 0; i < numberOfCharToDelete; i++) {
  85.                             keyboard.pressKey((char) java.awt.event.KeyEvent.VK_BACK_SPACE);
  86.                             sleep(random(200, 300));
  87.                             keyboard.releaseKey((char) java.awt.event.KeyEvent.VK_BACK_SPACE);
  88.                         }
  89.                     }
  90.                     username = prefix + ((suffix == -1) ? "" : ("" + suffix));
  91.                     if (username.length() > 12) {
  92.                         log("Used up all account names");
  93.                         stopScript();
  94.                         return -1;
  95.                     }
  96.                     if (usernameTaken) {
  97.                         keyboard.sendText("" + suffix, false);
  98.                     } else {
  99.                         keyboard.sendText(username, false);
  100.                     }
  101.                     suffix++;
  102.                     interfaces.getComponent(673, 65).doClick();
  103.                     sleep(random(1500, 2000));
  104.                     while (interfaceThatContains("Please wait...") != null) {
  105.                         sleep(100);
  106.                     }
  107.                     usernameTaken = true;
  108.                 } while (interfaces.getComponent(673, 84).getBackgroundColor() != 1803);
  109.                 usernameTaken = false;
  110.                 do {
  111.                     if (passwordDunMatch) {
  112.                         RSComponent temp = interfaces.getComponent(673, 65);
  113.                         mouse.move(random(temp.getAbsoluteX() + 142, temp.getAbsoluteX() + temp.getWidth()), random(temp.getAbsoluteY(), temp.getAbsoluteY() + temp.getHeight()));
  114.                         mouse.click(true);
  115.                         sleep(random(1000, 1500));
  116.                         int numberOfCharInTextBox = interfaces.getComponent(673, 66).getText().length();
  117.                         for (int i = 0; i < numberOfCharInTextBox; i++) {
  118.                             keyboard.pressKey((char) java.awt.event.KeyEvent.VK_BACK_SPACE);
  119.                             sleep(random(200, 300));
  120.                             keyboard.releaseKey((char) java.awt.event.KeyEvent.VK_BACK_SPACE);
  121.                         }
  122.                     }
  123.                     sleep(random(1000, 1500));
  124.                     keyboard.sendText(password, false);
  125.                     if (passwordDunMatch) {
  126.                         RSComponent temp = interfaces.getComponent(673, 49);
  127.                         mouse.move(random(temp.getAbsoluteX() + 142, temp.getAbsoluteX() + temp.getWidth()), random(temp.getAbsoluteY(), temp.getAbsoluteY() + temp.getHeight()));
  128.                         mouse.click(true);
  129.                         sleep(random(1000, 1500));
  130.                         int numberOfCharInTextBox = interfaces.getComponent(673, 50).getText().length();
  131.                         for (int i = 0; i < numberOfCharInTextBox; i++) {
  132.                             keyboard.pressKey((char) java.awt.event.KeyEvent.VK_BACK_SPACE);
  133.                             sleep(random(200, 300));
  134.                             keyboard.releaseKey((char) java.awt.event.KeyEvent.VK_BACK_SPACE);
  135.                         }
  136.                     } else {
  137.                         interfaces.getComponent(673, 49).doClick();
  138.                     }
  139.                     sleep(random(1000, 1500));
  140.                     keyboard.sendText(password, false);
  141.                     interfaces.getComponent(673, 28).doClick();
  142.                     sleep(random(1500, 2000));
  143.                     passwordDunMatch = true;
  144.                 } while (interfaceThatContains("Please make sure both passwords match") != null);
  145.                 passwordDunMatch = false;
  146.                 while (interfaceThatContains("Please wait...") != null) {
  147.                     sleep(100);
  148.                 }
  149.                 while (interfaceThatContains("Play RuneScape") != null) {
  150.                     interfaces.getComponent(669, 18).doClick();
  151.                     sleep(random(1000, 2000));
  152.                 }
  153.                 interfaces.getComponent(596, 55).doClick();
  154.                 sleep(random(1000, 1500));
  155.                 keyboard.sendText(username, false);
  156.                 interfaces.getComponent(596, 62).doClick();
  157.                 sleep(random(1000, 1500));
  158.                 keyboard.sendText(password, false);
  159.                 while (interfaceThatContains("Click Here To Play") == null) {
  160.                     interfaces.getComponent(596, 63).doClick();
  161.                     sleep(random(2000, 3000));
  162.                 }
  163.                 sleep(random(750, 1000));
  164.                 while (interfaceThatContains("Date of Birth Entry") == null || interfaceThatContains("Click Here To Play") != null) {
  165.                     interfaces.getComponent(906, 170).doClick();
  166.                     sleep(random(3000, 4000));
  167.                 }
  168.                 interfaces.getComponent(204, 29).doClick();
  169.                 sleep(random(500, 1000));
  170.                 interfaces.getComponent(204, 86).getComponent(0).doClick();
  171.                 sleep(random(500, 1000));
  172.                 interfaces.getComponent(204, 45).doClick();
  173.                 sleep(random(500, 1000));
  174.                 interfaces.getComponent(204, 98).getComponent(0).doClick();
  175.                 sleep(random(500, 1000));
  176.                 interfaces.getComponent(204, 61).doClick();
  177.                 sleep(random(500, 1000));
  178.                 mouse.move(interfaces.getComponent(204, 111).getComponent(1).getLocation());
  179.                 sleep(500);
  180.                 mouse.drag(interfaces.getComponent(204, 111).getComponent(5).getLocation());
  181.                 sleep(500);
  182.                 interfaces.getComponent(204, 110).getComponent(2).doClick();
  183.                 sleep(random(500, 1000));
  184.                 interfaces.getComponent(204, 18).doClick();
  185.                 sleep(random(1000, 1500));
  186.                 while (interfaceThatContains("Select Character") == null) {
  187.                     interfaces.getComponent(1051, 14).doClick();
  188.                     sleep(random(2000, 3000));
  189.                 }
  190.                 interfaces.getComponent(1028, random(17, 37)).doClick();
  191.                 sleep(random(500, 1000));
  192.                 interfaces.getComponent(1028, 94).doClick();
  193.                 sleep(random(500, 1000));
  194.                 interfaces.getComponent(1028, 96).doClick();
  195.                 sleep(random(2000, 3000));
  196.                 return 100;
  197.             } else {
  198.                 log("Please login first =)");
  199.                 stopScript();
  200.                 return -1;
  201.             }
  202.         }
  203.         if (canContinue()) {
  204.             clickContinue();
  205.             return random(200, 300);
  206.         }
  207.         if (!interfaces.getComponent(752, 4).getText().contains(blabla)) {
  208.             blabla = interfaces.getComponent(752, 4).getText();
  209.             mouse.move(random(188, 332), random(444, 453));
  210.             mouse.click(true);
  211.             return random(750, 1000);
  212.         }
  213.         if (interfaceThatContains("Controls") != null) {
  214.             int key = java.awt.event.KeyEvent.VK_UP;
  215.             keyboard.pressKey((char) key);
  216.             sleep(random(1000, 1500));
  217.             keyboard.releaseKey((char) key);
  218.             key = (random(0, 2) == 0) ? java.awt.event.KeyEvent.VK_LEFT : java.awt.event.KeyEvent.VK_RIGHT;
  219.             keyboard.pressKey((char) key);
  220.             sleep(random(1000, 1500));
  221.             keyboard.releaseKey((char) key);
  222.             return random(200, 300);
  223.         }
  224.         if (interfaceThatContains("Rotate the camera using the arrow") != null || interfaceThatContains("Talk to Sir Vant to find out") != null) {
  225.             if (interfaceThatContains("Great, you've got the dragon in the right place") != null) {
  226.                 Vant = npcs.getNearest(NPCIDs[2]);
  227.             } else {
  228.                 Vant = npcs.getNearest(NPCIDs[0]);
  229.             }
  230.             if (Vant == null) {
  231.                 return random(200, 300);
  232.             }
  233.             if (!Vant.isOnScreen()) {
  234.                 walking.walkTo(Vant.getLocation());
  235.                 sleepUntilNotMoving();
  236.             }
  237.             Vant.doAction("Talk");
  238.             sleep(random(1000, 2000));
  239.             return random(200, 300);
  240.         }
  241.         if (interfaceThatContains("Right-click on the items on the floor") != null) {
  242.             RSGroundItem stuff = groundItems.getNearest(armoursonfloor);
  243.             while (stuff != null) {
  244.                 stuff.doAction("Take");
  245.                 sleep(random(500, 750));
  246.                 stuff = groundItems.getNearest(armoursonfloor);
  247.             }
  248.             return random(200, 300);
  249.         }
  250.         if (interfaceThatContains("Click on the flashing") != null) {
  251.             if (interfaceThatContains("worn items") != null) {
  252.                 game.openTab(Game.TAB_EQUIPMENT);
  253.             } else if (interfaceThatContains("quest journal") != null) {
  254.                 game.openTab(Game.TAB_QUESTS);
  255.             } else if (interfaceThatContains("objectives") != null) {
  256.                 interfaceThatHasAction("Objectives").doClick();
  257.             } else if (interfaceThatContains("stats") != null) {
  258.                 game.openTab(Game.TAB_STATS);
  259.             } else {
  260.                 game.openTab(Game.TAB_INVENTORY);
  261.             }
  262.             return random(200, 300);
  263.         }
  264.         if (interfaceThatContains("Right-click on an item in your inventory") != null) {
  265.             while (inventory.getCount(1117) == 1) {
  266.                 inventory.getItem(1117).doAction("Wear");
  267.                 sleep(random(500, 750));
  268.             }
  269.             while (inventory.getCount(1173) == 1) {
  270.                 inventory.getItem(1173).doAction("Wield");
  271.                 sleep(random(500, 750));
  272.             }
  273.             while (inventory.getCount(1277) == 1) {
  274.                 inventory.getItem(1277).doAction("Wield");
  275.                 sleep(random(500, 750));
  276.             }
  277.             return random(200, 300);
  278.         }
  279.         if (interfaceThatContains("Your worn items screen shows you") != null) {
  280.             while ((Goblin = npcs.getNearest(NPCIDs[1])) != null) {
  281.                 if (Goblin.getAnimation() == 6182) {
  282.                     break;
  283.                 }
  284.                 if (!Goblin.isOnScreen()) {
  285.                     walking.walkTo(Goblin.getLocation());
  286.                     sleepUntilNotMoving();
  287.                 }
  288.                 if (!getMyPlayer().isInCombat()) {
  289.                     Goblin.doAction("Attack");
  290.                     sleep(random(3000, 4000));
  291.                 }
  292.             }
  293.             return random(300, 500);
  294.         }
  295.         if (interfaceThatContains("You'll see that Unstable Foundations is") != null) {
  296.             mouse.move(random(564, 664), random(309, 314));
  297.             mouse.click(true);
  298.             return random(750, 1000);
  299.         }
  300.         if (interfaceThatContains("Now click on the world map") != null) {
  301.             interfaces.getComponent(548, 176).doClick();
  302.             return random(750, 1000);
  303.         }
  304.         if (interfaceThatContains("Click on the compass") != null) {
  305.             while (interfaces.getComponent(755, 0).getComponents().length > 0) {
  306.                 sleep(100);
  307.             }
  308.             interfaceThatHasAction("Face North").doClick();
  309.             return random(750, 1000);
  310.         }
  311.         if (interfaceThatContains("Time to get on with the quest") != null) {
  312.             if (interfaceThatContains("You'll need to climb over") != null) {
  313.                 hole = objects.getNearest(45603);
  314.                 hole.doAction("Climb");
  315.                 return random(750, 1000);
  316.             }
  317.             bag = objects.getNearest(45783);
  318.             while (inventory.getCount(15277) == 0) {
  319.                 if (!calc.tileOnScreen(bag.getLocation())) {
  320.                     walking.walkTo(bag.getLocation());
  321.                     sleepUntilNotMoving();
  322.                 }
  323.                 bag.doAction("Search");
  324.                 sleep(random(6000, 7000));
  325.             }
  326.             return random(750, 1000);
  327.         }
  328.         if (interfaceThatContains("The wall is too high") != null) {
  329.             plank = objects.getNearest(45652);
  330.             camera.setAltitude(true);
  331.             plank.doAction("Take");
  332.             return random(1500, 2000);
  333.         }
  334.         if (interfaceThatContains("Right-click on the plank in your inventory") != null) {
  335.             hole = objects.getNearest(45603);
  336.             game.openTab(Game.TAB_INVENTORY);
  337.             while (inventory.getCount(15276) == 1) {
  338.                 inventory.getItem(15276).doAction("Use");
  339.                 sleep(random(750, 1000));
  340.                 hole.doAction("Use");
  341.                 sleep(random(2000, 3000));
  342.             }
  343.             return random(750, 1000);
  344.         }
  345.         if (interfaceThatContains("The ramp should make it possible for you") != null) {
  346.             hole = objects.getNearest(45603);
  347.             RSTile currentTile = getMyPlayer().getLocation();
  348.             while (getMyPlayer().getLocation().getY() == currentTile.getY()) {
  349.                 hole.doAction("Climb");
  350.                 sleep(random(1000, 1500));
  351.                 while (getMyPlayer().getAnimation() != -1) {
  352.                     sleep(100);
  353.                 }
  354.             }
  355.             return random(2000, 3000);
  356.         }
  357.         if (objects.getNearest(45795) != null) {
  358.             if (calc.distanceTo(objects.getNearest(45795).getLocation()) < 5) {
  359.                 while (inventory.getCount(15277) == 1) {
  360.                     inventory.getItem(15277).doAction("Use");
  361.                     sleep(random(300, 500));
  362.                     objects.getNearest(45795).doAction("Use");
  363.                     sleep(random(3000, 5000));
  364.                 }
  365.                 return random(200, 300);
  366.             }
  367.         }
  368.         if (interfaceThatContains("Explore the cellar until") != null) {
  369.             referenceTile = objects.getNearest(45563).getLocation();
  370.             if (calc.distanceTo(new RSTile(referenceTile.getX() - 1, referenceTile.getY() + 17)) > 5 && getMyPlayer().getLocation().getY() < referenceTile.getY() + 17) {
  371.                 walking.walkTo(new RSTile(referenceTile.getX() - 1, referenceTile.getY() + 17));
  372.                 sleepUntilNotMoving();
  373.                 walking.setRun(true);
  374.                 walking.walkTo(new RSTile(referenceTile.getX() - 1, referenceTile.getY() + 17));
  375.                 sleepUntilNotMoving();
  376.             }
  377.             walking.walkTo(new RSTile(referenceTile.getX() - 15, referenceTile.getY() + 24));
  378.             sleepUntilNotMoving();
  379.             return random(750, 1000);
  380.         }
  381.         if (interfaceThatContains("Check the quest journal") != null) {
  382.             camera.setAltitude(true);
  383.             if (inventory.getCount(590) == 0) {
  384.                 bag = objects.getNearest(45783);
  385.                 while (inventory.getCount(590) == 0) {
  386.                     if (!calc.tileOnScreen(bag.getLocation())) {
  387.                         walking.walkTo(bag.getLocation());
  388.                         sleepUntilNotMoving();
  389.                     }
  390.                     bag.doAction("Search");
  391.                     sleep(random(6000, 7000));
  392.                 }
  393.                 return random(500, 750);
  394.             }
  395.             if (inventory.getCount(15278) == 1) {
  396.                 inventory.getItem(15278).doAction("Rip");
  397.                 return random(500, 750);
  398.             }
  399.             if (inventory.getCount(15280) > 0) {
  400.                 inventory.getItem(15284).doAction("Use");
  401.                 sleep(random(500, 750));
  402.                 inventory.getItem(15280).doAction("Use");
  403.                 return random(500, 750);
  404.             }
  405.             RSObject Pillar = objects.getNearest(45564);
  406.             if (inventory.getCount(15281) == 2) {
  407.                 inventory.getItem(15281).doAction("Use");
  408.                 sleep(random(500, 750));
  409.                 Pillar.doAction("Use");
  410.                 return random(1000, 1500);
  411.             }
  412.             if (inventory.getCount(15282) == 1) {
  413.                 inventory.getItem(15282).doAction("Use");
  414.                 sleep(random(500, 750));
  415.                 Pillar.doAction("Use");
  416.                 return random(1000, 1500);
  417.             }
  418.             Pillar = objects.getNearest(45565);
  419.             if (!calc.tileOnScreen(Pillar.getLocation())) {
  420.                 walking.walkTo(Pillar.getLocation());
  421.                 sleepUntilNotMoving();
  422.                 return random(500, 750);
  423.             }
  424.             if (inventory.getCount(15281) == 1) {
  425.                 inventory.getItem(15281).doAction("Use");
  426.                 sleep(random(500, 750));
  427.                 Pillar.doAction("Use");
  428.                 return random(1000, 1500);
  429.             }
  430.             if (inventory.getCount(15283) == 1) {
  431.                 inventory.getItem(15283).doAction("Use");
  432.                 sleep(random(500, 750));
  433.                 Pillar.doAction("Use");
  434.                 return random(1000, 1500);
  435.             }
  436.  
  437.         }
  438.         if (interfaceThatContains("give Sir Vant a tinderbox") != null) {
  439.             camera.setAltitude(true);
  440.             Vant = npcs.getNearest(NPCIDs[2]);
  441.             if (Vant == null) {
  442.                 return random(500, 750);
  443.             }
  444.             if (!calc.pointOnScreen(Vant.getScreenLocation())) {
  445.                 walking.walkTo(Vant.getLocation());
  446.                 sleepUntilNotMoving();
  447.             }
  448.             while (inventory.getCount(590) > 1) {
  449.                 inventory.getItem(590).doAction("Use");
  450.                 sleep(random(500, 750));
  451.                 if (!Vant.doAction("Use")) {
  452.                     camera.setAngle(random(0, 360));
  453.                 }
  454.                 return random(2000, 3000);
  455.             }
  456.         }
  457.         if (interfaceThatContains("Use your tinderbox on the pillar") != null) {
  458.             camera.setAltitude(true);
  459.             RSObject Pillar = objects.getNearest(45565);
  460.             if (!calc.tileOnScreen(Pillar.getLocation())) {
  461.                 walking.walkTo(Pillar.getLocation());
  462.                 sleepUntilNotMoving();
  463.             }
  464.             inventory.getItem(590).doAction("Use");
  465.             sleep(random(500, 750));
  466.             Pillar.doAction("Use");
  467.             return random(3000, 4000);
  468.         }
  469.         if (interfaceThatContains("RUN! RUN! RUN!") != null) {
  470.             RSObject Pillar = objects.getNearest(45565);
  471.             walking.walkTo(new RSTile(Pillar.getLocation().getX() + 7, Pillar.getLocation().getY()));
  472.             return random(2000, 3000);
  473.         }
  474.         if (interfaceThatContains("Congratulations, the dragon's dead!") != null) {
  475.             Roddeck = npcs.getNearest(NPCIDs[3]);
  476.             Roddeck.doAction("Talk");
  477.             return random(1000, 1500);
  478.         }
  479.         if (interfaceThatContains("Click on the question mark button") != null) {
  480.             interfaceThatHasAction("Advisor").doClick();
  481.             return random(500, 750);
  482.         }
  483.         if (interfaceThatContains("Sir Vant wants his squire's kit back") != null) {
  484.             game.openTab(Game.TAB_EQUIPMENT);
  485.             sleep(random(500, 750));
  486.             while (equipment.getItem(17).getID() != -1) {
  487.                 equipment.getItem(17).doAction("Remove");
  488.                 sleep(random(750, 1000));
  489.             }
  490.             while (equipment.getItem(20).getID() != -1) {
  491.                 equipment.getItem(20).doAction("Remove");
  492.                 sleep(random(750, 1000));
  493.             }
  494.             while (equipment.getItem(23).getID() != -1) {
  495.                 equipment.getItem(23).doAction("Remove");
  496.                 sleep(random(750, 1000));
  497.             }
  498.             return random(500, 750);
  499.         }
  500.         if (interfaceThatContains("To give Sir Vant an item") != null) {
  501.             game.openTab(Game.TAB_INVENTORY);
  502.             sleep(random(500, 750));
  503.             Vant = npcs.getNearest(NPCIDs[2]);
  504.             if (!Vant.isOnScreen()) {
  505.                 walking.walkTo(Vant.getLocation());
  506.                 sleepUntilNotMoving();
  507.             }
  508.             while (inventory.getCount(590) == 1) {
  509.                 inventory.getItem(590).doAction("Use");
  510.                 sleep(random(500, 750));
  511.                 Vant.doAction("Use");
  512.                 sleep(random(5000, 6000));
  513.             }
  514.             return random(500, 750);
  515.         }
  516.         if (interfaceThatContains("Okay, I'll get on with it") != null) {
  517.             interfaceThatContains("Okay, I'll get on with it").doClick();
  518.             return random(500, 750);
  519.         }
  520.         if (interfaceThatContains("I'll mine through the rocks") != null) {
  521.             if (mining) {
  522.                 interfaceThatContains("I'll mine through the rocks").doClick();
  523.             } else {
  524.                 interfaceThatContains("I'll chop through the roots").doClick();
  525.             }
  526.             return random(500, 750);
  527.         }
  528.         if (interfaceThatContains("Speak to Roddeck, your advisor, about breaking") != null) {
  529.             camera.setAltitude(true);
  530.             Roddeck = npcs.getNearest(NPCIDs[3]);
  531.             if (!Roddeck.isOnScreen()) {
  532.                 walking.walkTo(Roddeck.getLocation());
  533.                 sleepUntilNotMoving();
  534.             }
  535.             Roddeck.doAction("Talk");
  536.             return random(500, 750);
  537.         }
  538.         if (interfaceThatContains("While you've got a pickaxe") != null) {
  539.             RSObject damagedWallRock = objects.getNearest(45595);
  540.             if (!calc.tileOnScreen(damagedWallRock.getLocation())) {
  541.                 walking.walkTo(damagedWallRock.getLocation());
  542.                 sleepUntilNotMoving();
  543.             }
  544.             damagedWallRock.doAction("Mine");
  545.             sleep(random(5000, 6000));
  546.             return random(500, 750);
  547.         }
  548.         if (interfaceThatContains("While you've got a hatchet") != null) {
  549.             RSObject roots = objects.getNearest(45598);
  550.             if (!calc.tileOnScreen(roots.getLocation())) {
  551.                 walking.walkTo(roots.getLocation());
  552.                 sleepUntilNotMoving();
  553.             }
  554.             roots.doAction("Chop");
  555.             sleep(random(5000, 6000));
  556.             return random(500, 750);
  557.         }
  558.         if (interfaceThatContains("Your current objective is to raise your Mining level") != null) {
  559.             camera.setAltitude(true);
  560.             RSObject Rocks = objects.getNearest(45580);
  561.             if (!calc.tileOnScreen(Rocks.getLocation())) {
  562.                 walking.walkTo(Rocks.getLocation());
  563.                 sleepUntilNotMoving();
  564.             }
  565.             while (skills.getCurrentLevel(Skills.MINING) < 2) {
  566.                 Rocks.doAction("Mine");
  567.                 sleep(random(2000, 3000));
  568.                 while (getMyPlayer().getAnimation() == 6747) {
  569.                     sleep(100);
  570.                 }
  571.             }
  572.             return random(500, 750);
  573.         }
  574.         if (interfaceThatContains("Your current objective is to raise your Woodcutting level") != null) {
  575.             camera.setAltitude(true);
  576.             RSObject treeRoots = objects.getTopAt(new RSTile(objects.getNearest(45589).getLocation().getX(), objects.getNearest(45589).getLocation().getY() + 1));
  577.             if (!calc.tileOnScreen(treeRoots.getLocation())) {
  578.                 walking.walkTo(treeRoots.getLocation());
  579.                 sleepUntilNotMoving();
  580.             }
  581.             while (skills.getCurrentLevel(Skills.WOODCUTTING) < 2) {
  582.                 treeRoots.doAction("Chop");
  583.                 sleep(random(2000, 3000));
  584.                 while (getMyPlayer().getAnimation() == 879) {
  585.                     sleep(100);
  586.                 }
  587.             }
  588.             return random(500, 750);
  589.         }
  590.         if (interfaceThatContains("set yourself an objective") != null) {
  591.             interfaceThatHasAction("Objectives").doClick();
  592.             sleep(random(1000, 1500));
  593.             if (mining) {
  594.                 if (interfaceThatContains("Increase Mining from") == null) {
  595.                     interfaceThatHasAction("Give random objective").doClick();
  596.                 }
  597.                 sleep(random(1000, 1500));
  598.                 interfaceThatContains("Increase Mining from").doClick();
  599.                 sleep(random(500, 750));
  600.             } else {
  601.                 if (interfaceThatContains("Increase Woodcutting from") == null) {
  602.                     interfaceThatHasAction("Give random objective").doClick();
  603.                 }
  604.                 sleep(random(1000, 1500));
  605.                 interfaceThatContains("Increase Woodcutting from").doClick();
  606.                 sleep(random(500, 750));
  607.             }
  608.             if (interfaceThatContains("Advisor") == null) {
  609.                 interfaceThatHasAction("Advisor").doClick();
  610.             }
  611.             return random(1000, 2000);
  612.         }
  613.         if (interfaceThatContains("advisor button") != null) {
  614.             if (interfaceThatContains("How can I raise my") == null) {
  615.                 interfaceThatHasAction("Advisor").doClick();
  616.             }
  617.             sleep(random(1000, 1500));
  618.             if (interfaceThatContains("How can I raise my") == null) {
  619.                 return random(500, 750);
  620.             }
  621.             interfaceThatContains("How can I raise my").doClick();
  622.             return random(500, 750);
  623.         }
  624.         if (interfaceThatContains("Your Mining level is now high enough") != null) {
  625.             RSObject damagedWallRock = objects.getNearest(45595);
  626.             if (damagedWallRock != null) {
  627.                 if (!calc.tileOnScreen(damagedWallRock.getLocation())) {
  628.                     walking.walkTo(damagedWallRock.getLocation());
  629.                     sleepUntilNotMoving();
  630.                 }
  631.                 damagedWallRock.doAction("Mine");
  632.                 return random(500, 750);
  633.             } else {
  634.                 damagedWallRock = objects.getNearest(45597);
  635.                 if (damagedWallRock == null) {
  636.                     return random(200, 300);
  637.                 }
  638.                 damagedWallRock.doAction("Climb");
  639.                 sleep(random(750, 1000));
  640.                 while (getMyPlayer().getAnimation() == 12280 || getMyPlayer().isMoving()) {
  641.                     sleep(100);
  642.                 }
  643.                 return random(500, 750);
  644.             }
  645.         }
  646.         if (interfaceThatContains("Your Woodcutting level is now high enough") != null) {
  647.             RSObject root = objects.getNearest(45598);
  648.             if (root != null) {
  649.                 if (!calc.tileOnScreen(root.getLocation())) {
  650.                     walking.walkTo(root.getLocation());
  651.                     sleepUntilNotMoving();
  652.                 }
  653.                 root.doAction("Chop");
  654.                 return random(500, 750);
  655.             } else {
  656.                 root = objects.getNearest(45600);
  657.                 if (root == null) {
  658.                     return random(200, 300);
  659.                 }
  660.                 root.doAction("Climb");
  661.                 sleep(random(750, 1000));
  662.                 while (getMyPlayer().isMoving()) {
  663.                     sleep(100);
  664.                 }
  665.                 return random(500, 750);
  666.             }
  667.         }
  668.         if (interfaceThatContains("Escape up the ladder to freedom!") != null) {
  669.             game.openTab(Game.TAB_INVENTORY);
  670.             while (inventory.contains(15286)) {
  671.                 inventory.getItem(15286).doAction("Drop");
  672.                 sleep(random(500, 750));
  673.                 clickContinue();
  674.             }
  675.             while (inventory.contains(15285)) {
  676.                 inventory.getItem(15285).doAction("Drop");
  677.                 sleep(random(500, 750));
  678.                 clickContinue();
  679.             }
  680.             RSObject ladder = objects.getNearest(45784);
  681.             if (ladder == null) {
  682.                 return random(250, 300);
  683.             }
  684.             interfaceThatHasAction("Face North").doClick();
  685.             if (calc.distanceTo(ladder.getLocation()) > 3) {
  686.                 walking.walkTo(ladder.getLocation());
  687.                 sleepUntilNotMoving();
  688.             }
  689.             while (interfaceThatContains("Thank you again") == null) {
  690.                 ladder = objects.getNearest(45784);
  691.                 if (ladder == null) {
  692.                     break;
  693.                 }
  694.                 ladder.doAction("Climb");
  695.             }
  696.             return random(500, 750);
  697.         }
  698.         if (interfaceThatContains("You're out!") != null) {
  699.             Vant = npcs.getNearest(NPCIDs[2]);
  700.             if (Vant == null) {
  701.                 mouse.move(random(188, 332), random(444, 453));
  702.                 mouse.click(true);
  703.                 return random(500, 750);
  704.             }
  705.             if (Vant.isMoving()) {
  706.                 mouse.move(random(188, 332), random(444, 453));
  707.                 mouse.click(true);
  708.                 return random(500, 750);
  709.             }
  710.             walking.walkTo(Vant.getLocation());
  711.             camera.setAltitude(true);
  712.             sleepUntilNotMoving();
  713.             if (!calc.pointOnScreen(Vant.getScreenLocation())) {
  714.                 walking.walkTo(Vant.getLocation());
  715.                 sleepUntilNotMoving();
  716.             }
  717.             Vant.doAction("Talk");
  718.             return random(500, 750);
  719.         }
  720.         if (interfaceThatContains("Roddeck would like to offer you some") != null) {
  721.             camera.setAltitude(true);
  722.             Roddeck = npcs.getNearest(NPCIDs[3]);
  723.             if (!Roddeck.isOnScreen()) {
  724.                 walking.walkTo(Roddeck.getLocation());
  725.                 sleepUntilNotMoving();
  726.             }
  727.             Roddeck.doAction("Talk");
  728.             return random(500, 750);
  729.         }
  730.         if (interfaceThatContains("You may now leave via the door") != null) {
  731.             interfaceThatHasAction("Face North").doClick();
  732.             RSObject door = objects.getNearest(45801);
  733.             if (door == null) {
  734.                 return random(200, 300);
  735.             }
  736.             door.doAction("Open");
  737.             return random(500, 750);
  738.         }
  739.         if (calc.distanceTo(new RSTile(3204, 3246)) < 8) {
  740.             if (!autoCreate) {
  741.                 log("Tutorial Finished! =)");
  742.                 game.logout(false);
  743.                 stopScript();
  744.             } else {
  745.                 java.io.BufferedWriter out;
  746.                 java.io.FileWriter fstream;
  747.                 java.io.File accounts = new java.io.File("Accounts.txt");
  748.                 if (accounts.exists()) {
  749.                     try {
  750.                         fstream = new java.io.FileWriter("Accounts.txt", true);
  751.                         out = new java.io.BufferedWriter(fstream);
  752.                         out.newLine();
  753.                         out.write(username);
  754.                         out.close();
  755.                     } catch (java.io.IOException e) {
  756.                     }
  757.                 } else {
  758.                     try {
  759.                         fstream = new java.io.FileWriter("Accounts.txt", false);
  760.                         out = new java.io.BufferedWriter(fstream);
  761.                         out.write(username);
  762.                         out.close();
  763.                     } catch (java.io.IOException e) {
  764.                     }
  765.                 }
  766.                 log("Account " + username + " has been saved");
  767.                 accountsCreated++;
  768.                 totalTime += System.currentTimeMillis() - startTime;
  769.                 averageTime = totalTime / accountsCreated;
  770.                 game.logout(true);
  771.                 while (game.isLoggedIn()) {
  772.                     sleep(10);
  773.                 }
  774.                 return random(2000, 3000);
  775.             }
  776.         }
  777.         return random(200, 300);
  778.     }
  779.  
  780.     public void onRepaint(Graphics g) {
  781.         final int x = 515 - 230;
  782.         int y = 4;
  783.         long timeToDisplay = averageTime;
  784.         long minutes = timeToDisplay / 1000 / 60;
  785.         timeToDisplay -= minutes * 1000 * 60;
  786.         long seconds = timeToDisplay / 1000;
  787.         g.setColor(new Color(0, 0, 0, 150));
  788.         g.fillRoundRect(x, y, 230, height, 15, 15);
  789.         g.setColor(new Color(0, 255, 0, 255));
  790.         g.drawRoundRect(x, y, 230, height, 20, 15);
  791.         g.drawString("TISolver v" + getVersion(), x + 76, y += 15);
  792.         if (autoCreate) {
  793.             g.drawString("Accounts Created: " + accountsCreated, x + 60, y += 15);
  794.             if (accountsCreated > 0) {
  795.                 g.drawString("Average Time per Account: " + minutes + "min" + seconds + "sec", x + 10, y += 15);
  796.             }
  797.         }
  798.         height = y + 3;
  799.     }
  800.  
  801.     public String getVersion() {
  802.         return "" + getClass().getAnnotation(ScriptManifest.class).version();
  803.     }
  804.  
  805.     public RSComponent interfaceThatContains(String str) {
  806.         for (RSInterface i : interfaces.getAll()) {
  807.             if (i.isValid()) {
  808.                 for (RSComponent children : i.getComponents()) {
  809.                     if (children.isValid()) {
  810.                         if (children.getComponents().length > 0) {
  811.                             for (RSComponent component : children.getComponents()) {
  812.                                 if (component.isValid()) {
  813.                                     if (component.containsText(str)) {
  814.                                         return component;
  815.                                     }
  816.                                 }
  817.                             }
  818.                         } else {
  819.                             if (children.containsText(str)) {
  820.                                 return children;
  821.                             }
  822.                         }
  823.                     }
  824.                 }
  825.             }
  826.         }
  827.         return null;
  828.     }
  829.  
  830.     public RSComponent interfaceThatHasAction(String str) {
  831.         for (RSInterface i : interfaces.getAll()) {
  832.             if (i.isValid()) {
  833.                 for (RSComponent child : i.getComponents()) {
  834.                     if (child.isValid()) {
  835.                         if (child.getActions() != null) {
  836.                             for (String s : child.getActions()) {
  837.                                 if (s != null && s.contains(str)) {
  838.                                     return child;
  839.                                 }
  840.                             }
  841.                         }
  842.                         if (child.getComponents().length > 0) {
  843.                             for (RSComponent component : child.getComponents()) {
  844.                                 if (component.isValid() && component.getActions() != null) {
  845.                                     for (String s : component.getActions()) {
  846.                                         if (s != null && s.contains(str)) {
  847.                                             return component;
  848.                                         }
  849.                                     }
  850.                                 }
  851.                             }
  852.                         }
  853.                     }
  854.                 }
  855.             }
  856.         }
  857.         return null;
  858.     }
  859.  
  860.     public void sleepUntilNotMoving() {
  861.         sleep(random(700, 1000));
  862.         while (getMyPlayer().isMoving()) {
  863.             sleep(random(25, 100));
  864.         }
  865.     }
  866.  
  867.     public RSComponent getContinueChildInterface() {
  868.         RSInterface[] valid = interfaces.getAll();
  869.         for (RSInterface iface : valid) {
  870.             if (iface.getIndex() != 137 && iface.getIndex() != 752) {
  871.                 int len = iface.getChildCount();
  872.                 for (int i = 0; i < len; i++) {
  873.                     RSComponent child = iface.getComponent(i);
  874.                     if (child.containsText("Click here to continue") && child.getWidth() > 30 && child.getAbsoluteY() > 337) {
  875.                         return child;
  876.                     }
  877.                 }
  878.             }
  879.         }
  880.         return null;
  881.     }
  882.  
  883.     public boolean canContinue() {
  884.         return getContinueChildInterface() != null;
  885.     }
  886.  
  887.     public boolean clickContinue() {
  888.         RSComponent cont = getContinueChildInterface();
  889.         return !(cont != null && cont.isValid()) || cont.doClick();
  890.     }
  891.  
  892.     public class TISolverGUI extends javax.swing.JFrame {
  893.  
  894.         /** Creates new form TISolverGUI */
  895.         public TISolverGUI() {
  896.             initComponents();
  897.             setLocationRelativeTo(getOwner());
  898.         }
  899.  
  900.         /** This method is called from within the constructor to
  901.          * initialize the form.
  902.          * WARNING: Do NOT modify this code. The content of this method is
  903.          * always regenerated by the Form Editor.
  904.          */
  905.         @SuppressWarnings("unchecked")
  906.     // <editor-fold defaultstate="collapsed" desc="Generated Code">
  907.     private void initComponents() {
  908.  
  909.         autoCheck = new javax.swing.JCheckBox();
  910.         jLabel1 = new javax.swing.JLabel();
  911.         prefixText = new javax.swing.JTextField();
  912.         jLabel2 = new javax.swing.JLabel();
  913.         passwordText = new javax.swing.JTextField();
  914.         jLabel3 = new javax.swing.JLabel();
  915.         skillCombo = new javax.swing.JComboBox();
  916.         jButton1 = new javax.swing.JButton();
  917.  
  918.         setTitle("Settings");
  919.         addWindowListener(new java.awt.event.WindowAdapter() {
  920.             public void windowClosing(java.awt.event.WindowEvent evt) {
  921.                 formWindowClosing(evt);
  922.             }
  923.         });
  924.  
  925.         autoCheck.setText("Auto-Create Account");
  926.         autoCheck.addActionListener(new java.awt.event.ActionListener() {
  927.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  928.                 autoCheckActionPerformed(evt);
  929.             }
  930.         });
  931.  
  932.         jLabel1.setText("Prefix:");
  933.  
  934.         prefixText.setEditable(false);
  935.  
  936.         jLabel2.setText("Password:");
  937.  
  938.         passwordText.setEditable(false);
  939.  
  940.         jLabel3.setText("Train Skill:");
  941.  
  942.         skillCombo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Mining", "Woodcutting" }));
  943.  
  944.         jButton1.setText("OK");
  945.         jButton1.addActionListener(new java.awt.event.ActionListener() {
  946.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  947.                 jButton1ActionPerformed(evt);
  948.             }
  949.         });
  950.  
  951.         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  952.         getContentPane().setLayout(layout);
  953.         layout.setHorizontalGroup(
  954.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  955.             .addGroup(layout.createSequentialGroup()
  956.                 .addContainerGap()
  957.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  958.                     .addComponent(jButton1)
  959.                     .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
  960.                         .addComponent(autoCheck)
  961.                         .addGroup(layout.createSequentialGroup()
  962.                             .addGap(21, 21, 21)
  963.                             .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  964.                                 .addComponent(jLabel2)
  965.                                 .addComponent(jLabel1))
  966.                             .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  967.                             .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
  968.                                 .addComponent(prefixText)
  969.                                 .addComponent(passwordText, javax.swing.GroupLayout.DEFAULT_SIZE, 101, Short.MAX_VALUE)))
  970.                         .addGroup(layout.createSequentialGroup()
  971.                             .addComponent(jLabel3)
  972.                             .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  973.                             .addComponent(skillCombo, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
  974.                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  975.         );
  976.         layout.setVerticalGroup(
  977.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  978.             .addGroup(layout.createSequentialGroup()
  979.                 .addContainerGap()
  980.                 .addComponent(autoCheck)
  981.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  982.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  983.                     .addComponent(jLabel1)
  984.                     .addComponent(prefixText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  985.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  986.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  987.                     .addComponent(jLabel2)
  988.                     .addComponent(passwordText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  989.                 .addGap(18, 18, 18)
  990.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  991.                     .addComponent(jLabel3)
  992.                     .addComponent(skillCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  993.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  994.                 .addComponent(jButton1)
  995.                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  996.         );
  997.  
  998.         pack();
  999.     }// </editor-fold>
  1000.  
  1001.         private void autoCheckActionPerformed(java.awt.event.ActionEvent evt) {
  1002.             if (autoCheck.isSelected()) {
  1003.                 prefixText.setEditable(true);
  1004.                 passwordText.setEditable(true);
  1005.             } else {
  1006.                 prefixText.setEditable(false);
  1007.                 passwordText.setEditable(false);
  1008.             }
  1009.         }
  1010.  
  1011.         private void formWindowClosing(java.awt.event.WindowEvent evt) {
  1012.             stopScript();
  1013.         }
  1014.  
  1015.         private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
  1016.             setVisible(false);
  1017.         }
  1018.     // Variables declaration - do not modify
  1019.     public javax.swing.JCheckBox autoCheck;
  1020.     private javax.swing.JButton jButton1;
  1021.     private javax.swing.JLabel jLabel1;
  1022.     private javax.swing.JLabel jLabel2;
  1023.     private javax.swing.JLabel jLabel3;
  1024.     private javax.swing.JTextField passwordText;
  1025.     public javax.swing.JTextField prefixText;
  1026.     public javax.swing.JComboBox skillCombo;
  1027.     // End of variables declaration
  1028.     }
  1029. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement