Guest User

Untitled

a guest
Dec 13th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.82 KB | None | 0 0
  1. import org.powerbot.core.script.ActiveScript;
  2. import org.powerbot.core.script.job.Task;
  3. import org.powerbot.core.script.job.state.Node;
  4. import org.powerbot.core.script.job.state.Tree;
  5. import org.powerbot.game.api.Manifest;
  6. import org.powerbot.game.api.methods.Walking;
  7. import org.powerbot.game.api.methods.interactive.NPCs;
  8. import org.powerbot.game.api.methods.interactive.Players;
  9. import org.powerbot.game.api.methods.node.GroundItems;
  10. import org.powerbot.game.api.methods.tab.Inventory;
  11. import org.powerbot.game.api.methods.widget.Bank;
  12. import org.powerbot.game.api.methods.widget.Camera;
  13. import org.powerbot.game.api.util.Filter;
  14. import org.powerbot.game.api.util.Random;
  15. import org.powerbot.game.api.wrappers.Area;
  16. import org.powerbot.game.api.wrappers.Entity;
  17. import org.powerbot.game.api.wrappers.Tile;
  18. import org.powerbot.game.api.wrappers.interactive.NPC;
  19. import org.powerbot.game.api.wrappers.map.TilePath;
  20. import org.powerbot.game.api.wrappers.node.GroundItem;
  21.  
  22. @Manifest(authors = { "AMD" }, name = "SpiderSlasher", description = "Kills Spiders and loots Carcass's for mega gp", version = 1.0)
  23. public class SpiderSlasher extends ActiveScript {
  24.  
  25. private Tree jobs = null;
  26.  
  27. @Override
  28. public int loop() {
  29.  
  30. if (jobs == null) {
  31.  
  32. jobs = new Tree(new Node[] { new Attack(), new Pickup(),
  33. new BankingMethod(), new WalkingToBank(),
  34. new WalkingToSpiders() });
  35. }
  36.  
  37. final Node job = jobs.state();
  38.  
  39. if (job != null) {
  40.  
  41. jobs.set(job);
  42. getContainer().submit(job);
  43. job.join();
  44. }
  45.  
  46. return Random.nextInt(200, 400);
  47. }
  48.  
  49. public static final int SPIDER_ID = 62;
  50. public static final int CARCASS_ID = 6291;
  51. public static final int BOOTH_ID = 2213;
  52.  
  53. public static final Area spiderArea = new Area(new Tile[] {
  54. new Tile(2677, 3101, 0), new Tile(2680, 3098, 0),
  55. new Tile(2686, 3088, 0), new Tile(2685, 3085, 0),
  56. new Tile(2684, 3081, 0), new Tile(2681, 3078, 0),
  57. new Tile(2677, 3082, 0), new Tile(2675, 3080, 0),
  58. new Tile(2671, 3081, 0), new Tile(2667, 3083, 0),
  59. new Tile(2665, 3084, 0), new Tile(2661, 3089, 0),
  60. new Tile(2669, 3093, 0), new Tile(2672, 3098, 0) });
  61. public static final Area bankArea = new Area(new Tile[] {
  62. new Tile(2608, 3097, 0), new Tile(2613, 3097, 0),
  63. new Tile(2613, 3089, 0), new Tile(2608, 3088, 0) });
  64. public final static Tile[] pathToBooth = { new Tile(2676, 3093, 0),
  65. new Tile(2677, 3098, 0), new Tile(2679, 3103, 0),
  66. new Tile(2677, 3108, 0), new Tile(2672, 3110, 0),
  67. new Tile(2667, 3111, 0), new Tile(2662, 3112, 0),
  68. new Tile(2657, 3111, 0), new Tile(2652, 3110, 0),
  69. new Tile(2651, 3105, 0), new Tile(2651, 3100, 0),
  70. new Tile(2648, 3096, 0), new Tile(2644, 3093, 0),
  71. new Tile(2642, 3088, 0), new Tile(2637, 3088, 0),
  72. new Tile(2632, 3088, 0), new Tile(2627, 3089, 0),
  73. new Tile(2626, 3094, 0), new Tile(2623, 3098, 0),
  74. new Tile(2621, 3103, 0), new Tile(2616, 3104, 0),
  75. new Tile(2612, 3101, 0), new Tile(2607, 3098, 0),
  76. new Tile(2606, 3093, 0), new Tile(2611, 3093, 0) };
  77.  
  78. public class Attack extends Node {
  79. @Override
  80. public void execute() {
  81. NPC spider = NPCs.getNearest(new Filter<NPC>() {
  82. @Override
  83. public boolean accept(NPC n) {
  84. return (n.getId() == SPIDER_ID);
  85. }
  86. });
  87. if (Players.getLocal().getInteracting() != spider) {
  88. if (spider.validate()) {
  89. if (spider.isOnScreen()) {
  90. if (!spider.isInCombat()) {
  91. spider.interact("Attack");
  92. Task.sleep(2000, 2200);
  93. }
  94. if (spider.isInCombat()) {
  95. Task.sleep(400, 600);
  96. }
  97. }
  98. if (!spider.isOnScreen()) {
  99. Camera.turnTo(spider);
  100. }
  101. }
  102. if (spider.validate()) {
  103. Task.sleep(300, 500);
  104. }
  105. }
  106. }
  107.  
  108. @Override
  109. public boolean activate() {
  110. return spiderArea.contains(Players.getLocal())
  111. && !Inventory.isFull()
  112. && GroundItems.getNearest(CARCASS_ID) == null;
  113. }
  114. }
  115.  
  116. public boolean LootCheck() {
  117. GroundItem g = GroundItems.getNearest(CARCASS_ID);
  118. if (g != null)
  119. ;
  120. return false;
  121. }
  122.  
  123. private class Pickup extends Node {
  124. @Override
  125. public void execute() {
  126. GroundItem gi = GroundItems.getNearest(CARCASS_ID);
  127. if (gi != null) {
  128. if (!gi.isOnScreen()) {
  129. Walking.walk(gi);
  130. Task.sleep(100, 200);
  131. } else {
  132. gi.interact("Take");
  133. Task.sleep(600, 1000);
  134. }
  135. Task.sleep(550, 750);
  136. }
  137. }
  138.  
  139. @Override
  140. public boolean activate() {
  141. if (LootCheck() == true && !Players.getLocal().isInCombat()) {
  142. return true;
  143. } else {
  144. return !Inventory.isFull();
  145. }
  146. }
  147.  
  148. }
  149.  
  150. private class WalkingToBank extends Node {
  151. @Override
  152. public void execute() {
  153. TilePath pathToBank = new TilePath(pathToBooth);
  154. if (pathToBank != null) {
  155. if (pathToBank.traverse()) {
  156. Task.sleep(1500, 2000);
  157. }
  158. }
  159. }
  160.  
  161. @Override
  162. public boolean activate() {
  163. Entity bank = Bank.getNearest();
  164. return bank != null && bank.isOnScreen() && Inventory.isFull();
  165. }
  166. }
  167.  
  168. public class BankingMethod extends Node {
  169. @Override
  170. public void execute() {
  171. if (!Bank.isOpen()) {
  172. Bank.open();
  173. Task.sleep(1000, 1500);
  174. } else {
  175. if (Inventory.getCount(true, CARCASS_ID) > 0) {
  176. Bank.deposit(CARCASS_ID,
  177. Inventory.getCount(true, CARCASS_ID));
  178. Task.sleep(500, 750);
  179. }
  180. }
  181. }
  182.  
  183. @Override
  184. public boolean activate() {
  185. Entity bank = Bank.getNearest();
  186. return bank != null && bank.isOnScreen() && Inventory.isFull();
  187. }
  188. }
  189.  
  190. public class WalkingToSpiders extends Node {
  191.  
  192. @Override
  193. public void execute() {
  194. TilePath path = new TilePath(pathToBooth);
  195. if (path != null) {
  196. path.reverse();
  197. if (path.traverse())
  198. Task.sleep(1500, 2000);
  199. }
  200. }
  201.  
  202. @Override
  203. public boolean activate() {
  204.  
  205. return !spiderArea.contains(Players.getLocal().getLocation())
  206. && !Inventory.isFull();
  207. }
  208.  
  209. }
  210.  
  211. }
Add Comment
Please, Sign In to add comment