Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Color;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import xobot.client.callback.listeners.PaintListener;
- import xobot.script.ActiveScript;
- import xobot.script.Manifest;
- import xobot.script.methods.GameObjects;
- import xobot.script.methods.Players;
- import xobot.script.methods.Walking;
- import xobot.script.methods.tabs.Skills;
- import xobot.script.util.Time;
- import xobot.script.util.Timer;
- import xobot.script.wrappers.Tile;
- import xobot.script.wrappers.interactive.GameObject;
- @Manifest(authors = { "pepsip77", "Sebo" }, name = "pAgility", version = 0.1, description = "Runs the wild agility course on Alora")
- public class pAgility extends ActiveScript implements PaintListener {
- public Timer t = null;
- Obstacle currObstacle;
- int agilStart = 0;
- @Override
- public boolean onStart() {
- currObstacle = null;
- t = new Timer(System.currentTimeMillis());
- agilStart = Skills.getCurrentExp(Skills.AGILITY);
- return true;
- }
- @Override
- public void onStop() {
- }
- @Override
- public int loop() {
- if (isAtCourse()) {
- if (!Players.getMyPlayer().isMoving() && Players.getMyPlayer().getAnimation() == -1) {
- currObstacle = getNextObstacle();
- if(currObstacle != null) {
- if(Players.getMyPlayer().getLocation().getX() == currObstacle.beginTile.getX() &&
- Players.getMyPlayer().getLocation().getY() == currObstacle.beginTile.getY()) {
- GameObject o = GameObjects.getNearest(currObstacle.getId());
- if( o != null && o.isReachable()) {
- o.interact(currObstacle.getAction());
- Time.sleep(950, 1050);
- }
- }else {
- Walking.walkTo(currObstacle.beginTile);
- Time.sleep(950, 1050);
- }
- }
- }
- }
- return 100;
- }
- public String format(int i) {
- if (i > 1000000) {
- return (i / 1000000) + "M";
- } else if (i > 1000) {
- return (i/ 1000) + "K";
- }
- return String.valueOf(i);
- }
- @Override
- public void repaint(Graphics g1) {
- int agil = Skills.getCurrentExp(Skills.AGILITY) - agilStart;
- int agilTimer = (int) ((agil) * 3600000D / (t.getElapsed()));
- Graphics2D g = (Graphics2D)g1;
- g.setColor(Color.WHITE);
- g.drawString("Agility XP Gained: " + format(agil), 5, 175);
- g.drawString("Agility XP/HR: " + format(agilTimer), 5, 190);
- }
- public boolean isAtCourse() {
- for (Obstacle o : Obstacle.values()) {
- GameObject ob = GameObjects.getNearest(o.getId());
- if (ob != null && ob.isReachable()) {
- return true;
- }
- }
- return false;
- }
- public Obstacle getNextObstacle() {
- if ((Players.getMyPlayer().getLocation().getY() <= Obstacle.PIPE.getBeginTile().getY()
- && Players.getMyPlayer().getLocation().getX() >= 2997)
- ||Players.getMyPlayer().getLocation().getY() <= Obstacle.WALL.getEndTile().getY()) {
- return Obstacle.PIPE;
- } else {
- boolean thisOne = false;
- for (Obstacle o : Obstacle.values()) {
- if (thisOne)
- return o;
- if (Players.getMyPlayer().getLocation().getX() == o.getEndTile().getX() &&
- Players.getMyPlayer().getLocation().getY() == o.getEndTile().getY())
- thisOne = true;
- if (Players.getMyPlayer().getLocation().getX() == o.getBeginTile().getX() &&
- Players.getMyPlayer().getLocation().getY() == o.getBeginTile().getY())
- return o;
- }
- }
- return null;
- }
- public enum Obstacle {
- PIPE(23137, new Tile(3004, 3937), new Tile(3004, 3950), "Squeeze-through"),
- SWING(23132, new Tile(3005, 3953), new Tile(3005, 3958), "Swing-on"),
- STONES(23556, new Tile(3002, 3960), new Tile(2996, 3960), "Cross"),
- LOG(23542, new Tile(3002, 3945), new Tile(2994, 3945), "Walk-across"),
- WALL(23640, new Tile(2995, 3937), new Tile(2995, 3933), "Climb");
- private int id;
- private Tile beginTile;
- private Tile endTile;
- private String action;
- Obstacle(int id, Tile beginTile, Tile endTile, String action) {
- this.id = id;
- this.beginTile = beginTile;
- this.endTile = endTile;
- this.action = action;
- }
- public int getId() {
- return id;
- }
- public Tile getBeginTile() {
- return beginTile;
- }
- public Tile getEndTile() {
- return endTile;
- }
- public String getAction() {
- return action;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement