Thondar

TT Tanner 0.1

Jun 10th, 2011
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.78 KB | None | 0 0
  1. import java.awt.*;
  2. import javax.imageio.ImageIO;
  3. import java.io.IOException;
  4. import java.net.URL;
  5.  
  6. import org.rsbot.event.listeners.PaintListener;
  7. import org.rsbot.script.*;
  8. import org.rsbot.script.wrappers.*;
  9.  
  10. @ScriptManifest(authors = {"TT Production"}, keywords = {"Cowhide Tanner"}, name = "TT Tanner", description = "A Cowhide Tanner", version = 0.1)
  11.  
  12. public class TTTanner extends Script implements PaintListener{
  13.  
  14. RSTile tannerTile = new RSTile (3276,3191);
  15. RSTile bankTile = new RSTile (3270,3166);
  16.  
  17. int cowhide = 1739;
  18. int gold = 995;
  19. int Inventory = 0;
  20. int bankerID = 496;
  21. int tannerID = 2824;
  22. int leatherID = 1741;
  23. int leatherGot;
  24. int cowhideprice;
  25. int leatherprice;
  26. int goldcheck;
  27.  
  28.  
  29. long starttime;
  30.  
  31. @Override
  32. public boolean onStart() {
  33. mouse.setSpeed(random(4, 6));
  34. starttime = System.currentTimeMillis();
  35. walking.setRun(true);
  36. cowhideprice = grandExchange.lookup(cowhide).getGuidePrice();
  37. leatherprice = grandExchange.lookup(leatherID).getGuidePrice();
  38. return true;
  39. }
  40.  
  41.  
  42. public void bank() {
  43. RSNPC banker = npcs.getNearest(bankerID);
  44. rest();
  45. if (bank.isOpen() && !inventory.contains(cowhide)) {
  46. bank.depositAll();
  47. Inventory = inventory.getCount(leatherID);
  48. leatherGot += Inventory;
  49. bank.withdraw(gold, 100);
  50. sleep(300, 500);
  51. bank.withdraw(cowhide, 100);
  52. sleep(500, 750);
  53. bank.close();
  54. } else {
  55. if(banker != null) {
  56. if(banker.isOnScreen())
  57. banker.doAction("Bank Banker");{
  58. } sleep(1800, 2100);
  59. } else {
  60. walking.getPath(bankTile).traverse();
  61. }
  62. }
  63. }
  64. public void tan(){
  65. RSNPC tanner = npcs.getNearest(tannerID);
  66. rest();
  67. if (tanner != null) {
  68. if(tanner.isOnScreen())
  69. tanner.doAction("Trade Ellis");{
  70. sleep(800, 1100);
  71. mouse.click(91,108,false);
  72. sleep(350, 500);
  73. mouse.click(91,198,true);
  74. } sleep(500, 800);
  75. }
  76. }
  77.  
  78. public boolean atBank(){
  79. RSArea BankArea = new RSArea(new RSTile(3265, 3160),
  80. new RSTile(3272, 3273));
  81. return BankArea.contains(getMyPlayer().getLocation());
  82. }
  83. public boolean atTanner(){
  84. RSArea TannerArea = new RSArea(new RSTile(3270, 3189),
  85. new RSTile(3277, 3194));
  86. return TannerArea.contains(getMyPlayer().getLocation());
  87. }
  88.  
  89. private void rest() {
  90. if(walking.getEnergy() < 30)
  91. walking.rest(random(70,95));
  92. }
  93. private void antiBan() {
  94. int t = random(0, 10);
  95. int r = random(0, 15);
  96. if (t == 7);
  97. if (r == 2) {
  98. mouse.moveSlightly();
  99. sleep(500, 800);
  100. }
  101.  
  102. if (r == 3) {
  103. mouse.moveRandomly(10, 50);
  104. }
  105.  
  106. if (r == 5) {
  107. camera.moveRandomly(random(350, 650));
  108. }
  109.  
  110. if (r == 6) {
  111. camera.moveRandomly(random(450, 750));
  112. }
  113.  
  114. if (r == 8) {
  115. camera.moveRandomly(random(150, 450));
  116. }
  117.  
  118. if (r == 10) {
  119. camera.moveRandomly(random(750, 1250));
  120. }
  121.  
  122. if (r == 12) {
  123. mouse.moveOffScreen();
  124. }
  125.  
  126. if (r == 14) {
  127. camera.moveRandomly(random(500, 900));
  128. }
  129. }
  130.  
  131. public int loop() {
  132. if(atBank() && !inventory.contains(cowhide)){
  133. bank();
  134. }
  135. if(atBank() && inventory.contains(leatherID)){
  136. bank();
  137. }
  138. if(atTanner() && inventory.contains(cowhide)){
  139. tan();
  140. }
  141. if(!atTanner() && inventory.contains(cowhide)){
  142. walking.walkTo(tannerTile);
  143. }
  144. if(!atBank() && !inventory.contains(cowhide)){
  145. walking.walkTo(bankTile);
  146. }
  147. antiBan();
  148. {
  149. }
  150. return random(500, 1500);
  151.  
  152. }
  153.  
  154. @Override
  155. public void onFinish() {
  156. }
  157. //START: Code generated using Enfilade's Easel
  158. private Image getImage(String url) {
  159. try {
  160. return ImageIO.read(new URL(url));
  161. } catch(IOException e) {
  162. return null;
  163. }
  164. }
  165.  
  166. private final Color color1 = new Color(73, 68, 68);
  167. private final Color color2 = new Color(153, 153, 153);
  168. private final Color color3 = new Color(204, 204, 204);
  169.  
  170. private final BasicStroke stroke1 = new BasicStroke(1);
  171.  
  172. private final Font font1 = new Font("Arial", 1, 12);
  173. private final Font font2 = new Font("Arial", 1, 14);
  174.  
  175. private final Image img1 = getImage("http://i.imgur.com/EJBHs.png");
  176. private final Image img2 = getImage("http://i.imgur.com/aUisg.png");
  177. private final Image img3 = getImage("http://i.imgur.com/eRsVJ.png");
  178. private final Image img4 = getImage("http://i.imgur.com/cwGcs.gif");
  179. private final Image img5 = getImage("http://i.imgur.com/wJiPx.png");
  180.  
  181. public void onRepaint(Graphics g1) {
  182.  
  183. long millis = System.currentTimeMillis() - starttime;
  184. long hours = millis / (1000 * 60 * 60);
  185. millis -= hours * (1000 * 60 * 60);
  186. long minutes = millis / (1000 * 60);
  187. millis -= minutes * (1000 * 60);
  188. long seconds = millis / 1000;
  189.  
  190. float leahtersec = 0;
  191. if ((minutes > 0 || hours > 0 || seconds > 0) && leatherGot > 0) {
  192. leahtersec = ((float) leatherGot)/(float)(seconds + (minutes*60) + (hours*60*60));
  193. }
  194.  
  195. int profitprice = leatherprice - cowhideprice;
  196.  
  197. float leahtermin = leahtersec * 60;
  198. float aleatherhour = leahtermin * 60;
  199. float agoldhour = aleatherhour * profitprice;
  200. int goldearned = leatherGot * profitprice;
  201. int leahterhour = Math.round(aleatherhour);
  202. int goldhour = Math.round(agoldhour);
  203.  
  204. Graphics2D g = (Graphics2D)g1;
  205. g.setColor(color1);
  206. g.fillRect(5, 343, 508, 131);
  207. g.setColor(color2);
  208. g.setStroke(stroke1);
  209. g.drawRect(5, 343, 508, 131);
  210. g.setFont(font1);
  211. g.setColor(color3);
  212. g.drawString("Total: " + leatherGot, 72, 460);
  213. g.drawString("Pr/H: " + leahterhour, 220, 460);
  214. g.drawString("Pr/H: " + goldhour, 220, 416);
  215. g.drawString("Total: " + goldearned, 72, 416);
  216. g.setColor(color2);
  217. g.drawLine(358, 474, 358, 344);
  218. g.drawLine(211, 474, 211, 388);
  219. g.drawLine(60, 474, 60, 344);
  220. g.drawImage(img1, 90, 290, null);
  221. g.setFont(font2);
  222. g.setColor(color3);
  223. g.drawString( + hours + ":" + minutes + ":" + seconds, 193, 370);
  224. g.setColor(color2);
  225. g.drawLine(5, 433, 358, 433);
  226. g.drawLine(5, 388, 358, 388);
  227. g.drawImage(img2, 383, 356, null);
  228. g.drawImage(img3, 20, 440, null);
  229. g.drawImage(img4, 17, 394, null);
  230. g.drawImage(img5, 19, 349, null);
  231. }
  232. //END: Code generated using Enfilade's Easel
  233.  
  234. }
Advertisement
Add Comment
Please, Sign In to add comment