Advertisement
Guest User

Untitled

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