Advertisement
Guest User

Untitled

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