Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.43 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. import java.awt.Point;
  7. import java.text.NumberFormat;
  8.  
  9. import org.rsbot.event.events.MessageEvent;
  10. import org.rsbot.event.listeners.MessageListener;
  11. import org.rsbot.event.listeners.PaintListener;
  12. import org.rsbot.script.Script;
  13. import org.rsbot.script.ScriptManifest;
  14. import org.rsbot.script.wrappers.RSArea;
  15. import org.rsbot.script.wrappers.RSItem;
  16. import org.rsbot.script.wrappers.RSObject;
  17. import org.rsbot.script.wrappers.RSTile;
  18. import org.rsbot.script.wrappers.RSTilePath;
  19.  
  20. @ScriptManifest(authors = "Robert G", keywords = "Moneymaking", name = "PastryDoughPro", description = "Make's Pastry dough.", version = 1.3)
  21. /**
  22. * PastryDoughPro by Robert G
  23. * v1.1
  24. * Now fills buckets from fountain in edgeville
  25. * v1.3
  26. * Made banking better.
  27. * Made script run smoother.
  28. * Added dough's per hour to paint.
  29. * I can't fix the profit per hour as it fetche's data from
  30. * the rs ge and for some reason it come's back wrong.
  31. *
  32. */
  33. public class PastryDoughPro extends Script implements PaintListener, MessageListener {
  34.  
  35. private int[] theseID = { 1925, 1929 };
  36. private int bucketID = 1925;
  37. private int bwaterID = 1929;
  38. private int pflourID = 1933;
  39. private int pdoughID = 1953;
  40. public int bboothID = 11758;
  41. private int[] doughkit = { 1929, 1933 };
  42. private int pastry = 0;
  43. private int pastrydoughPrice;
  44. public int bucketofwaterPrice;
  45. private int potofflourPrice;
  46. private static int profit;
  47. private static int profitPerHour;
  48. private static int doughsPerHour;
  49. boolean makingDough = false;
  50. boolean fillingBuckets = false;
  51. private static NumberFormat numberFormatProfit = NumberFormat.getInstance();
  52.  
  53. String addZero = "", addZero2 = "";
  54.  
  55. public long startTime = System.currentTimeMillis(); // timer
  56. long runTime, seconds, minutes = 0, hours = 0;
  57. long runTime2, seconds2, minutes2 = 0, hours2 = 0;
  58.  
  59. public static class constants {
  60. public static final int bucket = 1925;
  61. public static final int well = 26945;
  62. }
  63.  
  64. // Areas---------------------------------------------------
  65. RSArea well_area = new RSArea(new RSTile(3083, 3499),
  66. new RSTile(3086, 3502));
  67. RSArea bank_area = new RSArea(new RSTile(3090, 3487),
  68. new RSTile(3099, 3500));
  69. // Paths---------------------------------------------------
  70. RSTile[] tilesTobank = { new RSTile(3089, 3501), new RSTile(3093, 3497), new RSTile(3097, 3496) };
  71. RSTilePath pathTobank;
  72. RSTile[] tilesTowell = { new RSTile(3089, 3502), new RSTile(3085, 3501) };
  73. RSTilePath pathTowell;
  74.  
  75. public boolean onStart() {
  76. mouse.setSpeed(random(5, 6));
  77. startTime = System.currentTimeMillis();
  78. numberFormatProfit.setParseIntegerOnly(false);
  79. pastrydoughPrice = grandExchange.lookup(pdoughID).getGuidePrice();
  80. bucketofwaterPrice = grandExchange.lookup(bwaterID).getGuidePrice();
  81. potofflourPrice = grandExchange.lookup(pflourID).getGuidePrice();
  82. pathTobank = walking.newTilePath(tilesTobank);
  83. pathTowell = walking.newTilePath(tilesTowell);
  84. log("Welcome to PastryDoughPro!");
  85. return true;
  86. }
  87.  
  88. private boolean atBank() {
  89. if (bank_area.contains(getMyPlayer().getLocation())) {
  90. return true;
  91. }
  92. return false;
  93. }
  94.  
  95. private boolean flourCheck() {
  96. if (inventory.getCount(pflourID) == 0) {
  97. makingDough = false;
  98. return true;
  99. }
  100. return false;
  101.  
  102. }
  103.  
  104. private boolean atWell() {
  105. if (well_area.contains(getMyPlayer().getLocation())) {
  106. return true;
  107. }
  108. return false;
  109. }
  110.  
  111. private void walk2bank() {
  112. pathTobank.traverse();
  113. }
  114.  
  115. private void walk2well() {
  116. pathTowell.traverse();
  117. }
  118.  
  119. @Override
  120. public void onFinish() {
  121. env.saveScreenshot(true);
  122. log("Thanks for PastryDoughPro");
  123. }
  124.  
  125. private void fillBuckets() {
  126. RSItem bucket = inventory.getItem(bucketID);
  127. if (!inventory.isItemSelected()) {
  128. bucket.doClick(true);
  129. sleep(random(800, 1000));
  130. }
  131. if (inventory.isItemSelected()) {
  132. RSObject well = objects.getNearest(constants.well);
  133. well.doAction("use");
  134. sleep(random(800, 1000));
  135. fillingBuckets = true;
  136. }
  137.  
  138. }
  139.  
  140. private void makePastry() {
  141. RSItem flour = inventory.getItem(pflourID);
  142. RSItem bucket = inventory.getItem(bwaterID);
  143. if (!inventory.isItemSelected()) {
  144. flour.doClick(true);
  145. sleep(random(600, 800));
  146. }
  147. bucket.doClick(true);
  148. if (interfaces.getComponent(905, 15).isValid()){
  149. interfaces.getComponent(905, 15).doClick();
  150. sleep(random(800, 1000));
  151. makingDough = true;
  152. }
  153.  
  154. }
  155.  
  156. private void bank() {
  157. if (!bank.open()) {
  158. bank.open();
  159. sleep(1000, 1200);
  160. }
  161. if (bank.open()) {
  162. bank.depositAllExcept(theseID);
  163. sleep(1000, 1200);
  164. if (bank.getCount(pflourID) == 0 && inventory.getCount(pflourID) == 8) {
  165. log.severe("Ran out of flour!");
  166. stopScript(true);
  167. log("You made " + pastry + " in " + runTime);
  168. log("making a total profit of " + profit + ".");
  169. }
  170. if (!inventory.contains(pflourID)) {
  171. bank.withdraw(pflourID, 9);
  172. sleep(600, 1200);
  173. }
  174. if (inventory.contains(pflourID)) {
  175. bank.close();
  176. }
  177. }
  178.  
  179. }
  180.  
  181. private void setRun() {
  182. if (!walking.isRunEnabled() && walking.getEnergy() > 50) {
  183. walking.setRun(true);
  184. return;
  185. }
  186. }
  187.  
  188. public void antibanB() {
  189.  
  190. int b = random(0, 10);
  191. switch (b) {
  192. case 1:
  193. if (random(0, 10) == 5) {
  194. log("[Antiban] move mouse");
  195. mouse.moveSlightly();
  196. sleep(200, 600);
  197. mouse.moveRandomly(150, 350);
  198. }
  199. break;
  200. case 2:
  201. if (random(0, 13) == 2) {
  202. log("[Antiban] Turn screen");
  203. camera.setAngle(random(30, 70));
  204. sleep(400, 1200);
  205.  
  206. }
  207. break;
  208. case 3:
  209. if (random(0, 24) == 6) {
  210. log("[Antiban] mouse off screen");
  211. mouse.moveOffScreen();
  212. sleep(random(1200, 2000));
  213. }
  214. break;
  215. case 5:
  216. if (random(0, 30) == 4) {
  217. log("[antiban] Setting camera pitch.");
  218. camera.setPitch(random(10, 99));
  219. sleep(random(4500, 5400));
  220. }
  221. break;
  222. default:
  223. break;
  224. }
  225. }
  226.  
  227.  
  228. @Override
  229. public int loop() {
  230. antibanB();
  231. setRun();
  232. flourCheck();
  233. if (interfaces.getComponent(905, 15).isValid()){
  234. interfaces.getComponent(905, 15).doClick();
  235. sleep(random(800, 1000));
  236. makingDough = true;
  237. }
  238. if (fillingBuckets) {
  239. antibanB();
  240. }
  241. if (makingDough) {
  242. antibanB();
  243. }
  244. if (inventory.getCount(bucketID) == 0) {
  245. fillingBuckets = false;
  246. }
  247. if (atBank() && !inventory.contains(pflourID)) {
  248. bank();
  249. return random(800, 1000);
  250. }
  251. if (atBank() && !makingDough && inventory.containsAll(doughkit)) {
  252. makePastry();
  253. return random(1000, 1200);
  254. }
  255. if (inventory.contains(pflourID) && !atWell()) {
  256. if (inventory.getCount(bucketID) == 9)
  257. walk2well();
  258. return random(1200, 1400);
  259. }
  260. if (atWell() && !makingDough && inventory.getCount(bucketID) == 9) {
  261. fillBuckets();
  262. return random(1000, 1200);
  263. }
  264. if (atWell() && !fillingBuckets && !makingDough && inventory.containsAll(doughkit)) {
  265. makePastry();
  266. return random(1000, 1200);
  267. }
  268. if (atWell() && !makingDough && inventory.getCount(bucketID) == 9) {
  269. fillBuckets();
  270. return random(1000, 1200);
  271. }
  272. if (!atBank() && !inventory.contains(pflourID)) {
  273. if (inventory.getCount(bwaterID) == 9) {
  274. walk2bank();
  275. }
  276. return random(1000, 1200);
  277. }
  278.  
  279. return 0;
  280.  
  281. }
  282.  
  283. public void messageReceived(MessageEvent e) {
  284. String x = e.getMessage().toLowerCase();
  285. if (x.contains("mix the water and flour"))
  286. pastry++;
  287. }
  288. //START: Code generated using Enfilade's Easel
  289. private final Color color1 = new Color(51, 0, 51);
  290. private final Color color2 = new Color(255, 255, 255, 60);
  291. private final Color color3 = new Color(0, 0, 0);
  292. private final Color color4 = new Color(51, 0, 51, 222);
  293.  
  294. private final BasicStroke stroke1 = new BasicStroke(1);
  295.  
  296. private final Font font1 = new Font("Xirod", 1, 30);
  297. private final Font font2 = new Font("Georgia", 1, 12);
  298.  
  299. public void onRepaint(Graphics g1) {
  300. Graphics2D g = (Graphics2D)g1;
  301. g.setFont(font1);
  302. g.setColor(color1);
  303. g.drawString("PastryDoughPro", 10, 32);
  304. g.setColor(color2);
  305. g.fillRect(371, 40, 143, 73);
  306. g.setColor(color3);
  307. g.setStroke(stroke1);
  308. g.drawRect(371, 40, 143, 73);
  309. g.setFont(font2);
  310. g.setColor(color4);
  311. g.drawString("Runtime: " + hours2 + ":" + addZero + minutes2
  312. + ":" + addZero2 + seconds2, 377, 55);
  313. g.drawString("Dough's: " + pastry, 377, 67);
  314. g.drawString("Dough's/h: " + numberFormatProfit.format(doughsPerHour), 377, 79);
  315. g.drawString("Profit: " + (numberFormatProfit.format(profit)), 377, 91);
  316. g.drawString("Profit hr: " + numberFormatProfit.format(profitPerHour), 377, 103);
  317.  
  318. runTime2 = System.currentTimeMillis() - startTime;
  319. seconds2 = runTime2 / 1000; // seconds
  320. if (seconds2 >= 60) { // minutes
  321. minutes2 = seconds2 / 60;
  322. seconds2 -= (minutes2 * 60);
  323. }
  324. if (minutes2 >= 60) { // hours
  325. hours2 = minutes2 / 60;
  326. minutes2 -= (hours2 * 60);
  327. }
  328.  
  329. // adds zero before seconds
  330. if (seconds2 >= 10) {
  331. addZero2 = "";
  332. } else if (seconds2 < 10) {
  333. addZero2 = "0";
  334. }
  335.  
  336. doughsPerHour = (int) ((pastry) * 3600000.0 / runTime);
  337. profitPerHour = (int) ((profit) * 3600000.0 / runTime);
  338. profit = (int) (pastrydoughPrice * pastry) - potofflourPrice;
  339. runTime = System.currentTimeMillis() - startTime;
  340.  
  341. Point m = mouse.getLocation();
  342. g.setColor(Color.black);
  343. g.drawRoundRect(m.x - 6, m.y, 15, 3, 5, 5);
  344. g.drawRoundRect(m.x, m.y - 6, 3, 15, 5, 5);
  345. g.setColor(color2);
  346. g.fillRoundRect(m.x - 6, m.y, 15, 3, 5, 5);
  347. g.fillRoundRect(m.x, m.y - 6, 3, 15, 5, 5);
  348. }
  349. //END: Code generated using Enfilade's Easel
  350.  
  351. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement