Guest User

Untitled

a guest
Jun 22nd, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.47 KB | None | 0 0
  1. //Script Created by: Duggypker
  2. //Requested by: Jaque
  3. //Have fun!
  4.  
  5. package com.scripts;
  6.  
  7. import com.kbot2.handlers.eventSystem.eventListeners.PaintListener;
  8. import com.kbot2.scriptable.Script;
  9. import com.kbot2.scriptable.methods.data.Walking;
  10. import com.kbot2.scriptable.methods.wrappers.NPC;
  11. import com.kbot2.scriptable.methods.wrappers.Obj;
  12. import com.kbot2.scriptable.methods.wrappers.Tile;
  13.  
  14. import java.awt.Color;
  15. import java.awt.Font;
  16. import java.awt.Graphics;
  17. import java.awt.Point;
  18. import java.awt.Graphics2D;
  19.  
  20.  
  21. public class DugsCheesyBuyer extends Script implements PaintListener{
  22.  
  23. //=============
  24. // Variables
  25. //=============
  26.  
  27. int boothID = 2213;
  28. int potatoe = 6705;
  29. int cookID = 4293;
  30. int coinID = 995;
  31.  
  32.  
  33. //===============
  34. //Paint Variables
  35. //===============
  36.  
  37. long startTime = System.currentTimeMillis();
  38.  
  39. String status = "Starting Up...";
  40. String minute;
  41. String second;
  42. String hour;
  43. private int PotCount;
  44. int CashCount;
  45.  
  46. //=============
  47. //Paths
  48. //=============
  49. Tile[] toBank = new Tile[]{new Tile(2842,3552), new Tile(2840,3547), new Tile(2845,3547), new Tile(2845,3542), };
  50.  
  51.  
  52. Tile[] toStore = new Tile[]{new Tile(2843,3543), new Tile(2847,3546), new Tile(2842,3546), new Tile(2842,3551), };
  53.  
  54. Tile inStore = new Tile(2842,3551);
  55. Tile inBank = new Tile(2845,3542);
  56.  
  57.  
  58. @Override
  59. public boolean active(){
  60. return true;
  61. }
  62.  
  63. @Override
  64. public boolean onStart(){
  65. startTime = System.currentTimeMillis();
  66. return true;
  67. }
  68.  
  69. public String getName() {
  70. return "DugsCheesyBuyer";
  71. }
  72.  
  73. public String getAuthor() {
  74. return "Duggypker";
  75. }
  76.  
  77. public double getVersion() {
  78. return 1.0;
  79. }
  80.  
  81. public String getDescription() {
  82. return "Start in warriors guild either in bank or by the cook.";
  83.  
  84. }
  85.  
  86. @Override
  87. public void onStop(){
  88.  
  89. log("Please vote whether or not I should release the"
  90. + " script to the publc or not :P");
  91. log("If you had no errors, then congratz, you got "
  92. + Integer.toString(PotCount) + " Potatoes and spent "
  93. + Integer.toString(CashCount) + " coins.");
  94. }
  95.  
  96.  
  97. void logOut() {
  98. if(isLoggedIn()){
  99. Point logoutButton1 = new Point(744, 5);
  100. Point logoutButton2 = new Point(579, 368);
  101. mouse.clickMouse(logoutButton1, 17, 14, true);
  102. sleep(random(250, 500));
  103. mouse.clickMouse(logoutButton2, 129, 16, true);
  104. }
  105. }
  106.  
  107. public boolean isCollectionOpen() {
  108. Interface geInterface = interfaces.getInterface(109, 13);
  109. if (geInterface != null && geInterface.isValid()) { // GE
  110. log("Stupid collection box is opened. Closing...");
  111. geInterface.doClick();
  112. sleep(600, 1000);
  113. return true;
  114. }
  115. return false;
  116. }
  117.  
  118.  
  119. public int loop() {
  120.  
  121.  
  122. setMouseSpeed(random(1,5));
  123.  
  124. if(walking.getEnergy() >= random(40, 100) && settings.getSetting(173) != 1){
  125.  
  126. setMouseSpeed(random(1,5));
  127. walking.setRunning(true);
  128. }
  129.  
  130. if(inventory.contains(coinID)){
  131. if(!inventory.isFull()){
  132. if(distanceTo(inStore) <= 4){
  133.  
  134. setMouseSpeed(random(1,5));
  135. status = "Buying Cheesy Potatoes!";
  136. NPC cook = npcs.getClosest(7, cookID);
  137. cook.doAction("Trade");
  138.  
  139. }
  140. if(interfaces.interfaceGroupExists(620)){
  141. setMouseSpeed(random(1,5));
  142. Point PotPoint = new Point(197, 108);
  143. mouse.clickMouse(PotPoint, 8, 11, false);
  144. sleep(random(250, 500));
  145. atMenu("X");
  146. mouse.setMouseSpeed(3);
  147. sleep(random(2000, 2500));
  148. sendText(Integer.toString(random(27, 38)), true);
  149. setMouseSpeed(random(1,5));
  150. sleep(random(1000, 1500));
  151. PotCount += inventory.getCount(false, potatoe);
  152. CashCount = PotCount * 350;
  153.  
  154. }
  155. return 300;
  156.  
  157. }
  158. if(distanceTo(inStore) <= 7){
  159. status = "Walking to store...";
  160. walking.walkToMM(inStore);
  161. return 300;
  162. }else if(distanceTo(inStore) > 5){
  163. status = "Walking to store...";
  164. try{
  165. walking.walkPath(toStore);
  166. return 300;
  167. }catch(Exception e){
  168. status = "Error!";
  169. log("Error walking: " + e.toString());
  170. }
  171. return 300;
  172. }
  173. }else{
  174. if(distanceTo(inBank) <= 4){
  175. setMouseSpeed(random(1,5));
  176. status = "Banking...";
  177. Obj Bank = getClosestObject(7, boothID);
  178. Bank.doAction("Use-");
  179. sleep(random(500, 1000));
  180. if(bank.isOpen()){
  181. setMouseSpeed(random(1,5));
  182. bank.depositAllExcept(coinID);
  183. sleep(random(500, 1000));
  184. bank.close();
  185. }
  186. return 300;
  187. }
  188. if(inventory.isFull() && distanceTo(inBank) > 4) {
  189. status = "Walking to bank...";
  190. walking.walkPath(toBank);
  191.  
  192.  
  193. }else{
  194. status = "Out of money. Logging out.";
  195. log("Out of money. Logging out. If you had money but it was accidentally banked,");
  196. log("If this happens over and over again. Please report it. ");
  197. logOut();
  198. stopAllScripts();
  199. }
  200. }
  201. return 300;
  202.  
  203. }
  204. /* }else{
  205. interfaces.clickContinue();
  206. }
  207. return 300;*/
  208.  
  209.  
  210. public void onRepaint(Graphics g){
  211. long millis = System.currentTimeMillis() - startTime;
  212. long hours = millis / (1000 * 60 * 60);
  213. millis -= hours * (1000 * 60 * 60);
  214. long minutes = millis / (1000 * 60);
  215. millis -= minutes * (1000 * 60);
  216. long seconds = millis / 1000;
  217. hour = Long.toString(hours);
  218. minute = Long.toString(minutes);
  219. second = Long.toString(seconds);
  220. String time1 = "";
  221. String time2 = "";
  222. String time3 = "";
  223. if(hours < 10){
  224. time1 = "0";
  225. }
  226. if(minutes < 10){
  227. time2 = "0";
  228. }
  229. if(seconds < 10){
  230. time3 = "0";
  231. }
  232. Graphics2D g2d = (Graphics2D) g;
  233. g2d.setColor(new Color(255, 255, 255, 100));
  234. g2d.fill3DRect(5, 269, 150, 69, true);
  235. g2d.setColor(Color.green);
  236. g2d.setFont(new Font("Comic Sans", Font.BOLD, 14));
  237. g2d.drawString("CheesyBuyer v" + getVersion(), 11, 285);
  238. g2d.setColor(Color.red);
  239. g2d.setFont(new Font("Arial", Font.PLAIN, 12));
  240. g2d.drawString("Potatoes bought: " + Integer.toString(PotCount), 9, 297);
  241. g2d.drawString("Time running: " + time1 + hours + ":" + time2 + minutes + ":" + time3 + seconds, 9, 309);
  242. g2d.drawString("Money spent: " + CashCount, 9, 321);
  243. g2d.drawString("Status: " + status, 9, 333);
  244. }
  245. }
Add Comment
Please, Sign In to add comment