Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- *
- * @author Frederick
- */
- import java.awt.Graphics;
- import java.awt.Color;
- import org.rsbot.script.ScriptManifest;
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.script.Script;
- import org.rsbot.script.methods.Game;
- import org.rsbot.script.methods.Skills;
- import org.rsbot.script.wrappers.RSInterface;
- import org.rsbot.script.wrappers.RSComponent;
- import org.rsbot.script.wrappers.RSGroundItem;
- import org.rsbot.script.wrappers.RSObject;
- import org.rsbot.script.wrappers.RSTile;
- import org.rsbot.script.wrappers.RSNPC;
- @ScriptManifest(name = "TISolver", authors = {"Fred"}, version = 1.08, description = "Solves the Tutorial Quest for you")
- public class TISolver extends Script implements PaintListener {
- boolean autoCreate = false, usernameTaken = false, passwordDunMatch = false;
- String prefix, password, username;
- int[] interfaceID;
- int suffix = -1;
- RSTile referenceTile;
- RSObject hole, plank, bag;
- RSNPC Vant, Goblin, Vant2, Roddeck;
- int[] NPCIDs = {8850, 8862, 8848, 8867};
- int[] armoursonfloor = {1117, 1173, 1277};
- int accountsCreated = 0;
- int height = 1;
- long startTime = 0;
- long totalTime = 0;
- long averageTime = 0;
- boolean mining = true;
- String blabla = "random stuff";
- @Override
- public boolean onStart() {
- env.disableRandom("Login");
- env.enableRandom("InterfaceCloser");
- TISolverGUI gui = new TISolverGUI();
- gui.setVisible(true);
- while (gui.isVisible()) {
- sleep(500);
- }
- if (gui.autoCheck.isSelected()) {
- autoCreate = true;
- prefix = gui.prefixText.getText();
- password = gui.passwordText.getText();
- }
- if (gui.skillCombo.getSelectedItem() == "Woodcutting") {
- mining = false;
- }
- return true;
- }
- @Override
- public void onFinish() {
- env.enableRandom("LoginBot");
- }
- @Override
- public int loop() {
- if (!game.isLoggedIn()) {
- if (autoCreate) {
- startTime = System.currentTimeMillis();
- if (interfaceThatContains("Create a Free") == null) {
- if (!interfaces.getComponent(596, 85).isValid()) {
- return random(250, 300);
- }
- interfaces.getComponent(596, 85).doClick();
- sleep(random(1000, 1500));
- }
- interfaces.getComponent(673, 81).doClick();
- sleep(random(1000, 1500));
- do {
- if (usernameTaken) {
- interfaceThatContains("close").doClick();
- int numberOfCharToDelete = (suffix - 1 == -1) ? 0 : ("" + suffix).length();
- for (int i = 0; i < numberOfCharToDelete; i++) {
- keyboard.pressKey((char) java.awt.event.KeyEvent.VK_BACK_SPACE);
- sleep(random(200, 300));
- keyboard.releaseKey((char) java.awt.event.KeyEvent.VK_BACK_SPACE);
- }
- }
- username = prefix + ((suffix == -1) ? "" : ("" + suffix));
- if (username.length() > 12) {
- log("Used up all account names");
- stopScript();
- return -1;
- }
- if (usernameTaken) {
- keyboard.sendText("" + suffix, false);
- } else {
- keyboard.sendText(username, false);
- }
- suffix++;
- interfaces.getComponent(673, 65).doClick();
- sleep(random(1500, 2000));
- while (interfaceThatContains("Please wait...") != null) {
- sleep(100);
- }
- usernameTaken = true;
- } while (interfaces.getComponent(673, 84).getBackgroundColor() != 1803);
- usernameTaken = false;
- do {
- if (passwordDunMatch) {
- RSComponent temp = interfaces.getComponent(673, 65);
- mouse.move(random(temp.getAbsoluteX() + 142, temp.getAbsoluteX() + temp.getWidth()), random(temp.getAbsoluteY(), temp.getAbsoluteY() + temp.getHeight()));
- mouse.click(true);
- sleep(random(1000, 1500));
- int numberOfCharInTextBox = interfaces.getComponent(673, 66).getText().length();
- for (int i = 0; i < numberOfCharInTextBox; i++) {
- keyboard.pressKey((char) java.awt.event.KeyEvent.VK_BACK_SPACE);
- sleep(random(200, 300));
- keyboard.releaseKey((char) java.awt.event.KeyEvent.VK_BACK_SPACE);
- }
- }
- sleep(random(1000, 1500));
- keyboard.sendText(password, false);
- if (passwordDunMatch) {
- RSComponent temp = interfaces.getComponent(673, 49);
- mouse.move(random(temp.getAbsoluteX() + 142, temp.getAbsoluteX() + temp.getWidth()), random(temp.getAbsoluteY(), temp.getAbsoluteY() + temp.getHeight()));
- mouse.click(true);
- sleep(random(1000, 1500));
- int numberOfCharInTextBox = interfaces.getComponent(673, 50).getText().length();
- for (int i = 0; i < numberOfCharInTextBox; i++) {
- keyboard.pressKey((char) java.awt.event.KeyEvent.VK_BACK_SPACE);
- sleep(random(200, 300));
- keyboard.releaseKey((char) java.awt.event.KeyEvent.VK_BACK_SPACE);
- }
- } else {
- interfaces.getComponent(673, 49).doClick();
- }
- sleep(random(1000, 1500));
- keyboard.sendText(password, false);
- interfaces.getComponent(673, 28).doClick();
- sleep(random(1500, 2000));
- passwordDunMatch = true;
- } while (interfaceThatContains("Please make sure both passwords match") != null);
- passwordDunMatch = false;
- while (interfaceThatContains("Please wait...") != null) {
- sleep(100);
- }
- while (interfaceThatContains("Play RuneScape") != null) {
- interfaces.getComponent(669, 18).doClick();
- sleep(random(1000, 2000));
- }
- interfaces.getComponent(596, 55).doClick();
- sleep(random(1000, 1500));
- keyboard.sendText(username, false);
- interfaces.getComponent(596, 62).doClick();
- sleep(random(1000, 1500));
- keyboard.sendText(password, false);
- while (interfaceThatContains("Click Here To Play") == null) {
- interfaces.getComponent(596, 63).doClick();
- sleep(random(2000, 3000));
- }
- sleep(random(750, 1000));
- while (interfaceThatContains("Date of Birth Entry") == null || interfaceThatContains("Click Here To Play") != null) {
- interfaces.getComponent(906, 170).doClick();
- sleep(random(3000, 4000));
- }
- interfaces.getComponent(204, 29).doClick();
- sleep(random(500, 1000));
- interfaces.getComponent(204, 86).getComponent(0).doClick();
- sleep(random(500, 1000));
- interfaces.getComponent(204, 45).doClick();
- sleep(random(500, 1000));
- interfaces.getComponent(204, 98).getComponent(0).doClick();
- sleep(random(500, 1000));
- interfaces.getComponent(204, 61).doClick();
- sleep(random(500, 1000));
- mouse.move(interfaces.getComponent(204, 111).getComponent(1).getLocation());
- sleep(500);
- mouse.drag(interfaces.getComponent(204, 111).getComponent(5).getLocation());
- sleep(500);
- interfaces.getComponent(204, 110).getComponent(2).doClick();
- sleep(random(500, 1000));
- interfaces.getComponent(204, 18).doClick();
- sleep(random(1000, 1500));
- while (interfaceThatContains("Select Character") == null) {
- interfaces.getComponent(1051, 14).doClick();
- sleep(random(2000, 3000));
- }
- interfaces.getComponent(1028, random(17, 37)).doClick();
- sleep(random(500, 1000));
- interfaces.getComponent(1028, 94).doClick();
- sleep(random(500, 1000));
- interfaces.getComponent(1028, 96).doClick();
- sleep(random(2000, 3000));
- return 100;
- } else {
- log("Please login first =)");
- stopScript();
- return -1;
- }
- }
- if (canContinue()) {
- clickContinue();
- return random(200, 300);
- }
- if (!interfaces.getComponent(752, 4).getText().contains(blabla)) {
- blabla = interfaces.getComponent(752, 4).getText();
- mouse.move(random(188, 332), random(444, 453));
- mouse.click(true);
- return random(750, 1000);
- }
- if (interfaceThatContains("Controls") != null) {
- int key = java.awt.event.KeyEvent.VK_UP;
- keyboard.pressKey((char) key);
- sleep(random(1000, 1500));
- keyboard.releaseKey((char) key);
- key = (random(0, 2) == 0) ? java.awt.event.KeyEvent.VK_LEFT : java.awt.event.KeyEvent.VK_RIGHT;
- keyboard.pressKey((char) key);
- sleep(random(1000, 1500));
- keyboard.releaseKey((char) key);
- return random(200, 300);
- }
- if (interfaceThatContains("Rotate the camera using the arrow") != null || interfaceThatContains("Talk to Sir Vant to find out") != null) {
- if (interfaceThatContains("Great, you've got the dragon in the right place") != null) {
- Vant = npcs.getNearest(NPCIDs[2]);
- } else {
- Vant = npcs.getNearest(NPCIDs[0]);
- }
- if (Vant == null) {
- return random(200, 300);
- }
- if (!Vant.isOnScreen()) {
- walking.walkTo(Vant.getLocation());
- sleepUntilNotMoving();
- }
- Vant.doAction("Talk");
- sleep(random(1000, 2000));
- return random(200, 300);
- }
- if (interfaceThatContains("Right-click on the items on the floor") != null) {
- RSGroundItem stuff = groundItems.getNearest(armoursonfloor);
- while (stuff != null) {
- stuff.doAction("Take");
- sleep(random(500, 750));
- stuff = groundItems.getNearest(armoursonfloor);
- }
- return random(200, 300);
- }
- if (interfaceThatContains("Click on the flashing") != null) {
- if (interfaceThatContains("worn items") != null) {
- game.openTab(Game.TAB_EQUIPMENT);
- } else if (interfaceThatContains("quest journal") != null) {
- game.openTab(Game.TAB_QUESTS);
- } else if (interfaceThatContains("objectives") != null) {
- interfaceThatHasAction("Objectives").doClick();
- } else if (interfaceThatContains("stats") != null) {
- game.openTab(Game.TAB_STATS);
- } else {
- game.openTab(Game.TAB_INVENTORY);
- }
- return random(200, 300);
- }
- if (interfaceThatContains("Right-click on an item in your inventory") != null) {
- while (inventory.getCount(1117) == 1) {
- inventory.getItem(1117).doAction("Wear");
- sleep(random(500, 750));
- }
- while (inventory.getCount(1173) == 1) {
- inventory.getItem(1173).doAction("Wield");
- sleep(random(500, 750));
- }
- while (inventory.getCount(1277) == 1) {
- inventory.getItem(1277).doAction("Wield");
- sleep(random(500, 750));
- }
- return random(200, 300);
- }
- if (interfaceThatContains("Your worn items screen shows you") != null) {
- while ((Goblin = npcs.getNearest(NPCIDs[1])) != null) {
- if (Goblin.getAnimation() == 6182) {
- break;
- }
- if (!Goblin.isOnScreen()) {
- walking.walkTo(Goblin.getLocation());
- sleepUntilNotMoving();
- }
- if (!getMyPlayer().isInCombat()) {
- Goblin.doAction("Attack");
- sleep(random(3000, 4000));
- }
- }
- return random(300, 500);
- }
- if (interfaceThatContains("You'll see that Unstable Foundations is") != null) {
- mouse.move(random(564, 664), random(309, 314));
- mouse.click(true);
- return random(750, 1000);
- }
- if (interfaceThatContains("Now click on the world map") != null) {
- interfaces.getComponent(548, 176).doClick();
- return random(750, 1000);
- }
- if (interfaceThatContains("Click on the compass") != null) {
- while (interfaces.getComponent(755, 0).getComponents().length > 0) {
- sleep(100);
- }
- interfaceThatHasAction("Face North").doClick();
- return random(750, 1000);
- }
- if (interfaceThatContains("Time to get on with the quest") != null) {
- if (interfaceThatContains("You'll need to climb over") != null) {
- hole = objects.getNearest(45603);
- hole.doAction("Climb");
- return random(750, 1000);
- }
- bag = objects.getNearest(45783);
- while (inventory.getCount(15277) == 0) {
- if (!calc.tileOnScreen(bag.getLocation())) {
- walking.walkTo(bag.getLocation());
- sleepUntilNotMoving();
- }
- bag.doAction("Search");
- sleep(random(6000, 7000));
- }
- return random(750, 1000);
- }
- if (interfaceThatContains("The wall is too high") != null) {
- plank = objects.getNearest(45652);
- camera.setAltitude(true);
- plank.doAction("Take");
- return random(1500, 2000);
- }
- if (interfaceThatContains("Right-click on the plank in your inventory") != null) {
- hole = objects.getNearest(45603);
- game.openTab(Game.TAB_INVENTORY);
- while (inventory.getCount(15276) == 1) {
- inventory.getItem(15276).doAction("Use");
- sleep(random(750, 1000));
- hole.doAction("Use");
- sleep(random(2000, 3000));
- }
- return random(750, 1000);
- }
- if (interfaceThatContains("The ramp should make it possible for you") != null) {
- hole = objects.getNearest(45603);
- RSTile currentTile = getMyPlayer().getLocation();
- while (getMyPlayer().getLocation().getY() == currentTile.getY()) {
- hole.doAction("Climb");
- sleep(random(1000, 1500));
- while (getMyPlayer().getAnimation() != -1) {
- sleep(100);
- }
- }
- return random(2000, 3000);
- }
- if (objects.getNearest(45795) != null) {
- if (calc.distanceTo(objects.getNearest(45795).getLocation()) < 5) {
- while (inventory.getCount(15277) == 1) {
- inventory.getItem(15277).doAction("Use");
- sleep(random(300, 500));
- objects.getNearest(45795).doAction("Use");
- sleep(random(3000, 5000));
- }
- return random(200, 300);
- }
- }
- if (interfaceThatContains("Explore the cellar until") != null) {
- referenceTile = objects.getNearest(45563).getLocation();
- if (calc.distanceTo(new RSTile(referenceTile.getX() - 1, referenceTile.getY() + 17)) > 5 && getMyPlayer().getLocation().getY() < referenceTile.getY() + 17) {
- walking.walkTo(new RSTile(referenceTile.getX() - 1, referenceTile.getY() + 17));
- sleepUntilNotMoving();
- walking.setRun(true);
- walking.walkTo(new RSTile(referenceTile.getX() - 1, referenceTile.getY() + 17));
- sleepUntilNotMoving();
- }
- walking.walkTo(new RSTile(referenceTile.getX() - 15, referenceTile.getY() + 24));
- sleepUntilNotMoving();
- return random(750, 1000);
- }
- if (interfaceThatContains("Check the quest journal") != null) {
- camera.setAltitude(true);
- if (inventory.getCount(590) == 0) {
- bag = objects.getNearest(45783);
- while (inventory.getCount(590) == 0) {
- if (!calc.tileOnScreen(bag.getLocation())) {
- walking.walkTo(bag.getLocation());
- sleepUntilNotMoving();
- }
- bag.doAction("Search");
- sleep(random(6000, 7000));
- }
- return random(500, 750);
- }
- if (inventory.getCount(15278) == 1) {
- inventory.getItem(15278).doAction("Rip");
- return random(500, 750);
- }
- if (inventory.getCount(15280) > 0) {
- inventory.getItem(15284).doAction("Use");
- sleep(random(500, 750));
- inventory.getItem(15280).doAction("Use");
- return random(500, 750);
- }
- RSObject Pillar = objects.getNearest(45564);
- if (inventory.getCount(15281) == 2) {
- inventory.getItem(15281).doAction("Use");
- sleep(random(500, 750));
- Pillar.doAction("Use");
- return random(1000, 1500);
- }
- if (inventory.getCount(15282) == 1) {
- inventory.getItem(15282).doAction("Use");
- sleep(random(500, 750));
- Pillar.doAction("Use");
- return random(1000, 1500);
- }
- Pillar = objects.getNearest(45565);
- if (!calc.tileOnScreen(Pillar.getLocation())) {
- walking.walkTo(Pillar.getLocation());
- sleepUntilNotMoving();
- return random(500, 750);
- }
- if (inventory.getCount(15281) == 1) {
- inventory.getItem(15281).doAction("Use");
- sleep(random(500, 750));
- Pillar.doAction("Use");
- return random(1000, 1500);
- }
- if (inventory.getCount(15283) == 1) {
- inventory.getItem(15283).doAction("Use");
- sleep(random(500, 750));
- Pillar.doAction("Use");
- return random(1000, 1500);
- }
- }
- if (interfaceThatContains("give Sir Vant a tinderbox") != null) {
- camera.setAltitude(true);
- Vant = npcs.getNearest(NPCIDs[2]);
- if (Vant == null) {
- return random(500, 750);
- }
- if (!calc.pointOnScreen(Vant.getScreenLocation())) {
- walking.walkTo(Vant.getLocation());
- sleepUntilNotMoving();
- }
- while (inventory.getCount(590) > 1) {
- inventory.getItem(590).doAction("Use");
- sleep(random(500, 750));
- if (!Vant.doAction("Use")) {
- camera.setAngle(random(0, 360));
- }
- return random(2000, 3000);
- }
- }
- if (interfaceThatContains("Use your tinderbox on the pillar") != null) {
- camera.setAltitude(true);
- RSObject Pillar = objects.getNearest(45565);
- if (!calc.tileOnScreen(Pillar.getLocation())) {
- walking.walkTo(Pillar.getLocation());
- sleepUntilNotMoving();
- }
- inventory.getItem(590).doAction("Use");
- sleep(random(500, 750));
- Pillar.doAction("Use");
- return random(3000, 4000);
- }
- if (interfaceThatContains("RUN! RUN! RUN!") != null) {
- RSObject Pillar = objects.getNearest(45565);
- walking.walkTo(new RSTile(Pillar.getLocation().getX() + 7, Pillar.getLocation().getY()));
- return random(2000, 3000);
- }
- if (interfaceThatContains("Congratulations, the dragon's dead!") != null) {
- Roddeck = npcs.getNearest(NPCIDs[3]);
- Roddeck.doAction("Talk");
- return random(1000, 1500);
- }
- if (interfaceThatContains("Click on the question mark button") != null) {
- interfaceThatHasAction("Advisor").doClick();
- return random(500, 750);
- }
- if (interfaceThatContains("Sir Vant wants his squire's kit back") != null) {
- game.openTab(Game.TAB_EQUIPMENT);
- sleep(random(500, 750));
- while (equipment.getItem(17).getID() != -1) {
- equipment.getItem(17).doAction("Remove");
- sleep(random(750, 1000));
- }
- while (equipment.getItem(20).getID() != -1) {
- equipment.getItem(20).doAction("Remove");
- sleep(random(750, 1000));
- }
- while (equipment.getItem(23).getID() != -1) {
- equipment.getItem(23).doAction("Remove");
- sleep(random(750, 1000));
- }
- return random(500, 750);
- }
- if (interfaceThatContains("To give Sir Vant an item") != null) {
- game.openTab(Game.TAB_INVENTORY);
- sleep(random(500, 750));
- Vant = npcs.getNearest(NPCIDs[2]);
- if (!Vant.isOnScreen()) {
- walking.walkTo(Vant.getLocation());
- sleepUntilNotMoving();
- }
- while (inventory.getCount(590) == 1) {
- inventory.getItem(590).doAction("Use");
- sleep(random(500, 750));
- Vant.doAction("Use");
- sleep(random(5000, 6000));
- }
- return random(500, 750);
- }
- if (interfaceThatContains("Okay, I'll get on with it") != null) {
- interfaceThatContains("Okay, I'll get on with it").doClick();
- return random(500, 750);
- }
- if (interfaceThatContains("I'll mine through the rocks") != null) {
- if (mining) {
- interfaceThatContains("I'll mine through the rocks").doClick();
- } else {
- interfaceThatContains("I'll chop through the roots").doClick();
- }
- return random(500, 750);
- }
- if (interfaceThatContains("Speak to Roddeck, your advisor, about breaking") != null) {
- camera.setAltitude(true);
- Roddeck = npcs.getNearest(NPCIDs[3]);
- if (!Roddeck.isOnScreen()) {
- walking.walkTo(Roddeck.getLocation());
- sleepUntilNotMoving();
- }
- Roddeck.doAction("Talk");
- return random(500, 750);
- }
- if (interfaceThatContains("While you've got a pickaxe") != null) {
- RSObject damagedWallRock = objects.getNearest(45595);
- if (!calc.tileOnScreen(damagedWallRock.getLocation())) {
- walking.walkTo(damagedWallRock.getLocation());
- sleepUntilNotMoving();
- }
- damagedWallRock.doAction("Mine");
- sleep(random(5000, 6000));
- return random(500, 750);
- }
- if (interfaceThatContains("While you've got a hatchet") != null) {
- RSObject roots = objects.getNearest(45598);
- if (!calc.tileOnScreen(roots.getLocation())) {
- walking.walkTo(roots.getLocation());
- sleepUntilNotMoving();
- }
- roots.doAction("Chop");
- sleep(random(5000, 6000));
- return random(500, 750);
- }
- if (interfaceThatContains("Your current objective is to raise your Mining level") != null) {
- camera.setAltitude(true);
- RSObject Rocks = objects.getNearest(45580);
- if (!calc.tileOnScreen(Rocks.getLocation())) {
- walking.walkTo(Rocks.getLocation());
- sleepUntilNotMoving();
- }
- while (skills.getCurrentLevel(Skills.MINING) < 2) {
- Rocks.doAction("Mine");
- sleep(random(2000, 3000));
- while (getMyPlayer().getAnimation() == 6747) {
- sleep(100);
- }
- }
- return random(500, 750);
- }
- if (interfaceThatContains("Your current objective is to raise your Woodcutting level") != null) {
- camera.setAltitude(true);
- RSObject treeRoots = objects.getTopAt(new RSTile(objects.getNearest(45589).getLocation().getX(), objects.getNearest(45589).getLocation().getY() + 1));
- if (!calc.tileOnScreen(treeRoots.getLocation())) {
- walking.walkTo(treeRoots.getLocation());
- sleepUntilNotMoving();
- }
- while (skills.getCurrentLevel(Skills.WOODCUTTING) < 2) {
- treeRoots.doAction("Chop");
- sleep(random(2000, 3000));
- while (getMyPlayer().getAnimation() == 879) {
- sleep(100);
- }
- }
- return random(500, 750);
- }
- if (interfaceThatContains("set yourself an objective") != null) {
- interfaceThatHasAction("Objectives").doClick();
- sleep(random(1000, 1500));
- if (mining) {
- if (interfaceThatContains("Increase Mining from") == null) {
- interfaceThatHasAction("Give random objective").doClick();
- }
- sleep(random(1000, 1500));
- interfaceThatContains("Increase Mining from").doClick();
- sleep(random(500, 750));
- } else {
- if (interfaceThatContains("Increase Woodcutting from") == null) {
- interfaceThatHasAction("Give random objective").doClick();
- }
- sleep(random(1000, 1500));
- interfaceThatContains("Increase Woodcutting from").doClick();
- sleep(random(500, 750));
- }
- if (interfaceThatContains("Advisor") == null) {
- interfaceThatHasAction("Advisor").doClick();
- }
- return random(1000, 2000);
- }
- if (interfaceThatContains("advisor button") != null) {
- if (interfaceThatContains("How can I raise my") == null) {
- interfaceThatHasAction("Advisor").doClick();
- }
- sleep(random(1000, 1500));
- if (interfaceThatContains("How can I raise my") == null) {
- return random(500, 750);
- }
- interfaceThatContains("How can I raise my").doClick();
- return random(500, 750);
- }
- if (interfaceThatContains("Your Mining level is now high enough") != null) {
- RSObject damagedWallRock = objects.getNearest(45595);
- if (damagedWallRock != null) {
- if (!calc.tileOnScreen(damagedWallRock.getLocation())) {
- walking.walkTo(damagedWallRock.getLocation());
- sleepUntilNotMoving();
- }
- damagedWallRock.doAction("Mine");
- return random(500, 750);
- } else {
- damagedWallRock = objects.getNearest(45597);
- if (damagedWallRock == null) {
- return random(200, 300);
- }
- damagedWallRock.doAction("Climb");
- sleep(random(750, 1000));
- while (getMyPlayer().getAnimation() == 12280 || getMyPlayer().isMoving()) {
- sleep(100);
- }
- return random(500, 750);
- }
- }
- if (interfaceThatContains("Your Woodcutting level is now high enough") != null) {
- RSObject root = objects.getNearest(45598);
- if (root != null) {
- if (!calc.tileOnScreen(root.getLocation())) {
- walking.walkTo(root.getLocation());
- sleepUntilNotMoving();
- }
- root.doAction("Chop");
- return random(500, 750);
- } else {
- root = objects.getNearest(45600);
- if (root == null) {
- return random(200, 300);
- }
- root.doAction("Climb");
- sleep(random(750, 1000));
- while (getMyPlayer().isMoving()) {
- sleep(100);
- }
- return random(500, 750);
- }
- }
- if (interfaceThatContains("Escape up the ladder to freedom!") != null) {
- game.openTab(Game.TAB_INVENTORY);
- while (inventory.contains(15286)) {
- inventory.getItem(15286).doAction("Drop");
- sleep(random(500, 750));
- clickContinue();
- }
- while (inventory.contains(15285)) {
- inventory.getItem(15285).doAction("Drop");
- sleep(random(500, 750));
- clickContinue();
- }
- RSObject ladder = objects.getNearest(45784);
- if (ladder == null) {
- return random(250, 300);
- }
- interfaceThatHasAction("Face North").doClick();
- if (calc.distanceTo(ladder.getLocation()) > 3) {
- walking.walkTo(ladder.getLocation());
- sleepUntilNotMoving();
- }
- while (interfaceThatContains("Thank you again") == null) {
- ladder = objects.getNearest(45784);
- if (ladder == null) {
- break;
- }
- ladder.doAction("Climb");
- }
- return random(500, 750);
- }
- if (interfaceThatContains("You're out!") != null) {
- Vant = npcs.getNearest(NPCIDs[2]);
- if (Vant == null) {
- mouse.move(random(188, 332), random(444, 453));
- mouse.click(true);
- return random(500, 750);
- }
- if (Vant.isMoving()) {
- mouse.move(random(188, 332), random(444, 453));
- mouse.click(true);
- return random(500, 750);
- }
- walking.walkTo(Vant.getLocation());
- camera.setAltitude(true);
- sleepUntilNotMoving();
- if (!calc.pointOnScreen(Vant.getScreenLocation())) {
- walking.walkTo(Vant.getLocation());
- sleepUntilNotMoving();
- }
- Vant.doAction("Talk");
- return random(500, 750);
- }
- if (interfaceThatContains("Roddeck would like to offer you some") != null) {
- camera.setAltitude(true);
- Roddeck = npcs.getNearest(NPCIDs[3]);
- if (!Roddeck.isOnScreen()) {
- walking.walkTo(Roddeck.getLocation());
- sleepUntilNotMoving();
- }
- Roddeck.doAction("Talk");
- return random(500, 750);
- }
- if (interfaceThatContains("You may now leave via the door") != null) {
- interfaceThatHasAction("Face North").doClick();
- RSObject door = objects.getNearest(45801);
- if (door == null) {
- return random(200, 300);
- }
- door.doAction("Open");
- return random(500, 750);
- }
- if (calc.distanceTo(new RSTile(3204, 3246)) < 8) {
- if (!autoCreate) {
- log("Tutorial Finished! =)");
- game.logout(false);
- stopScript();
- } else {
- java.io.BufferedWriter out;
- java.io.FileWriter fstream;
- java.io.File accounts = new java.io.File("Accounts.txt");
- if (accounts.exists()) {
- try {
- fstream = new java.io.FileWriter("Accounts.txt", true);
- out = new java.io.BufferedWriter(fstream);
- out.newLine();
- out.write(username);
- out.close();
- } catch (java.io.IOException e) {
- }
- } else {
- try {
- fstream = new java.io.FileWriter("Accounts.txt", false);
- out = new java.io.BufferedWriter(fstream);
- out.write(username);
- out.close();
- } catch (java.io.IOException e) {
- }
- }
- log("Account " + username + " has been saved");
- accountsCreated++;
- totalTime += System.currentTimeMillis() - startTime;
- averageTime = totalTime / accountsCreated;
- game.logout(true);
- while (game.isLoggedIn()) {
- sleep(10);
- }
- return random(2000, 3000);
- }
- }
- return random(200, 300);
- }
- public void onRepaint(Graphics g) {
- final int x = 515 - 230;
- int y = 4;
- long timeToDisplay = averageTime;
- long minutes = timeToDisplay / 1000 / 60;
- timeToDisplay -= minutes * 1000 * 60;
- long seconds = timeToDisplay / 1000;
- g.setColor(new Color(0, 0, 0, 150));
- g.fillRoundRect(x, y, 230, height, 15, 15);
- g.setColor(new Color(0, 255, 0, 255));
- g.drawRoundRect(x, y, 230, height, 20, 15);
- g.drawString("TISolver v" + getVersion(), x + 76, y += 15);
- if (autoCreate) {
- g.drawString("Accounts Created: " + accountsCreated, x + 60, y += 15);
- if (accountsCreated > 0) {
- g.drawString("Average Time per Account: " + minutes + "min" + seconds + "sec", x + 10, y += 15);
- }
- }
- height = y + 3;
- }
- public String getVersion() {
- return "" + getClass().getAnnotation(ScriptManifest.class).version();
- }
- public RSComponent interfaceThatContains(String str) {
- for (RSInterface i : interfaces.getAll()) {
- if (i.isValid()) {
- for (RSComponent children : i.getComponents()) {
- if (children.isValid()) {
- if (children.getComponents().length > 0) {
- for (RSComponent component : children.getComponents()) {
- if (component.isValid()) {
- if (component.containsText(str)) {
- return component;
- }
- }
- }
- } else {
- if (children.containsText(str)) {
- return children;
- }
- }
- }
- }
- }
- }
- return null;
- }
- public RSComponent interfaceThatHasAction(String str) {
- for (RSInterface i : interfaces.getAll()) {
- if (i.isValid()) {
- for (RSComponent child : i.getComponents()) {
- if (child.isValid()) {
- if (child.getActions() != null) {
- for (String s : child.getActions()) {
- if (s != null && s.contains(str)) {
- return child;
- }
- }
- }
- if (child.getComponents().length > 0) {
- for (RSComponent component : child.getComponents()) {
- if (component.isValid() && component.getActions() != null) {
- for (String s : component.getActions()) {
- if (s != null && s.contains(str)) {
- return component;
- }
- }
- }
- }
- }
- }
- }
- }
- }
- return null;
- }
- public void sleepUntilNotMoving() {
- sleep(random(700, 1000));
- while (getMyPlayer().isMoving()) {
- sleep(random(25, 100));
- }
- }
- public RSComponent getContinueChildInterface() {
- RSInterface[] valid = interfaces.getAll();
- for (RSInterface iface : valid) {
- if (iface.getIndex() != 137 && iface.getIndex() != 752) {
- int len = iface.getChildCount();
- for (int i = 0; i < len; i++) {
- RSComponent child = iface.getComponent(i);
- if (child.containsText("Click here to continue") && child.getWidth() > 30 && child.getAbsoluteY() > 337) {
- return child;
- }
- }
- }
- }
- return null;
- }
- public boolean canContinue() {
- return getContinueChildInterface() != null;
- }
- public boolean clickContinue() {
- RSComponent cont = getContinueChildInterface();
- return !(cont != null && cont.isValid()) || cont.doClick();
- }
- public class TISolverGUI extends javax.swing.JFrame {
- /** Creates new form TISolverGUI */
- public TISolverGUI() {
- initComponents();
- setLocationRelativeTo(getOwner());
- }
- /** This method is called from within the constructor to
- * initialize the form.
- * WARNING: Do NOT modify this code. The content of this method is
- * always regenerated by the Form Editor.
- */
- @SuppressWarnings("unchecked")
- // <editor-fold defaultstate="collapsed" desc="Generated Code">
- private void initComponents() {
- autoCheck = new javax.swing.JCheckBox();
- jLabel1 = new javax.swing.JLabel();
- prefixText = new javax.swing.JTextField();
- jLabel2 = new javax.swing.JLabel();
- passwordText = new javax.swing.JTextField();
- jLabel3 = new javax.swing.JLabel();
- skillCombo = new javax.swing.JComboBox();
- jButton1 = new javax.swing.JButton();
- setTitle("Settings");
- addWindowListener(new java.awt.event.WindowAdapter() {
- public void windowClosing(java.awt.event.WindowEvent evt) {
- formWindowClosing(evt);
- }
- });
- autoCheck.setText("Auto-Create Account");
- autoCheck.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- autoCheckActionPerformed(evt);
- }
- });
- jLabel1.setText("Prefix:");
- prefixText.setEditable(false);
- jLabel2.setText("Password:");
- passwordText.setEditable(false);
- jLabel3.setText("Train Skill:");
- skillCombo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Mining", "Woodcutting" }));
- jButton1.setText("OK");
- jButton1.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton1ActionPerformed(evt);
- }
- });
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
- .addComponent(jButton1)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
- .addComponent(autoCheck)
- .addGroup(layout.createSequentialGroup()
- .addGap(21, 21, 21)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jLabel2)
- .addComponent(jLabel1))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
- .addComponent(prefixText)
- .addComponent(passwordText, javax.swing.GroupLayout.DEFAULT_SIZE, 101, Short.MAX_VALUE)))
- .addGroup(layout.createSequentialGroup()
- .addComponent(jLabel3)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(skillCombo, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(autoCheck)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel1)
- .addComponent(prefixText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel2)
- .addComponent(passwordText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGap(18, 18, 18)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel3)
- .addComponent(skillCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jButton1)
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- );
- pack();
- }// </editor-fold>
- private void autoCheckActionPerformed(java.awt.event.ActionEvent evt) {
- if (autoCheck.isSelected()) {
- prefixText.setEditable(true);
- passwordText.setEditable(true);
- } else {
- prefixText.setEditable(false);
- passwordText.setEditable(false);
- }
- }
- private void formWindowClosing(java.awt.event.WindowEvent evt) {
- stopScript();
- }
- private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
- setVisible(false);
- }
- // Variables declaration - do not modify
- public javax.swing.JCheckBox autoCheck;
- private javax.swing.JButton jButton1;
- private javax.swing.JLabel jLabel1;
- private javax.swing.JLabel jLabel2;
- private javax.swing.JLabel jLabel3;
- private javax.swing.JTextField passwordText;
- public javax.swing.JTextField prefixText;
- public javax.swing.JComboBox skillCombo;
- // End of variables declaration
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement