Guest User

Untitled

a guest
Jun 25th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.40 KB | None | 0 0
  1. import java.awt.*;
  2.  
  3. import org.rsbot.event.listeners.PaintListener;
  4.  
  5. import org.rsbot.script.*;
  6.  
  7. import org.rsbot.script.wrappers.*;
  8.  
  9.  
  10. @ScriptManifest(authors = {"Striker"}, keywords = {""}, name = "YellowDyes",
  11.  
  12. description = "Gets Dyes", version = 0.1)
  13.  
  14.  
  15. public class YellowDyes extends Script implements PaintListener {
  16.  
  17.  
  18.  
  19. int onionID = 1957;
  20.  
  21. int dyeID = 1765;
  22.  
  23. int coins = 995;
  24.  
  25. int aggieID = 922;
  26.  
  27.  
  28.  
  29. int dyesGot, profit, profith, dyesAtm, dyePrice, onionPrice;
  30.  
  31. public long runtime, starttime, millis, seconds, minutes, hours;
  32.  
  33.  
  34.  
  35. private boolean atAggie() {
  36.  
  37. RSNPC aggie = npcs.getNearest(aggieID);
  38.  
  39. if (aggie != null) {
  40.  
  41. if (aggie.isOnScreen()) {
  42.  
  43. return true;
  44.  
  45. }
  46.  
  47. }
  48.  
  49. return false;
  50.  
  51. }
  52.  
  53.  
  54.  
  55. private boolean atBank() {
  56.  
  57. RSArea area = new RSArea(new RSTile(3092, 3242), new RSTile(3095, 3250));
  58.  
  59. return area.contains(getMyPlayer().getLocation());
  60.  
  61. }
  62.  
  63.  
  64.  
  65. public void getDye() {
  66.  
  67. RSNPC aggie = npcs.getNearest(aggieID);
  68.  
  69. if (aggie != null) {
  70.  
  71. if (aggie.isOnScreen()) {
  72.  
  73. if (!interfaces.canContinue()) {
  74.  
  75. if (!interfaces.get(230).isValid()) {
  76.  
  77. aggie.doAction("dyes");
  78.  
  79. sleep(500, 1000);
  80.  
  81. }
  82.  
  83. } else {
  84.  
  85. if (!interfaces.get(519).isValid()) {
  86.  
  87. interfaces.clickContinue();
  88.  
  89. sleep(400, 500);
  90.  
  91. }
  92.  
  93. }
  94.  
  95. if (interfaces.get(230).isValid()) {
  96.  
  97. interfaces.getComponent(230, 4).doClick();
  98.  
  99. sleep(500, 700);
  100.  
  101. }
  102.  
  103. if (interfaces.get(519).isValid()) {
  104.  
  105. if (inventory.contains(onionID)) {
  106.  
  107. aggie.doAction("dyes");
  108.  
  109. sleep(500, 1000);
  110.  
  111. }
  112.  
  113. }
  114.  
  115. }
  116.  
  117. }
  118.  
  119. }
  120.  
  121.  
  122.  
  123. public void walkBank() {
  124.  
  125. if (!getMyPlayer().isMoving()) {
  126.  
  127. walking.walkTileMM(new RSTile(3093, 3245).randomize(2, 2));
  128.  
  129. sleep(1000, 1500);
  130.  
  131. }
  132.  
  133. }
  134.  
  135.  
  136.  
  137. public void walkAggie() {
  138.  
  139. if (!getMyPlayer().isMoving()) {
  140.  
  141. walking.walkTileMM(new RSTile(3085, 3260).randomize(2, 2));
  142.  
  143. sleep(1000, 1500);
  144.  
  145. }
  146.  
  147. }
  148.  
  149.  
  150.  
  151. public void bank() {
  152.  
  153. bank.open();
  154.  
  155. sleep(500, 1000);
  156.  
  157. if (bank.isOpen()) {
  158.  
  159. bank.depositAllExcept(coins);
  160.  
  161. sleep(500, 700);
  162.  
  163. if (inventory.getCount(onionID) <= 2 && bank.getItem(onionID) != null) {
  164.  
  165. bank.withdraw(onionID, 26);
  166.  
  167. sleep(200, 500);
  168.  
  169. } else {
  170.  
  171. log ("Out of onions");
  172.  
  173. bank.close();
  174.  
  175. sleep(200, 500);
  176.  
  177. stopScript();
  178.  
  179. }
  180.  
  181. }
  182.  
  183. }
  184.  
  185.  
  186.  
  187. @Override
  188.  
  189. public boolean onStart() {
  190.  
  191. dyesAtm = inventory.getCount(dyeID);
  192.  
  193. dyePrice = grandExchange.lookup(dyeID).getGuidePrice();
  194.  
  195. onionPrice = grandExchange.lookup(onionID).getGuidePrice();
  196.  
  197. starttime = System.currentTimeMillis();
  198.  
  199. log("Onion price: " + onionPrice + " " + "Dye price: " + dyePrice);
  200.  
  201. log("Profit per dye: " + (dyePrice - (2 * onionPrice) - 5));
  202.  
  203. return true;
  204.  
  205. }
  206.  
  207.  
  208.  
  209. @Override
  210.  
  211. public int loop() {
  212.  
  213. if (!inventory.contains(coins)) {
  214.  
  215. log("No coins in inventory, stopping.");
  216.  
  217. stopScript();
  218.  
  219. }
  220.  
  221. if (!walking.isRunEnabled() && walking.getEnergy() > random(30, 40)) {
  222.  
  223. walking.setRun(true);
  224.  
  225. sleep(300, 1000);
  226.  
  227. }
  228.  
  229. RSObject door = objects.getTopAt(new RSTile(3088, 3259));
  230.  
  231. if (door != null) {
  232.  
  233. door.doClick();
  234.  
  235. sleep(300, 500);
  236.  
  237. }
  238.  
  239. if (inventory.getCount(onionID) >= 2 ) {
  240.  
  241. if (atAggie()) {
  242.  
  243. getDye();
  244.  
  245. } else {
  246.  
  247. walkAggie();
  248.  
  249. }
  250.  
  251. } else {
  252.  
  253. if (atBank()) {
  254.  
  255. bank();
  256.  
  257. } else {
  258.  
  259. walkBank();
  260.  
  261. }
  262.  
  263. }
  264.  
  265. return random(200, 400);
  266.  
  267. }
  268.  
  269. //START: Code generated using Enfilade's Easel
  270.  
  271. private final Color color2 = new Color(0, 0, 0, 180);
  272.  
  273.  
  274. private final BasicStroke stroke1 = new BasicStroke(1);
  275.  
  276.  
  277. private final Font font1 = new Font("Arial", 0, 11);
  278.  
  279.  
  280. public void onRepaint(Graphics g1) {
  281.  
  282. millis = System.currentTimeMillis() - starttime;
  283.  
  284. hours = millis / (1000 * 60 * 60);
  285.  
  286. millis -= hours * (1000 * 60 * 60);
  287.  
  288. minutes = millis / (1000 * 60);
  289.  
  290. millis -= minutes * (1000 * 60);
  291.  
  292. seconds = millis / 1000;
  293.  
  294. runtime = System.currentTimeMillis() - starttime;
  295.  
  296. profit = dyesGot * (dyePrice - (2 * onionPrice) - 5);
  297.  
  298. profith = + (int) (profit * 3600000D / runtime);
  299.  
  300. Graphics2D g = (Graphics2D)g1;
  301.  
  302. g.setColor(new Color(0, 0, 0, 180));
  303.  
  304. g.fillRoundRect(29, 32, 137, 109, 16, 16);
  305.  
  306. g.setColor(color2);
  307.  
  308. g.setStroke(stroke1);
  309.  
  310. g.drawRoundRect(29, 32, 137, 109, 16, 16);
  311.  
  312. g.setFont(new Font("Tahoma", Font.BOLD, 11));
  313.  
  314. g.setColor(Color.RED);
  315.  
  316. g.drawString("YellowDyes By Striker", 36, 46);
  317.  
  318. g.setColor(Color.WHITE);
  319.  
  320. g.setFont(font1);
  321.  
  322. g.drawString("Time: " + hours + ":" + minutes + ":" + seconds, 36, 66);
  323.  
  324. g.drawString("Dyes got: " + dyesGot , 36, 88);
  325.  
  326. g.drawString("Profit: " + profit, 37, 110);
  327.  
  328. g.drawString("Profit/h: " + profith, 37, 134);
  329.  
  330.  
  331.  
  332. if (dyesAtm > inventory.getCount(dyeID)) {
  333.  
  334. dyesAtm = inventory.getCount(dyeID);
  335.  
  336. } else if (dyesAtm < inventory.getCount(dyeID)) {
  337.  
  338. dyesGot++;
  339.  
  340. dyesAtm = inventory.getCount(dyeID);
  341.  
  342. }
  343.  
  344. }
  345.  
  346. //END: Code generated using Enfilade's Easel
  347.  
  348. }
Add Comment
Please, Sign In to add comment