Advertisement
Guest User

Untitled

a guest
Feb 28th, 2015
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.39 KB | None | 0 0
  1. import org.parabot.environment.api.utils.Time;
  2. import org.parabot.environment.input.Mouse;
  3. import org.parabot.environment.scripts.Category;
  4. import org.parabot.environment.scripts.Script;
  5. import org.parabot.environment.scripts.ScriptManifest;
  6. import org.parabot.environment.scripts.framework.SleepCondition;
  7. import org.parabot.environment.scripts.framework.Strategy;
  8. import org.rev317.min.api.methods.*;
  9. import org.rev317.min.api.wrappers.Npc;
  10. import org.rev317.min.api.wrappers.SceneObject;
  11.  
  12. import java.awt.Point;
  13. import java.util.ArrayList;
  14.  
  15. @ScriptManifest(
  16. author = "Fryslan"
  17. , category = Category.FISHING
  18. , description = "Fishes and Deposits Rocktails"
  19. , name = "Fryslan's Rocktail Fisher - Edited by Ark"
  20. , version = 0.2
  21. , servers = {"UltimateScape"})
  22.  
  23. public class UltimateScapeRockTailer extends Script {
  24.  
  25. public static ArrayList<Strategy> strategies = new ArrayList<>();
  26.  
  27. @Override
  28. public boolean onExecute() {
  29. strategies.add(new Relogger());
  30. strategies.add(new Fish());
  31. strategies.add(new BankRocktails());
  32. provide(strategies);
  33. return true;
  34. }
  35.  
  36.  
  37. private class Fish implements Strategy {
  38. @Override
  39. public boolean activate() {
  40. return !Inventory.isFull() && Inventory.getCount(315) > 0 && Inventory.getCount(310) > 0;
  41. }
  42.  
  43. @Override
  44. public void execute() {
  45. Npc[] spot = Npcs.getNearest(233);
  46.  
  47. //Interacting with the Fishing Spot.
  48. if (spot != null) {
  49. if (Players.getMyPlayer().getAnimation() == -1) {
  50. System.out.println("Fishing...");
  51. spot[0].interact(0);
  52. Time.sleep(new SleepCondition() {
  53. @Override
  54. public boolean isValid() {
  55. return Players.getMyPlayer().getAnimation() != -1;
  56. }
  57. }, 5000);
  58. }
  59. }
  60.  
  61. }
  62. }
  63.  
  64.  
  65. private class BankRocktails implements Strategy {
  66. @Override
  67. public boolean activate() {
  68. return Inventory.isFull();
  69. }
  70.  
  71. @Override
  72. public void execute() {
  73.  
  74. //We Need to bank because we have an full Inventory.
  75.  
  76. //Bank is NOT open Opening Bank.
  77. if (Game.getOpenInterfaceId() != 5292) {
  78. SceneObject[] bank = SceneObjects.getNearest(5276);
  79.  
  80. if (bank != null) {
  81. //todo Fix the interacting Issue!
  82. System.out.println("Banking...");
  83. try {
  84. bank[0].interact(1);
  85. } catch (Exception e) {
  86. //pass
  87. }
  88. Time.sleep(new SleepCondition() {
  89. @Override
  90. public boolean isValid() {
  91. return Game.getOpenInterfaceId() == 5292;
  92. }
  93. }, 5000);
  94. }
  95. }
  96.  
  97. //Bank is open Depositing Fish.
  98. if (Game.getOpenInterfaceId() == 5292) {
  99. try{
  100. Bank.depositAllExcept(310,315);
  101. } catch(Exception e) {
  102. e.printStackTrace();
  103. }
  104. Time.sleep(200);
  105. }
  106.  
  107. //Closing Bank Interface
  108. Menu.sendAction(200, 9144, 36, 5384, 1);
  109. }
  110. }
  111. public class Relogger implements Strategy {
  112. public boolean activate() {
  113.  
  114. if (isLoggedIn()) {
  115. return false;
  116. }
  117. System.out.println("Logging In....");
  118. return true;
  119. }
  120.  
  121. public void execute() {
  122. Point login = new Point(452,280);
  123.  
  124. Mouse.getInstance().click(login);
  125. Time.sleep(new SleepCondition() {
  126. @Override
  127. public boolean isValid() {
  128. return isLoggedIn();
  129. }
  130. }, 6000);
  131. }
  132.  
  133. public boolean isLoggedIn() {
  134. try {
  135. return SceneObjects.getNearest().length > 0;
  136. } catch(IllegalArgumentException e) {
  137. // catch
  138. }
  139. return false;
  140.  
  141. }
  142.  
  143. }
  144. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement