Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import java.util.Properties;
- import java.io.*;
- import org.rsbot.script.Script;
- import org.rsbot.script.ScriptManifest;
- import org.rsbot.script.wrappers.*;
- import org.rsbot.script.methods.*;
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.Configuration;
- @ScriptManifest(authors = {"rewsky"}, keywords = {""}, name = "runeMysteries", description = "Completes the Rune Mysteries quest.", version = 1.21)
- public class runeMysteries extends Script implements PaintListener {
- private static final boolean endInVarrock = true; // Set to TRUE to walk to varrock after quest
- // FALSE to stay at wizard tower
- /* ID's of all the NPCs in the quest */
- private static final int DUKE = 741;
- private static final int SEDRIDOR = 300;
- private static final int AUBREY = 553;
- /* ID's of all the items recieved during the quest */
- private static final int AIR_TALISMAN = 15361;
- private static final int END_AIR_TALISMAN = 1438;
- private static final int RESEARCH_NOTES = 290;
- private static final int FURTHER_NOTES = 291;
- /* ID's of objects that may need to be interacted with during quest */
- private static final int CLOSED_DOOR = 36844;
- private static final int OPEN_DOOR = 36845;
- private static final int LUMB_STAIRS_DOWN = 36774;
- private static final int LUMB_STAIRS_UP = 36773;
- private static final int WT_OPEN_DOOR = 11994;
- private static final int WT_CLOSED_DOOR = 11993;
- private static final int WT_OPEN_BIG_DOOR = 31828;
- private static final int WT_CLOSED_BIG_DOOR = 33060;
- private static final int WT_LADDER_UP = 32015;
- private static final int WT_LADDER_DOWN = 2147;
- private static final int AUBREY_CLOSED_DOOR = 24381;
- private static final int AUBREY_OPEN_DOOR = 24379;
- /* Areas key to detecting which stage of the quest we're on */
- private static final RSArea DUKE_ROOM = new RSArea(new RSTile(3208, 3218), new RSTile(3212, 3225));
- private static final RSArea LUMB_STAIRCASE_LOWER = new RSArea(new RSTile(3200, 3206), new RSTile(3212, 3214));
- private static final RSArea WIZARD_TOWER = new RSArea(new RSTile(3111, 3160), new RSTile(3103, 3166));
- private static final RSArea WIZARD_BASEMENT = new RSArea(new RSTile(3115, 9563), new RSTile(3095, 9577));
- private static final RSArea SEDRIDORS_ROOM = new RSArea(new RSTile(3108, 9575), new RSTile(3094, 9565));
- private static final RSArea SHOP_AREA = new RSArea(new RSTile(3250, 3404), new RSTile(3255, 3398));
- private static final RSTile[] TOWER_PATH = {new RSTile(3205, 3209), new RSTile(3202, 3219),
- new RSTile(3190, 3216), new RSTile(3178, 3215), new RSTile(3168, 3212), new RSTile(3159, 3216),
- new RSTile(3147, 3217), new RSTile(3138, 3210), new RSTile(3127, 3210), new RSTile(3115, 3210),
- new RSTile(3112, 3202), new RSTile(3114, 3194), new RSTile(3113, 3186), new RSTile(3113, 3175),
- new RSTile(3109, 3163), new RSTile(3109, 3167), new RSTile(3109, 3163)};
- private static final RSTile[] VARROCK_PATH = {new RSTile(3104, 3161),
- new RSTile(3110, 3169), new RSTile(3113, 3181), new RSTile(3114, 3191), new RSTile(3113, 3202),
- new RSTile(3119, 3211), new RSTile(3127, 3219), new RSTile(3134, 3225), new RSTile(3145, 3231),
- new RSTile(3157, 3236), new RSTile(3167, 3238), new RSTile(3178, 3244), new RSTile(3189, 3244),
- new RSTile(3199, 3247), new RSTile(3212, 3247), new RSTile(3218, 3257), new RSTile(3229, 3262),
- new RSTile(3241, 3267), new RSTile(3238, 3278), new RSTile(3238, 3293), new RSTile(3238, 3306),
- new RSTile(3246, 3317), new RSTile(3254, 3325), new RSTile(3266, 3332), new RSTile(3278, 3339),
- new RSTile(3286, 3349), new RSTile(3296, 3357), new RSTile(3294, 3370), new RSTile(3293, 3380),
- new RSTile(3293, 3387), new RSTile(3290, 3399), new RSTile(3290, 3410), new RSTile(3285, 3420),
- new RSTile(3274, 3427), new RSTile(3266, 3416), new RSTile(3259, 3406), new RSTile(3253, 3401)};
- private enum state {
- TO_LUMBRIDGE, GET_QUEST, TO_TOWER, GET_NOTES, TO_VARROCK, GET_NEW_NOTES, FINISH_QUEST, END, WAIT, NEXT_ACCOUNT, LOGGING_IN
- };
- private state currentState = null;
- private String st = null;
- /* Variables for time-keeping */
- private long startTime = 0;
- private long millis = 0;
- private long hours = 0;
- private long minutes = 0;
- private long seconds = 0;
- private long last = 0;
- /* Method called when user chooses to run this script. Return True = continue, False = terminate */
- @Override
- public boolean onStart() {
- try {
- Acc.load(new FileInputStream(new File(Configuration.Paths.getScriptCacheDirectory(), "AccountsMade.ini")));
- } catch (Throwable e) {
- }
- startTime = System.currentTimeMillis();
- if (!game.isLoggedIn())
- currentState = state.NEXT_ACCOUNT;
- if (inventory.contains(END_AIR_TALISMAN))
- currentState = state.END;
- getState();
- if (currentState == null)
- currentState = state.TO_LUMBRIDGE;
- return true;
- }
- /* Returns a value denoting what floor the character is on
- * 0 = Ground floor / dungeons
- * 1 = Middle floor
- * 2 = Top floor
- */
- public int getFloor() {
- return game.getPlane();
- }
- /* Opens a closed door if needed */
- public boolean openDoor(int objectID, RSTile tile) {
- RSObject myDoor = null;
- RSObject[] onTile = null;
- onTile = objects.getAllAt(tile);
- for (RSObject tempObject : onTile) {
- if (tempObject.getID() == objectID) {
- myDoor = tempObject;
- break;
- }
- }
- if (myDoor != null)
- if (myDoor.isOnScreen()) {
- myDoor.doAction("Open");
- sleep(1500, 2000);
- return true;
- }
- return false;
- }
- /* If the interface where you accept the quest is open, it is returned, else null */
- public RSInterface questInterfaceOpen() {
- RSInterface[] allInterfaces = interfaces.getAll();
- RSComponent[] allComponents = null;
- // Loop through all the interfaces on screen
- for (RSInterface myInterface : allInterfaces) {
- allComponents = myInterface.getComponents();
- // Loop through all the components in the current interface
- for (RSComponent myComponent : allComponents) {
- if (myComponent.containsText("Rune Mysteries"))
- return myInterface;
- }
- }
- return null;
- }
- /* Uses the free teleport to lumbridge */
- public void teleToLumb() {
- if (!getMyPlayer().isIdle()) {
- sleep(500, 1000);
- } else {
- magic.castSpell(magic.SPELL_HOME_TELEPORT);
- }
- }
- /* Walks to the next tile in a given RSTile array (path) */
- public void walkNext(RSTile[] path, RSTile position, int randomX, int randomY) {
- int myX = position.getX();
- int myY = position.getY();
- RSTile nextTile = null;
- RSArea currentTileArea = new RSArea(new RSTile(myX - (randomX + 1), myY - (randomY + 1)),
- new RSTile(myX + (randomX + 1), myY + (randomY + 1)));
- for (int i = 0; i < path.length; i++) {
- if (currentTileArea.contains(path[i])) {
- if (i < (path.length - 1))
- nextTile = path[i + 1];
- else
- nextTile = path[i];
- break;
- }
- }
- if (nextTile != null) {
- walking.walkTileMM(nextTile, randomX, randomY);
- }
- }
- /* Walks from anywhere, to the duke of lumbridge's room */
- public void walkToDuke() {
- RSTile currentTile = getMyPlayer().getLocation();
- RSObject stairs = null;
- if (currentTile.getX() < 3191 || currentTile.getX() > 3242 || currentTile.getY() > 3264 ||
- currentTile.getY () < 3199) {
- teleToLumb();
- } else {
- if (getFloor() == 0) {
- if (LUMB_STAIRCASE_LOWER.contains(currentTile)) {
- stairs = objects.getNearest(LUMB_STAIRS_UP);
- if (stairs != null)
- stairs.doAction("Climb-up");
- } else {
- walking.walkTo(new RSTile(3206, 3209));
- }
- } else if (getFloor() == 1) {
- if (!DUKE_ROOM.contains(currentTile)) {
- openDoor(CLOSED_DOOR, new RSTile(3207, 3222));
- walking.walkTileMM(new RSTile(3210, 3221));
- } else {
- currentState = state.GET_QUEST;
- }
- } else if (getFloor() == 2) {
- stairs = objects.getNearest(36775);
- if (stairs != null)
- stairs.doAction("Climb-down");
- } else {
- log("Bot lost on username: "+userNames()[questsDone]+", moving on.");
- nextACC();
- }
- }
- }
- /* Walks from anywhere, to the basement of the wizards tower */
- public void walkToSedridor() {
- RSTile currentTile = getMyPlayer().getLocation();
- RSObject wizLadder = null;
- RSObject lumbStairs = null;
- if (!openDoor(WT_CLOSED_DOOR, new RSTile(3109, 3167))) {
- if (!openDoor(WT_CLOSED_DOOR, new RSTile(3107, 3162))) {
- if ((getFloor() == 1) && (DUKE_ROOM.contains(currentTile))) {
- openDoor(CLOSED_DOOR, new RSTile(3207, 3222));
- walking.walkTileMM(new RSTile(3206, 3209));
- } else if (getFloor() == 1) {
- lumbStairs = objects.getNearest(LUMB_STAIRS_DOWN);
- if (lumbStairs != null)
- lumbStairs.doAction("Climb-down");
- // If in sedridors room, we've arrived!
- } else if (SEDRIDORS_ROOM.contains(currentTile)) {
- currentState = state.GET_NOTES;
- // If in the basement of the tower, get into sedridors room
- } else if (WIZARD_BASEMENT.contains(currentTile)) {
- if (!openDoor(WT_CLOSED_BIG_DOOR, new RSTile(3108, 9570))) {
- walking.walkTileMM(new RSTile(3105, 9569));
- }
- // Walk to the wizards tower
- } else if ((getFloor() == 0) && !WIZARD_TOWER.contains(currentTile)) {
- walkNext(TOWER_PATH, currentTile, 2, 2);
- // Climb down to basement of the tower
- } else {
- wizLadder = objects.getNearest(WT_LADDER_DOWN);
- if (wizLadder != null)
- wizLadder.doAction("Climb-down");
- }
- }
- }
- }
- /* Walks from anywhere, to the magic shop in varrock */
- public void walkToAubrey() {
- RSTile currentTile = getMyPlayer().getLocation();
- RSObject wizLadder = null;
- // Exit the wizards tower basement
- if (WIZARD_BASEMENT.contains(currentTile)) {
- if (SEDRIDORS_ROOM.contains(currentTile)) {
- if (!openDoor(WT_CLOSED_BIG_DOOR, new RSTile(3108, 9570)))
- walking.walkTileMM(new RSTile(3109, 9574));
- } else {
- wizLadder = objects.getNearest(WT_LADDER_UP);
- if ((wizLadder != null) && (wizLadder.isOnScreen())) {
- wizLadder.doAction("Climb-up");
- } else {
- walking.walkTileMM(new RSTile(3109, 9574));
- }
- }
- } else if (!openDoor(WT_CLOSED_DOOR, new RSTile(3107, 3162))) {
- if (!openDoor(WT_CLOSED_DOOR, new RSTile(3109, 3167))) {
- if (!openDoor(AUBREY_CLOSED_DOOR, new RSTile(3253, 3398))) {
- if (interfaces.get(212).isValid()) {
- interfaces.getComponent(212, 4).doClick();
- } else if (interfaces.get(236).isValid()) {
- interfaces.getComponent(236, 1).doClick();
- } else if (SHOP_AREA.contains(currentTile)) {
- if (inventory.contains(END_AIR_TALISMAN)) {
- log("Script finished.");
- nextACC();
- } else {
- currentState = state.GET_NEW_NOTES;
- }
- } else {
- walkNext(VARROCK_PATH, currentTile, 3, 3);
- }
- }
- }
- }
- }
- /* Handles conversation with the duke */
- public void talkToDuke() {
- RSNPC myDuke = npcs.getNearest(DUKE);
- // If player is not in the dukes room, set state to walk to lumbridge
- if (!DUKE_ROOM.contains(getMyPlayer().getLocation())) {
- currentState = state.TO_LUMBRIDGE;
- } else {
- // If quest acceptance interface is open, click yes, otherwise converse with duke
- if (questInterfaceOpen() == null) {
- // If chat interface is open, continue talking, otherwise initiate conversation
- if (interfaces.get(241).isValid()) {
- interfaces.getComponent(241, 5).doClick();
- } else if (interfaces.get(228).isValid()) {
- interfaces.getComponent(228, 2).doClick();
- } else if (interfaces.get(64).isValid()) {
- interfaces.getComponent(64, 5).doClick();
- } else if (interfaces.get(242).isValid()) {
- interfaces.getComponent(242, 6).doClick();
- } else {
- // If the duke is on screen, talk to him, otherwise set the state as walk to lumbridge
- if (myDuke.isOnScreen()) {
- myDuke.doAction("Talk");
- }
- }
- } else {
- mouse.click(170, 305, 30, 10, true);
- sleep(1000, 500);
- currentState = state.TO_TOWER;
- }
- }
- }
- private int questsDone = 0;
- private Properties Acc = new Properties();
- private String[] userNames() {
- try {
- Acc.load(new FileInputStream(new File(Configuration.Paths.getScriptCacheDirectory(), "AccountsMade.ini")));
- } catch (FileNotFoundException e) {
- log.warning("[FUNDAMENTAL ERROR] Account made file was not found!");
- stopScript();
- return null;
- } catch (IOException e) {
- log.warning("[Account] Error loading names settings!");
- return null;
- }
- Object[] names = Acc.stringPropertyNames().toArray();
- String[] usernames = new String[names.length];
- System.arraycopy( names, 0, usernames, 0, names.length );
- return usernames;
- }
- public String[] passwords() {
- try {
- Acc.load(new FileInputStream(new File(Configuration.Paths.getScriptCacheDirectory(), "AccountsMade.ini")));
- } catch (FileNotFoundException e) {
- log.warning("[FUNDAMENTAL ERROR] Account made file was not found!");
- stopScript();
- return null;
- } catch (IOException e) {
- log.warning("[Account] Error loading passwwords settings!");
- return null;
- }
- String[] findPass = userNames();
- for (int i = 0; i < userNames().length; i++) {
- findPass[i] = Acc.getProperty(userNames()[i]);
- }
- return findPass;
- }
- //Logs out and then goes to
- public void nextACC() {
- while (passwords()[questsDone].contains("done")){
- questsDone += 1;
- }
- game.logout(false);
- sleep(5000,1000);
- if(userNames()[questsDone] == null || passwords()[questsDone] == null){
- log("Finished all accounts");
- stopScript();
- }
- Acc.setProperty(userNames()[questsDone], passwords()[questsDone]+" done");
- login(userNames()[questsDone],passwords()[questsDone]);
- currentState = state.LOGGING_IN;
- }
- /* Handles conversation with sedridor */
- public void talkToSedridor() {
- RSNPC mySed = npcs.getNearest(SEDRIDOR);
- // When research package is received, go to varrock
- if (inventory.contains(RESEARCH_NOTES)) {
- currentState = state.TO_VARROCK;
- } else if (inventory.contains(END_AIR_TALISMAN)) {
- currentState = state.FINISH_QUEST;
- mouse.click(443, 75, 10, 10, true);
- } else if (interfaces.get(241).isValid()) {
- interfaces.getComponent(241, 5).doClick();
- } else if (interfaces.get(242).isValid()) {
- interfaces.getComponent(242, 6).doClick();
- } else if (interfaces.get(243).isValid()) {
- interfaces.getComponent(243, 7).doClick();
- } else if (interfaces.get(244).isValid()) {
- interfaces.getComponent(244, 8).doClick();
- } else if (interfaces.get(230).isValid()) {
- interfaces.getComponent(230, 4).doClick();
- } else if (interfaces.get(64).isValid()) {
- interfaces.getComponent(64, 5).doClick();
- } else if (interfaces.get(65).isValid()) {
- interfaces.getComponent(65, 6).doClick();
- } else if (interfaces.get(66).isValid()) {
- interfaces.getComponent(66, 7).doClick();
- } else if (interfaces.get(519).isValid()) {
- interfaces.getComponent(519, 2).doClick();
- } else if (interfaces.get(228).isValid()) {
- interfaces.getComponent(228, 2).doClick();
- } else {
- // If sedridor is on screen, talk to him, otherwise set the state as walk to tower
- if (mySed.isOnScreen()) {
- mySed.doAction("Talk");
- } else {
- currentState = state.TO_TOWER;
- }
- }
- }
- /* Handles conversation with aubrey */
- public void talkToAubrey() {
- RSNPC myAubrey = npcs.getNearest(AUBREY);
- RSTile currentTile = getMyPlayer().getLocation();
- if (getMyPlayer().isIdle()) {
- if (inventory.contains(FURTHER_NOTES) && !SHOP_AREA.contains(currentTile)) {
- currentState = state.TO_TOWER;
- } else if (interfaces.get(241).isValid()) {
- interfaces.getComponent(241, 5).doClick();
- } else if (interfaces.get(242).isValid()) {
- interfaces.getComponent(242, 6).doClick();
- } else if (interfaces.get(243).isValid()) {
- interfaces.getComponent(243, 7).doClick();
- } else if (interfaces.get(244).isValid()) {
- interfaces.getComponent(244, 8).doClick();
- } else if (interfaces.get(230).isValid()) {
- interfaces.getComponent(230, 4).doClick();
- } else if (interfaces.get(64).isValid()) {
- interfaces.getComponent(64, 5).doClick();
- } else if (interfaces.get(65).isValid()) {
- interfaces.getComponent(65, 6).doClick();
- } else if (interfaces.get(228).isValid()) {
- interfaces.getComponent(228, 2).doClick();
- } else if (interfaces.get(210).isValid()) {
- interfaces.getComponent(210, 2).doClick();
- } else if (inventory.contains(FURTHER_NOTES)) {
- currentState = state.TO_TOWER;
- } else {
- // If aubrey is on screen, talk to him, otherwise set the state as walk to varrock
- if (myAubrey.isOnScreen()) {
- myAubrey.doAction("Talk");
- } else {
- currentState = state.TO_VARROCK;
- }
- }
- }
- }
- public void getState() {
- if (DUKE_ROOM.contains(getMyPlayer().getLocation()) && !inventory.contains(AIR_TALISMAN)) {
- currentState = state.GET_QUEST;
- } else if (inventory.contains(AIR_TALISMAN)) {
- if (!SEDRIDORS_ROOM.contains(getMyPlayer().getLocation()))
- currentState = state.TO_TOWER;
- else
- currentState = state.GET_NOTES;
- } else if (inventory.contains(RESEARCH_NOTES)) {
- if (!SHOP_AREA.contains(getMyPlayer().getLocation()))
- currentState = state.TO_VARROCK;
- else
- currentState = state.GET_NEW_NOTES;
- } else if (inventory.contains(FURTHER_NOTES))
- currentState = state.TO_TOWER;
- }
- /* Main body of the script, called continuously till value < 0 is returned */
- @Override
- public int loop() {
- // If the player is moving, wait.
- if (!getMyPlayer().isIdle())
- return random(500, 1500);
- switch (currentState) {
- case TO_LUMBRIDGE:
- st = "Walking to the Duke's room.";
- walkToDuke();
- break;
- case GET_QUEST:
- st = "Getting quest from the Duke.";
- talkToDuke();
- break;
- case TO_TOWER:
- st = "Walking to the Wizard Tower.";
- walkToSedridor();
- break;
- case GET_NOTES:
- if (inventory.contains(FURTHER_NOTES))
- st = "Giving notes to Sedridor";
- else
- st = "Getting notes from Sedridor.";
- talkToSedridor();
- break;
- case TO_VARROCK:
- if (!inventory.contains(END_AIR_TALISMAN))
- st = "Walking to Aubrey.";
- walkToAubrey();
- break;
- case GET_NEW_NOTES:
- st = "Getting notes from Aubrey.";
- talkToAubrey();
- break;
- case FINISH_QUEST:
- st = "Finished quest.";
- if (endInVarrock)
- currentState = state.TO_VARROCK;
- else
- currentState = state.NEXT_ACCOUNT;
- break;
- case NEXT_ACCOUNT:
- nextACC();
- break;
- case LOGGING_IN:
- login(userNames()[questsDone],passwords()[questsDone]);
- break;
- case END:
- return -1;
- default:
- return -1;
- }
- // Turn on run and open inventory if needed
- if ((walking.getEnergy() > 30) && (currentState != state.GET_NOTES) && (currentState != state.GET_NEW_NOTES))
- walking.setRun(true);
- game.openTab(4);
- return random(500, 1500);
- }
- /* Handles painting of the progress report */
- public void onRepaint(Graphics g) {
- Graphics2D g2d = (Graphics2D)g;
- Color colour1 = new Color(255, 255, 255);
- Font font1 = new Font("Monospaced", 0, 12);
- int y = 310;
- int x = 95;
- millis = System.currentTimeMillis() - startTime;
- hours = millis / (1000 * 60 * 60);
- millis -= hours * (1000 * 60 * 60);
- minutes = millis / (1000 * 60);
- millis -= minutes * (1000 * 60);
- seconds = millis / 1000;
- g2d.setColor(new Color(69, 139, 0, 125));
- g2d.fillRect(x, y, 330, 28);
- g2d.setColor(new Color(69, 139, 0, 100));
- g2d.fillRect(x, y + 14, 330, 14);
- g2d.setColor(new Color(20, 20, 20, 200));
- g2d.drawRect(x, y, 330, 28);
- g2d.setColor(colour1);
- g2d.setFont(font1);
- g2d.drawString("Time elapsed: " + hours + " hours, " + minutes + " minutes, " + seconds + " seconds.", 105, 322);
- g2d.drawString("Current state: " + st, 105, 335);
- }
- /* Any code to run as script terminates */
- @Override
- public void onFinish() {
- }
- public static final int INTERFACE_LOGIN_SCREEN = 596;
- public static final int INTERFACE_LOGIN_SCREEN_ENTER_GAME = 60;
- public static final int INTERFACE_LOGIN_SCREEN_USERNAME_TEXT = 73;
- public static final int INTERFACE_LOGIN_SCREEN_PASSWORD_TEXT = 79;
- public static final int INTERFACE_LOGIN_SCREEN_ALERT_TEXT = 14;
- public static final int INTERFACE_LOGIN_SCREEN_ALERT_BACK = 68;
- public static final int INTERFACE_GRAPHICS_NOTICE = 976;
- public static final int INTERFACE_GRAPHICS_LEAVE_ALONE = 6;
- public static final int INTERFACE_LOBBY_HIGH_RISK_WORLD_TEXT = 98;
- public static final int INTERFACE_LOBBY_HIGH_RISK_WORLD_LOGIN_BUTTON = 104;
- private boolean isUsernameCorrect = false;
- private boolean isPasswordValid = false;
- public int login(String u, String p) {
- if (lobby.inLobby()) {
- if (lobby.getSelectedTab() != Lobby.TAB_PLAYERS) {
- lobby.open(Lobby.TAB_PLAYERS);
- return random(500, 800);
- }
- if (lobby.clickPlay()) {
- for (int i = 0; i < 4 && game.getClientState() == 6; i++) {
- sleep(500);
- }
- final String returnText = interfaces.getComponent(Lobby.INTERFACE_LOBBY, Lobby.INTERFACE_LOBBY_ALERT_TEXT).getText().toLowerCase().trim();
- if (interfaces.getComponent(Lobby.INTERFACE_LOBBY, Lobby.INTERFACE_LOBBY_ALERT_CLOSE).isValid()) {
- interfaces.getComponent(Lobby.INTERFACE_LOBBY, Lobby.INTERFACE_LOBBY_ALERT_CLOSE).doClick();
- }
- for (solution subSolution : lobbySolutions) {
- if (subSolution.canApply(returnText)) {
- return subSolution.apply();
- }
- }
- }
- }
- if (game.getClientState() == Game.INDEX_LOGIN_SCREEN) {
- if (interfaces.getComponent(INTERFACE_GRAPHICS_NOTICE, INTERFACE_GRAPHICS_LEAVE_ALONE).isValid()) {
- interfaces.getComponent(INTERFACE_GRAPHICS_NOTICE, INTERFACE_GRAPHICS_LEAVE_ALONE).doClick();
- return random(500, 600);
- }
- final String returnText = interfaces.getComponent(INTERFACE_LOGIN_SCREEN, INTERFACE_LOGIN_SCREEN_ALERT_TEXT).getText().toLowerCase().trim();
- if (interfaces.getComponent(INTERFACE_LOGIN_SCREEN, INTERFACE_LOGIN_SCREEN_ALERT_BACK).isValid()) {
- interfaces.getComponent(INTERFACE_LOGIN_SCREEN, INTERFACE_LOGIN_SCREEN_ALERT_BACK).doClick();
- }
- for (solution subSolution : loginSolutions) {
- if (subSolution.canApply(returnText)) {
- return subSolution.apply();
- }
- }
- if (isUsernameCorrect() && isPasswordValid()) {
- attemptLogin();
- return random(1200, 1500);
- }
- if (!isUsernameCorrect()) {
- atLoginInterface(interfaces.getComponent(INTERFACE_LOGIN_SCREEN, INTERFACE_LOGIN_SCREEN_USERNAME_TEXT));
- sleep(random(500, 700));
- final int textLength = interfaces.getComponent(INTERFACE_LOGIN_SCREEN, INTERFACE_LOGIN_SCREEN_USERNAME_TEXT).getText().length();
- if (textLength > 0) {
- for (int i = 0; i <= textLength + random(1, 5); i++) {
- keyboard.sendText("\b", false);
- if (random(0, 2) == 1) {
- sleep(random(25, 100));
- }
- }
- return random(500, 600);
- }
- keyboard.sendText(u, false);
- return random(500, 600);
- }
- if (isUsernameCorrect() && !isPasswordValid()) {
- atLoginInterface(interfaces.getComponent(INTERFACE_LOGIN_SCREEN, INTERFACE_LOGIN_SCREEN_PASSWORD_TEXT));
- sleep(random(500, 700));
- final int textLength = interfaces.getComponent(INTERFACE_LOGIN_SCREEN, INTERFACE_LOGIN_SCREEN_PASSWORD_TEXT).getText().length();
- if (textLength > 0) {
- for (int i = 0; i <= textLength + random(1, 5); i++) {
- keyboard.sendText("\b", false);
- if (random(0, 2) == 1) {
- sleep(random(25, 100));
- }
- }
- return random(500, 600);
- }
- keyboard.sendText(p, false);
- return random(500, 600);
- }
- }
- if(game.isLoggedIn){
- currentState = state.TO_LUMBRIDGE;
- }
- return -1;
- }
- private boolean switchingWorlds() {
- return interfaces.getComponent(Lobby.INTERFACE_LOBBY, Lobby.INTERFACE_LOBBY_ALERT_TEXT).isValid() &&
- interfaces.getComponent(Lobby.INTERFACE_LOBBY, Lobby.INTERFACE_LOBBY_ALERT_TEXT).containsText("just left another world");
- }
- private boolean atLoginInterface(final RSComponent i) {
- if (!i.isValid()) {
- return false;
- }
- final Rectangle pos = i.getArea();
- if (pos.x == -1 || pos.y == -1 || pos.width == -1 || pos.height == -1) {
- return false;
- }
- final int dy = (int) (pos.getHeight() - 4) / 2;
- final int maxRandomX = (int) (pos.getMaxX() - pos.getCenterX());
- final int midx = (int) pos.getCenterX();
- final int midy = (int) (pos.getMinY() + pos.getHeight() / 2);
- if (i.getIndex() == INTERFACE_LOGIN_SCREEN_PASSWORD_TEXT) {
- mouse.click(minX(i), midy + random(-dy, dy), true);
- } else {
- mouse.click(midx + random(1, maxRandomX), midy + random(-dy, dy), true);
- }
- return true;
- }
- private int minX(final RSComponent a) {
- int x = 0;
- final Rectangle pos = a.getArea();
- final int dx = (int) (pos.getWidth() - 4) / 2;
- final int midx = (int) (pos.getMinX() + pos.getWidth() / 2);
- if (pos.x == -1 || pos.y == -1 || pos.width == -1 || pos.height == -1) {
- return 0;
- }
- for (int i = 0; i < interfaces.getComponent(INTERFACE_LOGIN_SCREEN, INTERFACE_LOGIN_SCREEN_PASSWORD_TEXT).getText().length(); i++) {
- x += 11;
- }
- if (x > 44) {
- return (int) (pos.getMinX() + x + 15);
- } else {
- return midx + random(-dx, dx);
- }
- }
- private void attemptLogin() {
- if (random(0, 2) == 0) {
- keyboard.sendKey('\n');
- } else {
- interfaces.getComponent(INTERFACE_LOGIN_SCREEN, INTERFACE_LOGIN_SCREEN_ENTER_GAME).doClick();
- }
- }
- private boolean isUsernameCorrect() {
- final String userName = userNames()[questsDone];
- return interfaces.getComponent(INTERFACE_LOGIN_SCREEN, INTERFACE_LOGIN_SCREEN_USERNAME_TEXT).getText().toLowerCase().equalsIgnoreCase(userName);
- }
- private boolean isPasswordValid() {
- String passWord = passwords()[questsDone];
- if (passWord.isEmpty()) {
- passWord = passwords()[questsDone];
- }
- return interfaces.getComponent(INTERFACE_LOGIN_SCREEN, INTERFACE_LOGIN_SCREEN_PASSWORD_TEXT).getText().length() == (passWord == null ? 0 : passWord.length());
- }
- } // end of script
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement