Advertisement
Guest User

CCSoftClay.java

a guest
Nov 24th, 2013
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.05 KB | None | 0 0
  1. package scripts;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Font;
  5. import java.awt.Graphics;
  6. import java.awt.Polygon;
  7.  
  8. import org.tribot.api.DynamicClicking;
  9. import org.tribot.api.General;
  10. import org.tribot.api.Timing;
  11. import org.tribot.api.input.Mouse;
  12. import org.tribot.api2007.Banking;
  13. import org.tribot.api2007.Camera;
  14. import org.tribot.api2007.ChooseOption;
  15. import org.tribot.api2007.Game;
  16. import org.tribot.api2007.Interfaces;
  17. import org.tribot.api2007.Inventory;
  18. import org.tribot.api2007.Objects;
  19. import org.tribot.api2007.Options;
  20. import org.tribot.api2007.Player;
  21. import org.tribot.api2007.Skills;
  22. import org.tribot.api2007.Walking;
  23. import org.tribot.api2007.types.RSInterfaceChild;
  24. import org.tribot.api2007.types.RSItem;
  25. import org.tribot.api2007.types.RSObject;
  26. import org.tribot.api2007.types.RSTile;
  27. import org.tribot.script.Script;
  28. import org.tribot.script.ScriptManifest;
  29. import org.tribot.script.interfaces.Painting;
  30.  
  31. @ScriptManifest(authors = { "Coca Cola" }, category = "Money Making", name = "CC Claymaker", description = "Mines clay " +
  32. "at the Varrock west mine, softens it at the varrock square fountain, makes soft clay, and then banks it in Varrock west bank, and repeats.")
  33. public class CCSoftClay extends Script implements Painting {
  34.  
  35. Timer time = new Timer(3000);
  36.  
  37. final long startTime = System.currentTimeMillis();
  38.  
  39. private final int[] CLAY_ROCK = { 1760, 1758 };
  40. private final int BANK_BOOTH = 2213;
  41. private final int FOUNTAIN = 11785;
  42. private final int BUCKET = 1925;
  43. private final int BUCKET_OF_WATER = 1929;
  44. private final int CLAY_ITEM = 434;
  45. private final int[] SOFT_CLAY = { 1761 };
  46. private final int[] DO_NOT_BANK = { 1925, 1929, 434, 1265, 1267, 1269, 2372, 1273, 1275 };
  47.  
  48. private final int[] junk ={ 1521, 1971, 1917, 6961, 2327, 9003, 6180, 6181, 6182, 6654,
  49. 6655, 6656, 6657, 6658, 6659, 6183, 3057, 3058, 3059, 3060,
  50. 3061, 117, 1607, 1608, 1623, 1624, 1625, 1606, 1621, 1622,
  51. 1603, 1604, 1619, 1620, 1601, 1602, 1617, 1618, 1973, 995 };
  52.  
  53. private final Polygon bankArea = new Polygon(new int[] { 3179, 3186, 3186, 3179},
  54. new int[] { 3432, 3432, 3448, 3448 },4);
  55.  
  56. private final Polygon mineArea = new Polygon(new int[] { 3175, 3185, 3185, 3175},
  57. new int[] { 3366, 3366, 3377, 3377 },4);
  58.  
  59. private final Polygon vSqArea = new Polygon(new int[] { 3207, 3220, 3220, 3107},
  60. new int[] { 3420, 3420, 3435, 3435 },4);
  61.  
  62. RSTile[] banktomine = new RSTile[] { new RSTile(3178, 3429),
  63. new RSTile(3170, 3423), new RSTile(3170, 3415),
  64. new RSTile(3170, 3407), new RSTile(3170, 3398),
  65. new RSTile(3179, 3391), new RSTile(3179, 3384),
  66. new RSTile(3186, 3378), new RSTile(3184, 3373),
  67. new RSTile(3180, 3371)};
  68.  
  69. RSTile[] minetofountain = new RSTile[] { new RSTile(3186, 3373),
  70. new RSTile(3193, 3374), new RSTile(3201, 3376),
  71. new RSTile(3208, 3379), new RSTile(3211, 3384),
  72. new RSTile(3211, 3393), new RSTile(3211, 3400),
  73. new RSTile(3211, 3407), new RSTile(3211, 3418),
  74. new RSTile(3211, 3425)};
  75.  
  76. RSTile[] fountaintobank = new RSTile[] { new RSTile(3206, 3428),
  77. new RSTile(3199, 3428), new RSTile(3191, 3430),
  78. new RSTile(3184, 3431), new RSTile(3185, 3436)};
  79.  
  80. @SuppressWarnings("deprecation")
  81. int startLvl = Skills.getActualLevel("Mining");
  82. @SuppressWarnings("deprecation")
  83. int startXP = Skills.getXP("Mining");
  84. int bankedClay = 0;
  85.  
  86. public void run() {
  87. if (onStart()) {
  88. while (true) {
  89. sleep(loop());
  90. }
  91. }
  92. }
  93.  
  94. private boolean onStart() {
  95. println("Coca Cola's Soft Clay Miner/Softener has started.");
  96.  
  97. Mouse.setSpeed(150);
  98. return true;
  99.  
  100. }
  101.  
  102. public RSObject findNearest(int distance, int... ids) {
  103. RSObject[] objects = Objects.findNearest(distance, ids);
  104.  
  105. for (RSObject object : objects) {
  106. if (object != null) {
  107. return object;
  108. }
  109. }
  110.  
  111. return null;
  112.  
  113. }
  114.  
  115. private int loop() {
  116.  
  117. RSObject bankbooth = findNearest(15, BANK_BOOTH);
  118.  
  119. if (!Inventory.isFull() && bankArea.contains(Player.getPosition().getX(), Player.getPosition().getY())) {
  120. startRunning();
  121. checkForJunk();
  122. Walking.walkPath(banktomine);
  123. }
  124.  
  125. if (Inventory.isFull() && mineArea.contains(Player.getPosition().getX(), Player.getPosition().getY()) && Inventory.getCount(CLAY_ITEM) > 1) {
  126. startRunning();
  127. checkForJunk();
  128. Walking.walkPath(minetofountain);
  129. }
  130.  
  131. if (Inventory.isFull() && vSqArea.contains(Player.getPosition().getX(), Player.getPosition().getY()) && Inventory.getCount(CLAY_ITEM) > 1
  132. && Inventory.getCount(BUCKET_OF_WATER) < 1) {
  133. fillBuckets();
  134. }
  135.  
  136. if (Inventory.isFull() && vSqArea.contains(Player.getPosition().getX(), Player.getPosition().getY()) && Inventory.getCount(CLAY_ITEM) > 1
  137. && Inventory.getCount(SOFT_CLAY) < 1 && Inventory.getCount(BUCKET_OF_WATER) > 1 ) {
  138. softenClay();
  139. }
  140.  
  141. if (Inventory.isFull() && vSqArea.contains(Player.getPosition().getX(), Player.getPosition().getY()) && Inventory.getCount(BUCKET_OF_WATER) < 1
  142. && Inventory.getCount(CLAY_ITEM) < 1) {
  143. startRunning();
  144. Walking.walkPath(fountaintobank);
  145. }
  146.  
  147. if (Inventory.isFull() && vSqArea.contains(Player.getPosition().getX(), Player.getPosition().getY()) && Inventory.getCount(CLAY_ITEM) <= 1
  148. && Inventory.getCount(SOFT_CLAY) > 1) {
  149. startRunning();
  150. Walking.walkPath(fountaintobank);
  151. }
  152.  
  153. if (!Inventory.isFull() && mineArea.contains(Player.getPosition().getX(), Player.getPosition().getY())) {
  154. mine();
  155. }
  156.  
  157. if (Inventory.isFull() && bankArea.contains(Player.getPosition().getX(), Player.getPosition().getY())) {
  158. if (bankbooth != null) {
  159. if (bankbooth.isOnScreen()) {
  160. while(bankbooth.getPosition().distanceTo(Player.getPosition()) < 5 && bankArea.contains(Player.getPosition().getX(), Player.getPosition().getY()) && !Banking.isBankScreenOpen()) {
  161. bankbooth.click("Bank");
  162. sleep(2000);
  163. } if (Banking.isBankScreenOpen()) {
  164. Banking.depositAllExcept(DO_NOT_BANK);
  165. bankedClay += Inventory.getCount(SOFT_CLAY);
  166. Banking.close();
  167. startRunning();
  168. }
  169. }
  170. }
  171. }
  172.  
  173. return 100;
  174. }
  175.  
  176. public void softenClay() {
  177. RSItem[] waterbucket = Inventory.find(new int[] { BUCKET_OF_WATER });
  178. RSItem[] clayitem = Inventory.find(new int[] { CLAY_ITEM });
  179. RSInterfaceChild clayinterface = Interfaces.get(548, 88);
  180.  
  181. if (waterbucket[0].click(new String[] { "Use" })) {
  182. sleep(450, 655);
  183. if (clayitem[0].click(new String[] { "Use" })) {
  184. sleep(1455, 1644);
  185. if (clayinterface != null) {
  186. Mouse.clickBox(220, 400, 300, 450, 3);
  187. ChooseOption.select(new String[] { "All" });
  188.  
  189. sleep(17500, 18000);
  190. }
  191. }
  192. }
  193. }
  194.  
  195. public void fillBuckets() {
  196.  
  197. RSItem[] bucket = Inventory.find(new int[] { BUCKET });
  198. RSObject fountain = findNearest(15, FOUNTAIN);
  199.  
  200. if (fountain != null) {
  201. if (fountain.isOnScreen()) {
  202. if (bucket[0].click(new String[] { "Use" })) {
  203. sleep(800, 1000);
  204. while(fountain.getPosition().distanceTo(Player.getPosition()) < 7 && Inventory.getCount(BUCKET_OF_WATER) < 1) {
  205. DynamicClicking.clickRSObject(fountain, "Use Bucket -> Fountain");
  206. sleep(1000, 2000);
  207. }
  208. }
  209. sleep(2000);
  210. time.reset();
  211. while (Player.getRSPlayer().getAnimation() == -1 || Player.getRSPlayer().getAnimation() == 832 && time.isRunning()) {
  212. sleep(1000);
  213. }
  214. }
  215. }
  216. }
  217.  
  218.  
  219. public void mine() {
  220.  
  221. RSObject clayrock = findNearest(10, CLAY_ROCK);
  222.  
  223. if (clayrock != null) {
  224. if (clayrock.isOnScreen()) {
  225. clayrock.click("Mine");
  226. sleep(2000);
  227. time.reset();
  228. while (Player.getRSPlayer().getAnimation() == 628 && time.isRunning()) {
  229. sleep(10);
  230. }
  231. } else {
  232. Walking.walkTo(clayrock);
  233. Camera.turnToTile(clayrock.getPosition());
  234. }
  235. }
  236. }
  237.  
  238. public void checkForJunk() {
  239. if(Inventory.getCount(junk) >= 1) {
  240. Inventory.drop(junk);
  241. }
  242. }
  243.  
  244. public void startRunning() {
  245. if(!Game.isRunOn()) {
  246. Options.setRunOn(true);
  247. }
  248. }
  249.  
  250. @SuppressWarnings({ "deprecation" })
  251. public void onPaint (Graphics g) {
  252.  
  253. long timeRan = System.currentTimeMillis() - startTime;
  254. int currentLvl = Skills.getActualLevel("Mining");
  255. int gainedExp = Skills.getXP("Mining") - startXP;
  256. int gainedLvl = currentLvl - startLvl;
  257. int xpToLevel = Skills.getXPToNextLevel("Mining");
  258. long xpPerHour= (long)(gainedExp * 3600000d / timeRan);
  259. long clayPerHour = (long)(bankedClay * 3600000d / timeRan);
  260.  
  261. Font font = new Font("Trajan Pro", Font.BOLD, 14);
  262. g.setColor(new Color(164, 152, 151));
  263. g.setFont(font);
  264. g.drawString("Time running: " + Timing.msToString(timeRan), 10, 250);
  265. g.drawString("Mining EXP Gained: " + gainedExp + " (" + xpPerHour + " EXP per hour.)", 10, 270);
  266. g.drawString("Mining Level: " + currentLvl + " (Gained " + gainedLvl + " levels.)", 10, 290);
  267. g.drawString("Experience to next level: " + xpToLevel, 10, 310);
  268. g.drawString("Soft clay made: " + bankedClay + " (" + clayPerHour + " Soft clay per hour.)", 10, 330);
  269.  
  270. }
  271.  
  272. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement