Guest User

Jueix's potatos v2 main script

a guest
May 23rd, 2020
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.21 KB | None | 0 0
  1. import org.osbot.rs07.api.map.Area;
  2. import org.osbot.rs07.api.map.constants.Banks;
  3. import org.osbot.rs07.api.model.RS2Object;
  4. import org.osbot.rs07.api.ui.RS2Widget;
  5. import org.osbot.rs07.api.ui.Skill;
  6. import org.osbot.rs07.event.WebWalkEvent;
  7. import org.osbot.rs07.script.Script;
  8. import org.osbot.rs07.script.ScriptManifest;
  9. import org.osbot.rs07.utility.ConditionalSleep;
  10.  
  11. import java.awt.*;
  12. import java.awt.event.KeyEvent;
  13. import java.util.concurrent.TimeUnit;
  14.  
  15. @ScriptManifest(name = "Jueixs baked potatos", author = "Jueix", version = 1.0, info = "Makes baked potatos", logo = "")
  16.  
  17. public class main extends Script {
  18.  
  19. public String ScriptType;
  20. //Variables
  21. private int Stage = 1;
  22. private int randomclicks = 0;
  23. private String ScriptStatus = "None";
  24.  
  25. //Dialog GUI
  26. private Potatogui gui;
  27. private boolean ScriptStarted;
  28. //GUI
  29. public long timeBegan;
  30. private long timeRan;
  31.  
  32. private int beginningXP;
  33. private int currentXp;
  34. private int xpGained;
  35.  
  36. //Areas Butter Creator
  37. Area YanileChurn = new Area(2570, 3101, 2572, 3097);
  38.  
  39. //Areas Potato cooker
  40. Area CookPlace = new Area(2816, 3443, 2818, 3439);
  41.  
  42. public void onStart() {
  43.  
  44. ScriptStatus = "Starting script.";
  45. beginningXP = skills.getExperience(Skill.COOKING);
  46.  
  47. gui = new Potatogui(this);
  48. gui.setVisible(true);
  49. }
  50.  
  51. public int onLoop() throws InterruptedException {
  52. if(ScriptStarted) {
  53. if(ScriptType == "Butter creator") {
  54. log("Butter Creating: Current state: " + Stage);
  55. switch (Stage) {
  56. case 1: {
  57. if (inventory.contains("Pat of butter")) {
  58. ScriptStatus = "Banking butter.";
  59. Stage = 3;
  60. break;
  61. }
  62. else if(YanileChurn.contains(myPlayer())) {
  63. Stage = 2;
  64. break;
  65. }
  66. else if (!Banks.YANILLE.contains(myPlayer())) {
  67. log("you are not currently in yanille bank");
  68. stop();
  69. }
  70. else if (!getBank().isOpen()) {
  71. if (inventory.contains("Bucket of milk")) {
  72. log("You already have the ingredients in inventory");
  73. ScriptStatus = "Heading to churn.";
  74. bank.close();
  75. Stage = 2;
  76. break;
  77. }
  78. getBank().open();
  79. ScriptStatus = "Opening bank.";
  80. new ConditionalSleep(2500, 3000) {
  81. @Override
  82. public boolean condition() {
  83. return getBank().isOpen();
  84. }
  85. }.sleep();
  86. } else {
  87. if (!bank.contains("Bucket of milk")) {
  88. log("you don't have any buckets of milk in the bank");
  89. stop();
  90. }
  91. sleep(random(200, 1300));
  92. bank.withdraw("Bucket of milk", 28);
  93. sleep(random(250, 500));
  94. bank.close();
  95. ScriptStatus = "Heading to churn.";
  96. Stage = 2;
  97. break;
  98. }
  99. }
  100. case 2: {
  101. if(!YanileChurn.contains(myPlayer())) {
  102. log("We are now starting our journey to the churn");
  103. getWalking().webWalk(YanileChurn);
  104. }
  105. else if(inventory.contains("Pat of butter") && myPlayer().isAnimating()) {
  106. ScriptStatus = "Interacting with churn.";
  107. }
  108. else if(YanileChurn.contains(myPlayer()) && !myPlayer().isAnimating()) {
  109. if(inventory.contains("Bucket of milk") && !myPlayer().isAnimating()) {
  110. log("We are attempting to interact with the churn");
  111. ScriptStatus = "Interacting with churn.";
  112. sleep(random(100, 500));
  113. RS2Object Churn = objects.closest("Dairy churn");
  114. Churn.interact("Churn");
  115. sleep(random(500, 3500));
  116. getKeyboard().typeKey((char) 50);
  117. sleep(random(100, 500));
  118. ScriptStatus = "Should be making butter.";
  119. new ConditionalSleep(151000, 151000) {
  120. @Override
  121. public boolean condition() {
  122. return !myPlayer().isAnimating() | !inventory.contains("Bucket of milk");
  123. }
  124. }.sleep();
  125. }
  126. else if(!inventory.contains("Bucket of milk")) {
  127. ScriptStatus = "Heading to bank.";
  128. getWalking().webWalk(Banks.YANILLE);
  129. Stage = 3;
  130. sleep(random(100, 500));
  131. break;
  132. }
  133. }
  134. }
  135. case 3: {
  136. if (!getBank().isOpen()) {
  137. if (inventory.contains("Bucket of milk")) {
  138. log("You already have the ingredients in inventory");
  139. ScriptStatus = "Heading to churn.";
  140. bank.close();
  141. Stage = 2;
  142. break;
  143. }
  144. else {
  145. getBank().open();
  146. ScriptStatus = "Opening bank.";
  147. new ConditionalSleep(2500, 3000) {
  148. @Override
  149. public boolean condition() {
  150. return getBank().isOpen();
  151. }
  152. }.sleep();
  153. }
  154. } else {
  155. if (inventory.contains("Pat of butter")) {
  156. bank.depositAll();
  157. ScriptStatus = "Withdrawing buckets of milk.";
  158. sleep(random(100, 750));
  159. Stage = 1;
  160. }
  161. }
  162. }
  163. }
  164. }
  165. if(ScriptType == "Baked potato") {
  166. log("Cooking potato's: Current state: " + Stage);
  167. switch (Stage) {
  168. case 1 : {
  169. if (inventory.contains("Baked potato")) {
  170. ScriptStatus = "Banking baked potato's.";
  171. Stage = 3;
  172. break;
  173. }
  174. else if(YanileChurn.contains(myPlayer())) {
  175. Stage = 2;
  176. break;
  177. }
  178. else if (!Banks.CATHERBY.contains(myPlayer())) {
  179. log("you are not currently in catherby bank");
  180. stop();
  181. }
  182. else if (!getBank().isOpen()) {
  183. if (inventory.contains("Potato")) {
  184. log("You already have the ingredients in inventory");
  185. ScriptStatus = "Closing bank, starting potatos.";
  186. bank.close();
  187. Stage = 2;
  188. break;
  189. }
  190. getBank().open();
  191. ScriptStatus = "Opening bank.";
  192. new ConditionalSleep(2500, 3000) {
  193. @Override
  194. public boolean condition() {
  195. return getBank().isOpen();
  196. }
  197. }.sleep();
  198. } else {
  199. if (!bank.contains("Potato")) {
  200. log("You don't have any Potato's in the bank.");
  201. stop();
  202. }
  203. ScriptStatus = "Withdrawing potato's.";
  204. sleep(random(200, 1300));
  205. bank.withdraw("Potato", 28);
  206. sleep(random(250, 850));
  207. bank.close();
  208. ScriptStatus = "Heading to range.";
  209. Stage = 2;
  210. break;
  211. }
  212. }
  213. case 2: {
  214. if(!CookPlace.contains(myPlayer())) {
  215. log("We are now starting our journey to the range");
  216. getWalking().webWalk(CookPlace);
  217. }
  218. else if(CookPlace.contains(myPlayer()) && !myPlayer().isAnimating()) {
  219. log("We are attempting to interact with the churn");
  220. ScriptStatus = "Interacting with range.";
  221. sleep(random(100, 500));
  222. RS2Object Range = objects.closest("Range");
  223. Range.interact("Cook");
  224. sleep(random(500, 3500));
  225. getKeyboard().typeKey((char) 32);
  226. sleep(random(500, 1500));
  227. ScriptStatus = "Should be making baked potato's.";
  228. new ConditionalSleep(18000, 22000) {
  229. @Override
  230. public boolean condition() {
  231. return !myPlayer().isAnimating() | !inventory.contains("Potato");
  232. }
  233. }.sleep();
  234. }
  235. else if(!inventory.contains("Potato")) {
  236. ScriptStatus = "Heading to bank.";
  237. getWalking().webWalk(Banks.CATHERBY);
  238. Stage = 3;
  239. sleep(random(100, 500));
  240. break;
  241. }
  242. }
  243. case 3: {
  244. if (!getBank().isOpen()) {
  245. if (inventory.contains("Potato")) {
  246. log("You already have the ingredients in inventory");
  247. ScriptStatus = "Heading to range.";
  248. bank.close();
  249. Stage = 2;
  250. break;
  251. }
  252. else {
  253. getBank().open();
  254. ScriptStatus = "Opening bank.";
  255. new ConditionalSleep(2500, 3000) {
  256. @Override
  257. public boolean condition() {
  258. return getBank().isOpen();
  259. }
  260. }.sleep();
  261. }
  262. } else {
  263. if (inventory.contains("Baked potato")) {
  264. bank.depositAll();
  265. ScriptStatus = "Withdrawing Potato's.";
  266. sleep(random(100, 750));
  267. Stage = 1;
  268. }
  269. }
  270. }
  271. }
  272. }
  273. if(ScriptType == "Potato with butter") {
  274. log("Potato with butter: Current state: " + Stage);
  275. switch (Stage) {
  276. case 1: {
  277. log("attempting to bank");
  278. if (!getBank().isOpen()) {
  279. if (inventory.contains("Baked potato") && inventory.contains("Pat of butter")) {
  280. log("You already have the ingredients in inventory");
  281. ScriptStatus = "Closing bank, starting potatos.";
  282. bank.close();
  283. Stage = 2;
  284. break;
  285. }
  286. getBank().open();
  287. ScriptStatus = "Opening bank.";
  288. new ConditionalSleep(2500, 3000) {
  289. @Override
  290. public boolean condition() {
  291. return getBank().isOpen();
  292. }
  293. }.sleep();
  294. } else {
  295. if (!bank.contains("Baked potato") | !bank.contains("Pat of butter")) {
  296. log("You don't have a baked potato or pat of butter in teh bank");
  297. stop();
  298. }
  299. randomclicks = random(1, 5);
  300. log("Random clicks = " + randomclicks);
  301. if (randomclicks < 3) {
  302. ScriptStatus = "Withdrawing baked potato and butter.";
  303. sleep(random(200, 1250));
  304. bank.withdraw("Baked potato", 14);
  305. sleep(random(200, 1300));
  306. bank.withdraw("Pat of butter", 14);
  307. sleep(random(250, 500));
  308. bank.close();
  309. log("Bank Closed");
  310. Stage = 2;
  311. sleep(random(100, 1000));
  312. } else if (randomclicks >= 3) {
  313. ScriptStatus = "Withdrawing butter and potato.";
  314. sleep(random(200, 1250));
  315. bank.withdraw("Pat of butter", 14);
  316. sleep(random(200, 1300));
  317. bank.withdraw("Baked potato", 14);
  318. sleep(random(200,600));
  319. bank.close();
  320. log("Bank Closed");
  321. Stage = 2;
  322. sleep(random(100, 1000));
  323. }
  324. }
  325. break;
  326. }
  327. case 2: {
  328. log("Attempting to make the items");
  329. if (inventory.contains("Baked potato") && inventory.contains("Pat of butter")) {
  330. randomclicks = random(1, 5);
  331. log("Random clicks = " + randomclicks);
  332. if (randomclicks < 3) {
  333. ScriptStatus = "Using butter on potato.";
  334. log("uses butter before the baked.");
  335. getInventory().interact("Use", "Pat of butter");
  336. sleep(random(100, 1500));
  337. getInventory().interact("Use", "Baked Potato");
  338. sleep(random(100, 1200));
  339. log("Dialog after it's shown");
  340. sleep(random(100, 1700));
  341. getKeyboard().typeKey((char) 32);
  342. log("Dialog after space");
  343. sleep(random(18500, 20000));
  344. Stage = 3;
  345. } else if (randomclicks >= 3) {
  346. ScriptStatus = "Using potato on butter.";
  347. log("Uses baked before the butter.");
  348. getInventory().interact("Use", "Baked Potato");
  349. sleep(random(100, 1000));
  350. getInventory().interact("Use", "Pat of butter");
  351. sleep(random(100, 2000));
  352. log("Dialog after it's shown");
  353. sleep(random(500, 1500));
  354. getKeyboard().typeKey((char) 32);
  355. log("Dialog after space");
  356. sleep(random(18500, 20000));
  357. Stage = 3;
  358. }
  359. }
  360. break;
  361. }
  362. case 3: {
  363. log("Banking the items");
  364. ScriptStatus = "Banking items.";
  365. if (!getBank().isOpen()) {
  366. getBank().open();
  367. new ConditionalSleep(2500, 3000) {
  368. @Override
  369. public boolean condition() {
  370. return getBank().isOpen();
  371. }
  372. }.sleep();
  373. } else if (getBank().isOpen()) {
  374. bank.depositAll();
  375. sleep(random(500, 1200));
  376. Stage = 1;
  377. }
  378. break;
  379. }
  380. case 4: {
  381. break;
  382. }
  383. }
  384. }
  385. }
  386. return 100; //The amount of time in milliseconds before the loop starts over
  387. }
  388.  
  389.  
  390. public void onPaint(Graphics2D g) {
  391. if(ScriptStarted) {
  392. timeRan = System.currentTimeMillis() - this.timeBegan;
  393. currentXp = skills.getExperience(Skill.COOKING);
  394. xpGained = currentXp - beginningXP;
  395. g.setColor(Color.WHITE);
  396. g.drawString("Time ran: " + ft(timeRan), 14, 286);
  397. g.drawString("Status: " + ScriptStatus, 14, 306);
  398. g.drawString("Experience: " + xpGained, 14, 326);
  399. }
  400. }
  401.  
  402. private String ft(long duration)
  403. {
  404. String res = "";
  405. long days = TimeUnit.MILLISECONDS.toDays(duration);
  406. long hours = TimeUnit.MILLISECONDS.toHours(duration)
  407. - TimeUnit.DAYS.toHours(TimeUnit.MILLISECONDS.toDays(duration));
  408. long minutes = TimeUnit.MILLISECONDS.toMinutes(duration)
  409. - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS
  410. .toHours(duration));
  411. long seconds = TimeUnit.MILLISECONDS.toSeconds(duration)
  412. - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS
  413. .toMinutes(duration));
  414. if (days == 0) {
  415. res = (hours + ":" + minutes + ":" + seconds);
  416. } else {
  417. res = (days + ":" + hours + ":" + minutes + ":" + seconds);
  418. }
  419. return res;
  420. }
  421.  
  422. public void onExit() {
  423. stop();
  424. //Code here will execute after the script ends
  425. }
  426.  
  427. public void setScriptStarted(boolean ScriptStarted) {
  428. this.ScriptStarted = ScriptStarted;
  429. }
  430. }
Add Comment
Please, Sign In to add comment