Advertisement
Guest User

Untitled

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