rendered paste bodyimport org.rsbot.script.Script;
import org.rsbot.script.ScriptManifest;
import org.rsbot.script.util.Timer;
import org.rsbot.script.wrappers.*;
import org.rsbot.script.methods.*;
import org.rsbot.event.listeners.*;
import org.rsbot.event.events.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import java.util.*;
import java.net.*;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.List;
import javax.imageio.ImageIO;
import java.awt.geom.RoundRectangle2D;
import java.net.URL;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.ArrayList;
import org.rsbot.Configuration;
@ScriptManifest(authors = {"Anarki, Mika"}, keywords = {"Epic, Gnome, ,Barbarian, Advanced, Ape, Atoll, Agility, Trainer, Anarki, Mika" }, name = "Epic Agility Trainer", description = "Made by Anarki.", version = 1.07, website = "http://www.powerbot.org/community/topic/562222-epic-agility-trainer-no1-fastest-aio-agility-script-best-agility-script-70k-exp-hour/")
public class EpicAgilityTrainer extends Script implements PaintListener {
private String getVersion() {
return "1.07";
}
// ---------- Gui ----------
public boolean WaitingGui = true;
EpicAgilityTrainerGUI gui = new EpicAgilityTrainerGUI();
// ---------- Mouse Methods & Values ------------
Image cursor = null;
Image cursor80 = null;
Image cursor60 = null;
Image cursor40 = null;
Image cursor20 = null;
private final RenderingHints rh = new RenderingHints(
RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
private void mouse(Graphics g) {
((Graphics2D) g).setRenderingHints(rh);
final int mouse_x = mouse.getLocation().x;
final int mouse_y = mouse.getLocation().y;
final long mpt = System.currentTimeMillis() - mouse.getPressTime();
if (mouse.getPressTime() == -1 || mpt >= 1000)
g.drawImage(cursor, mouse_x, mouse_y, null);
if (mpt < 200)
g.drawImage(cursor20, mouse_x, mouse_y, null);
if (mpt < 400 && mpt >= 200)
g.drawImage(cursor40, mouse_x, mouse_y, null);
if (mpt < 600 && mpt >= 400)
g.drawImage(cursor60, mouse_x, mouse_y, null);
if (mpt < 1000 && mpt >= 600)
g.drawImage(cursor80, mouse_x, mouse_y, null);
}
Obstacle RopeSwing, BarbarianAdvandedLogBalance, Wall1, Wall2, SpringDevice, BalanceBeam, Gap, Roof;
Obstacle GnomeAdvandedLogBalance, ObstacleNet, TreeBranch, Tree, Signpost, Pole, Barrier;
Obstacle Pause, ApeAtollTree, ApeAtollBars, ApeAtollSlope, ApeAtollSwing, ApeAtollRope, ApeAtollStep;
int last = -1;
int getAgilityCourse = -1;
String debug;
Obstacle[] course;
Timer runTime;
Timer changeStateTimer;
Timer failsafeTimer;
RSObject next;
Image bg;
int EatAt;
int startingXp = 0, startingLevel = 0, xp = 0, level = 0;
double perc = 0;
// --------------------------- Barbarian Advanced Agility Course --------------------------
RSArea RopeSwingArea1 = new RSArea(new RSTile(2543, 3553), new RSTile(2556, 3559), 0);
RSArea RopeSwingArea2 = new RSArea(new RSTile(2543, 3549), new RSTile(2549, 3556), 0);
RSArea RopeSwingArea3 = new RSArea(new RSTile(2544, 3550), new RSTile(2556, 3559), 0);
RSArea BarbarianAdvandedLogBalanceArea1 = new RSArea(new RSTile(2550, 3542), new RSTile(2555, 3550), 0);
RSArea BarbarianAdvandedLogBalanceArea2 = new RSArea(new RSTile(2545, 3542), new RSTile(2549, 3545), 0);
RSArea WallArea1 = new RSArea(new RSTile(2537, 3542), new RSTile(2541, 3549), 0);
RSArea WallArea2 = new RSArea(new RSTile(2537, 3542), new RSTile(2538, 3547), 2);
RSArea SpringDeviceArea = new RSArea(new RSTile(2532, 3545), new RSTile(2537, 3547), 3);
RSArea BalanceBeamArea = new RSArea(new RSTile(2530, 3553), new RSTile(2534, 3554), 3);
RSArea GapArea = new RSArea(new RSTile(2535, 3553), new RSTile(2536, 3556), 3);
RSArea RoofArea = new RSArea(new RSTile(2536, 3552), new RSTile(2539, 3554), 2);
RSArea RopeSwingWaitingArea = new RSArea(new RSTile(2548, 3554), new RSTile(2550, 3557), 0);
RSArea RoofSlidingArea = new RSArea(new RSTile(2540, 3552), new RSTile(2544, 3554), 1);
RSArea BarbarianAdvandedLogBalanceClickingArea = new RSArea(new RSTile(2550, 3550), new RSTile(2553, 3553), 0);
RSArea WallClickingArea1 = new RSArea(new RSTile(2541, 3546), new RSTile(2543, 3546), 0);
RSArea WallClickingArea2 = new RSArea(new RSTile(2537, 3542), new RSTile(2538, 3545), 2);
// ----------------------------- Gnome Advanced Agility Course --------------------------
RSArea GnomeAdvandedLogBalanceArea = new RSArea(new RSTile(2469, 3436), new RSTile(2491, 3440), 0);
RSArea ObstacleNetArea = new RSArea(new RSTile(2469, 3424), new RSTile(2479, 3429), 0);
RSArea TreeBranchArea = new RSArea(new RSTile(2471, 3422), new RSTile(2476, 3424), 1);
RSArea TreeArea = new RSArea(new RSTile(2471, 3418), new RSTile(2477, 3421), 2);
RSArea SignpostArea = new RSArea(new RSTile(2472, 3418), new RSTile(2477, 3420), 3);
RSArea PoleArea = new RSArea(new RSTile(2482, 3418), new RSTile(2487, 3421), 3);
RSArea BarrierArea = new RSArea(new RSTile(2482, 3432), new RSTile(2488, 3435), 3);
RSArea ObstacleNetClickingArea = new RSArea(new RSTile(2469, 3429), new RSTile(2479, 3432), 0);
RSArea PoleClickingArea = new RSArea(new RSTile(2482, 3418), new RSTile(2484, 3419), 3);
RSArea BarrierClickngArea = new RSArea(new RSTile(2482, 3429), new RSTile(2489, 3432), 3);
// ----------------------------- Gnome Advanced Agility Course --------------------------
RSArea TreeAreaAfterStep = new RSArea(new RSTile(2751, 2742), new RSTile(2753, 2742));
RSArea ApeAtollStartArea = new RSArea(new RSTile(2755, 2742), new RSTile(2778, 2761));
RSTilePath pathToStep;
RSTilePath pathToSwing;
RSTile[] TilesToStep = { new RSTile(2770, 2747), new RSTile(2768, 2747),
new RSTile(2766, 2747), new RSTile(2765, 2747), new RSTile(2764, 2748),
new RSTile(2762, 2748), new RSTile(2760, 2748), new RSTile(2759, 2747),
new RSTile(2759, 2745), new RSTile(2758, 2745), new RSTile(2758, 2744),
new RSTile(2756, 2742), new RSTile(2755, 2742) };
RSTile[] TilesToSwing = { new RSTile(2742, 2741), new RSTile(2742, 2739),
new RSTile(2744, 2737), new RSTile(2745, 2737), new RSTile(2746, 2736),
new RSTile(2747, 2736), new RSTile(2749, 2734), new RSTile(2750, 2733),
new RSTile(2751, 2733), new RSTile(2751, 2731) };
// ----------------------------- Werewolf Agility Course --------------------------
RSArea WerewolfStartArea = new RSArea(new RSTile(3534, 9866), new RSTile(3546, 9874));
RSArea doHurdleArea = new RSArea(new RSTile(3534, 9880), new RSTile(3545, 9902));
RSArea pipeArea = new RSArea(new RSTile(3535, 9900), new RSTile(3545, 9904));
RSArea skullSlopeArea = new RSArea(new RSTile(3533, 9907), new RSTile(3548, 9917));
RSArea slideArea = new RSArea(new RSTile(3523, 9908), new RSTile(3532, 9912));;
RSArea slideDownArea = new RSArea(new RSTile(3524, 9877), new RSTile(3531, 9895));
RSArea stickManArea = new RSArea(new RSTile(3523, 9862), new RSTile(3532, 9876));
RSArea agilityArea = new RSArea(new RSTile(3520, 9860), new RSTile(3550,3920), 0);
RSArea stone1Area = new RSArea(new RSTile(3538, 9874), new RSTile(3538, 9875));
RSArea stone2Area = new RSArea(new RSTile(3538, 9876), new RSTile(3538, 9877));
RSArea stone3Area = new RSArea(new RSTile(3539, 9877), new RSTile(3540, 9877));
RSArea stone4Area = new RSArea(new RSTile(3540, 9878), new RSTile(3540, 9879));
RSTilePath pathToWerewolfStartArea;
RSTile[] TilesToWerewolfStartArea = { new RSTile(3530, 9894), new RSTile(3530, 9892), new RSTile(3530, 9890),
new RSTile(3530, 9888), new RSTile(3530, 9886), new RSTile(3530, 9884),
new RSTile(3530, 9882), new RSTile(3530, 9880), new RSTile(3530, 9878),
new RSTile(3530, 9876), new RSTile(3530, 9874), new RSTile(3530, 9872),
new RSTile(3530, 9870), new RSTile(3530, 9868), new RSTile(3528, 9866) };
RSTile stone1 = new RSTile(3538, 9875);
RSTile stone2 = new RSTile(3538, 9877);
RSTile stone3 = new RSTile(3540, 9877);
RSTile stone4 = new RSTile(3540, 9879);
RSTile stone5 = new RSTile(3540, 9881);
RSTile[] hurdleStart = { new RSTile(3538, 9893), new RSTile(3540, 9893), new RSTile(3542, 9893) };
RSTile hurdleOne = new RSTile(3540,9892);
int[] hurdles = { 5133, 5134, 5135 };
int pipe = 5152;
int skullSlope = 5136;
int[] slide = { 5139, 5140, 5141 };
int stickNPC = 1664;
int stick = 4179;
//hurdleY's + 3 each time
int hurdle1Y = 9893;
int hurdle2Y = 9896;
int hurdle3Y = 9899;
int stone1Y = 9875;
int stone2Y = 9877;
int stone3Y = 9877;
int stone4Y = 9879;
int stone5Y = 9881;
RSObject hurdle;
RSObject stone;
private enum state { eatFood, step1, step2, step3, step4, step5, hurdles, pipes, stickNSlope, slide, fallen, end, error; };
private state getState() {
if (getLifePoints() < EatAt)
return state.eatFood;
else if (stickManArea.contains(getMyPlayer().getLocation()))
return state.end;
else if (slideDownArea.contains(getMyPlayer().getLocation()))
return state.fallen;
else if (slideArea.contains(getMyPlayer().getLocation()))
return state.slide;
else if (skullSlopeArea.contains(getMyPlayer().getLocation()))
return state.stickNSlope;
else if (pipeArea.contains(getMyPlayer().getLocation()))
return state.pipes;
else if (doHurdleArea.contains(getMyPlayer().getLocation()) || (doHurdleArea.contains(getMyPlayer().getLocation()) && getMyPlayer().getAnimation() == 1604))
return state.hurdles;
else if (stone4Area.contains(getMyPlayer().getLocation()) || (stone4Area.contains(getMyPlayer().getLocation()) && getMyPlayer().getAnimation() == 1604))
return state.step5;
else if (stone3Area.contains(getMyPlayer().getLocation()) || (stone3Area.contains(getMyPlayer().getLocation()) && getMyPlayer().getAnimation() == 1604))
return state.step4;
else if (stone2Area.contains(getMyPlayer().getLocation()) || (stone2Area.contains(getMyPlayer().getLocation()) && getMyPlayer().getAnimation() == 1604))
return state.step3;
else if (stone1Area.contains(getMyPlayer().getLocation()) || (stone1Area.contains(getMyPlayer().getLocation()) && getMyPlayer().getAnimation() == 1604))
return state.step2;
else if (WerewolfStartArea.contains(getMyPlayer().getLocation()))
return state.step1;
return state.step1;
}
public void onRepaint(Graphics graphics) {
try {
Graphics2D g = (Graphics2D) graphics;
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
Font f = new Font("Arial", Font.PLAIN, 12);
FontMetrics fm = g.getFontMetrics(f);
g.setFont(f);
g.setColor(new Color(0, 0, 0, 100));
double hours = (double) runTime.getElapsed() / 1000 / 60 / 60;
int gained = skills.getCurrentExp(Skills.AGILITY) - startingXp;
int level = skills.getRealLevel(Skills.AGILITY);
int laps = gained/580;
if (hours == 0.0)
return;
double perHour = (gained / hours);
String[][] msg = {
{"Time: ", runTime.toElapsedString()},
{"Agility: ", format(gained) + " xp"},
{"", format((int) perHour) + " xp/hr"},
{"Laps: ", format(laps)},
{"", format((int)(laps/hours))+" / hr"},
};
g.setColor(new Color(0, 0, 0, 60));
for (int i = 0; i < 5; i++) {
RoundRectangle2D box = new RoundRectangle2D.Double(20 + i * 1.5, 40 + i * 1.5, 150, 142, 10, 10);
g.fill(box);
}
g.drawImage(bg, 20, 40, null);
int y = 60;
if (getAgilityCourse == 1) {
String title = "Barbarian Adv Course";
int logoX = (150 - fm.stringWidth(title)) / 2 + 20;
g.setColor(Color.BLACK);
g.drawString(title, logoX + 1, y + 1);
g.setColor(new Color(255, 205, 0));
g.drawString(title, logoX, y);
} else if (getAgilityCourse == 2) {
String title = "Gnome Adv Course";
int logoX = (150 - fm.stringWidth(title)) / 2 + 20;
g.setColor(Color.BLACK);
g.drawString(title, logoX + 1, y + 1);
g.setColor(new Color(255, 205, 0));
g.drawString(title, logoX, y);
} else if (getAgilityCourse == 3) {
String title = "Ape Atoll Course";
int logoX = (150 - fm.stringWidth(title)) / 2 + 20;
g.setColor(Color.BLACK);
g.drawString(title, logoX + 1, y + 1);
g.setColor(new Color(255, 205, 0));
g.drawString(title, logoX, y);
} else {
String title = "";
int logoX = (150 - fm.stringWidth(title)) / 2 + 20;
g.setColor(Color.BLACK);
g.drawString(title, logoX + 1, y + 1);
g.setColor(new Color(255, 205, 0));
g.drawString(title, logoX, y);
}
f = new Font("Verdana", Font.PLAIN, 11);
fm = g.getFontMetrics(f);
g.setFont(f);
int longest = -1;
for (String[] s : msg)
if (fm.stringWidth(s[0]) > longest)
longest = fm.stringWidth(s[0]);
y += 3;
for (String[] s : msg) {
y += 15;
g.setColor(Color.BLACK);
g.drawString(s[0], 31, y + 1);
g.setColor(new Color(255, 205, 0));
g.drawString(s[0], 30, y);
g.setColor(new Color(0, 0, 0, 90));
RoundRectangle2D box = new RoundRectangle2D.Double(30 + longest, y - 10, fm.stringWidth(s[1]) + 9, 13, 5, 5);
g.fill(box);
g.setColor(Color.BLACK);
g.drawString(s[1], 35 + longest, y + 1);
g.setColor(new Color(255, 205, 0));
g.drawString(s[1], 34 + longest, y);
}
y += 12;
double perc = (double) skills.getPercentToNextLevel(Skills.AGILITY) / 100;
g.setColor(new Color(0, 0, 0, 120));
RoundRectangle2D box = new RoundRectangle2D.Double(33, y, 125, 15, 5, 5);
g.fill(box);
g.setColor(new Color(179, 126, 63));
box = new RoundRectangle2D.Double(35, y + 2, 121 * perc + 1, 9, 3, 3);
g.fill(box);
g.setColor(new Color(128, 80, 37));
box = new RoundRectangle2D.Double(36, y + 3, 121 * perc, 9, 3, 3);
g.fill(box);
if (perHour == 0)
return;
double time = skills.getExpToNextLevel(Skills.AGILITY) / perHour; //I should kill myself for this abomination in these this and the next line.
String timeLeft = (int) Math.floor(time) + ":" + String.format("%02d", (int) ((time * 60) % 60)) + " until " + (level + 1);
int timeLeftX = (125 - fm.stringWidth(timeLeft)) / 2 + 33;
g.setColor(new Color(119, 72, 33));
box = new RoundRectangle2D.Double(36, y + 3, 121 * perc, 9, 3, 3);
g.draw(box);
g.setColor(new Color(0, 0, 0));
g.drawString(timeLeft, timeLeftX + 1, y + 13);
g.setColor(new Color(255, 205, 0));
g.drawString(timeLeft, timeLeftX, y + 12);
mouse(graphics);
} catch (Exception e) {
e.printStackTrace();
}
}
public void onServerMessage(String s) {
}
public void build() {
if (getAgilityCourse == 1) {
RopeSwing = new Obstacle() {
@Override
boolean isCurrent() {
return (RopeSwingArea1.contains(getMyPlayer().getLocation())
|| RopeSwingArea2.contains(getMyPlayer().getLocation())
|| RopeSwingArea3.contains(getMyPlayer().getLocation())) && getMyPlayer().getAnimation() == -1;
}
@Override
String actionName() {
return "Swing-on Rope swing";
}
@Override
RSObject get() {
return objects.getNearest(43526);
}
@Override
RSTile walkTile() {
return new RSTile(2551, 3554);
}
};
BarbarianAdvandedLogBalance = new Obstacle() {
@Override
boolean isCurrent() {
return (BarbarianAdvandedLogBalanceArea1.contains(getMyPlayer().getLocation()) || BarbarianAdvandedLogBalanceArea2.contains(getMyPlayer().getLocation()));
}
@Override
String actionName() {
return "Walk-across Log balance";
}
@Override
RSObject get() {
return objects.getNearest(43595);
}
};
Wall1 = new Obstacle() {
@Override
boolean isCurrent() {
return WallArea1.contains(getMyPlayer().getLocation()) && getMyPlayer().getAnimation() == -1;
}
@Override
String actionName() {
return "Run-up Wall";
}
@Override
RSObject get() {
return objects.getNearest(43533);
}
};
Wall2 = new Obstacle() {
@Override
boolean isCurrent() {
return WallArea2.contains(getMyPlayer().getLocation());
}
@Override
String actionName() {
return "Climb-up Wall";
}
@Override
RSObject get() {
return objects.getNearest(43597);
}
};
SpringDevice = new Obstacle() {
@Override
boolean isCurrent() {
return SpringDeviceArea.contains(getMyPlayer().getLocation());
}
@Override
String actionName() {
return "Fire Spring device";
}
@Override
RSObject get() {
return objects.getNearest(43587);
}
};
BalanceBeam = new Obstacle() {
@Override
boolean isCurrent() {
return BalanceBeamArea.contains(getMyPlayer().getLocation());
}
@Override
String actionName() {
return "Cross Balance beam";
}
@Override
RSObject get() {
return objects.getNearest(43527);
}
};
Gap = new Obstacle() {
@Override
boolean isCurrent() {
return GapArea.contains(getMyPlayer().getLocation()) && getMyPlayer().getAnimation() == -1;
}
@Override
String actionName() {
return "Jump-over Gap";
}
@Override
RSObject get() {
return objects.getNearest(43531);
}
};
Roof = new Obstacle() {
@Override
boolean isCurrent() {
return RoofArea.contains(getMyPlayer().getLocation());
}
@Override
String actionName() {
return "Slide-down Roof";
}
@Override
RSObject get() {
return objects.getNearest(43532);
}
};
course = new Obstacle[] { RopeSwing, BarbarianAdvandedLogBalance, Wall1, Wall2, SpringDevice, BalanceBeam, Gap, Roof };
} else if (getAgilityCourse == 2) {
GnomeAdvandedLogBalance = new Obstacle() {
@Override
boolean isCurrent() {
return GnomeAdvandedLogBalanceArea.contains(getMyPlayer().getLocation());
}
@Override
String actionName() {
return "Walk-across Log balance";
}
@Override
RSObject get() {
return objects.getNearest(2295);
}
@Override
RSTile walkTile() {
return new RSTile(2474, 3436);
}
};
ObstacleNet = new Obstacle() {
@Override
boolean isCurrent() {
return ObstacleNetArea.contains(getMyPlayer().getLocation());
}
@Override
String actionName() {
return "Climb-over Obstacle net";
}
@Override
RSObject get() {
return objects.getNearest(2285);
}
};
TreeBranch = new Obstacle() {
@Override
boolean isCurrent() {
return TreeBranchArea.contains(getMyPlayer().getLocation());
}
@Override
String actionName() {
return "Climb Tree branch";
}
@Override
RSObject get() {
return objects.getNearest(35970);
}
};
Tree = new Obstacle() {
@Override
boolean isCurrent() {
return TreeArea.contains(getMyPlayer().getLocation());
}
@Override
String actionName() {
return "Climb-up Tree";
}
@Override
RSObject get() {
return objects.getNearest(43528);
}
};
Signpost = new Obstacle() {
@Override
boolean isCurrent() {
return SignpostArea.contains(getMyPlayer().getLocation());
}
@Override
String actionName() {
return "Run-across Signpost";
}
@Override
RSObject get() {
return objects.getNearest(43581);
}
};
Pole = new Obstacle() {
@Override
boolean isCurrent() {
return PoleArea.contains(getMyPlayer().getLocation());
}
@Override
String actionName() {
return "Swing-to Polo";
}
@Override
RSObject get() {
return objects.getNearest(43529);
}
};
Barrier = new Obstacle() {
@Override
boolean isCurrent() {
return BarrierArea.contains(getMyPlayer().getLocation());
}
@Override
String actionName() {
return "Jump-over Barrier";
}
@Override
RSObject get() {
return objects.getNearest(43540);
}
};
course = new Obstacle[] { GnomeAdvandedLogBalance, ObstacleNet, TreeBranch, Tree, Signpost, Pole, Barrier };
} else if (getAgilityCourse == 3) {
Pause = new Obstacle() {
@Override
boolean isCurrent() {
return game.getPlane() == 0 && getMyPlayer().getLocation().equals(new RSTile(2754, 2742));
}
@Override
String actionName() {
return "Walking over step... PAUSE!";
}
@Override
RSObject get() {
return objects.getNearest(12570);
}
@Override
boolean overcome() {
return false;
}
};
ApeAtollTree = new Obstacle() {
@Override
boolean isCurrent() {
return TreeAreaAfterStep.contains(getMyPlayer().getLocation());
}
@Override
String actionName() {
return "Climb Tropical tree";
}
@Override
RSObject get() {
return objects.getNearest(12570);
}
};
ApeAtollBars = new Obstacle() {
@Override
boolean isCurrent() {
int x = getMyPlayer().getLocation().getX();
int y = getMyPlayer().getLocation().getY();
return game.getPlane() == 2 && x <= 2754 && y <= 2742 && x >= 2752 && y >= 2741;
}
@Override
String actionName() {
return "Swing Across Monkeybars";
}
@Override
RSObject get() {
return objects.getNearest(12573);
}
};
ApeAtollSlope = new Obstacle() {
@Override
boolean isCurrent() {
int x = getMyPlayer().getLocation().getX();
int y = getMyPlayer().getLocation().getY();
RSTile dest = walking.getDestination();
return y==2741 && x<=2748 && (x>=2746 || (getMyPlayer().isMoving() && x>=2744));
}
@Override
String actionName() {
return "Climb-up Skull slope";
}
@Override
RSObject get() {
RSObject[] o = objects.getAt(new RSTile(2746, 2741), 2);
if (o.length > 0)
return o[0];
return null;
}
};
ApeAtollSwing = new Obstacle() {
@Override
boolean isCurrent() {
return getMyPlayer().getLocation().getX() <= 2752;
}
@Override
String actionName() {
return "Swing Rope";
}
@Override
RSObject get() {
return objects.getNearest(12578); // objects.getTopAt(new RSTile(2752,2731));
}
@Override
RSTile walkTile() {
return new RSTile(2751,2731);
}
};
ApeAtollRope = new Obstacle() {
@Override
boolean isCurrent() {
return getMyPlayer().getLocation().getY() <= 2737;
}
@Override
String actionName() {
return "Climb-down Tropical tree";
}
@Override
RSObject get() {
return objects.getNearest(12618);
}
};
ApeAtollStep = new Obstacle() {
@Override
boolean isCurrent() {
return ApeAtollStartArea.contains(getMyPlayer().getLocation());
}
@Override
String actionName() {
return "Jump-to Stepping stone";
}
@Override
RSObject get() {
RSObject[] o = objects.getAt(new RSTile(2754, 2742), 2);
RSObject stone = null;
if (o.length > 0)
stone = o[0];
return stone;
}
@Override
RSTile walkTile() {
return new RSTile(2755,2742);
}
};
course = new Obstacle[] { Pause, ApeAtollTree, ApeAtollBars, ApeAtollSlope, ApeAtollSwing, ApeAtollRope, ApeAtollStep };
}
}
@Override
public int loop() {
mouse.setSpeed(random(6, 8));
if (camera.getPitch() < 3000)
camera.setPitch(true);
while (interfaces.get(906).containsText("Logging")) {
sleep(6000, 6200);
}
if (getAgilityCourse == 1) {
while (RopeSwingWaitingArea.contains(getMyPlayer().getLocation()) && getMyPlayer().isMoving()) {
sleep(random(2400, 2500));
}
while (RopeSwingArea1.contains(getMyPlayer().getLocation()) && getMyPlayer().getAnimation() == 2588) {
// moveToScreenTile(new RSTile(2551, 3554));
clickObject(objects.getNearest(43526), "Swing-on Rope swing");
sleep(random(200, 450));
}
while (RoofSlidingArea.contains(getMyPlayer().getLocation())
&& getMyPlayer().getAnimation() == 11791
&& game.getPlane() == 1) {
// moveToScreenTile(new RSTile(2550, 3554, 1));
mouse.click(true);
sleep(random(200, 450));
}
while (BarbarianAdvandedLogBalanceClickingArea.contains(getMyPlayer().getLocation()) || getMyPlayer().getAnimation() == 751) {
clickObject(objects.getNearest(43595), "Walk-across Log balance");
sleep(random(200, 450));
}
while (WallClickingArea1.contains(getMyPlayer().getLocation())) {
mouse.setSpeed(random(6, 7));
clickObject(objects.getNearest(43533), "Run-up Wall");
sleep(random(200, 300));
}
/*
while (getMyPlayer().getAnimation() == 10493) {
objects.getNearest(43597).interact("Climb-up Wall");
sleep(random(200, 450));
}
*/
while (BalanceBeamArea.contains(getMyPlayer().getLocation())
&& (getMyPlayer().getAnimation() == 4189
|| getMyPlayer().getAnimation() == 10477
|| getMyPlayer().getAnimation() == 10478
|| getMyPlayer().getAnimation() == 10482)) {
clickObject(objects.getNearest(43527), "Cross Balance beam");
sleep(random(200, 450));
}
while (RoofArea.contains(getMyPlayer().getLocation()) && getMyPlayer().getAnimation() == 2588) {
moveToScreenTile(new RSTile(2540, 3553));
sleep(random(200, 450));
}
if (!failsafeTimer.isRunning())
return -1;
if (!game.isLoggedIn() || game.isWelcomeScreen())
return random(50, 100);
if (startingXp == 0) {
startingXp = skills.getCurrentExp(Skills.AGILITY);
startingLevel = skills.getRealLevel(Skills.AGILITY);
}
xp = skills.getCurrentExp(Skills.AGILITY);
level = skills.getRealLevel(Skills.AGILITY);
perc = skills.getPercentToNextLevel(Skills.AGILITY);
while (RopeSwingWaitingArea.contains(getMyPlayer().getLocation()) && getMyPlayer().isMoving()) {
sleep(random(2400, 2500));
}
while (RopeSwingArea1.contains(getMyPlayer().getLocation()) && getMyPlayer().getAnimation() == 2588) {
// moveToScreenTile(new RSTile(2551, 3554));
clickObject(objects.getNearest(43526), "Swing-on Rope swing");
sleep(random(200, 450));
}
while (RoofSlidingArea.contains(getMyPlayer().getLocation())
&& getMyPlayer().getAnimation() == 11791
&& game.getPlane() == 1) {
// moveToScreenTile(new RSTile(2550, 3554, 1));
mouse.click(true);
sleep(random(200, 450));
}
while (BarbarianAdvandedLogBalanceClickingArea.contains(getMyPlayer().getLocation()) || getMyPlayer().getAnimation() == 751) {
clickObject(objects.getNearest(43595), "Walk-across Log balance");
sleep(random(200, 450));
}
while (WallClickingArea1.contains(getMyPlayer().getLocation())) {
mouse.setSpeed(random(6, 7));
clickObject(objects.getNearest(43533), "Run-up Wall");
sleep(random(200, 300));
}
/*
while (getMyPlayer().getAnimation() == 10493) {
objects.getNearest(43597).interact("Climb-up Wall");
sleep(random(200, 450));
}
*/
while (BalanceBeamArea.contains(getMyPlayer().getLocation())
&& (getMyPlayer().getAnimation() == 4189
|| getMyPlayer().getAnimation() == 10477
|| getMyPlayer().getAnimation() == 10478
|| getMyPlayer().getAnimation() == 10482)) {
clickObject(objects.getNearest(43527), "Cross Balance beam");
sleep(random(200, 450));
}
while (RoofArea.contains(getMyPlayer().getLocation()) && getMyPlayer().getAnimation() == 2588) {
moveToScreenTile(new RSTile(2540, 3553));
sleep(random(200, 450));
}
try {
while (RopeSwingWaitingArea.contains(getMyPlayer().getLocation()) && getMyPlayer().isMoving()) {
sleep(random(2400, 2500));
}
while (RopeSwingArea1.contains(getMyPlayer().getLocation()) && getMyPlayer().getAnimation() == 2588) {
// moveToScreenTile(new RSTile(2551, 3554));
clickObject(objects.getNearest(43526), "Swing-on Rope swing");
sleep(random(200, 450));
}
while (RoofSlidingArea.contains(getMyPlayer().getLocation())
&& getMyPlayer().getAnimation() == 11791
&& game.getPlane() == 1) {
// moveToScreenTile(new RSTile(2550, 3554, 1));
mouse.click(true);
sleep(random(200, 450));
}
while (BarbarianAdvandedLogBalanceClickingArea.contains(getMyPlayer().getLocation()) || getMyPlayer().getAnimation() == 751) {
clickObject(objects.getNearest(43595), "Walk-across Log balance");
sleep(random(200, 450));
}
while (WallClickingArea1.contains(getMyPlayer().getLocation())) {
mouse.setSpeed(random(6, 7));
clickObject(objects.getNearest(43533), "Run-up Wall");
sleep(random(200, 300));
}
/*
while (getMyPlayer().getAnimation() == 10493) {
objects.getNearest(43597).interact("Climb-up Wall");
sleep(random(200, 450));
}
*/
while (BalanceBeamArea.contains(getMyPlayer().getLocation())
&& (getMyPlayer().getAnimation() == 4189
|| getMyPlayer().getAnimation() == 10477
|| getMyPlayer().getAnimation() == 10478
|| getMyPlayer().getAnimation() == 10482)) {
clickObject(objects.getNearest(43527), "Cross Balance beam");
sleep(random(200, 450));
}
while (RoofArea.contains(getMyPlayer().getLocation()) && getMyPlayer().getAnimation() == 2588) {
moveToScreenTile(new RSTile(2540, 3553));
sleep(random(200, 450));
}
if (changeStateTimer != null && !(getMyPlayer().getAnimation() == -1
|| getMyPlayer().getAnimation() == 751
|| getMyPlayer().getAnimation() == 10493
|| getMyPlayer().getAnimation() == 10477
|| getMyPlayer().getAnimation() == 10478
|| getMyPlayer().getAnimation() == 10482
|| getMyPlayer().getAnimation() == 10295
|| getMyPlayer().getAnimation() == 2588
|| getMyPlayer().getAnimation() == 2586
|| getMyPlayer().getAnimation() == 11794
|| getMyPlayer().getAnimation() == 9908
|| getMyPlayer().getAnimation() == 11790
|| getMyPlayer().getAnimation() == 11791
|| getMyPlayer().getAnimation() == 11792))
changeStateTimer = new Timer(3000);
if (getLifePoints() < EatAt && getMyPlayer().getAnimation() == -1) {
RSItem food = edible();
if (food == null) {
sleep(random(300, 400));
if (food == null) {
sleep(random(300, 400));
if (food == null) {
sleep(random(300, 400));
if (food == null) {
sleep(random(300, 400));
if (food == null) {
sleep(random(300, 400));
if (food == null) {
sleep(random(300, 400));
if (food == null) {
sleep(random(300, 400));
if (food == null) {
sleep(random(300, 400));
if (food == null) {
sleep(random(300, 400));
if (food == null) {
log("No More Food.");
game.logout(true);
return -1;
}
}
}
}
}
}
}
}
}
} else {
food.interact("Eat ");
}
}
if (changeStateTimer == null) {
if (!(getMyPlayer().getAnimation() == -1
|| getMyPlayer().getAnimation() == 751
|| getMyPlayer().getAnimation() == 10493
|| getMyPlayer().getAnimation() == 10477
|| getMyPlayer().getAnimation() == 10478
|| getMyPlayer().getAnimation() == 10482
|| getMyPlayer().getAnimation() == 10295
|| getMyPlayer().getAnimation() == 2588
|| getMyPlayer().getAnimation() == 2586
|| getMyPlayer().getAnimation() == 11794
|| getMyPlayer().getAnimation() == 9908
|| getMyPlayer().getAnimation() == 11790
|| getMyPlayer().getAnimation() == 11791
|| getMyPlayer().getAnimation() == 11792))
return random(50, 100);
}
if (changeStateTimer != null) {
int current = -1;
for (int i = 0; i < course.length; i++) {
if (course[i].isCurrent()) {
current = i;
break;
}
}
if (current != last || !changeStateTimer.isRunning()) {
changeStateTimer = null;
last = current;
}
}
if (changeStateTimer != null) {
debug = "busy";
return random(50, 100);
}
for (int i = 0; i < course.length; i++) {
if (course[i].isCurrent()) {
while (RopeSwingWaitingArea.contains(getMyPlayer().getLocation()) && getMyPlayer().isMoving()) {
sleep(random(2400, 2500));
}
while (RopeSwingArea1.contains(getMyPlayer().getLocation()) && getMyPlayer().getAnimation() == 2588) {
// moveToScreenTile(new RSTile(2551, 3554));
clickObject(objects.getNearest(43526), "Swing-on Rope swing");
sleep(random(200, 450));
}
while (RoofSlidingArea.contains(getMyPlayer().getLocation())
&& getMyPlayer().getAnimation() == 11791
&& game.getPlane() == 1) {
// moveToScreenTile(new RSTile(2550, 3554, 1));
mouse.click(true);
sleep(random(200, 450));
}
while (BarbarianAdvandedLogBalanceClickingArea.contains(getMyPlayer().getLocation()) || getMyPlayer().getAnimation() == 751) {
clickObject(objects.getNearest(43595), "Walk-across Log balance");
sleep(random(200, 450));
}
while (WallClickingArea1.contains(getMyPlayer().getLocation())) {
mouse.setSpeed(random(6, 7));
clickObject(objects.getNearest(43533), "Run-up Wall");
sleep(random(200, 300));
}
/*
while (getMyPlayer().getAnimation() == 10493) {
objects.getNearest(43597).interact("Climb-up Wall");
sleep(random(200, 450));
}
*/
while (BalanceBeamArea.contains(getMyPlayer().getLocation())
&& (getMyPlayer().getAnimation() == 4189
|| getMyPlayer().getAnimation() == 10477
|| getMyPlayer().getAnimation() == 10478
|| getMyPlayer().getAnimation() == 10482)) {
clickObject(objects.getNearest(43527), "Cross Balance beam");
sleep(random(200, 450));
}
while (RoofArea.contains(getMyPlayer().getLocation()) && getMyPlayer().getAnimation() == 2588) {
moveToScreenTile(new RSTile(2540, 3553));
sleep(random(200, 450));
}
last = i;
debug = course[i].actionName();
if (i == 3) {
mouse.setSpeed(random(6, 7));
moveToScreenTile(new RSTile(2537, 3546));
sleep(random(200, 300));
moveToScreenTile(new RSTile(2537, 3546));
sleep(random(200, 300));
moveToScreenTile(new RSTile(2537, 3546));
sleep(random(200, 300));
if (course[i].overcome()) {
camera.setAngle(34);
mouse.move(175 + random(7, -7), 88 + random(7, -7));
failsafeTimer = new Timer(120000);
changeStateTimer = new Timer(3000);
return random(600, 1200);
}
} else if (i == 4) {
moveToScreenTile(new RSTile(2533, 3547));
sleep(random(200, 450));
moveToScreenTile(new RSTile(2533, 3547));
sleep(random(200, 450));
if (course[i].overcome()) {
camera.setAngle(316);
mouse.move(277 + random(7, -7), 159 + random(7, -7));
while (BalanceBeamArea.contains(getMyPlayer().getLocation())
&& (getMyPlayer().getAnimation() == 4189
|| getMyPlayer().getAnimation() == 10477
|| getMyPlayer().getAnimation() == 10478
|| getMyPlayer().getAnimation() == 10482)) {
objects.getNearest(43527).interact("Cross Balance beam");
sleep(random(200, 450));
}
failsafeTimer = new Timer(120000);
changeStateTimer = new Timer(3000);
return random(600, 1200);
}
} else if (i == 6) {
if (moveToScreenTile(new RSTile(2537, 3553))) {
camera.setAngle(316);
failsafeTimer = new Timer(120000);
changeStateTimer = new Timer(3000);
return random(600, 1200);
}
} else if (i == 7) {
mouse.setSpeed(random(6, 7));
if (moveToScreenTile(new RSTile(2540, 3553))) {
camera.setAngle(213);
while (RopeSwingArea1.contains(getMyPlayer().getLocation()) && getMyPlayer().getAnimation() == 2588) {
// moveToScreenTile(new RSTile(2551, 3554));
clickObject(objects.getNearest(43526), "Swing-on Rope swing");
sleep(random(200, 450));
}
while (RoofSlidingArea.contains(getMyPlayer().getLocation())
&& getMyPlayer().getAnimation() == 11791
&& game.getPlane() == 1) {
// moveToScreenTile(new RSTile(2550, 3554, 1));
mouse.click(true);
sleep(random(200, 450));
}
mouse.move(29 + random(7, -7), 62 + random(7, -7));
failsafeTimer = new Timer(120000);
changeStateTimer = new Timer(3000);
return random(600, 1200);
}
} else {
if (course[i].overcome()) {
if (i == 0) {
camera.setAngle(232);
mouse.move(471 + random(7, -7), 58 + random(7, -7));
while (RopeSwingWaitingArea.contains(getMyPlayer().getLocation()) && getMyPlayer().isMoving()) {
sleep(random(2400, 2500));
}
while (BarbarianAdvandedLogBalanceClickingArea.contains(getMyPlayer().getLocation()) || getMyPlayer().getAnimation() == 751) {
clickObject(objects.getNearest(43595), "Walk-across Log balance");
sleep(random(200, 450));
}
} else if (i == 1) {
camera.setAngle(199);
mouse.move(501 + random(7, -7), 83 + random(7, -7));
while (WallClickingArea1.contains(getMyPlayer().getLocation())) {
mouse.setSpeed(random(6, 7));
clickObject(objects.getNearest(43533), "Run-up Wall");
sleep(random(200, 300));
}
} else if (i == 2) {
camera.setAngle(34);
mouse.move(244 + random(7, -7), 102 + random(7, -7));
while (getMyPlayer().getAnimation() == 10493) {
clickObject(objects.getNearest(43597), "Climb-up Wall");
sleep(random(200, 450));
}
} else if (i == 5) {
sleep(random(100, 200));
if (course[i].overcome()) {
camera.setAngle(316);
moveToScreenTile(new RSTile(2537, 3553));
sleep(random(200, 450));
moveToScreenTile(new RSTile(2537, 3553));
sleep(random(200, 450));
while (RoofArea.contains(getMyPlayer().getLocation()) && getMyPlayer().getAnimation() == 2588) {
moveToScreenTile(new RSTile(2540, 3553));
sleep(random(200, 450));
}
}
}
failsafeTimer = new Timer(120000);
changeStateTimer = new Timer(3000);
return random(600, 1200);
} else {
sleep(random(100, 250));
if (!course[i].overcome()) {
sleep(random(100, 250));
if (!course[i].overcome()) {
sleep(random(100, 250));
if (!course[i].overcome()) {
course[i].overcome();
}
}
}
}
}
RSObject obs = course[i].get();
if (obs == null || obs.isOnScreen()){
return random(50, 100);
}
if (i == 0) {
if (!obs.isOnScreen()) {
if (moveToScreenTile(course[i].walkTile())) {
sleep(random(300, 550));
while (!getMyPlayer().isMoving()) {
moveToScreenTile(course[i].walkTile());
sleep(random(300, 550));
}
} else {
if (walking.walkTileMM(course[i].walkTile())) {
sleep(random(300, 550));
while (!getMyPlayer().isMoving()) {
walking.walkTileMM(course[i].walkTile());
sleep(random(300, 550));
}
}
}
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return random(50, 100);
} else if (getAgilityCourse == 2) {
while (ObstacleNetClickingArea.contains(getMyPlayer().getLocation()) && getMyPlayer().isMoving()) {
// objects.getNearest(2285).interact("Climb-over");
clickObject(objects.getNearest(2285), "Climb-over");
sleep(random(200, 450));
}
if (!failsafeTimer.isRunning())
return -1;
if (!game.isLoggedIn() || game.isWelcomeScreen())
return random(50, 100);
if (startingXp == 0) {
startingXp = skills.getCurrentExp(Skills.AGILITY);
startingLevel = skills.getRealLevel(Skills.AGILITY);
}
xp = skills.getCurrentExp(Skills.AGILITY);
level = skills.getRealLevel(Skills.AGILITY);
perc = skills.getPercentToNextLevel(Skills.AGILITY);
while (ObstacleNetClickingArea.contains(getMyPlayer().getLocation()) && getMyPlayer().isMoving()) {
// objects.getNearest(2285).interact("Climb-over");
clickObject(objects.getNearest(2285), "Climb-over");
sleep(random(200, 450));
}
try {
while (ObstacleNetClickingArea.contains(getMyPlayer().getLocation()) && getMyPlayer().isMoving()) {
// objects.getNearest(2285).interact("Climb-over");
clickObject(objects.getNearest(2285), "Climb-over");
sleep(random(200, 450));
}
if (changeStateTimer != null && !(getMyPlayer().getAnimation() == -1
|| getMyPlayer().getAnimation() == 9908
|| getMyPlayer().getAnimation() == 2922
// || getMyPlayer().getAnimation() == 10477
// || getMyPlayer().getAnimation() == 10478
// || getMyPlayer().getAnimation() == 10482
|| getMyPlayer().getAnimation() == 11789))
changeStateTimer = new Timer(3000);
if (getLifePoints() < EatAt && getMyPlayer().getAnimation() == -1) {
RSItem food = edible();
if (food == null) {
sleep(random(300, 400));
if (food == null) {
sleep(random(300, 400));
if (food == null) {
sleep(random(300, 400));
if (food == null) {
sleep(random(300, 400));
if (food == null) {
sleep(random(300, 400));
if (food == null) {
sleep(random(300, 400));
if (food == null) {
sleep(random(300, 400));
if (food == null) {
sleep(random(300, 400));
if (food == null) {
sleep(random(300, 400));
if (food == null) {
log("No More Food.");
game.logout(true);
return -1;
}
}
}
}
}
}
}
}
}
} else {
food.interact("Eat ");
}
}
if (changeStateTimer == null) {
if (!(getMyPlayer().getAnimation() == -1
|| getMyPlayer().getAnimation() == 9908
|| getMyPlayer().getAnimation() == 2922
// || getMyPlayer().getAnimation() == 10477
// || getMyPlayer().getAnimation() == 10478
// || getMyPlayer().getAnimation() == 10482
|| getMyPlayer().getAnimation() == 11789))
return random(50, 100);
}
if (changeStateTimer != null) {
int current = -1;
for (int i = 0; i < course.length; i++) {
if (course[i].isCurrent()) {
current = i;
break;
}
}
if (current != last || !changeStateTimer.isRunning()) {
changeStateTimer = null;
last = current;
}
}
if (changeStateTimer != null) {
debug = "busy";
return random(50, 100);
}
for (int i = 0; i < course.length; i++) {
if (course[i].isCurrent()) {
while (ObstacleNetClickingArea.contains(getMyPlayer().getLocation()) && getMyPlayer().isMoving()) {
// objects.getNearest(2285).interact("Climb-over");
clickObject(objects.getNearest(2285), "Climb-over");
sleep(random(200, 450));
}
last = i;
debug = course[i].actionName();
if (i == 5) {
mouse.setSpeed(random(6, 7));
moveToScreenTileForGnome(new RSTile(2486, 3418));
if (objects.getNearest(43529).interact("Swing-to Pole")) { // <----Pole
camera.setAngle(302);
mouse.move(226 + random(-7, 7), 157 + random(-7, 7));
failsafeTimer = new Timer(120000);
changeStateTimer = new Timer(3000);
return random(600, 1200);
}
} else if (i == 6) {
if (moveToScreenTile(new RSTile(2485, 3433))) {
sleep(200, 300);
if (moveToScreenTile(new RSTile(2485, 3433))) {
sleep(200, 300);
if (moveToScreenTile(new RSTile(2485, 3433))) {
sleep(200, 300);
if (!atTile(new RSTile(2485, 3434), 0, 0.5, 0.2, "Jump-over")) {
camera.setAngle(302);
if (!atTile(new RSTile(2485, 3434), 0, 0.5, 0.2, "Jump-over")) {
camera.setAngle(302);
if (!atTile(new RSTile(2485, 3434), 0, 0.5, 0.2, "Jump-over")) {
camera.setAngle(302);
if (!atTile(new RSTile(2485, 3434), 0, 0.5, 0.2, "Jump-over")) {
camera.setAngle(302);
if (!atTile(new RSTile(2485, 3434), 0, 0.5, 0.2, "Jump-over")) {
camera.setAngle(302);
}
}
}
}
}
}
}
}
camera.setAngle(153);
failsafeTimer = new Timer(120000);
changeStateTimer = new Timer(3000);
return random(600, 1200);
} else {
if (course[i].overcome()) {
if (i == 0) {
camera.setAngle(235);
while (ObstacleNetClickingArea.contains(getMyPlayer().getLocation()) && getMyPlayer().isMoving()) {
objects.getNearest(2285).interact("Climb-over");
sleep(random(200, 450));
}
} else if (i == 1) {
camera.setAngle(235);
mouse.move(337 + random(-7, 7), 126 + random(-7, 7));
// mouse.move(275 + random(-7, 7), 106 + random(-7, 7));
} else if (i == 2) {
camera.setAngle(235);
mouse.move(351 + random(-7, 7), 146 + random(-7, 7));
// mouse.move(302 + random(-7, 7), 85 + random(-7, 7));
} else if (i == 3) {
camera.setAngle(191);
mouse.move(79 + random(7, -7), 26 + random(7, -7));
} else if (i == 4) {
camera.setAngle(302);
mouse.move(346 + random(7, -7), 50 + random(7, -7));
// mouse.move(40 + random(7, -7), 31 + random(7, -7));
}
failsafeTimer = new Timer(120000);
changeStateTimer = new Timer(3000);
return random(600, 1200);
}
}
RSObject obs = course[i].get();
if (obs == null || obs.isOnScreen()){
return random(50, 100);
}
if (i == 0) {
if (!obs.isOnScreen()) {
if (walking.walkTileMM(course[i].walkTile())) {
sleep(random(300, 550));
while (!getMyPlayer().isMoving()) {
walking.walkTileMM(course[i].walkTile());
sleep(random(300, 550));
}
}
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return random(50, 100);
} else if (getAgilityCourse == 3) {
while (getMyPlayer().getLocation().getY() < 2732 && getMyPlayer().isMoving()) {
mouse.setSpeed(random(7, 8));
moveToScreenTile(new RSTile(2757, 2734));
sleep(random(100, 300));
}
while (getMyPlayer().getAnimation() == 3481 && getMyPlayer().getLocation().getX() < 2755) {
moveToScreenTile(new RSTile(2752, 2741));
sleep(random(200, 450));
}
if (!failsafeTimer.isRunning())
return -1;
if (!game.isLoggedIn() || game.isWelcomeScreen())
return random(50, 100);
if (startingXp == 0) {
startingXp = skills.getCurrentExp(Skills.AGILITY);
startingLevel = skills.getRealLevel(Skills.AGILITY);
}
xp = skills.getCurrentExp(Skills.AGILITY);
level = skills.getRealLevel(Skills.AGILITY);
perc = skills.getPercentToNextLevel(Skills.AGILITY);
while (getMyPlayer().getLocation().getY() < 2732 && getMyPlayer().isMoving()) {
mouse.setSpeed(random(7, 8));
moveToScreenTile(new RSTile(2757, 2734));
sleep(random(100, 300));
}
while (getMyPlayer().getAnimation() == 3481 && getMyPlayer().getLocation().getX() < 2755) {
moveToScreenTile(new RSTile(2752, 2741));
sleep(random(200, 450));
}
try {
game.openTab(Game.TAB_INVENTORY);
RSItem greegree = getItem("Monkey greegree");
while (getMyPlayer().getLocation().getY() < 2732 && getMyPlayer().isMoving()) {
mouse.setSpeed(random(7, 8));
moveToScreenTile(new RSTile(2757, 2734));
sleep(random(100, 300));
}
while (getMyPlayer().getAnimation() == 3481 && getMyPlayer().getLocation().getX() < 2755) {
moveToScreenTile(new RSTile(2752, 2741));
sleep(random(200, 450));
}
if (greegree != null)
greegree.interact("Use");
if (changeStateTimer != null && ((getMyPlayer().isMoving() && getMyPlayer().getLocation().getY() > 2737)
|| !(getMyPlayer().getAnimation() == -1
|| getMyPlayer().getAnimation() == 3481
|| getMyPlayer().getAnimation() == 3488
|| getMyPlayer().getAnimation() == 3484)))
changeStateTimer = new Timer(3000);
if (getLifePoints() < EatAt) {
RSItem food = edible();
if (food == null) {
sleep(random(300, 400));
if (food == null) {
sleep(random(300, 400));
if (food == null) {
sleep(random(300, 400));
if (food == null) {
sleep(random(300, 400));
if (food == null) {
sleep(random(300, 400));
if (food == null) {
sleep(random(300, 400));
if (food == null) {
sleep(random(300, 400));
if (food == null) {
sleep(random(300, 400));
if (food == null) {
sleep(random(300, 400));
if (food == null) {
log("No More Food.");
game.logout(true);
return -1;
}
}
}
}
}
}
}
}
}
} else {
food.interact("Eat ");
}
}
if (changeStateTimer == null) {
if (!(getMyPlayer().getAnimation() == -1
|| getMyPlayer().getAnimation() == 3481
|| getMyPlayer().getAnimation() == 3488
|| getMyPlayer().getAnimation() == 3484))
return random(50, 100);
if (getMyPlayer().isMoving()) {
RSTile dest = walking.getDestination();
RSObject a = course[last].get();
if (a==null || dest==null || calc.distanceBetween(dest,a.getLocation()) < 2)
if (course[last] == ApeAtollSlope)
return random(50, 100);
if (dest != null && calc.distanceTo(dest) > 5 && calc.distanceTo(dest) < 18)
return random(50, 100);
if (dest == null)
return random(50, 100);
}
}
if (changeStateTimer != null) {
int current = -1;
for (int i = 0; i < course.length; i++) {
if (course[i].isCurrent()) {
current = i;
break;
}
}
if (current != last || !changeStateTimer.isRunning()) {
changeStateTimer = null;
last = current;
}
}
if (changeStateTimer != null) {
debug = "busy";
return random(50, 100);
}
for (int i = 0; i < course.length; i++) {
if (course[i].isCurrent()) {
while (getMyPlayer().getLocation().getY() < 2732 && getMyPlayer().isMoving()) {
mouse.setSpeed(random(7, 8));
moveToScreenTile(new RSTile(2757, 2734));
sleep(random(100, 300));
}
while (getMyPlayer().getAnimation() == 3481 && getMyPlayer().getLocation().getX() < 2755) {
moveToScreenTile(new RSTile(2752, 2741));
sleep(random(200, 450));
}
last = i;
debug = course[i].actionName();
if (i == 1) {
if (moveToScreenTile(new RSTile(2752, 2741))) {
failsafeTimer = new Timer(120000);
changeStateTimer = new Timer(3000);
return random(600, 1200);
}
} else if (i == 5) {
mouse.setSpeed(random(7, 8));
if (moveToScreenTile(new RSTile(2757, 2734))) {
mouse.move(682 + random(7, -7), 101 + random(7, -7));
sleep(random(2000, 2300));
failsafeTimer = new Timer(120000);
changeStateTimer = new Timer(3000);
return random(600, 1200);
}
} else {
if (course[i].overcomeForApeAtoll()) {
if (i == 4) {
mouse.move(752+ random(0, 5), 38 + random(0, 7));
camera.setAngle(210);
while (getMyPlayer().getAnimation() == 3488 || (getMyPlayer().getLocation().getY() < 2732 && getMyPlayer().isMoving())) {
moveToScreenTile(new RSTile(2757, 2734));
sleep(random(100, 300));
}
} else if (i == 3) {
camera.setAngle(278);
}
failsafeTimer = new Timer(120000);
changeStateTimer = new Timer(3000);
return random(600, 1200);
}
}
while (getMyPlayer().getLocation().getY() < 2732 && getMyPlayer().isMoving()) {
mouse.setSpeed(random(7, 8));
moveToScreenTile(new RSTile(2757, 2734));
sleep(random(100, 300));
}
while (getMyPlayer().getAnimation() == 3481 && getMyPlayer().getLocation().getX() < 2755) {
moveToScreenTile(new RSTile(2752, 2741));
sleep(random(200, 450));
}
RSObject obs = course[i].get();
if (obs == null || obs.isOnScreen()){
return random(50, 100);
}
while (getMyPlayer().getLocation().getY() < 2732 && getMyPlayer().isMoving()) {
mouse.setSpeed(random(7, 8));
moveToScreenTile(new RSTile(2757, 2734));
sleep(random(100, 300));
}
while (getMyPlayer().getAnimation() == 3481 && getMyPlayer().getLocation().getX() < 2755) {
moveToScreenTile(new RSTile(2752, 2741));
sleep(random(200, 450));
}
RSTile t = obs.getLocation();
if (!obs.isOnScreen() && calc.distanceTo(t) < 5) {
if (i == 6) {
// pathToStep.traverse();
walkTo(new RSTile(2755, 2742));
} else {
// pathToSwing.traverse();
walkTo(new RSTile(2751, 2731));
}
camera.turnTo(obs);
}
while (getMyPlayer().getLocation().getY() < 2732 && getMyPlayer().isMoving()) {
mouse.setSpeed(random(7, 8));
moveToScreenTile(new RSTile(2757, 2734));
sleep(random(100, 300));
}
while (getMyPlayer().getAnimation() == 3481 && getMyPlayer().getLocation().getX() < 2755) {
moveToScreenTile(new RSTile(2752, 2741));
sleep(random(200, 450));
}
if (calc.distanceTo(t) >= 2 && !obs.isOnScreen()) {
if (i == 6) {
if (pathToStep.traverse()) {
//walkTo(new RSTile(2755, 2742));
sleep(random(130, 150));
mouse.click(true);
if (!obs.isOnScreen() && ApeAtollStartArea.contains(getMyPlayer().getLocation())) {
camera.turnTo(obs);
}
}
} else {
// pathToSwing.traverse();
walkTo(new RSTile(2751, 2731));
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return random(50, 100);
} else if (getAgilityCourse == 4) {
if (!game.isLoggedIn() || game.isWelcomeScreen())
return random(50, 100);
if (startingXp == 0) {
startingXp = skills.getCurrentExp(Skills.AGILITY);
startingLevel = skills.getRealLevel(Skills.AGILITY);
}
xp = skills.getCurrentExp(Skills.AGILITY);
level = skills.getRealLevel(Skills.AGILITY);
perc = skills.getPercentToNextLevel(Skills.AGILITY);
if (game.isLoggedIn()) {
camera.setAngle(45);
if (getMyPlayer().getAnimation() == 1602) {
antiBanForWerewolfCourse();
return random(250, 500);
}
if (!walking.isRunEnabled() && walking.getEnergy() > 45) {
walking.setRun(true);
}
switch (getState()) {
case eatFood:
if (getLifePoints() < EatAt) {
RSItem food = edible();
if (food == null) {
sleep(random(300, 400));
if (food == null) {
sleep(random(300, 400));
if (food == null) {
sleep(random(300, 400));
if (food == null) {
sleep(random(300, 400));
if (food == null) {
sleep(random(300, 400));
if (food == null) {
sleep(random(300, 400));
if (food == null) {
sleep(random(300, 400));
if (food == null) {
sleep(random(300, 400));
if (food == null) {
sleep(random(300, 400));
if (food == null) {
log("No More Food.");
game.logout(true);
return -1;
}
}
}
}
}
}
}
}
}
} else {
food.interact("Eat ");
}
}
return random(400, 500);
case step1:
stone = objects.getTopAt(stone1);
if (stone.isOnScreen())
moveToScreenTile(new RSTile(3538, 9875));
if (getMyPlayer().getAnimation() == 1604) {
return random(100, 150);
}
return random(550, 650);
case step2:
stone = objects.getTopAt(stone2);
if (stone.isOnScreen())
moveToScreenTile(new RSTile(3538, 9877));
if (getMyPlayer().getAnimation() == 1604) {
return random(100, 150);
}
return random(550, 650);
case step3:
stone = objects.getTopAt(stone3);
if (stone.isOnScreen())
moveToScreenTile(new RSTile(3540, 9877));
if (getMyPlayer().getAnimation() == 1604) {
return random(100, 150);
}
return random(550, 650);
case step4:
stone = objects.getTopAt(stone4);
if (stone.isOnScreen())
moveToScreenTile(new RSTile(3540, 9879));
if (getMyPlayer().getAnimation() == 1604) {
return random(100, 150);
}
return random(550, 650);
case step5:
stone = objects.getTopAt(stone5);
if (stone.isOnScreen())
moveToScreenTile(new RSTile(3540, 9881));
if (getMyPlayer().getAnimation() == 1604) {
return random(100, 150);
}
return random(600, 700);
case hurdles:
RSObject hurdleS = objects.getNearest(5133);
hurdle = hurdleS;
if (getMyPlayer().getLocation().getY() < hurdle1Y) {
if (hurdle != null) {
if (!hurdle.isOnScreen()) {
walking.walkTileMM(hurdleOne);
}
if (hurdle.isOnScreen()) {
moveToScreenTile(new RSTile(3541,9893));
if (getMyPlayer().getAnimation() == 1603) {
return random(100, 150);
}
return random(500, 600);
}
return random(750,1500);
}
}
if (getMyPlayer().getLocation().getY() < hurdle2Y) {
hurdle = objects.getTopAt(new RSTile(hurdleS.getLocation().getX(), hurdle2Y));
if (hurdle != null) {
moveToScreenTile(new RSTile(3541, 9896));
if (getMyPlayer().getAnimation() == 1603) {
return random(100, 150);
}
return random(600, 700);
}
}
if (getMyPlayer().getLocation().getY() < hurdle3Y) {
hurdle = objects.getTopAt(new RSTile(hurdleS.getLocation().getX(), hurdle3Y));
if (hurdle != null) {
moveToScreenTile(new RSTile(3541, 9899));
if (getMyPlayer().getAnimation() == 1603) {
return random(100, 150);
}
return random(1100,1200);
}
}
hurdle = null;
case pipes:
RSObject pipez = objects.getNearest(pipe);
if (pipez != null) {
if (pipez.isOnScreen()) {
moveToScreenTile(new RSTile(3541, 9905));
} else {
mouse.click(calc.tileToScreen(pipez.getLocation()), random(45,50), 5, true, 10);
}
}
return random(750,1500);
case stickNSlope:
RSGroundItem stickz = groundItems.getNearest(stick);
RSObject slope = objects.getTopAt(new RSTile(3532, 9910));
if (stickz != null) {
if (stickz.isOnScreen()) {
stickz.interact("Take");
} else {
walking.walkTileMM(stickz.getLocation());
}
} else if (slope != null) {
if (!slope.isOnScreen()) {
walking.walkTileMM(slope.getLocation());
}
if (slope.isOnScreen()) {
slope.interact("");
return random(400, 500);
}
}
return random(750,1000);
case slide:
RSObject deathSlide = objects.getNearest(5139);
if (deathSlide != null) {
doActionForWerewolfCourse(deathSlide, "Teeth-grip Zip line");
}
return random(200, 400);
case end:
RSNPC stickMasta = npcs.getNearest(stickNPC);
if (stickMasta != null) {
if (stickMasta.isOnScreen()) {
if (inventory.contains(stick)) {
stickMasta.interact("");
return random(400,500);
} else {
walking.walkTileMM(new RSTile(3539, 9871));
}
} else {
walking.walkTileMM(stickMasta.getLocation());
}
}
return random(750,1500);
case fallen:
if (calc.distanceTo(new RSTile(3528, 9866)) > 3)
// pathToWerewolfStartArea.traverse();
walkTo(new RSTile(3528, 9866));
return random(100, 200);
case error:
return -1;
}
}
}
return random(50, 100);
}
@Override
public boolean onStart() {
if (!game.isLoggedIn()) {
try {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
JOptionPane.showMessageDialog(null, "Please start the script after you have logged in.");
}
});
} catch (Throwable e) {
}
log.severe("Please start the script after you have logged in.");
return false;
}
runTime = new Timer(Integer.MAX_VALUE);
try {
final URL cursor100URL = new URL(
"http://i.imgur.com/89bk8.png");
final URL cursor80URL = new URL(
"http://i.imgur.com/RBp3d.png");
final URL cursor60URL = new URL(
"http://i.imgur.com/0w89C.png");
final URL cursor40URL = new URL(
"http://i.imgur.com/1jz2j.png");
final URL cursor20URL = new URL(
"http://i.imgur.com/CUIzF.png");
cursor = Toolkit.getDefaultToolkit().getImage(cursor100URL);
cursor80 = Toolkit.getDefaultToolkit().getImage(cursor80URL);
cursor60 = Toolkit.getDefaultToolkit().getImage(cursor60URL);
cursor40 = Toolkit.getDefaultToolkit().getImage(cursor40URL);
cursor20 = Toolkit.getDefaultToolkit().getImage(cursor20URL);
} catch (MalformedURLException e) {
log("Unable to buffer Cursor Image.");
e.printStackTrace();
}
try {
bg = ImageIO.read(new URL("http://i.imgur.com/JdK5N.png"));
} catch (Exception e) {
e.printStackTrace();
}
env.disableRandom("Improved Login");
pathToStep = newTilePath(TilesToStep);
pathToSwing = newTilePath(TilesToSwing);
camera.setPitch(true);
camera.setPitch(true);
walking.setRun(true);
EatAt = (int) (skills.getRealLevel(skills.CONSTITUTION) * 10 * 7 / 10);
if (SwingUtilities.isEventDispatchThread()) {
gui.setResizable(false);
gui.setVisible(true);
} else {
try {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
gui.setResizable(false);
gui.setVisible(true);
}
});
} catch (Throwable e) {
}
}
sleep(100);
while (WaitingGui == true) {
if (!gui.isVisible()) {
return false;
}
sleep(100);
}
failsafeTimer = new Timer(120000);
build();
return true;
}
@Override
public void onFinish() {
env.enableRandom("Improved Login");
log("Thanks for using Epic Agility Trainer. Always be the best! Yeah~");
log("Made by your Epic Script Writer / Improver, Anarki.");
gui.dispose();
}
// ============= Message Listener =============
public void messageReceived(MessageEvent e) {
String Message = e.getMessage();
if (Message.contains("The rope swing is")) {
clickObject(objects.getNearest(43526), "Swing-on Rope swing");
sleep(random(200, 450));
}
}
private RSItem edible() {
RSItem[] is = inventory.getItems();
for (RSItem i : is) {
if (i.getComponent().getActions() == null || i.getComponent().getActions()[0] == null) {
continue;
}
if (i.getComponent().getActions()[0].contains("Eat")) {
return i;
}
}
return null;
}
public RSItem getItem(String name) {
RSItem[] inv = inventory.getItems();
for (RSItem item:inv) {
if (item.getName().equalsIgnoreCase(name))
return item;
}
return null;
}
public int hp() {
return getLifePoints();
}
public void click(){
mouse.click(true);
}
//Methods
public int getLifePoints() {
try {
return Integer.parseInt(interfaces.get(748).getComponent(8).getText().trim());
} catch (final NumberFormatException ex) {
return 100;
}
}
private boolean moveToScreenTile(final RSTile t) {
Point p = calc.tileToScreen(t);
if (calc.pointOnScreen(p)) {
mouse.move(p.x, p.y, 5, 5);
p = calc.tileToScreen(t);
if (calc.pointOnScreen(p)) {
mouse.move(2, p.x, p.y, 5, 5);
mouse.click(true);
return true;
} else {
return false;
}
} else {
return false;
}
}
private boolean moveToScreenTileForGnome(final RSTile t) {
Point p = calc.tileToScreen(t);
if (calc.pointOnScreen(p)) {
mouse.move(p.x, p.y, 5, 5);
p = calc.tileToScreen(t);
if (calc.pointOnScreen(p)) {
mouse.move(2, p.x, p.y, 5, 5);
mouse.click(true);
return true;
} else {
return true;
}
} else {
return true;
}
}
private RSPath lastPath;
private RSTile lastDestination;
private RSTile lastStep;
/**
* Walks one tile towards the given destination using a generated path.
*
* @param destination The destination tile.
* @return <tt>true</tt> if the next tile was walked to; otherwise
* <tt>false</tt>.
*/
public void walkTo(final RSTile destination) {
if (lastPath == null || (!getMyPlayer().isMoving() && calc.distanceTo(destination) > 2)) {
lastPath = getPath(destination);
}
lastPath.traverse();
}
public RSPath getPath(final RSTile destination) {
return new RSLocalPath(ctx, destination);
}
// --------------------------- Custom RSLocalPath as main walking method ------------------------
public class RSLocalPath extends RSPath {
public static final int WALL_NORTH_WEST = 0x1;
public static final int WALL_NORTH = 0x2;
public static final int WALL_NORTH_EAST = 0x4;
public static final int WALL_EAST = 0x8;
public static final int WALL_SOUTH_EAST = 0x10;
public static final int WALL_SOUTH = 0x20;
public static final int WALL_SOUTH_WEST = 0x40;
public static final int WALL_WEST = 0x80;
public static final int BLOCKED = 0x1280100;
protected final RSTile end;
protected RSTile base;
protected int[][] flags;
protected int offX, offY;
private RSTilePath tilePath;
public RSLocalPath(final MethodContext ctx, final RSTile end) {
super(ctx);
this.end = end;
}
/**
* {@inheritDoc}
*/
@Override
public boolean traverse(final EnumSet<TraversalOption> options) {
return getNext() != null && tilePath.traverse();
}
/**
* {@inheritDoc}
*/
@Override
public boolean isValid() {
return getNext() != null && !getMyPlayer().getLocation().equals(getEnd());
}
/**
* {@inheritDoc}
*/
@Override
public RSTile getNext() {
if (game.isLoggedIn()) {
if (!game.getMapBase().equals(base)) {
final int[][] flags = walking.getCollisionFlags(game.getPlane());
if (flags != null) {
base = game.getMapBase();
final RSTile start = getMyPlayer().getLocation();
final RSTile[] tiles = findPath(start, end);
if (tiles == null) {
base = null;
return null;
}
tilePath = newTilePath(tiles);
}
}
return tilePath.getNext();
}
return null;
}
/**
* {@inheritDoc}
*/
@Override
public RSTile getStart() {
return null;
}
/**
* {@inheritDoc}
*/
@Override
public RSTile getEnd() {
return end;
}
/**
* Returns the calculated RSTilePath that is currently
* providing data to this RSLocalPath.
*
* @return The current RSTile path; or <code>null</code>.
*/
public RSTilePath getCurrentTilePath() {
return tilePath;
}
protected class Node {
public final int x;
public final int y;
public Node prev;
public double g, f;
public boolean border;
public Node(final int x, final int y, final boolean border) {
this.border = border;
this.x = x;
this.y = y;
g = f = 0;
}
public Node(final int x, final int y) {
this.x = x;
this.y = y;
g = f = 0;
}
@Override
public int hashCode() {
return x << 4 | y;
}
@Override
public boolean equals(final Object o) {
if (o instanceof Node) {
final Node n = (Node) o;
return x == n.x && y == n.y;
}
return false;
}
@Override
public String toString() {
return "(" + x + "," + y + ")";
}
public RSTile toRSTile(final int baseX, final int baseY) {
return new RSTile(x + baseX, y + baseY);
}
}
protected RSTile[] findPath(final RSTile start, final RSTile end) {
return findPath(start, end, false);
}
private RSTile[] findPath(final RSTile start, final RSTile end, boolean remote) {
final int base_x = base.getX(), base_y = base.getY();
final int curr_x = start.getX() - base_x, curr_y = start.getY() - base_y;
int dest_x = end.getX() - base_x, dest_y = end.getY() - base_y;
// load client data
final int plane = game.getPlane();
flags = walking.getCollisionFlags(plane);
final RSTile offset = walking.getCollisionOffset(plane);
offX = offset.getX();
offY = offset.getY();
// loaded region only
if (flags == null || curr_x < 0 || curr_y < 0 || curr_x >= flags.length || curr_y >= flags.length) {
return null;
} else if (dest_x < 0 || dest_y < 0 || dest_x >= flags.length || dest_y >= flags.length) {
remote = true;
if (dest_x < 0) {
dest_x = 0;
} else if (dest_x >= flags.length) {
dest_x = flags.length - 1;
}
if (dest_y < 0) {
dest_y = 0;
} else if (dest_y >= flags.length) {
dest_y = flags.length - 1;
}
}
// structs
final HashSet<Node> open = new HashSet<Node>();
final HashSet<Node> closed = new HashSet<Node>();
Node curr = new Node(curr_x, curr_y);
final Node dest = new Node(dest_x, dest_y);
curr.f = heuristic(curr, dest);
open.add(curr);
// search
while (!open.isEmpty()) {
curr = lowest_f(open);
if (curr.equals(dest)) {
// reconstruct from pred tree
return path(curr, base_x, base_y);
}
open.remove(curr);
closed.add(curr);
for (final Node next : successors(curr)) {
if (!closed.contains(next)) {
final double t = curr.g + dist(curr, next);
boolean use_t = false;
if (!open.contains(next)) {
open.add(next);
use_t = true;
} else if (t < next.g) {
use_t = true;
}
if (use_t) {
next.prev = curr;
next.g = t;
next.f = t + heuristic(next, dest);
}
}
}
}
// no path
if (!remote || calc.distanceTo(end) < 10) {
return null;
}
return findPath(start, pull(end));
}
private RSTile pull(final RSTile tile) {
final RSTile p = players.getMyPlayer().getLocation();
int x = tile.getX(), y = tile.getY();
if (p.getX() < x) {
x -= 2;
} else if (p.getX() > x) {
x += 2;
}
if (p.getY() < y) {
y -= 2;
} else if (p.getY() > y) {
y += 2;
}
return new RSTile(x, y);
}
private double heuristic(final Node start, final Node end) {
double dx = start.x - end.x;
double dy = start.y - end.y;
if (dx < 0) {
dx = -dx;
}
if (dy < 0) {
dy = -dy;
}
return dx < dy ? dy : dx;
//double diagonal = dx > dy ? dy : dx;
//double manhattan = dx + dy;
//return 1.41421356 * diagonal + (manhattan - 2 * diagonal);
}
private double dist(final Node start, final Node end) {
if (start.x != end.x && start.y != end.y) {
return 1.41421356;
} else {
return 1.0;
}
}
private Node lowest_f(final Set<Node> open) {
Node best = null;
for (final Node t : open) {
if (best == null || t.f < best.f) {
best = t;
}
}
return best;
}
private RSTile[] path(final Node end, final int base_x, final int base_y) {
final LinkedList<RSTile> path = new LinkedList<RSTile>();
Node p = end;
while (p != null) {
path.addFirst(p.toRSTile(base_x, base_y));
p = p.prev;
}
return path.toArray(new RSTile[path.size()]);
}
private List<Node> successors(final Node t) {
final LinkedList<Node> tiles = new LinkedList<Node>();
final int x = t.x, y = t.y;
final int f_x = x - offX, f_y = y - offY;
final int here = flags[f_x][f_y];
final int upper = flags.length - 1;
if (f_y > 0 && (here & WALL_SOUTH) == 0 && (flags[f_x][f_y - 1] & BLOCKED) == 0) {
tiles.add(new Node(x, y - 1));
}
if (f_x > 0 && (here & WALL_WEST) == 0 && (flags[f_x - 1][f_y] & BLOCKED) == 0) {
tiles.add(new Node(x - 1, y));
}
if (f_y < upper && (here & WALL_NORTH) == 0 && (flags[f_x][f_y + 1] & BLOCKED) == 0) {
tiles.add(new Node(x, y + 1));
}
if (f_x < upper && (here & WALL_EAST) == 0 && (flags[f_x + 1][f_y] & BLOCKED) == 0) {
tiles.add(new Node(x + 1, y));
}
if (f_x > 0 && f_y > 0 && (here & (WALL_SOUTH_WEST | WALL_SOUTH | WALL_WEST)) == 0
&& (flags[f_x - 1][f_y - 1] & BLOCKED) == 0
&& (flags[f_x][f_y - 1] & (BLOCKED | WALL_WEST)) == 0
&& (flags[f_x - 1][f_y] & (BLOCKED | WALL_SOUTH)) == 0) {
tiles.add(new Node(x - 1, y - 1));
}
if (f_x > 0 && f_y < upper && (here & (WALL_NORTH_WEST | WALL_NORTH | WALL_WEST)) == 0
&& (flags[f_x - 1][f_y + 1] & BLOCKED) == 0
&& (flags[f_x][f_y + 1] & (BLOCKED | WALL_WEST)) == 0
&& (flags[f_x - 1][f_y] & (BLOCKED | WALL_NORTH)) == 0) {
tiles.add(new Node(x - 1, y + 1));
}
if (f_x < upper && f_y > 0 && (here & (WALL_SOUTH_EAST | WALL_SOUTH | WALL_EAST)) == 0
&& (flags[f_x + 1][f_y - 1] & BLOCKED) == 0
&& (flags[f_x][f_y - 1] & (BLOCKED | WALL_EAST)) == 0
&& (flags[f_x + 1][f_y] & (BLOCKED | WALL_SOUTH)) == 0) {
tiles.add(new Node(x + 1, y - 1));
}
if (f_x > 0 && f_y < upper && (here & (WALL_NORTH_EAST | WALL_NORTH | WALL_EAST)) == 0
&& (flags[f_x + 1][f_y + 1] & BLOCKED) == 0
&& (flags[f_x][f_y + 1] & (BLOCKED | WALL_EAST)) == 0
&& (flags[f_x + 1][f_y] & (BLOCKED | WALL_NORTH)) == 0) {
tiles.add(new Node(x + 1, y + 1));
}
return tiles;
}
}
// -------------------------------------- End of Custom RSLocalPath ----------------------------------
// --------------------------- Custom RSTilePath as main walking method ------------------------
public class RSTilePath extends RSPath {
protected RSTile[] tiles;
protected RSTile[] orig;
private boolean end;
public RSTilePath(final MethodContext ctx, final RSTile[] tiles) {
super(ctx);
orig = tiles;
this.tiles = Arrays.copyOf(tiles, tiles.length);
}
/**
* {@inheritDoc}
*/
@Override
public boolean traverse(final EnumSet<TraversalOption> options) {
final RSTile next = getNext();
if (next == null) {
return false;
}
if (next.equals(getEnd())) {
if (calc.distanceTo(next) <= 5 || end && (!getMyPlayer().isMoving() || calc.distanceTo(next) < 3)) {
walking.walkTileMM(next, 0, 0);
sleep(random(300, 400));
return false;
}
end = true;
} else {
end = false;
}
if (options != null && options.contains(TraversalOption.HANDLE_RUN) && !walking.isRunEnabled() && walking.getEnergy() > 50) {
walking.setRun(true);
sleep(300);
}
if (options != null && options.contains(TraversalOption.SPACE_ACTIONS)) {
final RSTile dest = walking.getDestination();
if (dest != null && getMyPlayer().isMoving() && calc.distanceTo(dest) > 5 && calc.distanceBetween(next, dest) < 7) {
return true;
}
}
return walking.walkTileMM(next, 0, 0);
}
/**
* {@inheritDoc}
*/
@Override
public boolean isValid() {
return tiles.length > 0 && getNext() != null && !getMyPlayer().getLocation().equals(getEnd());
}
/**
* {@inheritDoc}
*/
@Override
public RSTile getNext() {
for (int i = tiles.length - 1; i >= 0; --i) {
final RSTile dest = methods.walking.getDestination();
if (methods.calc.tileOnMap(tiles[i]) && (methods.calc.canReach(tiles[i], false) || (i != 0 && (dest != null ? methods.calc.distanceBetween(dest, tiles[i - 1]) < 3 : methods.calc.distanceTo(tiles[i - 1]) < 7)))) {
return tiles[i];
}
}
return null;
}
/**
* {@inheritDoc}
*/
@Override
public RSTile getStart() {
return tiles[0];
}
/**
* {@inheritDoc}
*/
@Override
public RSTile getEnd() {
return tiles[tiles.length - 1];
}
/**
* Randomize this path. The original path is stored so
* this method may be called multiple times without the
* waypoints drifting far from their original locations.
*
* @param maxX The max deviation on the X axis
* @param maxY The max deviation on the Y axis
* @return This path.
*/
public RSTilePath randomize(final int maxX, final int maxY) {
for (int i = 0; i < tiles.length; ++i) {
tiles[i] = orig[i].randomize(maxX, maxY);
}
return this;
}
/**
* Reverses this path.
*
* @return This path.
*/
public RSTilePath reverse() {
RSTile[] reversed = new RSTile[tiles.length];
for (int i = 0; i < orig.length; ++i) {
reversed[i] = orig[tiles.length - 1 - i];
}
orig = reversed;
reversed = new RSTile[tiles.length];
for (int i = 0; i < tiles.length; ++i) {
reversed[i] = tiles[tiles.length - 1 - i];
}
tiles = reversed;
return this;
}
/**
* Returns an array containing all of the vertices in this path.
*
* @return an array containing all of the vertices in this path.
*/
public RSTile[] toArray() {
final RSTile[] a = new RSTile[tiles.length];
System.arraycopy(tiles, 0, a, 0, tiles.length);
return a;
}
}
// -------------------------------------- End of Custom RSTilePath ----------------------------------
public RSTilePath newTilePath(final RSTile[] tiles) {
if (tiles == null) {
throw new IllegalArgumentException("null waypoint list");
}
return new RSTilePath(ctx, tiles);
}
@SuppressWarnings("static-access")
public void antiBanForWerewolfCourse() {
switch (random(0,10)) {
case 0:
if (random(0,10) > 8) {
game.openTab(game.TAB_STATS);
sleep(random(750,1000));
skills.doHover(skills.INTERFACE_AGILITY);
sleep(random(750,1000));
game.openTab(game.TAB_INVENTORY);
}
break;
case 1:
if (random(0, 10) > 5) {
mouse.moveOffScreen();
}
break;
case 2:
mouse.moveSlightly();
break;
case 3:
mouse.moveSlightly();
break;
case 4:
if (random(0, 10) > 9) {
game.openTab(game.TAB_FRIENDS);
sleep(random(750,1500));
game.openTab(game.TAB_INVENTORY);
}
break;
case 5:
mouse.moveRandomly(1, 3);
break;
}
}
public String format(int num) {
DecimalFormat df = new DecimalFormat();
DecimalFormatSymbols dfs = new DecimalFormatSymbols();
dfs.setGroupingSeparator(',');
df.setDecimalFormatSymbols(dfs);
return df.format(num);
}
public boolean modelContains(RSModel m, Point p) {
if (m == null || p == null)
return false;
Polygon[] poly = m.getTriangles();
if (poly.length < 1)
return false;
for (Polygon t : poly)
if (t.contains(p))
return true;
return false;
}
private boolean doActionForWerewolfCourse(RSObject object, String... possibleActions) {
boolean contains = false, qualified = false;
try {
if (object != null) {
mouse.move(new Point((int)object.getModel().getCentralPoint().getX()+(random(-5,5)), (int)object.getModel().getCentralPoint().getY()+(random(-5,5))));
for (String action : possibleActions) {
if (menu.getItems()[0].equals(action)) {
mouse.click(true);
return true;
} else {
return false;
}
}
}
return false;
} catch (final Exception ignored) {
}
return false;
}
private boolean doActionOn(RSObject object, String... possibleActions) {
try {
if (object != null && object.isOnScreen()) {
for (int i = 0; i < 2; i++) {
mouse.move(new Point((int) object.getModel().getCentralPoint().getX()+(random(-5,5)), (int) object.getModel().getCentralPoint().getY()+(random(-5,5))));
}
mouse.click(true);
return true;
}
clearMenu();
return false;
} catch (final Exception ignored) {
}
return false;
}
private boolean clickObject(RSObject object, String action) {
if (object != null && object.isOnScreen()) {
for (int i = 0; i < 10; i++) {
if (isPartiallyOnScreen(object.getModel())) {
Point p = getCentralPoint(object.getModel());
if (p == null || !calc.pointOnScreen(p)) {
continue;
}
mouse.move(p, 3, 3);
String[] items = menu.getItems();
if (items.length > 0 && items[0].contains(action)) {
mouse.click(true);
return true;
} else if (menu.contains(action)) {
mouse.click(false);
sleep(random(100, 200));
for (int x = 0; x < 4; x++) {
if (!menu.contains(action)) {
clearMenu();
break;
}
if (menu.click(action)) {
return true;
}
}
}
}
}
}
return false;
}
private boolean isPartiallyOnScreen(RSModel m) {
return getPointOnScreen(m, true) != null;
}
private Point getPointOnScreen(RSModel m, boolean first) {
if (m == null)
return null;
ArrayList<Point> list = new ArrayList<Point>();
try {
Polygon[] tris = m.getTriangles();
for (int i = 0; i < tris.length; i++) {
Polygon p = tris[i];
for (int j = 0; j < p.xpoints.length; j++) {
Point pt = new Point(p.xpoints[j], p.ypoints[j]);
if (calc.pointOnScreen(pt)) {
if (first)
return pt;
list.add(pt);
}
}
}
} catch (Exception e) {
}
return list.size() > 0 ? list.get(random(0, list.size())) : null;
}
private double distanceBetween(Point p1, Point p2) {
return Math.sqrt(((p1.x - p2.x) * (p1.x - p2.x)) + ((p1.y - p2.y) * (p1.y - p2.y)));
}
private RSTile closerTile(RSTile t, int dist) {
RSTile loc = getMyPlayer().getLocation();
int newX = t.getX(), newY = t.getY();
for (int i = 1; i < dist; i++) {
newX = t.getX() != loc.getX() ? (t.getX() < loc.getX() ? newX-- : newX++) : newX;
newY = t.getY() != loc.getY() ? (t.getY() < loc.getY() ? newY-- : newY++) : newY;
}
return new RSTile(newX, newY);
}
private Point getCentralPoint(RSModel m) {
if(m == null)
return null;
try {
/* Add X and Y of all points, to get a rough central point */
int x = 0, y = 0, total = 0;
for(Polygon poly : m.getTriangles()) {
for(int i = 0; i < poly.npoints; i++) {
x += poly.xpoints[i];
y += poly.ypoints[i];
total++;
}
}
Point central = new Point(x / total, y / total);
/* Find a real point on the NPC that is closest to the central point */
Point curCentral = null;
double dist = 20000;
for (Polygon poly : m.getTriangles()) {
for(int i = 0; i < poly.npoints; i++) {
Point p = new Point(poly.xpoints[i], poly.ypoints[i]);
if(!calc.pointOnScreen(p))
continue;
double dist2 = distanceBetween(central, p);
if(curCentral == null || dist2 < dist) {
curCentral = p;
dist = dist2;
}
}
}
return curCentral;
} catch (Exception e) {}
return null;
}
private void clearMenu() {
if (menu.isOpen()) {
final Point p = mouse.getLocation();
p.x += random(120, 140);
if (random(1, 2) == 2) {
p.y += random(1, 140);
} else {
p.y -= random(1, 140);
}
if (p.x > 761) {
p.x = 761;
}
if (p.y < 1) {
p.y = 1;
}
if (p.y > 500) {
p.y = 500;
}
mouse.move(4, p.x, p.y, 5, 5);
sleep(50, 100);
mouse.move(4, p.x, p.y, 5, 5);
}
}
public boolean atTile(final RSTile tile, final int h, final double xd, final double yd, final String action) {
try {
final Point location = calc.tileToScreen(new RSTile(tile.getX(),
tile.getY()), xd, yd, h);
if (location.x == -1 || location.y == -1) {
return false;
}
mouse.move(location, 5, 3);
String[] items = menu.getItems();
if (items.length > 0 && items[0].contains(action)) {
mouse.click(true);
return true;
} else {
return false;
}
} catch (final Exception e) {
return false;
}
}
public boolean CrazyAtTile(final RSTile tile, final int h, final double xd, final double yd, final String action) {
try {
final Point location = calc.tileToScreen(new RSTile(tile.getX(),
tile.getY()), xd, yd, h);
if (location.x == -1 || location.y == -1) {
return false;
}
mouse.move(location, 5, 3);
String[] items = menu.getItems();
if (items.length > 0 && items[0].contains(action)) {
mouse.click(true);
return true;
} else {
return false;
}
} catch (final Exception e) {
return false;
}
}
public boolean doAction(RSObject o, String s) {
return o!= null && ((!modelContains(o.getModel(),mouse.getLocation()) && o.interact(s)) || (menu.contains(s) && menu.click(s)));
}
abstract class Obstacle {
abstract boolean isCurrent();
boolean overcome() {
for (int i = 0; i < 5; i++) {
RSObject o = get();
next = o;
if (o != null) {
if (clickObject(o,actionName()) && menu.contains(actionName())) // doAction --> clickObject
return true;
}
}
return false;
}
boolean overcomeForApeAtoll() {
for (int i = 0; i < 5; i++) {
RSObject o = get();
next = o;
if (o != null) {
if (doAction(o,actionName()) && menu.contains(actionName())) // doAction --> clickObject
return true;
}
}
return false;
}
boolean OverClickObject() {
for (int i = 0; i < 5; i++) {
RSObject o = get();
next = o;
if (o != null) {
if (clickObject(o, actionName()) && menu.contains(actionName()))
return true;
}
}
return false;
}
RSTile walkTile() {
RSObject o = get();
if (o==null)
return null;
return o.getLocation();
}
abstract String actionName();
abstract RSObject get();
}
/*
* Created by JFormDesigner on Mon Aug 01 20:11:19 CST 2011
*/
/**
* @author Anarki99
*/
public class EpicAgilityTrainerGUI extends JFrame {
private final File settings = new File(new File(Configuration.Paths.getSettingsDirectory()), "EpicAgilityTrainerSettingFile.txt");
public EpicAgilityTrainerGUI() {
initComponents();
}
private void StartActionPerformed(ActionEvent e) {
if (comboBox5.getSelectedItem().toString() == "Advanced Barbarian Outpost Course") {
getAgilityCourse = 1;
} else if (comboBox5.getSelectedItem().toString() == "Advanced Gnome Stronghold Course") {
getAgilityCourse = 2;
} else if (comboBox5.getSelectedItem().toString() == "Ape Atoll Agility Course") {
getAgilityCourse = 3;
} else if (comboBox5.getSelectedItem().toString() == "Werewolf Agility Course") {
getAgilityCourse = 4;
}
WaitingGui = false;
saveSettings();
gui.dispose();
}
private void initComponents() {
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
// Generated using JFormDesigner Evaluation license - Anarki99
label1 = new JLabel();
label2 = new JLabel();
label11 = new JLabel();
comboBox5 = new JComboBox();
button1 = new JButton();
//======== this ========
setTitle("Epic Agility Trainer - Made by Anarki");
Container contentPane = getContentPane();
contentPane.setLayout(null);
//---- label1 ----
label1.setText("- Epic Agility Trainer -");
label1.setFont(new Font("Arial", Font.PLAIN, 20));
contentPane.add(label1);
label1.setBounds(85, 10, 245, 35);
//---- label2 ----
label2.setText("Version " + getVersion() + ", Made by Anarki");
label2.setFont(new Font("Arial", Font.PLAIN, 12));
contentPane.add(label2);
label2.setBounds(100, 40, 165, 20);
//---- label11 ----
label11.setText("Choose your Agility Course:");
label11.setFont(new Font("Arial", Font.PLAIN, 12));
contentPane.add(label11);
label11.setBounds(20, 70, 240, 25);
//---- comboBox5 ----
comboBox5.setModel(new DefaultComboBoxModel(new String[] {
"Werewolf Agility Course",
"Ape Atoll Agility Course",
"Advanced Gnome Stronghold Course",
"Advanced Barbarian Outpost Course"
}));
contentPane.add(comboBox5);
comboBox5.setBounds(20, 95, 315, 21);
//---- button1 ----
button1.setText("Start");
button1.setFont(new Font("Arial", Font.BOLD, 12));
button1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
StartActionPerformed(e);
}
});
contentPane.add(button1);
button1.setBounds(45, 135, 275, 23);
contentPane.setPreferredSize(new Dimension(365, 175));
pack();
setLocationRelativeTo(getOwner());
// JFormDesigner - End of component initialization //GEN-END:initComponents
loadSettings();
}
private void saveSettings() {
PrintWriter out;
try {
out = new PrintWriter(new FileWriter(settings));
String[] setting = { "" + comboBox5.getSelectedIndex(),
};
for (String line : setting) {
out.println(line);
}
out.close();
} catch (IOException ignored) {
}
}
private void loadSettings() {
BufferedReader in;
try {
in = new BufferedReader(new FileReader(settings));
String line;
String[] setting = new String[5];
for (int i = 0; i < setting.length && (line = in.readLine()) != null; i++) {
setting[i] = line;
}
comboBox5.setSelectedIndex(Integer.parseInt(setting[0]));
in.close();
} catch (Exception ignored) {
}
}
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
// Generated using JFormDesigner Evaluation license - Anarki99
private JLabel label1;
private JLabel label2;
private JLabel label11;
private JComboBox comboBox5;
private JButton button1;
// JFormDesigner - End of variables declaration //GEN-END:variables
}
}