Advertisement
Guest User

Untitled

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