Guest User

snapeloot

a guest
Oct 17th, 2020
21
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.awt.Color;
  2. import java.awt.Graphics2D;
  3. import java.util.ArrayList;
  4. import java.util.List;
  5. import java.util.function.BooleanSupplier;
  6.  
  7. import org.osbot.rs07.api.map.Area;
  8. import org.osbot.rs07.api.map.Position;
  9. import org.osbot.rs07.api.model.GroundItem;
  10. import org.osbot.rs07.api.ui.Message;
  11. import org.osbot.rs07.script.Script;
  12. import org.osbot.rs07.script.ScriptManifest;
  13.  
  14. @ScriptManifest(author = "ironmanscripting", name = "Snape Grass Looter", info = "Loots snape grass in East Hosidius from the 10 spawn area", version = 1, logo = "")
  15. public final class SnapeLooter extends Script {
  16.  
  17. String currentState;
  18. public final Position bankTile = new Position(1809, 3564, 0);
  19. public final Position snapeTile = new Position(1836, 3641, 0);
  20.  
  21. @Override
  22. public final void onStart() {
  23. currentState = "Starting script...";
  24. }
  25.  
  26. public void hopWorld() throws InterruptedException {
  27. int oldWorld = getWorlds().getCurrentWorld();
  28. if (getWorlds().hopToP2PWorld()) {
  29. Sleep.sleepUntil(() -> getWorlds().getCurrentWorld() != oldWorld && getClient().isLoggedIn(), 7000);
  30. }
  31. }
  32.  
  33. public void handleBank() throws InterruptedException {
  34. if (!getBank().isOpen()){ //If the bank is not open
  35. getBank().open(); //Opens bank chests, booths, etc.
  36. if (getBank().isOpen()) {
  37. getBank().depositAll();
  38. if (getBank().close()) {
  39. Sleep.sleepUntil(() -> !getBank().isOpen(), 4000);
  40. }
  41. }
  42. }
  43. }
  44.  
  45. public boolean findsnapes() {
  46. GroundItem i = getGroundItems().closest("Snape Grass");
  47. return i != null && map.canReach(i) && map.distance(i) <= 15;
  48. }
  49.  
  50. public void lootsnapes() {
  51. GroundItem i = getGroundItems().closest("Snape Grass");
  52. if (i != null && map.canReach(i) && map.distance(i) <= 15) {
  53. if (i.interact("Take")) {
  54. Sleep.sleepUntil(() -> !i.exists() || i == null || getInventory().isFull(), 9000);
  55. }
  56. }
  57. }
  58.  
  59. @Override
  60. public final int onLoop() throws InterruptedException {
  61.  
  62. if (getInventory().isFull()) {
  63. if (bankTile.distance(myPlayer().getPosition()) <= 2) {
  64. currentState = "Depositing";
  65. handleBank();
  66. } else {
  67. currentState = "Navigating to bank";
  68. getWalking().webWalk(bankTile);
  69. }
  70. } else {
  71. if (snapeTile.distance(myPlayer().getPosition()) <= 7) {
  72. if (findsnapes()) {
  73. currentState = "Looting Snape Grass";
  74. lootsnapes();
  75. } else {
  76. currentState = "No Grass, hop world";
  77. hopWorld();
  78. }
  79. } else {
  80. currentState = "Running to snapes";
  81. getWalking().webWalk(snapeTile);
  82. }
  83. }
  84.  
  85. return random(50, 500);
  86. }
  87.  
  88. @Override
  89. public final void onExit() {
  90. log("Script terminated! :)");
  91. }
  92.  
  93. @Override
  94. public final void onMessage(final Message message) {
  95. // log("New msg: " + message.getMessage());
  96. }
  97.  
  98. @Override
  99. public void onPaint(final Graphics2D g) {
  100. g.drawString("Snape Looter v0.1", 12, 130);
  101. g.drawString("A modified version of Rare Scripts Barbarian Plank Looter", 12, 150);
  102. g.drawString("State: " + currentState, 12, 170);
  103. }
  104.  
  105. }
RAW Paste Data