forget it itws outdated=/
import java.awt.*;
import java.util.*;
import java.awt.event.*;
import com.speljohan.rsbot.script.*;
import com.speljohan.rsbot.bot.*;
import com.speljohan.rsbot.script.wrappers.*;
import com.speljohan.rsbot.event.listeners.*;
import com.speljohan.rsbot.event.events.*;
import java.awt.event.KeyEvent;
import java.applet.Applet;
public class RuneMysteries extends Script {
//todo: walk to lumbridge on message "Congratulations! Quest complete!"
final int NOTES_ID = 291;
final int PACKAGE_ID = 290;
final int TALISMAN_ID = 1438;
final int DOOR_DUKE_ID = 36844;
final int DOOR_TOWER_ID = 11993;
final int UNDERGROUND_DOOR_ID = 33060;
final RSTile[] TO_LUMBRIDGE_STAIRS = {new RSTile(3222,3218), new RSTile(3213,3227), new RSTile(3206,3228)};
final RSTile[] TO_DUKE = {new RSTile(3205,3228), new RSTile(3211,3219)};
final RSTile[] LUMBRIDGE_TO_WIZARDS = {new RSTile(3206, 3228), new RSTile(3214, 3219), new RSTile(3229, 3219), new RSTile(3236, 3210),
new RSTile(3236, 3201), new RSTile(3244, 3192), new RSTile(3231, 3190), new RSTile(3217, 3195),
new RSTile(3201, 3194), new RSTile(3186, 3200), new RSTile(3174, 3198), new RSTile(3158, 3199),
new RSTile(3144, 3208), new RSTile(3135, 3219), new RSTile(3120, 3215), new RSTile(3113, 3204),
new RSTile(3114, 3196), new RSTile(3114, 3180), new RSTile(3113, 3170), new RSTile(3109, 3163)};
final RSTile[] WIZARDS_TO_VARROCK = {
new RSTile(3109, 3166), new RSTile(3113, 3179), new RSTile(3113, 3194), new RSTile(3114, 3209),
new RSTile(3107, 3224), new RSTile(3101, 3239), new RSTile(3103, 3255), new RSTile(3104, 3269),
new RSTile(3108, 3285), new RSTile(3111, 3301), new RSTile(3110, 3317), new RSTile(3127, 3319),
new RSTile(3135, 3330), new RSTile(3137, 3346), new RSTile(3139, 3359), new RSTile(3137, 3373),
new RSTile(3127, 3385), new RSTile(3113, 3390), new RSTile(3104, 3404), new RSTile(3098, 3415),
new RSTile(3113, 3420), new RSTile(3126, 3414), new RSTile(3140, 3416), new RSTile(3153, 3417),
new RSTile(3167, 3426), new RSTile(3182, 3429), new RSTile(3199, 3428), new RSTile(3213, 3429),
new RSTile(3229, 3428), new RSTile(3243, 3428), new RSTile(3244, 3412), new RSTile(3253, 3401)};
final RSTile[] TO_UNDERGROUND_DOOR = {new RSTile(3104,9576), new RSTile(3106, 9570)};
final RSTile LUMBRIDGE_STAIRS = new RSTile(3204,3230);
final RSTile DOOR_DUKE = new RSTile(3207,3222);
final RSTile DOOR_TOWER1 = new RSTile(3109,3167);
final RSTile DOOR_TOWER2 = new RSTile(3107, 3162);
final RSTile UNDERGROUND_DOOR = new RSTile(3108, 9570);
public String getName() {
return "Rune Mysteries";
}
public double getVersion() {
return 1.0;
}
public String getAuthor() {
return "Mike";
}
public String getScriptCategory() {
return "Mike's Scripts/BotArmy";
}
public String getScriptDescription() {
return "<html>\n" +
"<head></head>\n" +
"<body>\n" +
"<center>" +
"<h2>" + getName() + "</h2>" +
"</center>\n" +
"<b>Author:</b> " + getAuthor() + "<br/>\n" +
"<b>Version:</b> " + getVersion() + "<br/>\n" +
"<br/>\n" +
"<b>Starting Location:</b> Tutorial island/Lumbridge<br/>" +
"<b>Function:</b> Will do 'Learning The Ropes' then train your stats to the desired levels." +
"<br/>" +
"<b>Version Notes:</b> " +
"<ul>" +
"<li>" +
"<li>" +
"<b>0.*:</b> Beta Versions" +
"</li>" +
"</ul>" +
"</body>\n" +
"</html>";
}
public boolean onStart(String[] args) {
return true;
}
public boolean isInWizardRoom() {
int nameX[] = new int[]{3105,3103,3102,3106,3109};
int nameY[] = new int[]{3164,3164,3163,3158,3160};
Polygon name=new Polygon(nameX, nameY, 5);
if(name.contains(getLocation().getX(), getLocation().getY()))
return true;
return false;
}
public boolean isInWizardTower() {
int nameX[] = new int[]{3112,3112,3107,3104,3103,3102,3106,3108,3112,3110};
int nameY[] = new int[]{3164,3166,3166,3164,3165,3163,3158,3159,3165,3166};
Polygon name=new Polygon(nameX, nameY, 10);
if(name.contains(getLocation().getX(), getLocation().getY()))
return true;
return false;
}
public boolean isUnderWizardTower() {
if(getLocation().getY()>=9555)
return true;
return false;
}
public boolean isInSedridorsRoom() {
int nameX[] = new int[]{3107,3107,3096,3097};
int nameY[] = new int[]{9566,9574,9574,9566};
Polygon name=new Polygon(nameX, nameY, 4);
if(name.contains(getLocation().getX(), getLocation().getY()))
return true;
return false;
}
public boolean isInRuneShop() {
int nameX[] = new int[]{3249,3257,3257,3249};
int nameY[] = new int[]{3405,3405,3399,3399};
Polygon name=new Polygon(nameX, nameY, 4);
if(name.contains(getLocation().getX(), getLocation().getY()))
return true;
return false;
}
public int getStep() {
if(getInventoryCount(TALISMAN_ID,PACKAGE_ID,NOTES_ID) <= 0) {
if(isInRuneShop())
return 4;
return 0;
}
if(getInventoryCount(NOTES_ID) >= 1)
if(!isUnderWizardTower())
return 5;
else
return 2;
if(getInventoryCount(PACKAGE_ID) >= 1)
if(isUnderWizardTower())
return 3;
else
return 4;
if(getInventoryCount(TALISMAN_ID) >= 1)
if(!isUnderWizardTower())
return 1;
else
return 2;
return -1;
}
public int loop() {
try {
if(getMyPlayer().isMoving())
return random(50,750);
if(canContinue()) {
clickContinue();
return random(200,700);
}
int step = getStep();
int height = getPlane();
log("Currently On Step: "+step);
if(RSInterface.getInterface(228).isValid()) {
atInterface(228,2);
return random(200,700);
}
if(RSInterface.getInterface(230).isValid()) {
atInterface(230,4);
return random(50,100);
}
switch(step) {
case 0:
if(height==0) {
if(!walkPathMM(randomizePath(TO_LUMBRIDGE_STAIRS,1,1),17))
return random(50,100);
if(!atTile(LUMBRIDGE_STAIRS, "Climb-up"))
turnToTile(LUMBRIDGE_STAIRS);
}
if(height==1) {
if(!walkPathMM(randomizePath(TO_DUKE,2,2),17)) {
RSObject door = getObjectAt(DOOR_DUKE);
if(door!=null && door.getID() == DOOR_DUKE_ID) {
log("Door closed");
if(!atDoor(door, "east", "Open"))
turnToTile(DOOR_DUKE);
}
return random(50,100);
}
RSNPC duke = getNearestNPCByName("Duke Horacio");
if(duke==null)
return random(50,100);
if(!atNPC(duke, "Talk-to"));
turnToTile(duke.getLocation());
}
if(height==2) {
if(!atTile(LUMBRIDGE_STAIRS, "Climb-down"))
turnToTile(LUMBRIDGE_STAIRS);
}
return random(50,100);
case 1:
if(height != 0) {
if(!walkPathMM(randomizePath(reversePath(TO_DUKE),2,2),17)) {
RSObject door = getObjectAt(DOOR_DUKE);
if(door!=null && door.getID() == DOOR_DUKE_ID) {
log("Door closed");
if(!atDoor(door, "east", "Open"))
turnToTile(DOOR_DUKE);
}
return random(50,100);
}
if(!atTile(LUMBRIDGE_STAIRS, "Climb-down"))
turnToTile(LUMBRIDGE_STAIRS);
}
if(!isInWizardTower()) {
RSObject door = getObjectAt(DOOR_TOWER1);
if(door!=null && door.getID() == DOOR_TOWER_ID && distanceTo(door) <= 5) {
log("Door closed");
if(!atDoor(door, "east", "Open"))
turnToTile(DOOR_DUKE);
return random(50,100);
}
if(!walkPathMM(randomizePath(LUMBRIDGE_TO_WIZARDS,2,2),17))
return random(50,100);
}
if(!isInWizardRoom()) {
RSObject door2 = getObjectAt(DOOR_TOWER2);
if(door2!=null && door2.getID() == DOOR_TOWER_ID && distanceTo(door2) <= 5) {
log("Door closed");
if(!atDoor(door2, "east", "Open"))
turnToTile(DOOR_DUKE);
}
RSTile[] randomTile = {new RSTile(3104,3161), new RSTile(3106,3161), new RSTile(3106,3162), new RSTile(3105,3160)};
RSTile tile = randomTile[random(0,randomTile.length)];
if(!atTile(tile, "Walk here"))
doWalk(tile);
return random(50,100);
}
RSTile ladder = new RSTile(3104,3162);
if(!atTile(ladder, "Climb-down"))
turnToTile(ladder);
return random(50,100);
case 2:
if(isInSedridorsRoom()) {
RSNPC sedridor = getNearestNPCByName("Sedridor");
if(sedridor==null)
return random(50,100);
if(!atNPC(sedridor, "Talk-to"))
turnToTile(sedridor.getLocation());
return random(50,100);
}
if(!walkPathMM(randomizePath(TO_UNDERGROUND_DOOR,2,2),17))
return random(50,100);
RSObject undergroundDoor = getObjectAt(UNDERGROUND_DOOR);
if(undergroundDoor!=null && undergroundDoor.getID() == UNDERGROUND_DOOR_ID) {
log("Door closed");
if(!atDoor(undergroundDoor, "west", "Open"))
turnToTile(UNDERGROUND_DOOR);
return random(50,100);
}
doWalk(new RSTile(random(3102,3105),random(9570,9573)));
return random(50,100);
case 3:
if(isInSedridorsRoom()) {
RSObject undergroundDoor2 = getObjectAt(UNDERGROUND_DOOR);
if(undergroundDoor2!=null && undergroundDoor2.getID() == UNDERGROUND_DOOR_ID) {
log("Door closed");
if(!atDoor(undergroundDoor2, "west", "Open")) {
walkTileMM(new RSTile(random(3106,3108),random(9569,9571)));
turnToTile(UNDERGROUND_DOOR);
}
return random(50,100);
}
}
if(!walkPathMM(randomizePath(reversePath(TO_UNDERGROUND_DOOR),2,2),17))
return random(50,100);
RSObject undergroundLadder = findObject(32015);
if(undergroundLadder==null)
return random(50,100);
if(!atObject(undergroundLadder, "Climb"))
turnToTile(undergroundLadder.getLocation());
return random(50,100);
case 4:
if(isInWizardRoom()) {
RSObject door3 = getObjectAt(DOOR_TOWER2);
if(door3!=null && door3.getID() == DOOR_TOWER_ID && distanceTo(door3) <= 5) {
log("Door closed");
if(!atDoor(door3, "east", "Open"))
turnToTile(DOOR_DUKE);
}
RSTile[] randomTile2 = {new RSTile(3107,3164), new RSTile(3108,3164), new RSTile(3110,3165), new RSTile(3105,3164)};
RSTile tile2 = randomTile2[random(0,randomTile2.length)];
if(!atTile(tile2, "Walk here"))
doWalk(tile2);
return random(50,100);
}
if(isInWizardTower()) {
RSObject door4 = getObjectAt(DOOR_TOWER1);
if(door4!=null && door4.getID() == DOOR_TOWER_ID && distanceTo(door4) <= 5) {
log("Door closed");
if(!atDoor(door4, "east", "Open"))
turnToTile(DOOR_DUKE);
return random(50,100);
}
}
if(RSInterface.getInterface(230).isValid()) {
atInterface(230,4);
return random(50,100);
}
if(!walkPathMM(randomizePath(WIZARDS_TO_VARROCK,2,2),17))
return random(50,750);
RSNPC aubury = getNearestNPCByName("Aubury");
if(aubury==null)
return random(50,100);
if(!atNPC(aubury, "Talk-to"))
turnToTile(aubury.getLocation());
return random(50,100);
case 5:
if(!isInWizardTower()) {
RSObject door = getObjectAt(DOOR_TOWER1);
if(door!=null && door.getID() == DOOR_TOWER_ID && distanceTo(door) <= 5) {
log("Door closed");
if(!atDoor(door, "east", "Open"))
turnToTile(DOOR_DUKE);
return random(50,100);
}
if(!walkPathMM(randomizePath(reversePath(WIZARDS_TO_VARROCK),2,2),17))
return random(50,100);
}
if(!isInWizardRoom()) {
RSObject door2 = getObjectAt(DOOR_TOWER2);
if(door2!=null && door2.getID() == DOOR_TOWER_ID && distanceTo(door2) <= 5) {
log("Door closed");
if(!atDoor(door2, "east", "Open"))
turnToTile(DOOR_DUKE);
}
RSTile[] randomTile = {new RSTile(3104,3161), new RSTile(3106,3161), new RSTile(3106,3162), new RSTile(3105,3160)};
RSTile tile = randomTile[random(0,randomTile.length)];
if(!atTile(tile, "Walk here"))
doWalk(tile);
return random(50,100);
}
RSTile ladder2 = new RSTile(3104,3162);
if(!atTile(ladder2, "Climb-down"))
turnToTile(ladder2);
return random(50,100);
case 6:
return random(50,100);
case 7:
return random(50,100);
case 8:
return random(50,100);
case 9:
return random(50,100);
}
} catch(Exception e) {
}
return random(50,100);
}
public int getAngleToCoordinates(int x2, int y2) {
int x1 = getMyPlayer().getLocation().getX();
int y1 = getMyPlayer().getLocation().getY();
int x = x1 - x2;
int y = y1 - y2;
double angle = Math.toDegrees(Math.atan2(x , y));
if(x == 0 && y > 0)
angle = 180;
if(x < 0 && y == 0)
angle = 90;
if(x == 0 && y < 0)
angle = 0;
if(x < 0 && y == 0)
angle = 270;
if(x < 0 && y > 0)
angle+=270;
if(x > 0 && y > 0)
angle+=90;
if(x < 0 && y < 0)
angle=Math.abs(angle)-180;
if(x > 0 && y < 0)
angle=Math.abs(angle)+270;
if(angle<0)
angle=360+angle;
if(angle>=360)
angle-=360;
return (int)angle;
}
public void turnToTile(RSTile tile) {
int angle=getAngleToCoordinates(tile.getX(),tile.getY());
angle = angle+random(-20,20);
if(angle<0)
angle=360+angle;
if(angle>=360)
angle-=360;
setCameraRotation2(angle);
}
public void setCameraRotation2(int degrees) {
//Made by aftermath. Was suggested into SVN and i just added it into here until somebody does the right thing
char left = 37;
char right = 39;
char whichDir = left;
int start = getCameraAngle();
if(start < 180)
start += 360;
if(degrees < 180)
degrees += 360;
if(degrees > start) {
if(degrees - 180 < start)
whichDir = right;
} else if(start > degrees) {
if(start - 180 >= degrees)
whichDir = right;
}
degrees %= 360;
Bot.getInputManager().pressKey(whichDir);
int timeWaited = 0;
while (getCameraAngle() > degrees + 5 || getCameraAngle() < degrees - 5) {
wait(10);
timeWaited += 10;
if (timeWaited > 500) {
int time = timeWaited - 500;
if (time == 0) {
Bot.getInputManager().pressKey(whichDir);
} else if (time % 40 == 0) {
Bot.getInputManager().pressKey(whichDir);
}
}
}
Bot.getInputManager().releaseKey(whichDir);
}
}

