Advertisement
TheBat

killing stuff

Apr 12th, 2012
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.55 KB | None | 0 0
  1. package scripts;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Graphics;
  5. import java.awt.Point;
  6. import java.awt.Rectangle;
  7. import java.awt.event.KeyEvent;
  8.  
  9. import org.tribot.bot.ClientContext;
  10. import org.tribot.input.MouseHandler;
  11. import org.tribot.script.Script;
  12. import org.tribot.script.ScriptManifest;
  13. import org.tribot.script.interfaces.Painting;
  14. import org.tribot.script.methods.General;
  15. import org.tribot.script.methods.Timing;
  16.  
  17. @ScriptManifest(
  18. authors = { "TheBat"},
  19. name = "BatCombat",
  20. version = 1.0,
  21. description = "Kills ghouls",
  22. category = "Combat")
  23.  
  24. public class BatCombat extends Script implements Painting {
  25. final private static Rectangle VIEWPORT = new Rectangle(4,4,513,335);
  26. final private static Rectangle VIEWPORT1 = new Rectangle(4,4,209,282);
  27. final private static Rectangle VIEWPORT2 = new Rectangle(209,57,80,282);
  28. final private static Rectangle VIEWPORT3 = new Rectangle(289,4,224,282);
  29. final private static Rectangle COMCECK = new Rectangle(215,115,85,35);
  30. final private static Rectangle MINIMAP = new Rectangle(565,34,115,126);
  31. private final static Point CENTER = new Point(255,165);
  32.  
  33. //dtm for a goul
  34. Point[] F_CRAWLER_DTM_PTS = { new Point( 198, 197), new Point( 203, 193), new Point( 200, 197)};
  35. Color[] F_CRAWLER_DTM_RGB = { new Color( 50, 47, 15), new Color( 118, 98, 37), new Color( 53, 49, 16)};
  36. DTM dtmFCrawler1 = new DTM(F_CRAWLER_DTM_PTS, F_CRAWLER_DTM_RGB);
  37. Point[] RAT_DTM_PTS = { new Point( 320, 224), new Point( 332, 224)};
  38. Color[] RAT_DTM_RGB = { new Color( 116, 112, 101), new Color( 83, 79, 72)};
  39. DTM dtmRat1 = new DTM(RAT_DTM_PTS, RAT_DTM_RGB);
  40. Point[] GOUL1_DTM_PTS = { new Point( 214, 152), new Point( 215, 154)};
  41. Color[] GOUL1_DTM_RGB = { new Color( 186, 185, 160), new Color( 168, 167, 144)};
  42. DTM dtmGoul1 = new DTM(GOUL1_DTM_PTS, GOUL1_DTM_RGB);
  43.  
  44. //dtm for green
  45. Point[] GREEN1_DTM_PTS = { new Point( 286, 146)};
  46. Color[] GREEN1_DTM_RGB = { new Color( 156, 216, 0)};
  47. DTM dtmGreen1 = new DTM(GREEN1_DTM_PTS, GREEN1_DTM_RGB);
  48.  
  49. //dtm for red
  50. Point[] RED1_DTM_PTS = { new Point( 188, 110)};
  51. Color[] RED1_DTM_RGB = { new Color( 185, 0, 8)};
  52. DTM dtmRed1 = new DTM(RED1_DTM_PTS, RED1_DTM_RGB);
  53.  
  54. //dtm for the yellow dots
  55. Point[] YELLOW1_DTM_PTS = { new Point( 656, 72)};
  56. Color[] YELLOW1_DTM_RGB = { new Color( 237, 234, 9)};
  57. DTM dtmYellow1 = new DTM(YELLOW1_DTM_PTS, YELLOW1_DTM_RGB);
  58.  
  59. //dtm for a fully red health bar.
  60. Point[] RED_BAR1_DTM_PTS = { new Point( 232, 126), new Point( 238, 126), new Point( 282, 125), new Point( 285, 126)};
  61. Color[] RED_BAR1_DTM_RGB = { new Color( 108, 0, 0), new Color( 138, 0, 1), new Color( 225, 16, 8), new Color( 171, 0, 8)};
  62. DTM dtmRedBar1 = new DTM(RED_BAR1_DTM_PTS, RED_BAR1_DTM_RGB);
  63.  
  64. //dtm for players bar
  65. Point[] PLAY_BAR1_DTM_PTS = { new Point( 229, 143), new Point( 244, 143)};
  66. Color[] PLAY_BAR1_DTM_RGB = { new Color( 131, 197, 0), new Color( 136, 198, 0)};
  67. DTM dtmPlayerBar1 = new DTM(PLAY_BAR1_DTM_PTS, PLAY_BAR1_DTM_RGB);
  68.  
  69. private Rectangle rect = new Rectangle();
  70. private long TIME = 0;
  71. private static int KILLED = 0;
  72. private String userName = "hotskater89";
  73. private String password = "dragondyce";
  74. private MouseHandler mos = new MouseHandler(ClientContext.get().client);
  75.  
  76. @Override
  77. public void run() {
  78. if(onStart())while(loop() > 0 && !Thread.interrupted());
  79. }
  80. public boolean onStart(){
  81. TIME = System.currentTimeMillis();
  82. mos.clickMouse(new Point(543,26),1);
  83. sleep(200);
  84. ClientContext.get().client.getKeyboardHandler().sendPressEvent((char)KeyEvent.VK_UP);
  85. sleep(800);
  86. ClientContext.get().client.getKeyboardHandler().sendReleaseEvent((char)KeyEvent.VK_UP);
  87. return true;
  88. }
  89.  
  90. public int loop() {
  91. //mos.mouseSpeed = 500;
  92. General.setMouseSpeed(General.random(160,180));
  93. if(dtmGoul1.findDTMS(10, VIEWPORT)){
  94. int i = General.random(0,dtmGoul1.getList().size()-1);
  95. Point Pt = dtmGoul1.getDTM(i);
  96. if(isDistance(Pt, CENTER, 55))return 100;
  97. rect = new Rectangle(Pt.x-30, Pt.y-30,60,30);
  98. if(dtmGreen1.findDTMS(20, rect) || dtmRed1.findDTMS(20, rect))return 100;
  99. mos.clickMouse(Pt,1);
  100. sleep(3100);
  101. int k = 0;
  102. while(k <= 1200 &&!(dtmRedBar1.findDTMS(20, VIEWPORT1) || dtmRedBar1.findDTMS(20, VIEWPORT2) || dtmRedBar1.findDTMS(20, VIEWPORT3))){
  103. if(k > 300 && !dtmGreen1.findDTMS(30, COMCECK)){
  104. return 100;
  105. }
  106. sleep(10);
  107. k++;
  108. }
  109. if(k < 1200){
  110. KILLED++;
  111. }
  112. sleep(800);
  113. }else if(dtmYellow1.findDTMS(20, MINIMAP)){
  114. int i = General.random(0,dtmYellow1.getList().size()-1);
  115. Point Pt = new Point((int)dtmYellow1.getList().get(i).getCenterX(),(int)dtmYellow1.getList().get(i).getCenterY());
  116. mos.clickMouse(Pt,1);
  117. sleep(4000);
  118. }
  119. return 100;
  120. }
  121. public void onPaint(Graphics g){
  122. g.setColor(Color.YELLOW);
  123. g.drawLine(General.getMousePos().x,0,General.getMousePos().x,2100);
  124. g.drawLine(0,General.getMousePos().y,2100,General.getMousePos().y);
  125.  
  126. int kph = (int) ((3600000*(long)KILLED)/(long)(System.currentTimeMillis() - TIME));
  127. g.drawString("Time Running: " + Timing.msToString(System.currentTimeMillis() - TIME), 11, 30);
  128. g.drawString("Total Killed: " + KILLED ,11,42);
  129. try{
  130. g.drawString("Kills/Hour: " + kph,11,54);
  131. }catch(ArithmeticException e){}
  132. g.drawRect(rect.x,rect.y,rect.width,rect.height);
  133. g.setColor(Color.RED);
  134. g.drawRect(COMCECK.x,COMCECK.y,COMCECK.width,COMCECK.height);
  135.  
  136. }
  137. private boolean isDistance(Point pt1, Point pt2, int tolerance) {
  138. int distance = 0;
  139. distance = (int)Point.distance(pt1.x, pt1.y, pt2.x, pt2.y);
  140. if(distance < tolerance) return true;
  141. return false;
  142. }
  143.  
  144. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement