Guest User

StealthChickenAIO

a guest
Feb 27th, 2012
518
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.28 KB | None | 0 0
  1. import java.awt.Color; // SealthChickenAIO 0.2 by Stealth
  2. import java.awt.Font;
  3. import java.awt.Graphics;
  4. import java.awt.Graphics2D;
  5. import java.awt.Image;
  6. import java.awt.Point;
  7. import java.awt.Rectangle;
  8. import java.awt.RenderingHints;
  9. import java.awt.event.MouseEvent;
  10. import java.awt.event.MouseListener;
  11. import java.io.IOException;
  12. import java.net.URL;
  13. import java.util.ArrayList;
  14. import java.util.Iterator;
  15. import java.awt.*;
  16. import java.awt.event.*;
  17. import javax.swing.*;
  18.  
  19. import javax.imageio.ImageIO;
  20.  
  21. import com.rarebot.event.listeners.PaintListener;
  22. import com.rarebot.script.Script;
  23. import com.rarebot.script.ScriptManifest;
  24. import com.rarebot.script.methods.Game.Tab;
  25. import com.rarebot.script.methods.Methods;
  26. import com.rarebot.script.methods.Skills;
  27. import com.rarebot.script.util.Filter;
  28. import com.rarebot.script.wrappers.RSArea;
  29. import com.rarebot.script.wrappers.RSGroundItem;
  30. import com.rarebot.script.wrappers.RSItem;
  31.  
  32. import com.rarebot.script.wrappers.RSNPC;
  33. import com.rarebot.script.wrappers.RSObject;
  34. import com.rarebot.script.wrappers.RSTile;
  35. import com.rarebot.script.wrappers.RSWeb;
  36. @ScriptManifest(authors = { "Stealth" }, keywords = {"combat"}, name = "StealthChickenAIO", description =
  37.  
  38. "Kills Chickens!", version = 0.2)
  39. public class StealthChickenAIO extends Script implements PaintListener, MouseListener
  40. {
  41.  
  42.  
  43.  
  44. private int[] junkID = {2138, 526};
  45. final Object lock = new Object();
  46. boolean pressed = false;
  47. String status;
  48. public int featherID = 314;
  49. private long startTime = 0;
  50. public int[] ChickenID = {41, 1017, 2314, 2315, 2313}, foodID = {373}; // adding more food
  51. RSNPC curChicken = null;
  52.  
  53. private enum State {
  54. UNKNOWN, ANTIBAN, ATTACK, EAT, CAMERATOChicken, SPEC
  55. }
  56.  
  57. public State getState() {
  58. RSNPC Chicken = npcs.getNearest(ChickenID);
  59. try {
  60. if (players.getMyPlayer().getHPPercent() >= 30) {
  61. if (!players.getMyPlayer().isInCombat()) {
  62. if (Chicken != null) {
  63. if (Chicken.isOnScreen()) {
  64. return State.ATTACK;
  65. } else {
  66.  
  67. return State.CAMERATOChicken;
  68. }
  69. }
  70. }
  71. } else {
  72. if (inventory.containsOneOf(foodID)) {
  73. return State.EAT;
  74. }
  75. }
  76. } catch (Exception e) {
  77. return State.UNKNOWN;
  78. }
  79. return State.ANTIBAN;
  80. }
  81. public boolean onStart() {
  82. startTime = System.currentTimeMillis();
  83. return true;
  84.  
  85. }
  86.  
  87.  
  88. private void drawMouse1(Graphics g) {
  89. Point p = mouse.getLocation();
  90. ((Graphics2D) g).setRenderingHints(new RenderingHints
  91.  
  92. (RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
  93. Graphics2D line1 = (Graphics2D) g.create();
  94. Graphics2D line2 = (Graphics2D) g.create();
  95. Graphics2D arc1 = (Graphics2D) g.create();
  96. Graphics2D arc2 = (Graphics2D) g.create();
  97. final int outerSize = 20;
  98. final int innerSize = 20;
  99. line1.rotate(System.currentTimeMillis() % 2000d / 2000d * (360d) * 2
  100. * Math.PI / 180.0, p.x, p.y);
  101. line2.rotate(System.currentTimeMillis() % 2000d / 2000d * (-360d)
  102. * 2 * Math.PI / 180.0, p.x, p.y);
  103. arc1.rotate(System.currentTimeMillis() % 2000d / 2000d * (360d) * 2
  104. * Math.PI / 180.0, p.x, p.y);
  105. arc2.rotate(System.currentTimeMillis() % 2000d / 2000d * (-360d)
  106. * 2 * Math.PI / 180.0, p.x, p.y);
  107. line1.setColor(Color.WHITE);
  108. line1.drawLine(p.x, p.y, p.x, p.y + 7);
  109. line1.drawLine(p.x, p.y, p.x, p.y - 7);
  110. line2.setColor(Color.WHITE);
  111. line2.drawLine(p.x, p.y, p.x - 7, p.y);
  112. line2.drawLine(p.x, p.y, p.x + 7, p.y);
  113. arc1.setColor(Color.BLACK);
  114. arc1.drawArc(p.x - (outerSize / 2), p.y - (outerSize / 2), outerSize, outerSize, 100, 75);
  115. arc2.setColor(Color.RED);
  116. arc2.drawArc(p.x - (outerSize / 2), p.y - (outerSize / 2), outerSize, outerSize, -100, 75);
  117. arc2.drawArc(p.x - (innerSize / 2), p.y - (innerSize / 2), innerSize, innerSize, 100, 75);
  118. arc1.drawArc(p.x - (innerSize / 2), p.y - (innerSize / 2), innerSize, innerSize, -100, 75);
  119. }
  120. @Override
  121. public int loop() {
  122. if(walking.getEnergy() > random(65,100)) {
  123. if(!walking.isRunEnabled()) {
  124. status = "Enabling Running";
  125. walking.setRun(true);
  126. }else if (walking.getEnergy() > random(10,25)) {
  127.  
  128.  
  129.  
  130. }
  131. }
  132. RSNPC Chicken = npcs.getNearest(ChickenID);
  133. mouse.setSpeed(5);
  134.  
  135. if (inventory.containsOneOf(junkID)) {
  136. inventory.dropAllExcept(featherID);
  137. status = "Dropping junk";
  138. }
  139. switch(getState()) {
  140. case ATTACK:
  141. fightChickens();
  142.  
  143. break;
  144. case CAMERATOChicken:
  145. status = " Camera to Chicken";
  146.  
  147. camera.turnTo(Chicken);
  148. Methods.sleep(Methods.random(500, 750));
  149. break;
  150. case EAT:
  151. status = "Eating Food";
  152. inventory.getItem(foodID).interact("Eat");
  153. break;
  154. case ANTIBAN:
  155. int b = random(1, 43);
  156. switch (b) {
  157. case 1:
  158.  
  159. status = "Moving mouse";
  160. mouse.moveSlightly();
  161. sleep(200, 600);
  162. mouse.moveRandomly(150, 350);
  163.  
  164. break;
  165. case 2:
  166.  
  167. status = " Camera";
  168. camera.setAngle(random(30, 70));
  169. sleep(400, 1200);
  170.  
  171. break;
  172. case 3:
  173.  
  174. status = " Mouse AFK";
  175. mouse.moveOffScreen();
  176. sleep(random(600, random(1200, 2000)));
  177.  
  178. break;
  179. case 4:
  180.  
  181. status = "Checking Exp";
  182. game.openTab(Tab.STATS);
  183. skills.doHover(Skills.INTERFACE_COOKING);
  184. sleep(random(1250, 2000));
  185. game.openTab(Tab.INVENTORY);
  186. break;
  187. case 5:
  188.  
  189. status = " Opening CC";
  190. clanChat.openInformation();
  191. Methods.sleep(1500);
  192. clanChat.closeInformation();
  193. Methods.sleep(300);
  194. game.openTab(Tab.INVENTORY);
  195.  
  196. break;
  197. case 6:
  198.  
  199. status = " Camera";
  200. camera.setAngle(random(20, 90));
  201. sleep(400, 800);
  202.  
  203. break;
  204. case 7:
  205.  
  206. status = " Pitch";
  207. camera.setPitch(1250);
  208. Methods.sleep(Methods.random(300, 1000));
  209. camera.setCompass('n');
  210. break;
  211. case 8:
  212.  
  213. status = "Randomly";
  214. mouse.moveRandomly(Methods.random(1500, 2000));
  215.  
  216. break;
  217. case 9:
  218.  
  219. status = " Moving Camera";
  220. camera.moveRandomly(Methods.random(800, 1200));
  221.  
  222. break;
  223. case 10:
  224.  
  225. status = " Randomly";
  226. camera.moveRandomly(Methods.random(1000, 2000));
  227. status = "Pitch";
  228. camera.setPitch(true);
  229. case 11:
  230.  
  231. status = "Moving Mouse";
  232. mouse.moveSlightly();
  233. mouse.moveRandomly(1500);
  234.  
  235. break;
  236. case 12:
  237.  
  238. if (inventory.containsOneOf(foodID)) {
  239. inventory.getItem(foodID).interact("Examine");
  240. }
  241.  
  242. break;
  243. case 13:
  244.  
  245. quests.openTab();
  246. Methods.sleep(450);
  247.  
  248. break;
  249. case 14:
  250.  
  251. camera.moveRandomly(1500);
  252.  
  253. break;
  254. }
  255. default:
  256. break;
  257. }
  258. return 1000;
  259.  
  260. }
  261.  
  262. private int fightChickens() {
  263. RSNPC newChicken = npcs.getNearest(new Filter<RSNPC>(){
  264. public boolean accept(RSNPC in) {
  265. if (in == null)
  266. return false;
  267. if (!in.getName().contains("Chicken"))
  268. return false;
  269. if (in.isDead())
  270.  
  271. return false;
  272. pickUpfeather();
  273. if (in.getInteracting() != null && !in.getInteracting().equals
  274.  
  275. (getMyPlayer()))
  276.  
  277. return false;
  278. return true;
  279. }
  280. });
  281. if (newChicken != null) {
  282. if (combat.getSpecialBarEnergy() == 155 && !combat.isSpecialEnabled()) {
  283. game.openTab(Tab.ATTACK);
  284. Methods.sleep(300);
  285. status = "Enabling Special";
  286. combat.setSpecialAttack(true);
  287. Methods.sleep(500);
  288. game.openTab(Tab.INVENTORY);
  289. }
  290. if (!players.getMyPlayer().isInCombat()) {
  291. if (newChicken.isOnScreen()) {
  292. status = "Attacking";
  293. newChicken.interact("Attack "+newChicken.getName());
  294. curChicken = newChicken;
  295.  
  296. } else {
  297.  
  298. status = "Walking to Chicken";
  299. walking.walkTileMM(newChicken.getLocation());
  300. }
  301.  
  302. }
  303. }
  304.  
  305. return 1;
  306. }
  307.  
  308. public void onFinish() {
  309.  
  310. }
  311. //START: Code generated using Enfilade's Easel
  312. private Image getImage(String url) {
  313. try {
  314. return ImageIO.read(new URL(url));
  315. } catch(IOException e) {
  316. return null;
  317. }
  318. }
  319. private final Color color1 = new Color(255, 255, 255);
  320. private final Color color2 = new Color(0, 0, 0);
  321. private final Image logo = getImage("http://i.imgur.com/zax3P.png");
  322. private final Image background = getImage("http://i.imgur.com/aZgmj.png");
  323.  
  324. private final BasicStroke stroke1 = new BasicStroke(1);
  325.  
  326. public void onRepaint(Graphics g1) {
  327. Graphics2D g = (Graphics2D)g1;
  328. long millis = System.currentTimeMillis() - startTime;
  329. long hours = millis / (1000 * 60 * 60);
  330. millis -= hours * (1000 * 60 * 60);
  331. long minutes = millis / (1000 * 60);
  332. millis -= minutes * (1000 * 60);
  333. long seconds = millis / 1000;
  334. g.setColor(color1);
  335. g.fillOval(510, 361, 0, 0);
  336. g.setColor(color2);
  337. g.setStroke(stroke1);
  338. g.drawOval(510, 361, 0, 0);
  339.  
  340. g.drawImage(background, 160, 206, null);
  341. g.drawImage(logo, 265, 226, null);
  342. g.drawString("Time Running: "+ hours + ":" + minutes + ":" + seconds, 200, 315);
  343. g.drawString("Created by Stealth", 200, 280);
  344. g.drawString("Status: " +status, 361, 314);
  345. }
  346. //END: Code generated using Enfilade's Easel
  347. public void pickUpfeather() {
  348. RSGroundItem feather = groundItems.getNearest(featherID);
  349. if (feather != null) {
  350. if (feather.isOnScreen()) {
  351. if (feather.interact("Take " + feather.getItem().getName())) {
  352. sleep(random(500, 800));
  353. status = "Looting Feathers";
  354.  
  355. }
  356. } else {
  357. walking.walkTileMM(feather.getLocation());
  358. camera.moveRandomly(200);
  359. }
  360. }
  361. sleep(random(800, 1000));
  362. }
  363.  
  364. @Override
  365. public void mouseClicked(MouseEvent e) {
  366. // TODO Auto-generated method stub
  367.  
  368. }
  369. @Override
  370. public void mouseEntered(MouseEvent e) {
  371. // TODO Auto-generated method stub
  372.  
  373. }
  374. @Override
  375. public void mouseExited(MouseEvent e) {
  376. // TODO Auto-generated method stub
  377.  
  378. }
  379. @Override
  380. public void mousePressed(MouseEvent e) {
  381.  
  382. }
  383. @Override
  384. public void mouseReleased(MouseEvent e) {
  385.  
  386. }
  387.  
  388. public void mouseDragged(MouseEvent e) {
  389. // TODO Auto-generated method stub
  390.  
  391. }
  392.  
  393. public void mouseMoved(MouseEvent e) {
  394. // TODO Auto-generated method stub
  395.  
  396. }
  397. }
Advertisement
Add Comment
Please, Sign In to add comment