- import java.text.*;
- import java.awt.Color;
- import java.awt.Graphics;
- import java.awt.Point;
- import java.util.Map;
- import org.rsbot.bot.Bot;
- import org.rsbot.bot.input.CanvasWrapper;
- import org.rsbot.bot.input.Mouse;
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.script.Script;
- import org.rsbot.script.ScriptManifest;
- import org.rsbot.script.wrappers.RSItemTile;
- import org.rsbot.script.wrappers.RSTile;
- import org.rsbot.script.wrappers.RSInterface;
- import org.rsbot.script.wrappers.RSNPC;
- import org.rsbot.script.wrappers.RSObject;
- import org.rsbot.script.Constants;
- import org.rsbot.script.wrappers.RSArea;
- //YES, I IMPORTED CONSTANTS FOR 1 SINGLE FUCKING CONSTANT.
- @ScriptManifest(authors = { "Coco" }, category = "@QUESTAN", name = "RUNE MYSTERIES", version = 1.0, description = "<html><body>" +
- "<h2>Rune Mysteries solver</h2>by Coco<br><hr><p>" +
- " <select name='initialstate'>" +
- "<option>Walking to duke</option" +
- "<option>Talking Duke</option>" +
- "<option>Walking to lumby</option>" +
- "<option>walking to draynor</option>" +
- "<option>getting to serdidor</option>" +
- "<option>talking to serdidor</option>" +
- "<option>lumby to varrock</option>" +
- "<option>talking to aubury</option>" +
- "<option>back to draynor</option>" +
- "<option>to serdidor again</option>" +
- "<option>talking serdidor again</option>" +
- "</select> <br></body></html>")
- public class runemysteries extends Script implements PaintListener {
- private RSObject closedDoor;
- // duke
- private RSTile toDukeStairs[] = new RSTile[] { new RSTile(3222,3218),new RSTile(3214,3216),new RSTile(3213,3210),new RSTile(3206,3210) };
- private RSTile dukeToLumby[] = reversePath(toDukeStairs);
- private RSObject stairDukeO;
- private final int stairDuke = 36773;
- private final int Duke =741;
- private RSNPC duke;
- private final int closedDukedoor = 36844;
- private final RSTile outsideduke = new RSTile (3207, 3222);
- private final RSTile insideduke = new RSTile (3208, 3222);
- private final int floorduke =1;
- private final RSArea room = new RSArea(new RSTile(3208, 3218), new RSTile(3212, 3225));
- private final RSTile nearStairDukeNorth = new RSTile (3205, 3228);
- // /duke
- // wizard tower
- private final int wizardEntranceDoorID = 11993;
- //same as stair divison, should use attile? maybe getNearestObjectByID will solve it..
- private final int stairToBasementID = 2147;
- private final int stairFromBasementID = 32015;
- private final int doorToSerdidorID =33060;
- private final RSTile doorToSerdidorT = new RSTile(3108, 9570);
- private final int serdidorID = 300;
- private final RSArea serdidorRoom = new RSArea(new RSTile(3096, 9566), new RSTile(3107,9574));
- private RSTile lumbyToDraynor[]= new RSTile[] { new RSTile(3222,3219),new RSTile(3232,3220),new RSTile(3230, 3230),new RSTile(3225,3235),new RSTile(3213,3238),
- new RSTile(3200,3238),new RSTile(3188,3235),new RSTile(3177,3231),new RSTile(3165,3232),new RSTile(3155,3230),new RSTile(3143,3229),new RSTile(3130,3225),
- new RSTile(3119,3220),new RSTile(3114,3210),new RSTile(3114,3197),new RSTile(3114,3188),new RSTile(3114,3176),new RSTile(3109,3167)};
- //ends up BEFORE THE DOOR
- private RSTile LumbyToVarrock[] = new RSTile[] { new RSTile(3220, 3219), new RSTile(3235, 3223), new RSTile(3248, 3226), new RSTile(3259, 3227),
- new RSTile(3259, 3241), new RSTile(3251, 3252), new RSTile(3249, 3266), new RSTile(3242, 3276), new RSTile(3237, 3286), new RSTile(3237, 3300),
- new RSTile(3238, 3302), new RSTile(3238, 3316), new RSTile(3238, 3328), new RSTile(3239, 3335), new RSTile(3230, 3337), new RSTile(3225, 3343),
- new RSTile(3225, 3354), new RSTile(3217, 3394), new RSTile(3225, 3354), new RSTile(3220, 3359), new RSTile(3216, 3364), new RSTile(3212, 3368),
- new RSTile(3211, 3374), new RSTile(3209, 3382), new RSTile(3211, 3388), new RSTile(3211, 3394), new RSTile(3210, 3404), new RSTile(3221, 3410),
- new RSTile(3234, 3406), new RSTile(3247, 3401), new RSTile(3253, 3398), new RSTile(3293, 3406), new RSTile(3253, 3398) };
- private RSTile varrockToDraynor[] = new RSTile[]{ new RSTile(3253, 3398), new RSTile(3243, 3403),new RSTile(3243, 3414), new RSTile(3236, 3428), new RSTile(3224, 3430),
- new RSTile(3217, 3429), new RSTile(3203, 3429), new RSTile(3202, 3430), new RSTile(3162, 3454), new RSTile(3202, 3430), new RSTile(3192, 3429),
- new RSTile(3184, 3429), new RSTile(3171, 3429), new RSTile(3161, 3424), new RSTile(3150, 3424), new RSTile(3138, 3422), new RSTile(3127, 3421),
- new RSTile(3116, 3421), new RSTile(3107, 3421), new RSTile(3102, 3421), new RSTile(3096, 3414), new RSTile(3098, 3407), new RSTile(3099, 3400),
- new RSTile(3100, 3393), new RSTile(3099, 3388), new RSTile(3108, 3387), new RSTile(3120, 3385), new RSTile(3123, 3381), new RSTile(3126, 3378),
- new RSTile(3129, 3377), new RSTile(3135, 3368), new RSTile(3136, 3358), new RSTile(3135, 3353), new RSTile(3135, 3349), new RSTile(3135, 3340),
- new RSTile(3146, 3337), new RSTile(3145, 3326), new RSTile(3145, 3314), new RSTile(3145, 3302), new RSTile(3138, 3292), new RSTile(3135, 3281),
- new RSTile(3134, 3268), new RSTile(3134, 3259), new RSTile(3135, 3255), new RSTile(3134, 3252), new RSTile(3136, 3242), new RSTile(3136, 3236),
- new RSTile(3136, 3230), new RSTile(3131, 3224), new RSTile(3125, 3221), new RSTile(3122, 3218), new RSTile(3118, 3213), new RSTile(3122, 3218),
- new RSTile(3118, 3213), new RSTile(3113, 3207), new RSTile(3113, 3193), new RSTile(3112, 3182), new RSTile(3112, 3178), new RSTile(3111, 3170),
- new RSTile(3109, 3167)};
- // /wizard tower
- // aubury
- private final int auburyClosedID =24381;
- private final int auburyID = 553;
- private int state = 0;
- private final int walkingToDuke=0,talkingDuke = 1, walkingToLumby=2, walkingToDraynor=3, gettingToSerdidor=4, talkingToSerdidor=5,
- lumbyToVarrock=6, talkingToAubury=7, backToDraynor=8, toSerdidorAgain=9,talkingSerdidorAgain=10;
- @Override
- public int loop() {
- if (!isRunning() && getEnergy() > 50) setRun(true);
- switch (state) {
- case walkingToDuke:
- if(getPlane() == 0) {
- if (distanceTo(toDukeStairs[toDukeStairs.length -1]) > 5) {
- walk(toDukeStairs);
- return 1000;
- }
- stairDukeO = getNearestObjectByID(stairDuke);
- if (stairDukeO !=null) {
- atObject(stairDukeO, "Climb-up");
- return 1000;
- }
- } else {
- duke =getNearestNPCByID(Duke);
- if (room.contains(duke.getLocation()) && !room.contains(getMyPlayer().getLocation()) ||
- !room.contains(duke.getLocation()) && room.contains(getMyPlayer().getLocation())) {
- //duke is inthe room (and i am not)
- //OR I am in the room, the duke walked out
- closedDoor = getNearestObjectByID(closedDukedoor);
- if (closedDoor !=null) { //and some noob closed the door
- atDoor(closedDukedoor, 'E'); // open
- return 700;
- }
- }
- if (distanceTo(duke.getLocation()) > 5) {
- walkTileMM(duke.getLocation(),0,0); //to duke
- return (500);
- }
- }
- if(duke !=null){
- if (distanceTo(duke.getLocation()) <= 5) state++;
- }
- break;
- case talkingDuke:
- manageTalkingDuke();
- break;
- case walkingToLumby:
- //check door
- closedDoor = getNearestObjectByID(closedDukedoor);
- if (closedDoor !=null && room.contains(getMyPlayer().getLocation())) { //and some noob closed the door
- atDoor(closedDukedoor, 'E'); // open
- return 700;
- }
- if(getPlane() == 1) {
- if (distanceTo(new RSTile(3205,3209)) > 5) {
- walkTileMM(new RSTile(3205,3209),0,0);
- return 1000;
- }
- RSObject stairs = getNearestObjectByID(36774);
- if (stairs!= null) { //bug here :D
- atObject(stairs, "Climb-down");
- return 1000;
- }
- } else {
- if (distanceTo(dukeToLumby[dukeToLumby.length -1]) > 5) {
- walk(dukeToLumby);
- return 1000;
- }
- }
- if (distanceTo(dukeToLumby[dukeToLumby.length -1]) <= 5) state++;
- break;
- case walkingToDraynor:
- if (distanceTo(lumbyToDraynor[lumbyToDraynor.length -1]) > 5) {
- walk(lumbyToDraynor);
- return 1000;
- }
- state++;
- break;
- case gettingToSerdidor:
- if (distanceTo(new RSTile(3109,3167)) <= 20) {
- RSObject entrancedoor = getNearestObjectByID(wizardEntranceDoorID);
- if (entrancedoor != null && distanceBetween(entrancedoor.getLocation(), new RSTile(3111,3163)) > 1) {
- if (tileOnScreen(entrancedoor.getLocation())) {
- if (distanceBetween(entrancedoor.getLocation(), new RSTile(3107,3162)) < 2) { //to trapdoor
- atDoorTiles(new RSTile(3107,3161), new RSTile(3107,3162));
- } else { //main door
- atDoorTiles(new RSTile(3109,3166), new RSTile(3109,3167));
- }
- } else {
- walkTileMM(entrancedoor.getLocation(),0,0);
- }
- return 1000;
- }
- RSObject stairstobasement =getNearestObjectByID(stairToBasementID);
- if (stairstobasement!=null) {
- if (tileOnScreen(stairstobasement.getLocation())) {
- atObject(stairstobasement, "Climb-down");
- } else {
- walkTileMM(stairstobasement.getLocation(),0,0);
- }
- return 1000;
- }
- } else {
- RSNPC serdidor =getNearestNPCByID(serdidorID);
- if (serdidorRoom.contains(serdidor.getLocation()) && !serdidorRoom.contains(getMyPlayer().getLocation()) ||
- !serdidorRoom.contains(serdidor.getLocation()) && serdidorRoom.contains(getMyPlayer().getLocation())) {
- RSObject closedDoors = getNearestObjectByID(doorToSerdidorID);
- if (closedDoors != null && !serdidorRoom.contains(getMyPlayer().getLocation())) { // in the room and door is closed, should be in the next state
- //if (distanceBetween(closedDoors.getLocation(),new RSTile(3107,9570)) <= 3) {
- if (tileOnScreen(closedDoors.getLocation()) ) { //trying to get in to serdidor
- atDoorTiles(new RSTile(3108,9570), new RSTile(3107,9570));
- return 100;
- } else {
- walkTileMM(closedDoors.getLocation(),0,0);
- return 1000;
- }
- //}
- }
- }
- if (distanceTo(serdidor.getLocation()) > 5) {
- walkTileMM(serdidor.getLocation(),0,0); //to duke
- return (500);
- }
- if (distanceTo(serdidor.getLocation()) <= 5 && serdidorRoom.contains(getMyPlayer().getLocation())) state++;
- }
- break;
- case talkingToSerdidor:
- manageTalkingSerdidor();
- break;
- case lumbyToVarrock:
- if (distanceTo(LumbyToVarrock[LumbyToVarrock.length -1]) > 5) {
- walk(LumbyToVarrock);
- return 1000;
- }
- state++;
- break;
- case talkingToAubury:
- manageTalkingAubury();
- break;
- case backToDraynor:
- if (distanceTo(varrockToDraynor[varrockToDraynor.length -1]) > 5) {
- walk(varrockToDraynor);
- return 1000;
- }
- state++;
- //MISSCLICK OUT OF THE PALACE STATE 1
- break;
- case toSerdidorAgain:
- if (distanceTo(new RSTile(3109,3167)) <= 20) {
- RSObject entrancedoor = getNearestObjectByID(wizardEntranceDoorID);
- if (entrancedoor != null && distanceBetween(entrancedoor.getLocation(), new RSTile(3111,3163)) > 1) {
- if (tileOnScreen(entrancedoor.getLocation())) {
- if (distanceBetween(entrancedoor.getLocation(), new RSTile(3107,3162)) < 2) { //to trapdoor
- atDoorTiles(new RSTile(3107,3161), new RSTile(3107,3162));
- } else { //main door
- atDoorTiles(new RSTile(3109,3166), new RSTile(3109,3167));
- }
- } else {
- walkTileMM(entrancedoor.getLocation(),0,0);
- }
- return 1000;
- }
- RSObject stairstobasement =getNearestObjectByID(stairToBasementID);
- if (stairstobasement!=null) {
- if (tileOnScreen(stairstobasement.getLocation())) {
- atObject(stairstobasement, "Climb-down");
- } else {
- walkTileMM(stairstobasement.getLocation(),0,0);
- }
- return 1000;
- }
- } else {
- RSNPC serdidor =getNearestNPCByID(serdidorID);
- if (serdidor == null) {
- state--;
- return 1000;
- }
- if (serdidorRoom.contains(serdidor.getLocation()) && !serdidorRoom.contains(getMyPlayer().getLocation()) ||
- !serdidorRoom.contains(serdidor.getLocation()) && serdidorRoom.contains(getMyPlayer().getLocation())) {
- RSObject closedDoors = getNearestObjectByID(doorToSerdidorID);
- if (closedDoors != null && !serdidorRoom.contains(getMyPlayer().getLocation())) { // in the room and door is closed, should be in the next state
- //if (distanceBetween(closedDoors.getLocation(),new RSTile(3107,9570)) <= 3) {
- if (tileOnScreen(closedDoors.getLocation()) ) { //trying to get in to serdidor
- atDoorTiles(new RSTile(3108,9570), new RSTile(3107,9570));
- return 100;
- } else {
- walkTileMM(closedDoors.getLocation(),0,0);
- return 1000;
- }
- //}
- }
- }
- if (distanceTo(serdidor.getLocation()) > 5) {
- walkTileMM(serdidor.getLocation(),0,0); //to duke
- return (500);
- }
- if (distanceTo(serdidor.getLocation()) <= 5 && serdidorRoom.contains(getMyPlayer().getLocation())) state++;
- }
- break;
- case talkingSerdidorAgain:
- manageTalkingSerdidorAgain();
- break;
- //if tally, quest complete :D
- }
- return 150;
- }
- //bug climbing down (duke-> lumby)
- private void manageTalkingDuke() {
- duke = getNearestNPCByID(Duke);
- closedDoor = getNearestObjectByID(closedDukedoor);
- if (getPlane() != floorduke) {
- return;
- }
- if (duke == null) {
- // state = bankToDuke;
- wait(600);
- return;
- }
- if (canContinue()) {
- clickContinue();
- wait(450);
- return ;
- }
- if (getInterface(228).isValid()) {
- atInterface(getInterface(228).getChild(2), "Continue"); //have you any quests for me?
- return;
- }
- if (getInterface(178).isValid()) {
- atInterface(getInterface(178).getChild(62), "Yes"); //YES (accept quest)
- return;
- }
- if (getInventoryCount(15361) > 0) state++;
- if (!tileOnScreen(duke.getLocation())) {
- walkTileMM(duke.getLocation(),0,0);
- } else {
- atNPC(duke, "Talk-to");
- }
- wait(600);
- return;
- }
- private void manageTalkingSerdidor() {
- if (getInventoryCount(290) > 0) {//the package
- if (distanceTo(new RSTile(3223, 3219)) < 10) {
- state++;
- } else {
- castSpell(Constants.SPELL_HOME_TELEPORT);
- wait(3000);
- while (getMyPlayer().getAnimation() != -1) wait(30);
- }
- return;
- }
- //get plane, distance to
- RSObject closedDoors = getNearestObjectByID(doorToSerdidorID);
- if (closedDoors != null && !serdidorRoom.contains(getMyPlayer().getLocation())) { // in the room and door is closed, should be in the next state
- if (distanceBetween(closedDoors.getLocation(),new RSTile(3107,9570)) <= 5) {
- if (tileOnScreen(closedDoors.getLocation()) ) { //trying to get in to serdidor
- atDoorTiles(new RSTile(3108,9570), new RSTile(3107,9570));
- return;
- } else {
- walkTileMM(closedDoors.getLocation(),0,0);
- wait(1000);
- return;
- }
- }
- }
- if (canContinue()) {
- clickContinue();
- wait(450);
- return ;
- }
- if (getInterface(230).isValid()) {
- atInterface(getInterface(230).getChild(4), "Continue");
- return;
- }
- if (getInterface(228).isValid()) {
- atInterface(getInterface(228).getChild(2), "Continue");
- return;
- }
- RSNPC serdidor = getNearestNPCByID(serdidorID);
- if (!tileOnScreen(serdidor.getLocation())) {
- walkTileMM(serdidor.getLocation(),0,0);
- wait(1000);
- return;
- }
- atNPC(serdidor, "Talk-to");
- wait(500);
- }
- private void manageTalkingAubury() {
- if (getInventoryCount(291) > 0) state++; //notes -> go to serdidor
- if (canContinue()) {
- clickContinue();
- wait(450);
- return ;
- }
- if (getInterface(230).isValid()) {
- atInterface(getInterface(230).getChild(4), "Continue");
- return;
- }//ive been sent
- if (getInventoryCount(291) > 0) state++; //notes -> go to serdidor
- RSNPC aubury = getNearestNPCByID(auburyID);
- if (aubury != null) atNPC(aubury, "Talk-to");
- }
- private void manageTalkingSerdidorAgain() {
- if (getInventoryCount(1438) > 0) {//TALISMAN
- log("QUEST COMPLETED!");
- stopScript();
- return;
- }
- RSObject closedDoors = getNearestObjectByID(doorToSerdidorID);
- if (closedDoors != null && !serdidorRoom.contains(getMyPlayer().getLocation())) { // in the room and door is closed, should be in the next state
- if (tileOnScreen(closedDoors.getLocation()) && distanceBetween(closedDoors.getLocation(),new RSTile(3107,9570)) <= 2 ) { //trying to get in to serdidor
- atDoorTiles(new RSTile(3108,9570), new RSTile(3107,9570));
- return;
- } else if(!tileOnScreen(closedDoors.getLocation())) {
- walkTileMM(closedDoors.getLocation(),0,0);
- wait(1000);
- return;
- }
- }
- if (canContinue()) {
- clickContinue();
- wait(450);
- return ;
- }
- RSNPC serdidor = getNearestNPCByID(serdidorID);
- atNPC(serdidor, "Talk-to");
- wait(500);
- }
- public void getStartupState() {
- return;
- }
- public void onRepaint(final Graphics g) {
- if (!isLoggedIn()) return;
- g.drawString("State: " + stringstate(state), 560,450);
- }
- public String stringstate(int a) {
- switch (a) {
- case 0: return "Walking to duke";
- case 1: return "Talking Duke";
- case 2: return "Walking to lumby";
- case 3: return "walking to draynor";
- case 4: return "getting to serdidor";
- case 5: return "talking to serdidor";
- case 6: return "lumby to varrock";
- case 7: return "talking to aubury";
- case 8: return "back to draynor";
- case 9: return "to serdidor again";
- case 10: return "talking serdidor again";
- }
- return ("huh? this is wierd");
- }
- public double redondear( double numero, int decimales ) {
- return Math.round(numero*Math.pow(10,decimales))/Math.pow(10,decimales);
- }
- @Override
- public boolean onStart(final Map<String, String> args) {
- setCameraAltitude(true);
- if (args.get("initialstate").equals("Walking to duke")) state = 0;
- if (args.get("initialstate").equals("Talking Duke")) state = 1;
- if (args.get("initialstate").equals("Walking to lumby")) state = 2;
- if (args.get("initialstate").equals("walking to draynor")) state = 3;
- if (args.get("initialstate").equals("getting to serdidor")) state = 4;
- if (args.get("initialstate").equals("talking to serdidor")) state = 5;
- if (args.get("initialstate").equals("lumby to varrock")) state = 6;
- if (args.get("initialstate").equals("talking to aubury")) state = 7;
- if (args.get("initialstate").equals("back to draynor")) state = 8;
- if (args.get("initialstate").equals("to serdidor again")) state = 9;
- if (args.get("initialstate").equals("talking serdidor again")) state = 10;
- log("starting at state = " + state);
- return true;
- }
- public void onFinish() {
- }
- private void walk(RSTile path[]) {
- if (!getMyPlayer().isMoving() || distanceTo(getDestination()) <= random(4, 7)) walkPathMM(path, 0,0);
- }
- }
