Advertisement
Guest User

Untitled

a guest
Mar 2nd, 2018
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.16 KB | None | 0 0
  1. import java.awt.Color;
  2. import java.awt.Graphics;
  3. import java.awt.Graphics2D;
  4.  
  5. import xobot.client.callback.listeners.PaintListener;
  6. import xobot.script.ActiveScript;
  7. import xobot.script.Manifest;
  8. import xobot.script.methods.GameObjects;
  9. import xobot.script.methods.Players;
  10. import xobot.script.methods.Walking;
  11. import xobot.script.methods.tabs.Skills;
  12. import xobot.script.util.Time;
  13. import xobot.script.util.Timer;
  14. import xobot.script.wrappers.Tile;
  15. import xobot.script.wrappers.interactive.GameObject;
  16.  
  17. @Manifest(authors = { "pepsip77", "Sebo" }, name = "pAgility", version = 0.1, description = "Runs the wild agility course on Alora")
  18. public class pAgility extends ActiveScript implements PaintListener {
  19.  
  20. public Timer t = null;
  21.  
  22. Obstacle currObstacle;
  23.  
  24. int agilStart = 0;
  25.  
  26. @Override
  27. public boolean onStart() {
  28. currObstacle = null;
  29. t = new Timer(System.currentTimeMillis());
  30. agilStart = Skills.getCurrentExp(Skills.AGILITY);
  31. return true;
  32. }
  33.  
  34. @Override
  35. public void onStop() {
  36.  
  37. }
  38.  
  39. @Override
  40. public int loop() {
  41. if (isAtCourse()) {
  42. if (!Players.getMyPlayer().isMoving() && Players.getMyPlayer().getAnimation() == -1) {
  43. currObstacle = getNextObstacle();
  44. if(currObstacle != null) {
  45. if(Players.getMyPlayer().getLocation().getX() == currObstacle.beginTile.getX() &&
  46. Players.getMyPlayer().getLocation().getY() == currObstacle.beginTile.getY()) {
  47. GameObject o = GameObjects.getNearest(currObstacle.getId());
  48. if( o != null && o.isReachable()) {
  49. o.interact(currObstacle.getAction());
  50. Time.sleep(950, 1050);
  51. }
  52. }else {
  53. Walking.walkTo(currObstacle.beginTile);
  54. Time.sleep(950, 1050);
  55. }
  56. }
  57. }
  58. }
  59. return 100;
  60. }
  61.  
  62. public String format(int i) {
  63. if (i > 1000000) {
  64. return (i / 1000000) + "M";
  65. } else if (i > 1000) {
  66. return (i/ 1000) + "K";
  67. }
  68. return String.valueOf(i);
  69. }
  70.  
  71. @Override
  72. public void repaint(Graphics g1) {
  73. int agil = Skills.getCurrentExp(Skills.AGILITY) - agilStart;
  74. int agilTimer = (int) ((agil) * 3600000D / (t.getElapsed()));
  75.  
  76. Graphics2D g = (Graphics2D)g1;
  77.  
  78. g.setColor(Color.WHITE);
  79. g.drawString("Agility XP Gained: " + format(agil), 5, 175);
  80. g.drawString("Agility XP/HR: " + format(agilTimer), 5, 190);
  81. }
  82.  
  83. public boolean isAtCourse() {
  84. for (Obstacle o : Obstacle.values()) {
  85. GameObject ob = GameObjects.getNearest(o.getId());
  86. if (ob != null && ob.isReachable()) {
  87. return true;
  88. }
  89. }
  90. return false;
  91. }
  92.  
  93. public Obstacle getNextObstacle() {
  94. if ((Players.getMyPlayer().getLocation().getY() <= Obstacle.PIPE.getBeginTile().getY()
  95. && Players.getMyPlayer().getLocation().getX() >= 2997)
  96. ||Players.getMyPlayer().getLocation().getY() <= Obstacle.WALL.getEndTile().getY()) {
  97. return Obstacle.PIPE;
  98. } else {
  99. boolean thisOne = false;
  100. for (Obstacle o : Obstacle.values()) {
  101. if (thisOne)
  102. return o;
  103. if (Players.getMyPlayer().getLocation().getX() == o.getEndTile().getX() &&
  104. Players.getMyPlayer().getLocation().getY() == o.getEndTile().getY())
  105. thisOne = true;
  106. if (Players.getMyPlayer().getLocation().getX() == o.getBeginTile().getX() &&
  107. Players.getMyPlayer().getLocation().getY() == o.getBeginTile().getY())
  108. return o;
  109. }
  110. }
  111. return null;
  112. }
  113.  
  114. public enum Obstacle {
  115. PIPE(23137, new Tile(3004, 3937), new Tile(3004, 3950), "Squeeze-through"),
  116. SWING(23132, new Tile(3005, 3953), new Tile(3005, 3958), "Swing-on"),
  117. STONES(23556, new Tile(3002, 3960), new Tile(2996, 3960), "Cross"),
  118. LOG(23542, new Tile(3002, 3945), new Tile(2994, 3945), "Walk-across"),
  119. WALL(23640, new Tile(2995, 3937), new Tile(2995, 3933), "Climb");
  120.  
  121. private int id;
  122. private Tile beginTile;
  123. private Tile endTile;
  124. private String action;
  125.  
  126. Obstacle(int id, Tile beginTile, Tile endTile, String action) {
  127. this.id = id;
  128. this.beginTile = beginTile;
  129. this.endTile = endTile;
  130. this.action = action;
  131. }
  132.  
  133. public int getId() {
  134. return id;
  135. }
  136.  
  137. public Tile getBeginTile() {
  138. return beginTile;
  139. }
  140.  
  141. public Tile getEndTile() {
  142. return endTile;
  143. }
  144.  
  145. public String getAction() {
  146. return action;
  147. }
  148. }
  149. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement