Advertisement
asciicat

GateStones.java 2.52

Jun 5th, 2011
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.12 KB | None | 0 0
  1. import java.awt.Color;
  2. import java.awt.Graphics;
  3. import java.awt.Graphics2D;
  4. import java.awt.Image;
  5. import java.awt.RenderingHints;
  6. import org.rsbot.script.Script;
  7. import org.rsbot.script.ScriptManifest;
  8.  
  9. import org.rsbot.script.methods.Skills;
  10. import org.rsbot.script.wrappers.RSObject;
  11. import org.rsbot.script.wrappers.RSTile;
  12. import org.rsbot.script.wrappers.RSArea;
  13.  
  14. import java.awt.event.KeyEvent;
  15. import java.io.IOException;
  16. import java.net.URL;
  17. import javax.imageio.ImageIO;
  18. import javax.swing.JOptionPane;
  19. import org.rsbot.event.listeners.PaintListener;
  20. import org.rsbot.script.methods.Game;
  21.  
  22. @ScriptManifest(authors = "Maze2234", name = "GateStone Maker", version = 2.53, description = "Creates gatestones within daemonheim for magic experience.")
  23.  
  24.  
  25. public class GateStones extends Script implements PaintListener {
  26.  
  27.  
  28. //Variables_______________________________________________________________________
  29.  
  30. private int startExp;
  31. private int gainedExp;
  32. private int startLvl;
  33. private int gainedLvls;
  34. private int currentLevel;
  35. private int percentLevel;
  36. private int mouseSpeed = 1;
  37. private int[] dungLadderID = {51156, 50604, 51704, 54675};
  38. private int ExpHour = 0;
  39. private long startTime;
  40. private long runTime;
  41. private long expLevel;
  42. private boolean checkedSkill = false;
  43.  
  44. private final Image gateStone = getImage("http://rs2basic.webs.com/Images/Gatestone%20(Main).PNG");
  45.  
  46. //Voids & Booleans________________________________________________________________
  47.  
  48. //Locations and Walking
  49. private boolean outSide(){
  50. RSArea area = new RSArea(new RSTile(3445, 3718), new RSTile(3472, 3729));
  51. return area.contains(getMyPlayer().getLocation());
  52. }
  53.  
  54. //Clicking Objects
  55. private void clickDoor() {
  56. antiBan();
  57. if (objects.getNearest(48496) != null) {
  58. if (!interfaces.get(236).isValid() && !interfaces.get(210).isValid()) {
  59. if (!interfaces.get(947).isValid() && !interfaces.get(938).isValid()) {
  60. RSObject dungDoor = objects.getNearest(48496);
  61. RSTile doorLocation = objects.getNearest(48496).getLocation();
  62. if (!dungDoor.isOnScreen() && doorLocation != null) {
  63. walking.walkTileOnScreen(doorLocation);
  64. camera.turnTo(dungDoor);
  65. //web.getWeb(getMyPlayer().getLocation(), doorLocation).step();
  66. sleep(random(1200, 1400));
  67. }
  68. if (dungDoor.isOnScreen()) {
  69. dungDoor.doHover();
  70. sleep(random(50, 100));
  71. if (menu.contains("Climb-down")) {
  72. mouse.click(true);
  73. sleep(random(1200, 1600));
  74. }
  75. }
  76. }
  77. }
  78. }
  79. }
  80.  
  81. private void clickLadder() {
  82. antiBan();
  83. if (objects.getNearest(dungLadderID) != null) {
  84. if (!interfaces.get(236).isValid() && !interfaces.get(211).isValid()) {
  85. RSObject dungLadder = objects.getNearest(dungLadderID);
  86. RSTile ladderLocation = objects.getNearest(dungLadderID).getLocation();
  87. if (!dungLadder.isOnScreen() && ladderLocation != null) {
  88. walking.walkTileOnScreen(ladderLocation);
  89. camera.turnTo(dungLadder);
  90. //web.getWeb(getMyPlayer().getLocation(), ladderLocation).step();
  91. sleep(random(1200, 1400));
  92. }
  93. if (dungLadder.isOnScreen()) {
  94. dungLadder.doHover();
  95. sleep(random(50, 100));
  96. if (menu.contains("Climb-up")) {
  97. mouse.click(true);
  98. sleep(random(1500, 1800));
  99. }
  100. }
  101. }
  102. }
  103. }
  104.  
  105. private void clickStairs() {
  106. antiBan();
  107. if (objects.getNearest(50552) != null && getMyPlayer().getAnimation() != 13760) {
  108. RSObject dungStairs = objects.getNearest(50552);
  109. RSTile stairLocation = objects.getNearest(50552).getLocation();
  110. if (!dungStairs.isOnScreen() && stairLocation != null) {
  111. walking.walkTileOnScreen(stairLocation);
  112. camera.turnTo(dungStairs);
  113. //web.getWeb(getMyPlayer().getLocation(), stairLocation).step();
  114. sleep(random(1200, 1400));
  115. }
  116. if (dungStairs.isOnScreen()) {
  117. dungStairs.doHover();
  118. sleep(random(50, 100));
  119. if (menu.contains("Jump-down")) {
  120. mouse.click(true);
  121. sleep(random(500, 800));
  122. }
  123. }
  124. }
  125. }
  126.  
  127. //Exploring Interfaces
  128.  
  129. private void formParty() {
  130. antiBan();
  131. if (interfaces.get(210).getComponent(2).isValid()) {
  132. mouse.setSpeed(mouseSpeed + random(0, 5));
  133. interfaces.get(210).getComponent(2).doClick();
  134. sleep(random(300, 400));
  135. }
  136. if (interfaces.get(236).getComponent(1).isValid()) {
  137. mouse.setSpeed(mouseSpeed + random(0, 5));
  138. interfaces.get(236).getComponent(1).doClick();
  139. sleep(random(300, 400));
  140. }
  141. }
  142.  
  143. private void setDifficulty() {
  144. antiBan();
  145. if (interfaces.get(947).getComponent(761).isValid()) {
  146. mouse.setSpeed(mouseSpeed + random(0, 5));
  147. interfaces.get(947).getComponent(761).doClick();//change floor (finish)
  148. sleep(random(200, 400));
  149. }
  150. if (interfaces.get(938).getComponent(39).isValid()) {
  151. mouse.setSpeed(mouseSpeed + random(0, 5));
  152. interfaces.get(938).getComponent(39).doClick();//change complexity (finish)
  153. sleep(random(200, 400));
  154. }
  155. }
  156.  
  157. private void setSize() {
  158. if (interfaces.get(236).getComponent(1).isValid()) {
  159. mouse.setSpeed(mouseSpeed + random(0, 5));
  160. interfaces.get(236).getComponent(1).doClick();//size (small)
  161. }
  162. }
  163.  
  164. private void makeStones() {
  165. if (inventory.contains(17489)) {
  166. antiBan();
  167. mouse.setSpeed(mouseSpeed + random(0, 3));
  168. inventory.getItem(17489).doAction("Drop");
  169. keyboard.pressKey((char) KeyEvent.VK_F4);
  170. sleep(random(75, 100));
  171. keyboard.releaseKey((char) KeyEvent.VK_F4);
  172. mouse.setSpeed(mouseSpeed + random(0, 3));
  173. interfaces.get(950).getComponent(38).doAction("Quick-cast");//make gatestone
  174. sleep(random(650, 750));
  175. keyboard.pressKey((char) KeyEvent.VK_F1);
  176. sleep(random(75, 100));
  177. keyboard.releaseKey((char) KeyEvent.VK_F1);
  178. } else if (!inventory.contains(17489)) {
  179. keyboard.pressKey((char) KeyEvent.VK_F4);
  180. sleep(random(75, 100));
  181. keyboard.releaseKey((char) KeyEvent.VK_F4);
  182. mouse.setSpeed(mouseSpeed + random(0, 3));
  183. interfaces.get(950).getComponent(38).doAction("Quick-cast");//make gatestone
  184. keyboard.pressKey((char) KeyEvent.VK_F1);
  185. sleep(random(75, 100));
  186. keyboard.releaseKey((char) KeyEvent.VK_F1);
  187. sleep(random(650, 750));
  188. }
  189. }
  190.  
  191. private void leaveDung() {
  192. clickLadder();
  193. antiBan();
  194. if (interfaces.get(211).getComponent(3).isValid()) {
  195. mouse.setSpeed(mouseSpeed + random(0, 5));
  196. interfaces.get(211).getComponent(3).doClick();//Leave party (Continue)
  197. sleep(random(800, 1000));
  198. }
  199. if (interfaces.get(236).getComponent(1).isValid()) {
  200. mouse.setSpeed(mouseSpeed + random(0, 5));
  201. interfaces.get(236).getComponent(1).doClick();//Leave party (Yes)
  202. }
  203. }
  204.  
  205. //Other
  206. @Override
  207. public boolean onStart(){
  208. startExp = skills.getCurrentExp(Skills.MAGIC);
  209. startLvl = skills.getRealLevel(Skills.MAGIC);
  210. startTime = System.currentTimeMillis();
  211. log("Welcome to Maze's GateStone maker.");
  212. Object[] options = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10"};
  213. mouseSpeed = (int)JOptionPane.showOptionDialog(null, "Choose the mouse speed for the script: \n" + "(1 being the fastest)", "GateStones",JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, 1);
  214. return true;
  215. }
  216.  
  217. @Override
  218. public void onFinish(){
  219. log("Thanks for using Maze's Gatestone maker.");
  220. log("You gained "+ (gainedExp) +" experiance and "+ gainedLvls +" magic levels.");
  221. env.saveScreenshot(true);
  222. sleep(500);
  223. }
  224.  
  225.  
  226. private String formatTime(final long time) {
  227. final int sec = (int) (time / 1000), h = sec / 3600, m = sec / 60 % 60, s = sec % 60;
  228. return (h < 10 ? "0" + h : h) + ":" + (m < 10 ? "0" + m : m) + ":"
  229. + (s < 10 ? "0" + s : s);
  230. }
  231.  
  232. private Image getImage(String url) {
  233. try {
  234. return ImageIO.read(new URL(url));
  235. } catch (IOException e) {
  236. return null;
  237. }
  238. }
  239.  
  240. private void antiBan() {
  241. int antiBan = random(1, 80);
  242. mouse.setSpeed(mouseSpeed + random(3, 7));
  243. switch (antiBan) {
  244. case 3:
  245. camera.moveRandomly(1000);
  246. sleep(random(300, 500));
  247. break;
  248. case 5:
  249. camera.setPitch(random(1, 100));
  250. sleep(random(300, 500));
  251. break;
  252. case 7:
  253. camera.setAngle(random(50, 500));
  254. sleep(random(300, 500));
  255. break;
  256. case 10:
  257. RSTile turnTo = new RSTile(getMyPlayer().getLocation().getX() + random(-5, 5), getMyPlayer().getLocation().getY() + random(1, 5), getMyPlayer().getLocation().getZ());
  258. if (turnTo != null) {
  259. camera.turnTo(turnTo, random(0, 10));
  260. sleep(random(300, 500));
  261. }
  262. break;
  263. case 15:
  264. mouse.moveSlightly();
  265. sleep(random(50, 300));
  266. break;
  267. case 20:
  268. if (random(1, 8) == 2) {
  269. mouse.moveOffScreen();
  270. sleep(random(1000, 10000));
  271. }
  272. break;
  273. case 25:
  274. if (random(1, 6) == 3) {
  275. game.openTab(Game.TAB_STATS);
  276. sleep(random(3000, 5000));
  277. }
  278. break;
  279. case 30:
  280. if (random(1, 10) == 4) {
  281. RSTile walkTo = new RSTile(getMyPlayer().getLocation().getX() + random(-5, 5), getMyPlayer().getLocation().getY() + random(1, 5), getMyPlayer().getLocation().getZ());
  282. if (walkTo != null){
  283. walking.walkTileOnScreen(walkTo);
  284. sleep(random(1000, 3000));
  285. }
  286. }
  287. break;
  288. default:
  289. break;
  290. }
  291. }
  292.  
  293. //LOOP____________________________________________________________
  294.  
  295. @Override
  296. public int loop() {
  297.  
  298. if(game.isLoggedIn() && getMyPlayer().isOnScreen()) {
  299.  
  300. //Starting a party
  301. if(game.getPlane() == 0 && outSide()) {
  302. clickDoor();
  303. formParty();
  304. clickDoor();
  305. setDifficulty();
  306. setSize();
  307. }
  308.  
  309. if (!outSide() && game.getPlane() == 0) {
  310. //Making gatestones
  311. if (inventory.getCount(true, 16100) >= 3) {
  312. if(inventory.contains(16845) == true)
  313. {
  314. mouse.click(580,265,5,1,false);
  315. sleep(55,75);
  316. mouse.click(580,342,5,1,true);
  317. }
  318. makeStones();
  319. }
  320. //Leaving Dungeon
  321. if (inventory.getCount(true, 16100) <=2 && inventory.getCount(true, 16100) != -1 || inventory.getCount(true, 16100) == -1) {
  322. leaveDung();
  323. }
  324. }
  325.  
  326. if (game.getPlane() == 1) {
  327. mouse.setSpeed(mouseSpeed + random(0, 6));
  328. clickStairs();
  329. }
  330.  
  331. }
  332.  
  333. return 0;
  334.  
  335. }
  336.  
  337.  
  338.  
  339. //Paint____________________________________________________
  340.  
  341. @Override
  342. public void onRepaint(Graphics g1) {
  343. if(game.isLoggedIn()) {
  344. final Graphics2D g2 = (Graphics2D) g1;
  345. g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
  346. RenderingHints.VALUE_ANTIALIAS_ON);
  347. currentLevel = skills.getRealLevel(Skills.MAGIC);
  348. gainedLvls = skills.getRealLevel(Skills.MAGIC) - startLvl;
  349. gainedExp = skills.getCurrentExp(Skills.MAGIC) - startExp;
  350. expLevel = skills.getExpToNextLevel(Skills.MAGIC);
  351. ExpHour = (int) ((3600000.0 / (double) runTime) * gainedExp);
  352. runTime = System.currentTimeMillis() - startTime;
  353. percentLevel = skills.getPercentToNextLevel(Skills.MAGIC);
  354. g2.setColor(Color.BLUE);
  355. g2.drawImage(gateStone, 2, 138, null);
  356. g2.drawString("By: Maze2234", 77, 215);
  357. g2.setColor(Color.BLACK);
  358. g2.drawString("Level: " + currentLevel + " (" + gainedLvls + ")", 80, 245);
  359. if (gainedExp /1000 <= 0) {
  360. g2.drawString("Gained: " + (gainedExp) + " (" + (ExpHour / 1000) + "K Xp/h)", 57, 260);
  361. } else if (gainedExp / 1000 >= 1) {
  362. g2.drawString("Gained: " + (gainedExp) / 1000 + "K " + " (" + (ExpHour / 1000) + "K Xp/h)", 57, 260);
  363. } else if (gainedExp / 1000000 >= 1) {
  364. g2.drawString("Gained: " + (gainedExp) / 1000000 + "M (WOW, Post a prog)" + " (" + (ExpHour / 1000) + "K Xp/h)", 57, 260);
  365. }
  366. if (expLevel /1000 <= 0) {
  367. g2.drawString("To Level: " + expLevel, 70, 275);
  368. } else if (expLevel /1000 >= 1) {
  369. g2.drawString("To Level: " + expLevel / 1000 + "K", 70, 275);
  370. } else if (expLevel /1000000 >= 1) {
  371. g2.drawString("To Level: " + expLevel / 1000000 + "M", 70, 275);
  372. }
  373. if(ExpHour != 0 && gainedExp >= 2000){
  374. float timeTNLhour = 0;
  375. timeTNLhour = (float) expLevel/(float)ExpHour;
  376. float timeTNLmin = timeTNLhour*60;
  377. float timeTNLsec = timeTNLmin*60;
  378. int estimatedHour = (int) (timeTNLsec/3600);
  379. float tempminutes = timeTNLsec%3600;
  380. int estimatedMinutes = (int) (tempminutes/60);
  381. int estimatedSeconds = (int) (tempminutes%60);
  382. if (estimatedMinutes < 10 && estimatedSeconds < 10) {
  383. g2.drawString("Time to Level: " + estimatedHour + ":0" + estimatedMinutes + ":0" + estimatedSeconds, 55, 290);
  384. } else if (estimatedMinutes > 10 && estimatedSeconds < 10) {
  385. g2.drawString("Time to Level: " + estimatedHour + ":" + estimatedMinutes + ":0" + estimatedSeconds, 55, 290);
  386. } else if (estimatedMinutes < 10 && estimatedSeconds > 10) {
  387. g2.drawString("Time to Level: " + estimatedHour + ":0" + estimatedMinutes + ":" + estimatedSeconds, 55, 290);
  388. } else {
  389. g2.drawString("Time to Level: " + estimatedHour + ":" + estimatedMinutes + ":" + estimatedSeconds, 55, 290);
  390. }
  391. } else if (ExpHour == 0 || gainedExp <= 5000) {
  392. g2.drawString("Time to Level: N/A", 62, 290);
  393. }
  394. g2.drawString("Run Time: " + formatTime(runTime), 60, 320);
  395. g2.setColor(Color.BLACK);
  396. g2.fillRect(65, 330, 100, 4);
  397. g2.setColor(Color.GREEN);
  398. g2.fillRect(63, 330, percentLevel, 4);
  399.  
  400. }
  401.  
  402. }
  403.  
  404.  
  405. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement