Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.16 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.rsbot.event.events.ServerMessageEvent;
  8. import org.rsbot.event.listeners.PaintListener;
  9. import org.rsbot.event.listeners.ServerMessageListener;
  10. import org.rsbot.script.Script;
  11. import org.rsbot.script.ScriptManifest;
  12. import org.rsbot.script.util.Timer;
  13. import org.rsbot.script.wrappers.RSObject;
  14.  
  15. @ScriptManifest(authors = {"Rapid"}, name = "AutoTunaPotatoer")
  16. public class AutoTunaPotatoer extends Script implements PaintListener, ServerMessageListener{
  17.  
  18. private enum State{
  19. SLEEP, BANK, HANDLEINTERFACE, MAKE_BUTTER_POTATO, MAKE_SWEETCORN_BOWL, MAKE_TUNASWEETCORN_BOWL, MAKE_TUNA_POTATO
  20. }
  21.  
  22. private int[] BankBoothID = { 11758, 11402, 34752, 35647, 2213, 25808, 2213, 26972, 27663, 4483, 14367, 19230, 29085, 12759, 6084, 24914 };
  23. private int PotatoID = 6701;
  24. private int PotatoButterID = 6703;
  25. private int ButterID = 6697;
  26. private int BowlID = 1923;
  27. private int TunaID = 361;
  28. private int SweetcornID = 5988;
  29. private int SweetcornBowlID = 7088;
  30. private int TunaSweetCornID = 7068;
  31. private int TunaPotatoID = 7060;
  32. private int KnifeID = 946;
  33. private int PotatoButterMade;
  34. private int BowlSweetcornMade;
  35. private int BowlTunaSweetcornMade;
  36. private int TunaPotatoMade;
  37. private int ButterPrice;
  38. private int PotatoPrice;
  39. private int SweetcornPrice;
  40. private int SweetcornBowlPrice;
  41. private int TunaPrice;
  42. private int TunaSweetcornPrice;
  43. private int PotatoButterPrice;
  44. private int TunaPotatoPrice;
  45. private long StartTime;
  46. private boolean MakeButter = true;
  47. private boolean MakeSweetcorn;
  48. private boolean MakeTunaSweetcorn;
  49. private boolean MakeTunaPotato;
  50.  
  51. private String LastMessage;
  52. private int InterfaceID = 905;
  53. private int CompID = 14;
  54.  
  55. private int timeout;
  56.  
  57. public boolean onStart(){
  58. StartTime = System.currentTimeMillis();
  59. return true;
  60. }
  61.  
  62. @Override
  63. public int loop() {
  64. if (!game.isLoggedIn()){
  65. return random(800, 1250);
  66. }else{
  67. switch(getState()){
  68. case BANK:
  69. if (bank.isOpen()){
  70. handleBank();
  71. }else{
  72. openBank();
  73. }
  74. break;
  75. case HANDLEINTERFACE:
  76. handleInterface();
  77. break;
  78. case SLEEP:
  79. return random(850, 1250);
  80. }
  81. }
  82. return random(850, 1250);
  83. }
  84.  
  85. private void handleInterface(){
  86. if (interfaces.get(916).isValid()){
  87. if (interfaces.get(InterfaceID).getComponent(CompID).doAction("Make All")){
  88. sleep(random(14000, 16000));
  89. }
  90. }else{
  91. if (MakeButter == true){
  92. if (inventory.isItemSelected()){
  93. inventory.getItem(PotatoID).doClick(true);
  94. }else{
  95. inventory.getItem(ButterID).doClick(true);
  96. }
  97. }else if (MakeSweetcorn == true){
  98. if (inventory.isItemSelected()){
  99. inventory.getItem(SweetcornID).doClick(true);
  100. }else{
  101. inventory.getItem(BowlID).doClick(true);
  102. }
  103. }else if (MakeTunaSweetcorn == true){
  104. if (inventory.isItemSelected()){
  105. inventory.getItem(TunaID).doClick(true);
  106. }else{
  107. inventory.getItem(SweetcornBowlID).doAction("Use");
  108. }
  109. }else if (MakeTunaPotato == true){
  110. if (inventory.isItemSelected()){
  111. inventory.getItem(PotatoButterID).doAction("Use");
  112. }else{
  113. inventory.getItem(TunaSweetCornID).doAction("Use");
  114. }
  115. }
  116. }
  117. }
  118.  
  119. private void openBank(){
  120. RSObject Bank = objects.getNearest(BankBoothID);
  121. if (Bank != null){
  122. Bank.doAction("Use-quickly");
  123. }else{
  124. return;
  125. }
  126. }
  127.  
  128. private void handleBank(){
  129. sleep(random(1000, 1500));
  130. if (bank.getCount(PotatoID) > 13 && bank.getCount(ButterID) > 13){
  131. bank.depositAllExcept(KnifeID);
  132. sleep(random(1000, 1500));
  133. if (bank.withdraw(PotatoID, 13)){
  134. sleep(random(850, 1250));
  135. if (bank.withdraw(ButterID, 13)){
  136. sleep(random(850, 1250));
  137. bank.close();
  138. }else{
  139. bank.withdraw(ButterID, 13);
  140. sleep(random(850, 1250));
  141. bank.close();
  142. }
  143. }
  144. MakeButter = true;
  145. }else if (bank.getCount(SweetcornID) > 13 && bank.getCount(BowlID) > 13){
  146. bank.depositAllExcept(KnifeID);
  147. sleep(random(1000, 1500));
  148. if (bank.withdraw(SweetcornID, 13)){
  149. sleep(random(850, 1250));
  150. if (bank.withdraw(BowlID, 13)){
  151. sleep(random(850, 1250));
  152. bank.close();
  153. }else{
  154. bank.withdraw(BowlID, 13);
  155. sleep(random(850, 1250));
  156. bank.close();
  157. }
  158. }
  159. MakeButter = false;
  160. MakeSweetcorn = true;
  161. }else if (bank.getCount(SweetcornBowlID) > 13 && bank.getCount(TunaID) > 13){
  162. bank.depositAllExcept(KnifeID);
  163. if (!inventory.contains(SweetcornBowlID)){
  164. if(bank.withdraw(SweetcornBowlID, 13)){
  165. if (bank.withdraw(TunaID, 13)){
  166. bank.close();
  167. }
  168. }
  169. }else{
  170. if (bank.withdraw(TunaID, 13)){
  171. bank.close();
  172. }
  173. }
  174. MakeButter = false;
  175. MakeSweetcorn = false;
  176. MakeTunaSweetcorn = true;
  177. }else if (bank.getCount(PotatoButterID) > 13 && bank.getCount(TunaSweetCornID) > 13){
  178. bank.depositAllExcept(KnifeID);
  179. if (!inventory.contains(TunaSweetCornID)){
  180. if (bank.withdraw(TunaSweetCornID, 13)){
  181. if (bank.withdraw(PotatoButterID, 13)){
  182. bank.close();
  183. }
  184. }
  185. }else{
  186. if (bank.withdraw(PotatoButterID, 13)){
  187. bank.close();
  188. }
  189. }
  190. MakeButter = false;
  191. MakeSweetcorn = false;
  192. MakeTunaSweetcorn = false;
  193. MakeTunaPotato = true;
  194. }else{
  195. stopScript();
  196. }
  197. }
  198.  
  199. private State getState(){
  200. if (MakeButter == true){
  201. if (inventory.getCount(PotatoButterID) == 13){
  202. return State.BANK;
  203. }else{
  204. int Potato[] = {ButterID, PotatoID};
  205. if (inventory.containsAll(Potato)){
  206. return State.HANDLEINTERFACE;
  207. }else{
  208. return State.BANK;
  209. }
  210. }
  211. }else if (MakeSweetcorn == true){
  212. if (inventory.getCount(SweetcornBowlID) == 13){
  213. return State.BANK;
  214. }else{
  215. int Sweetcorn[] = {BowlID, SweetcornID};
  216. if (inventory.containsAll(Sweetcorn)){
  217. return State.HANDLEINTERFACE;
  218. }else{
  219. return State.BANK;
  220. }
  221. }
  222. }else if (MakeTunaSweetcorn == true){
  223. if (inventory.getCount(TunaSweetCornID) == 13){
  224. return State.BANK;
  225. }else{
  226. int TunaSweetcorn[] = {TunaID, SweetcornBowlID};
  227. if (inventory.containsAll(TunaSweetcorn)){
  228. return State.HANDLEINTERFACE;
  229. }else{
  230. return State.BANK;
  231. }
  232. }
  233. }else if (MakeTunaPotato == true){
  234. if (inventory.getCount(TunaPotatoID) == 13){
  235. return State.BANK;
  236. }else{
  237. int TunaPotato[] = {TunaSweetCornID, PotatoButterID};
  238. if (inventory.containsAll(TunaPotato)){
  239. return State.HANDLEINTERFACE;
  240. }else{
  241. return State.BANK;
  242. }
  243. }
  244. }else{
  245. return State.SLEEP;
  246. }
  247. }
  248.  
  249. @Override
  250. public void onRepaint(Graphics g1) {
  251. final Color color1 = new Color(0, 51, 255, 125);
  252. final Color color2 = new Color(0, 0, 0);
  253. final BasicStroke stroke1 = new BasicStroke(1);
  254. final Font font1 = new Font("Arial", 1, 16);
  255. final Font font2 = new Font("Arial", 1, 12);
  256. Timer FormatTimer = new Timer(0);
  257. Graphics2D g = (Graphics2D)g1;
  258. g.setColor(color1);
  259. g.fillRoundRect(19, 355, 463, 94, 16, 16);
  260. g.setColor(color2);
  261. g.setStroke(stroke1);
  262. g.drawRoundRect(19, 355, 463, 94, 16, 16);
  263. g.setFont(font1);
  264. g.drawString("AutoTunaPotato", 30, 376);
  265. g.setFont(font2);
  266. g.drawString("Potato's buttered: " + PotatoButterMade, 50, 400);
  267. g.drawString("Sweetcorn bowl's made: " + BowlSweetcornMade, 50, 425);
  268. g.drawString("Tuna and sweetcorn made: " + BowlTunaSweetcornMade, 250, 400);
  269. g.drawString("Tuna potato's made: " + TunaPotatoMade, 250, 425);
  270. g.drawString("Run-time: " + FormatTimer.format(System.currentTimeMillis() - StartTime), 250, 375);
  271.  
  272. }
  273.  
  274. @Override
  275. public void serverMessageRecieved(ServerMessageEvent e) {
  276. LastMessage = e.getMessage().toLowerCase();
  277. if (LastMessage.contains("butter to the potato")){
  278. PotatoButterMade++;
  279. }
  280. if (LastMessage.contains("sweetcorn into the bowl")){
  281. BowlSweetcornMade++;
  282. }
  283. if (LastMessage.contains("mix ingredients")){
  284. BowlTunaSweetcornMade++;
  285. }
  286. if (LastMessage.contains("add the topping")){
  287. TunaPotatoMade++;
  288. }
  289. }
  290.  
  291. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement