Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.10 KB | None | 0 0
  1. import java.awt.BasicStroke;
  2. import java.awt.Color;
  3. import java.awt.Font;
  4. import java.awt.Graphics;
  5. import java.awt.Graphics2D;
  6.  
  7. import org.rsbuddy.net.GeItem;
  8. import org.rsbuddy.tabs.Inventory;
  9. import org.rsbuddy.widgets.Bank;
  10.  
  11. import com.rsbuddy.event.events.MessageEvent;
  12. import com.rsbuddy.event.listeners.MessageListener;
  13. import com.rsbuddy.event.listeners.PaintListener;
  14. import com.rsbuddy.script.ActiveScript;
  15. import com.rsbuddy.script.Manifest;
  16. import com.rsbuddy.script.methods.Calculations;
  17. import com.rsbuddy.script.methods.Camera;
  18. import com.rsbuddy.script.methods.Game;
  19. import com.rsbuddy.script.methods.Mouse;
  20. import com.rsbuddy.script.methods.Objects;
  21. import com.rsbuddy.script.methods.Players;
  22. import com.rsbuddy.script.methods.Skills;
  23. import com.rsbuddy.script.methods.Walking;
  24. import com.rsbuddy.script.util.Random;
  25. import com.rsbuddy.script.wrappers.Area;
  26. import com.rsbuddy.script.wrappers.GameObject;
  27. import com.rsbuddy.script.wrappers.Item;
  28. import com.rsbuddy.script.wrappers.Tile;
  29.  
  30. @Manifest(name = "WaterCrafterPro", authors = "skutr3")
  31. public class WaterCrafterPro extends ActiveScript implements MessageListener,
  32. PaintListener {
  33.  
  34. Area altarArea = new Area(new Tile(3477, 4830), new Tile(3498, 4844));
  35. Area bankArea = new Area(new Tile(3092, 3240), new Tile(3096, 3246));
  36. Area ruinArea = new Area(new Tile(3180, 3160), new Tile(3190, 3169));
  37. int runeEssence = 1436;
  38. int ruinID = 2454;
  39. int waterAltar = 2480;
  40. int portalID = 2467;
  41. int waterRune = 555;
  42. Tile bankTile = new Tile(3093, 3243);
  43. Tile ruinTile = new Tile(3183, 3162);
  44. Tile altarTile = new Tile(3488, 4834);
  45. Tile portalTile = new Tile(3490, 4833);
  46. private String Status = "Unknown";
  47. long startXp = 0;
  48. long currentXp = 0;
  49. long gainedXp = 0;
  50. long numOfRuns = 0;
  51. String word = "runs";
  52. long startTime = 0;
  53.  
  54. public boolean onStart() {
  55. startTime = System.currentTimeMillis();
  56. Mouse.setSpeed(5);
  57. log("Welcome to a script that Crafts Waters in a PROFESSIONAL MANNER");
  58. startXp = Skills.getCurrentExp(Skills.RUNECRAFTING);
  59. log("Water Runes are " + GeItem.lookup("Water Rune").getGuidePrice()
  60. + "gp");
  61.  
  62. return true;
  63. }
  64.  
  65. public void onFinish() {
  66. if (numOfRuns == 1) {
  67. word = "run";
  68. }
  69.  
  70. log("You made " + numOfRuns + " " + word);
  71. log("Hope you made lots of money");
  72. log("Goodbye");
  73.  
  74. }
  75.  
  76. public enum State {
  77. WALK_TO_RUIN, ENTER_RUIN, CRAFT, EXIT_RUIN, WALK_TO_BANK, BANK, WAITING
  78. }
  79.  
  80. public State getState() {
  81.  
  82. if (Inventory.getCount(runeEssence) > 0 && !atRuin() && !atAltar()) {
  83. return State.WALK_TO_RUIN;
  84. } else if (atRuin() && Inventory.getCount(runeEssence) > 0) {
  85. return State.ENTER_RUIN;
  86. } else if (Inventory.getCount(runeEssence) > 0 && atAltar()) {
  87. return State.CRAFT;
  88. } else if (Inventory.getCount(runeEssence) == 0 && !atRuin()
  89. && atAltar()) {
  90. return State.EXIT_RUIN;
  91. } else if (!atBank() && Inventory.getCount(waterRune) > 0) {
  92. return State.WALK_TO_BANK;
  93. } else if (atBank() && Inventory.getCount(waterRune) > 0
  94. || Inventory.getCount(runeEssence) == 0) {
  95. return State.BANK;
  96. }
  97. return State.WAITING;
  98. }
  99.  
  100. @Override
  101. public int loop() {
  102. switch (getState()) {
  103. case WALK_TO_RUIN:
  104. antiban();
  105. walkToRuin();
  106. break;
  107. case ENTER_RUIN:
  108. enterRuin();
  109. break;
  110. case CRAFT:
  111. walkUpToAltar();
  112. craftRunes();
  113. break;
  114. case EXIT_RUIN:
  115. exitRuins();
  116. break;
  117. case WALK_TO_BANK:
  118. walkToBank();
  119. break;
  120. case BANK:
  121. bank();
  122. break;
  123. }
  124.  
  125. return 590;
  126.  
  127. }
  128.  
  129. public void messageReceived(MessageEvent e) {
  130. if (e != null) { // not needed, if messageevent catches something, then
  131. // theres something there
  132. if (e.getMessage()
  133. .contains(
  134. "The Lumbridge ring sparkles to life, creating more runes for you.")) {
  135. log("Run Complete! You gained "
  136. + Inventory.getCount(runeEssence)
  137. * GeItem.lookup("Water Rune").getGuidePrice() + " gp");
  138. }
  139. }
  140. if (e != null) {
  141. if (e.getMessage()
  142. .contains(
  143. "The Lumbridge ring sparkles to life, creating more runes for you.")) {
  144. numOfRuns++;
  145. }
  146. }
  147. }
  148.  
  149. // START: Code generated using Enfilade's Easel
  150. private final Color color1 = new Color(255, 255, 255, 127);
  151. private final Color color2 = new Color(0, 0, 0);
  152. private final Color color3 = new Color(5, 20, 6);
  153.  
  154. private final BasicStroke stroke1 = new BasicStroke(1);
  155.  
  156. private final Font font1 = new Font("SansSerif", 0, 15);
  157. private final Font font2 = new Font("SansSerif", 0, 14);
  158. private final Font font3 = new Font("SansSerif", 0, 13);
  159.  
  160. public void onRepaint(Graphics g) {
  161.  
  162. }
  163.  
  164. /*
  165. * public void onRepaint(Graphics g1) {
  166. *
  167. * currentXp = Skills.getCurrentExp(Skills.RUNECRAFTING); gainedXp =
  168. * currentXp - startXp;
  169. *
  170. * long millis = System.currentTimeMillis() - startTime; long hours = millis
  171. * / (1000 * 60 * 60); millis -= hours * (1000 * 60 * 60); long minutes =
  172. * millis / (1000 * 60); millis -= minutes * (1000 * 60); long seconds =
  173. * millis / 1000;
  174. *
  175. * Graphics2D g = (Graphics2D) g1; g.setColor(color1); g.fillRoundRect(545,
  176. * 205, 191, 260, 16, 16); g.setColor(color2); g.setStroke(stroke1);
  177. * g.drawRoundRect(545, 205, 191, 260, 16, 16); g.setFont(font1);
  178. * g.setColor(color3); g.drawString("WaterCrafterPro ", 555, 233);
  179. * g.setFont(font2); g.drawString("[BETA] by skutr3", 559, 259);
  180. * g.setFont(font3); g.drawString("Status: " + getStatus(), 561, 308);
  181. * g.drawString("Time Running: " + hours + ":" + minutes + ":" + seconds +
  182. * ".", 560, 346); g.drawString("XP Gained: " + gainedXp, 556, 391);
  183. * drawMouse(g); }
  184. */
  185.  
  186. // END: Code generated using Enfilade's Easel
  187.  
  188. boolean atBank() {
  189. return bankArea.contains(Players.getLocal().getLocation());
  190. }
  191.  
  192. boolean atRuin() {
  193. return ruinArea.contains(Players.getLocal().getLocation());
  194. }
  195.  
  196. boolean atAltar() {
  197. return altarArea.contains(Players.getLocal().getLocation());
  198. }
  199.  
  200. public void enterRuin() {
  201. setStatus("Entering");
  202. GameObject ruin = Objects.getNearest(ruinID);
  203. if (ruin != null && ruin.isOnScreen()) {
  204. ruin.interact("Enter");
  205. sleep(750, 1000);
  206.  
  207. }
  208. }
  209.  
  210. public void walkToRuin() {
  211. setStatus("Walking");
  212.  
  213. Walking.findPath(ruinTile).traverse();
  214. }
  215.  
  216. public void walkToBank() {
  217. setStatus("Walking");
  218. Walking.findPath(bankTile).traverse();
  219. }
  220.  
  221. public void craftRunes() {
  222. setStatus("Crafting");
  223. GameObject altar = Objects.getNearest(waterAltar);
  224. if (Players.getLocal().getAnimation() == -1 && altar != null) {
  225. altar.interact("Craft-rune");
  226. sleep(750, 1000);
  227. }
  228. }
  229.  
  230. public void exitRuins() {
  231. setStatus("Exiting");
  232.  
  233. GameObject portal = Objects.getNearest(portalID);
  234. if (portal != null) {
  235. if (!portal.isOnScreen()) {
  236. Walking.findPath(portalTile).traverse();
  237. }
  238. }
  239. if (portal != null) {
  240. if (portal.isOnScreen()) {
  241. portal.interact("Enter");
  242. sleep(1500, 2000);
  243. } else {
  244. Camera.turnTo(portal);
  245. }
  246. }
  247. }
  248.  
  249. public void bank() {
  250. setStatus("Banking");
  251.  
  252. if (!Bank.isOpen()) {
  253. Bank.open();
  254. }
  255.  
  256. if (Inventory.contains(waterRune)) {
  257. Bank.depositAll();
  258. sleep(350, 500);
  259. }
  260. if (!Inventory.contains(runeEssence)) {
  261. // Bank.search("Rune Essence");
  262. withdrawAll(runeEssence);
  263. sleep(750, 1500);
  264. }
  265. Bank.close();
  266. }
  267.  
  268. public void depositAllOf(int i) {
  269. Item i2 = Inventory.getItem(i);
  270. if (i2 != null) {
  271. i2.interact("Deposit-All");
  272. }
  273.  
  274. }
  275.  
  276. public void withdrawAll(int i) {
  277. Item i2 = Bank.getItem(i);
  278. if (i2 != null) {
  279. i2.interact("Withdraw-All");
  280. }
  281. }
  282.  
  283. public void walkUpToAltar() {
  284. setStatus("Preparing to craft");
  285. if (Calculations.distanceTo(altarTile) < 10) {
  286. altarTile.clickOnMap();
  287. } else {
  288. Walking.findPath(altarTile).traverse();
  289.  
  290. }
  291.  
  292. }
  293.  
  294. public String getStatus() {
  295. return Status;
  296. }
  297.  
  298. private void drawMouse(Graphics g) {
  299. int x = Mouse.getLocation().x, y = Mouse.getLocation().y;
  300.  
  301. g.setColor(System.currentTimeMillis() - Mouse.getPressTime() < 300 ? Color.BLACK
  302. : Color.WHITE);
  303. g.fillOval(x - 6, y - 6, 12, 12);
  304. g.setColor(Color.BLACK);
  305. g.fillOval(x - 3, y - 3, 6, 6);
  306. g.drawLine(x - 10, y - 10, x + 10, y + 10);
  307. g.drawLine(x - 10, y + 10, x + 10, y - 10);
  308. }
  309.  
  310. public void setStatus(String s) {
  311. Status = s;
  312. }
  313.  
  314. public void antiban() {
  315.  
  316. int b = Random.nextInt(0, 10);
  317. switch (b) {
  318. case 1:
  319. if (Random.nextInt(0, 10) == 5) {
  320. log("[Antiban] move mouse");
  321.  
  322. Mouse.moveSlightly();
  323. sleep(200, 600);
  324. Mouse.moveRandomly(150, 350);
  325. }
  326. break;
  327. case 2:
  328. if (Random.nextInt(0, 13) == 2) {
  329.  
  330. log("[Antiban] Turn screen");
  331.  
  332. Camera.setCompassAngle(Random.nextInt(30, 70));
  333. sleep(400, 1200);
  334.  
  335. }
  336. break;
  337. case 3:
  338. if (Random.nextInt(0, 24) == 6) {
  339.  
  340. log("[Antiban] mouse off screen");
  341. Mouse.moveOffScreen();
  342. sleep(Random.nextInt(600, Random.nextInt(1200, 2000)));
  343. }
  344. break;
  345. case 4:
  346. if (Random.nextInt(0, 18) == 3) {
  347.  
  348. log("[antiban] Checking Xp.");
  349. Game.openTab(1);
  350. Skills.hover(Skills.COMPONENT_RUNECRAFTING);
  351. sleep(Random.nextInt(2100, 3400));
  352. }
  353. break;
  354. default:
  355. break;
  356. }
  357. }
  358.  
  359. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement