Advertisement
Guest User

Untitled

a guest
Aug 19th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.51 KB | None | 0 0
  1. import java.awt.*;
  2.  
  3. import org.rsbot.script.Script;
  4. import org.rsbot.script.ScriptManifest;
  5. import org.rsbot.script.wrappers.RSObject;
  6. import org.rsbot.script.wrappers.RSPath;
  7. import org.rsbot.script.wrappers.RSTile;
  8. import org.rsbot.script.wrappers.RSArea;
  9. import org.rsbot.script.wrappers.RSTilePath;
  10. import org.rsbot.event.listeners.PaintListener;
  11.  
  12. @ScriptManifest(authors = { "Creations" }, keywords = { "KEYWORDS" }, name = "CFungy", version = 1.0, description = "Picks Fungus.")
  13.  
  14. public class CFungusEnums extends Script implements PaintListener {
  15.  
  16. RSTile bankToGate[] = { new RSTile(3509, 3480), new RSTile(3506, 3480),
  17. new RSTile(3503, 3480), new RSTile(3500, 3481),
  18. new RSTile(3497, 3481), new RSTile(3494, 3481),
  19. new RSTile(3491, 3481), new RSTile(3488, 3480),
  20. new RSTile(3486, 3479), new RSTile(3484, 3478),
  21. new RSTile(3481, 3477), new RSTile(3478, 3477),
  22. new RSTile(3475, 3476), new RSTile(3472, 3475),
  23. new RSTile(3469, 3474), new RSTile(3466, 3473),
  24. new RSTile(3464, 3472), new RSTile(3462, 3470),
  25. new RSTile(3459, 3469), new RSTile(3457, 3467),
  26. new RSTile(3454, 3467), new RSTile(3451, 3466),
  27. new RSTile(3448, 3465), new RSTile(3446, 3463),
  28. new RSTile(3444, 3461), new RSTile(3444, 3458),
  29. new RSTile(3443, 3458) };
  30. RSTile PathToDoor[] = { new RSTile(3217, 3219), new RSTile(3223, 3219),
  31. new RSTile(3230, 3219), new RSTile(3232, 3215),
  32. new RSTile(3236, 3211), new RSTile(3241, 3207),
  33. new RSTile(3243, 3207) };
  34. RSTile[] barToBank = { new RSTile(3494, 3475), new RSTile(3494, 3479),
  35. new RSTile(3497, 3480), new RSTile(3500, 3480),
  36. new RSTile(3503, 3480), new RSTile(3506, 3480),
  37. new RSTile(3510, 3480), new RSTile(3512, 3480),
  38. new RSTile(3512, 3478) };
  39. RSTile teletoChurch[] = { new RSTile(3217, 3219),
  40. new RSTile(3223, 3219), new RSTile(3230, 3219),
  41. new RSTile(3232, 3215), new RSTile(3236, 3211),
  42. new RSTile(3241, 3207), new RSTile(3243, 3207) };
  43.  
  44. RSTile gateToFungus = new RSTile(3436, 3453);
  45.  
  46. public int[] gate = {3506, 3507};
  47. public int fungusLog = 3509;
  48. public int log = 3508;
  49. public int fungusID = 2383;
  50. public boolean THROUGH = false;
  51. int k;
  52. int w;
  53.  
  54. RSArea atBank = new RSArea(3512, 3483, 3511, 3477);//NE SW
  55. RSArea atGate = new RSArea(3445, 3459, 3442, 3458);//NE SW
  56. RSArea atPastGate = new RSArea(3444, 3457, 3442, 3456);//NE SW
  57. RSArea atFungusLog = new RSArea(3436, 3453, 3436, 3453);//NE SW
  58.  
  59.  
  60. public int nextenergy;
  61.  
  62. @Override
  63. public void onRepaint(Graphics arg0) {
  64. // TODO Auto-generated method stub
  65.  
  66. }
  67.  
  68. public enum State {
  69. walkToGate, openGate, walkToFungus, bloom, pickFungus, waiting
  70. }
  71.  
  72. private State getState() {
  73. if (!inventory.isFull()) {
  74. if (atLocation()) {
  75. if (logPresent()) {
  76. return State.pickFungus;
  77. } else {
  78. return State.bloom;
  79. }
  80. } else {
  81. if (atGate()) {
  82. return State.openGate;
  83. }
  84.  
  85. return State.walkToFungus;
  86. }
  87. } else {
  88. // do stuff when full?
  89. }
  90. return State.waiting;
  91. }
  92.  
  93. private boolean atGate() {
  94. RSObject g = objects.getNearest(gate);
  95. if (g != null && THROUGH == false) {
  96. return calc.distanceTo(g) < 6;
  97. }
  98. return false;
  99.  
  100. }
  101.  
  102. private boolean logPresent() {
  103. return objects.getNearest(fungusLog) != null;
  104. }
  105.  
  106. private boolean atLocation() {
  107. return atFungusLog.contains(getMyPlayer().getLocation());
  108. }
  109.  
  110.  
  111. private boolean walkThePath(RSTile[] path){
  112. int w = random(4,6);
  113. int k = random(2,4);
  114. int b = k;
  115. int t = w;
  116. boolean D=false;
  117. try{
  118. RSTilePath pathToWalk = walking.newTilePath(path);
  119. RSTile next = pathToWalk.getNext();
  120. RSTile start = pathToWalk.getStart();
  121. if ((walking.getDestination() == null||calc.distanceTo(walking.getDestination()) < t ||calc.distanceBetween(next,walking.getDestination()) > b)) {
  122. if(!walking.walkTileMM(next)){
  123. if(walking.walkTileMM(start)){
  124. sleep(412,565);
  125. D=true;
  126. }else{
  127. walkToTile(walking.getClosestTileOnMap(next));
  128. sleep(random(1000,2000));
  129. }
  130. }else{
  131. sleep(299,565);
  132. D=true;
  133. }
  134. }
  135. return D;
  136. }catch(Exception e ){ log("Caught a Exception in pathToWalk. Saved the script from stopping!"); sleep(554,789); }
  137. return D;
  138. }
  139.  
  140. private boolean walkToTile(RSTile tile){
  141. int q = k;
  142. int i = w;
  143. boolean D = false;
  144. try{
  145. if ((walking.getDestination() == null||(calc.distanceTo(walking.getDestination()) < q &&calc.distanceBetween(tile,walking.getDestination()) > i))) {
  146. if(calc.tileOnScreen(tile)){
  147. if(walking.walkTileOnScreen(tile))
  148. D = true;
  149. }else if(calc.tileOnMap(tile)){
  150. if(walking.walkTileMM(tile))
  151. D = true;
  152. }else{
  153. if(walkToTile(walking.getClosestTileOnMap(tile)))
  154. D = true;
  155. }
  156. sleep(random(1000,2000));
  157. }
  158. return D;
  159. }catch(Exception e){ log("Caught an Exception in walkToTile. Saved the script from stopping!"); sleep(554,789); }
  160. return D;
  161. }
  162.  
  163.  
  164. public int loop() {
  165. switch(getState()) {
  166. case walkToGate:
  167. walkThePath(bankToGate);
  168. break;
  169. case openGate:
  170. objects.getNearest(gate).doAction("Open");
  171. THROUGH = true;
  172. break;
  173.  
  174. case walkToFungus:
  175. walking.walkTileMM(gateToFungus, 0, 0);
  176. break;
  177.  
  178. case bloom:
  179. game.openTab(5);
  180. sleep(100);
  181. interfaces.get(387).getComponent(17).doAction("Bloom");
  182. sleep(2600);
  183.  
  184. break;
  185.  
  186. case pickFungus:
  187. objects.getNearest(fungusLog).doAction(
  188. "Pick Fungi");
  189. break;
  190.  
  191. case waiting:
  192. sleep(random(300,600));
  193. break;
  194. }
  195. return 590;
  196. }
  197. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement