Advertisement
Guest User

Untitled

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