import com.speljohan.rsbot.bot.Bot;
import com.speljohan.rsbot.script.Script;
import com.speljohan.rsbot.script.wrappers.*;
import java.awt.event.KeyEvent;
import java.awt.*;
import com.speljohan.rsbot.event.listeners.PaintListener;
public class EssenceMiner extends Script implements PaintListener
{
public String getName()
{
return "Jan's Essence Miner";
}
public String getScriptCategory() {
return "Mining";
}
public double getVersion()
{
return 2.0;
}
public String getAuthor()
{
return "Jan274";
}
public boolean onStart(String as[])
{
startTime = System.currentTimeMillis();
Bot.getEventManager().addListener(PaintListener.class, this);
if(isLoggedIn()){
makeSouth();
}
return true;
}
public void onFinish() {
Bot.getEventManager( ).removeListener(PaintListener.class, this);
}
public int State = 0;
public int loadscomplete = 0;
public int essamount = 0;
public String position = "none";
public final int pickaxe[] = {1275, 1265, 1269, 1267, 1273, 1271};
public final int essrockId = 2491;
public final int boothId = 11402;
public final int aubury = 553;
public final int door = 24381;
public final int portal = 2492;
long startTime = 0;
private final RSTile NWportal[] = {new RSTile(2896, 4845), new RSTile(2885, 4849)};
private final RSTile NEportal[] = {new RSTile(2923, 4846), new RSTile(2931, 4854)};
private final RSTile SWportal[] = {new RSTile(2896, 4809), new RSTile(2890, 4812)};
private final RSTile SEportal[] = {new RSTile(2925, 4819), new RSTile(2933, 4816)};
private final RSTilePath NWpath= new RSTilePath(NWportal, this);
private final RSTilePath NEpath= new RSTilePath(NEportal, this);
private final RSTilePath SWpath= new RSTilePath(SWportal, this);
private final RSTilePath SEpath= new RSTilePath(SEportal, this);
private final RSTile MSWposA[] = {
new RSTile(2906, 4826), new RSTile(2897, 4817)};
private final RSTilePath MSWPathA= new RSTilePath(MSWposA, this);
private final RSTile MNEpos[] = {
new RSTile(2912, 4833), new RSTile(2923, 4846)};
private final RSTilePath MNEPath= new RSTilePath(MNEpos, this);
private final RSTile toBankA[] = {
new RSTile(3253, 3402), new RSTile(3260, 3414)};
private final RSTilePath toBankPathA= new RSTilePath(toBankA, this);
private final RSTile toBankB[] = {
new RSTile(3260, 3414), new RSTile(3254, 3420)};
private final RSTilePath toBankPathB= new RSTilePath(toBankB, this);
private final RSTile toAuburyA[]={
new RSTile(3253, 3420), new RSTile(3245, 3410)};
private final RSTilePath toAuburyPathA= new RSTilePath(toAuburyA, this);
private final RSTile toAuburyB[]={
new RSTile(3245, 3410), new RSTile(3253, 3402)};
private final RSTilePath toAuburyPathB= new RSTilePath(toAuburyB, this);
public boolean openDoor() {//wakka's opener
RSObject obj = findObject(door);
if (obj !=null) {
if (distanceTo(findObject(door)) <= 5) {
atDoor(findObject(door), "West", "Open");
wait (random(1000, 2000));
return true;
}
}
return false;
}
public void makeSouth(){
setCompass('N');
wait(random(200, 700));
Bot.getInputManager().pressKey(
((char) (KeyEvent.VK_LEFT)));
wait(1900);
Bot.getInputManager().releaseKey(
((char) (KeyEvent.VK_LEFT)));
}
public void onRepaint(Graphics g){
long runTime = System.currentTimeMillis() - startTime;
long TotalSecs = runTime / 1000;
long TotalMins = TotalSecs / 60;
long TotalHours = TotalMins / 60;
int seconds = (int) TotalSecs % 60;
int minutes = (int) TotalMins % 60;
int hours = (int) TotalHours % 60;
StringBuilder b = new StringBuilder();
if (hours < 10)
b.append('0');
b.append(hours);
b.append(':');
if (minutes < 10)
b.append('0');
b.append(minutes);
b.append(':');
if (seconds < 10)
b.append('0');
b.append(seconds);
if(isLoggedIn()){
int x = 18;
int y = 240;
g.setColor(Color.BLACK);
g.drawString("Jan274's Essence Miner ", x, y += 15);
g.setColor(Color.BLUE);
g.drawString("Ran for: " + b.toString(), x, y += 25);
g.drawString("Mined: " + essamount + " essence", x, y += 20);
g.drawString("Completed: " + loadscomplete + " loads", x, y += 20);
}
}
public void essAntiBan(){
int t;
int u;
t = random(0,9);
u = random(0,10);
if( u == 3 ){
try{
switch(t){
case 0://random mouse
moveMouse(0 + random(0, 500), 0 + random(0, 500));
wait(random(500, 1000));
break;
case 4://random tab.
openTab(random(1, 15));
wait(random(500,1000));
break;
case 2:
moveMouse(0 + random(0, 500), 0 + random(0, 500));
wait(random(500, 1000));
break;
case 3:
case 1:
case 5:
case 8:
case 7:
case 6://examing object
int hu = random(0, 3);
if(hu == 1){
int robj[] = {743, 2491, 2492, 724, 484, 485, 744};
if(atObject(findObject(robj[random(0, 6)]), "amine")){
wait(random(500,1000));
}
}else{
break;
}
break;
}
}catch(Exception e){
e.printStackTrace();
}
}
}
public boolean randomPath(int path) throws InterruptedException{
int rpath = 0;
if(path == 2){
rpath = random(0,5);
if(rpath == 2){
toAuburyPathB.walkToStart();
wait(random(400,500));
toAuburyPathA.walkToStart();
}
else{
toBankPathA.walkToEnd();
wait(random(400,500));
toBankPathB.walkToEnd();
}
}
if(path == 1){
rpath = random(0,5);
if(rpath == 2){
toAuburyPathA.walkToEnd();
wait(random(400,500));
toAuburyPathB.walkToEnd();
}
else{
toBankPathB.walkToStart();
wait(random(400,500));
toBankPathA.walkToStart();
}
}
return true;
}
public int loop()
{
try{
if(getMyPlayer().isMoving()){
return random(10, 100);
}
switch(State){
case 0:
if(distanceTo(toBankA[0]) < 5)
{
State = 1;
} else
{
closeBank();
setRun(true);
randomPath(1);
if(getMyPlayer().isMoving()){
return random(10, 100);
}
openDoor();
}
return random(100, 500);
case 1:
if(distanceTo(toBankA[0]) < 5)
{
RSNPC rsnpc = getNearestNPCByID(aubury);
if(atNPC(rsnpc, "Teleport"))
State = 2;
}else{
State = 0;
}
return random(500, 1000);
case 2:
if(distanceTo(toBankA[0]) < 5){
return random(100, 500);
}
if(distanceTo(MSWposA[0]) < 2)
{
MSWPathA.walkToEnd();
position = "SW";
}
if(distanceTo(MNEpos[0]) < 2)
{
MNEPath.walkToEnd();
position = "NE";
}
State = 3;
return random(100, 500);
case 3:
if(isInventoryFull()){
State = 4;
}
else
{
if(!(getMyPlayer().getAnimation() == -1)){
essAntiBan();
return random(100,200);
}else{
if (getMyPlayer().getAnimation() == -1){
wait(random(3000, 4000));
if(!getMyPlayer().isMoving() && getMyPlayer().getAnimation() == -1){
if(!(atObject(findObject(essrockId), "Mine"))){
makeSouth();
}
}else{
essAntiBan();
}
}
}
}
return random(100, 500);
case 4:
if(distanceTo(NEportal[0]) < 10)
NEpath.walkToEnd();
if(distanceTo(NWportal[0]) < 10)
NWpath.walkToEnd();
if(distanceTo(SEportal[0]) < 10)
SEpath.walkToEnd();
if(distanceTo(SWportal[0]) < 10)
SWpath.walkToEnd();
if(getMyPlayer().isMoving())
return random(10, 100);
if(!(distanceTo(toBankA[0]) < 10)){
wait(random(400,500));
atObject(findObject(portal), "Use");
wait(random(500,800));
}else{
State = 5;
}
return random(100, 200);
case 5:
if(distanceTo(toBankA[0]) < 10){
openDoor();
randomPath(2);
essamount += getInventoryCount(1436);
loadscomplete++;
State = 6;
}
return random(100, 200);
case 6:
if(RSInterface.getInterface(INTERFACE_BANK).isValid())
{
depositAllExcept(pickaxe);
wait(random(500,800));
State = 0;
}
if(atObject(findObject(boothId), "Use-quickly")){
wait(random(400, 500));
if(RSInterface.getInterface(INTERFACE_BANK).isValid())
{
depositAllExcept(pickaxe);
wait(random(500,800));
State = 0;
}
}
return random(100,200);
}
}catch(Exception e){
e.printStackTrace();
}
return random(100,500);
}
}