Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 30th, 2012  |  syntax: None  |  size: 8.21 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import java.awt.*;
  2. import org.rsbot.script.Script;
  3. import org.rsbot.script.methods.*;
  4. import org.rsbot.script.wrappers.*;
  5. import org.rsbot.script.ScriptManifest;
  6. import org.rsbot.event.listeners.PaintListener;
  7. import java.awt.image.BufferedImage;
  8. import java.io.BufferedReader;
  9. import java.io.IOException;
  10. import java.net.URL;
  11. import javax.imageio.ImageIO;
  12.  
  13. @ScriptManifest (authors = "WarLord Burn (Kieren Boal)",
  14. name = "Chicken Theft",
  15. description = "Start at Port Sarim, next to the crate that loots chickens.",
  16. version = 1.00)
  17. public class ChickenTheft extends Script implements PaintListener{
  18.  
  19. long startTime;
  20.  
  21. RSObject Crate, Door, Door2, DepositBox;
  22.  
  23. int LootFailSafe, DepositFailSafe, DoorFailSafe, Looted, Deposits, Price, Delay, SleepDelay, CrateID=15032, DoorID=2069, Door2ID=40108, DepositBoxID=36788, ChickenID=2138;
  24.  
  25. RSTile CheckPoint1, CheckPoint2, CheckPoint3, CheckPoint4, CheckPoint5;
  26.  
  27. BufferedImage MainPicture, Users;
  28.  
  29. boolean CP1, CP2, CP3, CP4, CP5;
  30.  
  31. public boolean onStart() {
  32. try {
  33. Users = ImageIO.read(new URL ("http://www.webcounter.com/4d8362b90a47f/counter.png"));
  34. MainPicture = ImageIO.read(new URL ("http://img838.imageshack.us/img838/7672/44569764.png"));
  35. }catch (final IOException e) {
  36. log("Images have failed to load!");
  37. e.printStackTrace();
  38. }
  39.  
  40. Price = grandExchange.lookup(ChickenID).getGuidePrice();
  41.  
  42. log("Raw chicken Guide Price: "+Price+"gp.");
  43. camera.setPitch(0);
  44. if (!game.isFixed()) {log.severe("Failed to start up. Please change graphics to 'fixed' mode!"); return false;}
  45. if (equipment.getItem(Equipment.BODY).getID()!=1005) {log.severe("Failed to start up. Please start the script while wearing a 'White apron'!"); return false;}
  46. startTime = System.currentTimeMillis();
  47. return true;
  48.  
  49. }
  50.  
  51. public void onFinish() {
  52. log.severe("--WarLord Burn's Chicken Theft 1.00--");
  53. //env.saveScreenshot(true);
  54. }
  55.  
  56. public boolean epicFailSafe() {
  57. if (players.getMyPlayer().getLocation().getX()<2950) {log.severe("epicFailSafe()==false; Saved the day!"); return false;}
  58. if (players.getMyPlayer().getLocation().getX()>3100) {log.severe("epicFailSafe()==false; Saved the day!"); return false;}
  59. if (players.getMyPlayer().getLocation().getY()>3300) {log.severe("epicFailSafe()==false; Saved the day!"); return false;}
  60. if (players.getMyPlayer().getLocation().getY()<3100) {log.severe("epicFailSafe()==false; Saved the day!"); return false;}
  61. if (!game.isLoggedIn()) {log.severe("epicFailSafe()==false; Saved the day!"); return false;}
  62. return true;
  63. }
  64.  
  65. public boolean canLoot() {
  66. if (players.getMyPlayer().getLocation().getX()>3008 && players.getMyPlayer().getLocation().getX()<3012 && players.getMyPlayer().getLocation().getY()<3211 && players.getMyPlayer().getLocation().getY()>3202) {return true;}
  67. return false;
  68. }
  69.  
  70. public boolean inHouse() {
  71. if (players.getMyPlayer().getLocation().getX()>3008 && players.getMyPlayer().getLocation().getX()<3017 && players.getMyPlayer().getLocation().getY()<3211 && players.getMyPlayer().getLocation().getY()>3202) {return true;}
  72. return false;
  73. }
  74.  
  75. public void LootChicken() {
  76.  
  77. if (canLoot()==false) {
  78. if (inHouse()==false){openDoor2();}
  79. if (inHouse()==true) {openDoor();}
  80. sleep(SleepDelay);
  81. }
  82.  
  83. if (canLoot()==true) {
  84. Crate=objects.getNearest(CrateID);
  85. if (Crate!=null && !Crate.isOnScreen()) {camera.turnToObject(Crate);}
  86. if (Crate!=null && Crate.isOnScreen()) {
  87. mouse.move(Crate.getModel().getPoint());
  88. Crate.doAction("Search Crates");
  89. sleep(1,2000);
  90. mouse.move(random(240,280),random(395,410));
  91. while (!interfaces.get(228).isValid() && LootFailSafe<30 && epicFailSafe()==true){sleep(50,250);
  92. LootFailSafe++;
  93. int i=random(1,150);
  94. if (i==5) {camera.setAngle(camera.getAngle()+random(-20,21));}
  95. }
  96. LootFailSafe=0;
  97. mouse.click(true);
  98. Looted++;
  99. }
  100. }
  101. }
  102.  
  103. public void proWalk(boolean B, RSTile T){
  104. walking.walkTileMM(T);
  105. while (B==false && epicFailSafe()==true) {
  106. int i=random(1,10000);
  107. if (i==5) {camera.setAngle(camera.getAngle()+random(-20,21));;}
  108. if (calc.distanceTo(T) > 5 && players.getMyPlayer().isMoving()==false) {walking.walkTileMM(T);}
  109. if (calc.distanceTo(T) < 6) {B=true;}
  110. sleep(1);
  111. }
  112. }
  113.  
  114. public void openDoor() {
  115. if(!walking.isRunEnabled()) {Delay=random(950,1050);}
  116. if(walking.isRunEnabled()) {Delay=random(450,550);}
  117. Door=objects.getNearest(DoorID);
  118. if (Door!=null && !Door.isOnScreen()) {camera.turnToObject(Door);}
  119. if (Door!=null && Door.isOnScreen()) {Door.doAction("Open Door"); SleepDelay=calc.distanceTo(Door.getLocation())*Delay*2;}
  120. }
  121.  
  122. public void openDoor2() {
  123. if(!walking.isRunEnabled()) {Delay=random(950,1050);}
  124. if(walking.isRunEnabled()) {Delay=random(450,550);}
  125.  
  126. Door2=objects.getNearest(Door2ID);
  127.  
  128. if (Door2!=null && !Door2.isOnScreen() && Door2.getLocation().getY()==3206 && Door2.getLocation().getX()==3017) {
  129. if (inHouse()==false) {camera.turnToObject(Door2);}
  130. if (inHouse()==true) {camera.setAngle(random(270,335));}
  131. }
  132. if (Door2!=null && Door2.isOnScreen() && Door2.getLocation().getY()==3206 && Door2.getLocation().getX()==3017) {Door2.doAction("Open Door"); SleepDelay=calc.distanceTo(Door2.getLocation())*Delay;}
  133.  
  134. if (Door2!=null && Door2.getLocation().getY()!=3206 && Door2.getLocation().getX()!=3017) {
  135. if (inHouse()==true) {walking.walkTileMM(new RSTile(3023,3206)); SleepDelay=calc.distanceTo(new RSTile(3023,3206))*Delay;}
  136. if (inHouse()==false) {walking.walkTileMM(new RSTile(3013,3206)); SleepDelay=calc.distanceTo(new RSTile(3013,3206))*Delay;}
  137. }
  138. }
  139.  
  140. public void depositChickens() {
  141. DepositFailSafe=0;
  142.  
  143. while (!interfaces.get(11).isValid() && epicFailSafe()==true){
  144. sleep(1);
  145. DepositFailSafe--;{
  146. if (DepositFailSafe<0) {
  147. DepositBox=objects.getNearest(DepositBoxID);
  148. if (DepositBox!=null && !DepositBox.isOnScreen()) {camera.turnToObject(DepositBox);}
  149. if (DepositBox!=null && DepositBox.isOnScreen()) {
  150. mouse.move(DepositBox.getModel().getPoint());
  151. DepositBox.doAction("Deposit bank deposit box");
  152. mouse.move(random(320,375),random(260,295));
  153. DepositFailSafe=5000;
  154. }
  155. }
  156. }
  157. }
  158.  
  159. if (interfaces.get(11).isValid()){
  160. Deposits++;
  161. sleep(200,500);
  162. mouse.click(random(338,358),random(271,285),true);
  163. CP1=false;
  164. CP2=false;
  165. CP3=false;
  166. CP4=false;
  167. CP5=false;
  168. }
  169.  
  170. }
  171.  
  172. public void goBank() {
  173.  
  174. CheckPoint1 = new RSTile(3025+random(-1,2), 3207+random(-1,2));
  175. CheckPoint2 = new RSTile(3027+random(0,2), 3221+random(-1,2));
  176. CheckPoint3 = new RSTile(3028+random(-1,2), 3231+random(-1,2));
  177. CheckPoint4 = new RSTile(3036+random(-3,4), 3236+random(-1,2));
  178. CheckPoint5 = new RSTile(3047+random(-3,4), 3235+random(-1,2));
  179.  
  180. if(!walking.isRunEnabled() && walking.getEnergy()>random(25,50)){walking.setRun(true);}
  181.  
  182. while (inHouse()==true && epicFailSafe()==true){
  183. if (canLoot()==true) {openDoor();}
  184. if (canLoot()==false) {openDoor2();}
  185. sleep(SleepDelay);
  186. }
  187.  
  188. proWalk(CP1, CheckPoint1);
  189. proWalk(CP2, CheckPoint2);
  190. proWalk(CP3, CheckPoint3);
  191. proWalk(CP4, CheckPoint4);
  192. proWalk(CP4, CheckPoint5);
  193.  
  194. depositChickens();
  195.  
  196. if(!walking.isRunEnabled() && walking.getEnergy()>random(25,50)){walking.setRun(true);}
  197.  
  198. proWalk(CP4, CheckPoint4);
  199. proWalk(CP3, CheckPoint3);
  200. proWalk(CP2, CheckPoint2);
  201. proWalk(CP1, CheckPoint1);
  202.  
  203. while (canLoot()==false && epicFailSafe()==true) {
  204. if (inHouse()==false) {openDoor2();}
  205. if (inHouse()==true) {openDoor();}
  206. sleep(SleepDelay);
  207. }
  208. }
  209.  
  210. public int loop() {
  211. camera.setPitch(0);
  212. mouse.setSpeed(random(4,8));
  213. if (inventory.getCount()<27) {LootChicken();}
  214. if (inventory.getCount()>26) {goBank();}
  215. return 100;
  216. }
  217.  
  218. public void onRepaint(Graphics g) {
  219. g.setFont(new Font("Arial", 0, 16));
  220. g.setColor(new Color(0,0,0));
  221.  
  222. g.drawImage(MainPicture,0,338,null);
  223. g.drawImage(Users,436,320,null);
  224.  
  225. long millis = System.currentTimeMillis() - startTime;
  226. long hours = millis / (1000 * 60 * 60);
  227. millis -= hours * (1000 * 60 * 60);
  228. long minutes = millis / (1000 * 60);
  229. millis -= minutes * (1000 * 60);
  230. long seconds = millis / 1000;
  231.  
  232. double lootHr = Looted*3600000/(System.currentTimeMillis()-startTime);
  233.  
  234. g.drawString(hours+":"+minutes+":"+seconds, 107,370);
  235. g.drawString(""+Looted,63,395);
  236. g.drawString(""+lootHr,63,417);
  237. g.drawString(((Looted*Price)/1000)+"k ("+Price+"gp each)",63,445);
  238. g.drawString(((lootHr*Price)/1000)+"k",63,465);
  239.  
  240. g.setColor(new Color(255,0,0));
  241. g.fillOval(mouse.getLocation().x-10, mouse.getLocation().y-1, 22, 3);
  242. g.fillOval(mouse.getLocation().x-1, mouse.getLocation().y-10, 3, 22);
  243. }
  244. }