Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Color;
- import java.awt.Dimension;
- import java.awt.FlowLayout;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import javax.swing.JButton;
- import javax.swing.JComboBox;
- import javax.swing.JDialog;
- 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.2, description = "Runs agility course laps.")
- public class pAgility extends ActiveScript implements PaintListener {
- public Timer t = null;
- Obstacle currObstacle;
- int agilStart = 0;
- String course = "null";
- String coursePicked = "null";
- @Override
- public boolean onStart() {
- currObstacle = null;
- t = new Timer(System.currentTimeMillis());
- agilStart = Skills.getCurrentExp(Skills.AGILITY);
- JDialog frame = new JDialog();
- frame.setPreferredSize(new Dimension(250, 90));
- frame.setLocationRelativeTo(null);
- frame.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
- FlowLayout layout = new FlowLayout();
- layout.setHgap(5);
- layout.setVgap(5);
- frame.setLayout(layout);
- JComboBox<String> combo = new JComboBox<String>();
- combo.setPreferredSize(new Dimension(150, 30));
- combo.setFocusable(false);
- combo.addItem("Gnome Agility");
- combo.addItem("Barbarian Agility");
- combo.addItem("Wilderness Agility");
- JButton button = new JButton("Start");
- button.setFocusable(false);
- button.setPreferredSize(new Dimension(60, 32));
- button.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent ae) {
- course = (String) combo.getSelectedItem();
- switch (course) {
- case "Gnome Agility":
- coursePicked = "Gnome";
- break;
- case "Barbarian Agility":
- coursePicked = "Barb";
- break;
- case "Wilderness Agility":
- coursePicked = "Wild";
- break;
- }
- frame.dispose();
- }
- });
- frame.add(combo);
- frame.add(button);
- frame.setTitle("XoBot - pAgility 0.2");
- frame.pack();
- frame.setVisible(true);
- while (frame.isVisible()) {
- Time.sleep(100);
- }
- 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() {
- switch (coursePicked) {
- case "Gnome":
- if ((Players.getMyPlayer().getLocation().getY() >= Obstacle.LOG_GNOME.getBeginTile().getY()
- && Players.getMyPlayer().getLocation().getX() >= 2474)
- || Players.getMyPlayer().getLocation().getY() >= 3436)
- return Obstacle.LOG_GNOME;
- break;
- case "Barb":
- if ((Players.getMyPlayer().getLocation().getX() == Obstacle.WALL3_BARB.getEndTile().getX()
- && Players.getMyPlayer().getLocation().getY() == Obstacle.WALL3_BARB.getEndTile().getY())
- || Players.getMyPlayer().getLocation().getY() >= 3554)
- return Obstacle.ROPE_BARB;
- break;
- case "Wild":
- if ((Players.getMyPlayer().getLocation().getY() <= Obstacle.PIPE_WILD.getBeginTile().getY()
- && Players.getMyPlayer().getLocation().getX() >= 2997)
- || Players.getMyPlayer().getLocation().getY() <= Obstacle.WALL_WILD.getEndTile().getY())
- return Obstacle.PIPE_WILD;
- break;
- }
- 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 {
- /* GNOME VILLAGE AGILITY OBSTACLES */
- LOG_GNOME(23145, new Tile(2474, 3436), new Tile(2474, 3429), "Walk-across"), NET_GNOME(23134,
- new Tile(2474, 3426), new Tile(2474, 3424),
- "Climb-over"), TREE_GNOME(23559, new Tile(2474, 3422), new Tile(2473, 3420), "Climb"), ROPE_GNOME(23557,
- new Tile(2477, 3420), new Tile(2483, 3420), "Walk-on"), TREE2_GNOME(23560, new Tile(2485, 3419),
- new Tile(2487, 3421), "Climb-down"), NET2_GNOME(23135, new Tile(2484, 3425),
- new Tile(2484, 3427), "Climb-over"), PIPE_GNOME(23138, new Tile(2484, 3430),
- new Tile(2484, 3437), "Squeeze-through"),
- /* BARBARIAN VILLAGE AGILITY OBSTACLES */
- ROPE_BARB(23131, new Tile(2551, 3554), new Tile(2551, 3549), "Swing-on"), LOG_BARB(23144, new Tile(2551, 3546),
- new Tile(2541, 3546),
- "Walk-across"), NET_BARB(20211, new Tile(2539, 3546), new Tile(2537, 3546), "Climb-over"), LEDGE_BARB(
- 23547, new Tile(2536, 3547), new Tile(2532, 3546), "Walk-across"), WALL_BARB(1948,
- new Tile(2535, 3553), new Tile(2537, 3553), "Climb-over"), WALL2_BARB(1948,
- new Tile(2538, 3553), new Tile(2540, 3553), "Climb-over"), WALL3_BARB(1948,
- new Tile(2541, 3553), new Tile(2543, 3553), "Climb-over"),
- /* WILDERNESS AGILITY OBSTACLES */
- PIPE_WILD(23137, new Tile(3004, 3937), new Tile(3004, 3950), "Squeeze-through"), SWING_WILD(23132,
- new Tile(3005, 3953), new Tile(3005, 3958), "Swing-on"), STONES_WILD(23556, new Tile(3002, 3960),
- new Tile(2996, 3960), "Cross"), LOG_WILD(23542, new Tile(3002, 3945), new Tile(2994, 3945),
- "Walk-across"), WALL_WILD(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