Guest User

XFADE48X_FIREMAKER

a guest
Sep 24th, 2013
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.96 KB | None | 0 0
  1. package xfade_firemaker;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Font;
  5. import java.awt.Graphics;
  6. import java.awt.Graphics2D;
  7. import java.awt.Point;
  8. import java.awt.Rectangle;
  9. import java.awt.event.MouseEvent;
  10. import java.awt.image.BufferedImage;
  11. import java.io.IOException;
  12. import java.net.MalformedURLException;
  13. import java.net.URL;
  14. import java.text.DecimalFormat;
  15.  
  16. import javax.imageio.ImageIO;
  17.  
  18. import org.osbot.script.Script;
  19. import org.osbot.script.ScriptManifest;
  20. import org.osbot.script.rs2.model.Entity;
  21. import org.osbot.script.rs2.model.Player;
  22. import org.osbot.script.rs2.skill.Skill;
  23. import org.osbot.script.rs2.ui.Bank;
  24. import org.osbot.script.rs2.ui.Inventory;
  25. import org.osbot.script.rs2.ui.Spell;
  26. import org.osbot.script.rs2.ui.Tab;
  27. import org.osbot.script.rs2.utility.Area;
  28.  
  29. import xfade_firemaker.Timer;
  30.  
  31. @ScriptManifest(author = "xFADE48x", info = "(BETA 1.1) Please read the FAQ for this script to know how to run this script.", name = "xFADE48x FireMaker", version = 1.1)
  32. public class XFADE_FIREMAKER extends Script {
  33.  
  34. private static long startTime = 0;
  35. static Timer runTime;
  36.  
  37. final String BANK_NAME = "Bank booth";
  38.  
  39. final String FIRE_NAME = "Fire";
  40.  
  41. boolean hide = false;
  42. Point p;
  43. Rectangle close = new Rectangle(2, 323, 17, 338);
  44. Rectangle open = new Rectangle(2, 318, 52, 338);
  45. public final Area BANK_AREA = (new Area(3180, 3434, 3185, 3439));
  46. public final Area SQ_AREA = (new Area(3205, 3428, 3209, 3430));
  47. public final Area FIREMAKE_AREA = (new Area(3173, 3428, 3209, 3430));
  48. public final Area TELEPORT_AREA = (new Area(3206, 3420, 3219, 3427));
  49. public final Area SQ_ERROR_AREA = (new Area(3205, 3431, 3222, 3437));
  50.  
  51. public final Area LEFT_AREA = (new Area(3204, 3430, 3207, 3430));
  52. public final Area MIDDLE_AREA = (new Area(3204, 3429, 3207, 3429));
  53. public final Area RIGHT_AREA = (new Area(3204, 3428, 3207, 3428));
  54.  
  55. final int TINDER_BOX_ID = 590;
  56. final int MAGIC_RUNE_ID = 563;
  57. final int FIRE_RUNE_ID = 554;
  58. final int AIR_RUNE_ID = 556;
  59. int LOGS_ID;
  60. int startExp;
  61. int startLvl;
  62. int flaxpicked = 0;
  63.  
  64. BufferedImage img;
  65. BufferedImage img2;
  66. BufferedImage img3;
  67.  
  68. public void onStart() {
  69. try {
  70. // hide
  71. img2 = ImageIO.read(new URL("http://i.imgur.com/CoVqqsG.png"));
  72. } catch (MalformedURLException e) {
  73. // TODO Auto-generated catch block
  74. e.printStackTrace();
  75. } catch (IOException e) {
  76. // TODO Auto-generated catch block
  77. e.printStackTrace();
  78. }
  79. try {
  80. // show
  81. img3 = ImageIO.read(new URL("http://i.imgur.com/IROKQtJ.png"));
  82. } catch (MalformedURLException e) {
  83. // TODO Auto-generated catch block
  84. e.printStackTrace();
  85. } catch (IOException e) {
  86. // TODO Auto-generated catch block
  87. e.printStackTrace();
  88. }
  89.  
  90. try {
  91. // paint
  92. img = ImageIO.read(new URL("http://i.imgur.com/JiifTdH.png"));
  93. } catch (MalformedURLException e) {
  94. // TODO Auto-generated catch block
  95. e.printStackTrace();
  96. } catch (IOException e) {
  97. // TODO Auto-generated catch block
  98. e.printStackTrace();
  99. }
  100.  
  101. runTime = new Timer(0);
  102.  
  103. startExp = client.getSkills().getExperience(Skill.FIREMAKING);
  104.  
  105. startLvl = client.getSkills().getLevel(Skill.FIREMAKING);
  106.  
  107. startTime = System.currentTimeMillis();
  108.  
  109. if (client.getInventory().contains(1511)) {
  110. log("Normal logs has been selected");
  111. LOGS_ID = 1511;
  112. } else if (client.getInventory().contains(1521)) {
  113. log("Oak logs has been selected");
  114. LOGS_ID = 1521;
  115. } else if (client.getInventory().contains(1519)) {
  116. log("Willow logs has been selected");
  117. LOGS_ID = 1519;
  118. } else if (client.getInventory().contains(6333)) {
  119. log("Teak logs has been selected");
  120. LOGS_ID = 6333;
  121. } else if (client.getInventory().contains(1517)) {
  122. log("Maple logs has been selected");
  123. LOGS_ID = 1517;
  124. } else if (client.getInventory().contains(1515)) {
  125. log("Yew logs has been selected");
  126. LOGS_ID = 1515;
  127. } else if (client.getInventory().contains(1513)) {
  128. log("Magic logs has been selected");
  129. LOGS_ID = 1513;
  130. } else {
  131. log("No logs found!");
  132.  
  133. }
  134.  
  135. }
  136.  
  137. public void onExit() {
  138. log("Thanks for using xFADE48x FireMaker!");
  139. log("Ran for: " + runTime(startTime));
  140. log("Fires made: " + flaxpicked);
  141. log("Fires made P/H: " + getPerHour(flaxpicked));
  142. log("If any errors occured when you ran this script, please contact me on skype or on the osbot fourms");
  143.  
  144. }
  145.  
  146. public void AntiBan() throws InterruptedException {
  147. switch (random(1, 100)) {
  148. case 14:
  149. this.client.rotateCameraPitch(50);
  150. case 6:
  151. this.client.rotateCameraToAngle(350);
  152. case 3:
  153. this.client.rotateCameraPitch(50);
  154. }
  155. random(100, 500);
  156. }
  157.  
  158. public void walkToSq() throws InterruptedException {
  159. switch (random(1, 3)) {
  160.  
  161. case 1:
  162. walkExact(LEFT_AREA);
  163. case 2:
  164. walkExact(MIDDLE_AREA);
  165. case 3:
  166. walkExact(RIGHT_AREA);
  167. }
  168. sleep(random(100, 200));
  169.  
  170. }
  171.  
  172. @Override
  173. public int onLoop() throws InterruptedException {
  174.  
  175. Inventory inven = client.getInventory();
  176. Player player = client.getMyPlayer();
  177. Bank bank = client.getBank();
  178.  
  179. if(!Tab.INVENTORY.isOpen(null)) {
  180. openTab(Tab.INVENTORY);
  181. }
  182.  
  183. if (client.getRunEnergy() > 50) {
  184. setRunning(true);
  185.  
  186. }
  187.  
  188. if (inven.contains(LOGS_ID)) {
  189. // firelight
  190.  
  191. if (SQ_ERROR_AREA.contains(player)) {
  192. if (!player.isMoving()) {
  193. walkToSq();
  194. sleep(random(700, 800));
  195. }
  196.  
  197. }
  198.  
  199. if (TELEPORT_AREA.contains(player)) {
  200. if (!player.isMoving()) {
  201. walkToSq();
  202. sleep(random(700, 800));
  203. }
  204.  
  205. }
  206.  
  207. if (FIREMAKE_AREA.contains(player)) {
  208. if (!player.isAnimating() && !player.isMoving()) {
  209. inven.interactWithId(LOGS_ID, "Use", true);
  210. sleep(random(100));
  211. inven.interactWithId(TINDER_BOX_ID, "Use", true);
  212. sleep(random(100));
  213. inven.interactWithId(TINDER_BOX_ID, "Use", true);
  214. sleep(random(1000, 1100));
  215.  
  216. }
  217.  
  218. }
  219.  
  220. if (BANK_AREA.contains(player)) {
  221.  
  222. if (inven.getAmount(AIR_RUNE_ID) < 3) {
  223. if (!player.isMoving()) {
  224. walkToSq();
  225. }
  226. }
  227.  
  228. if (inven.contains(MAGIC_RUNE_ID)
  229. && (inven.contains(FIRE_RUNE_ID))
  230. && (inven.getAmount(AIR_RUNE_ID) > 3)) {
  231. magicTab.open();
  232. magicTab.castSpell(Spell.VARROCK_TELEPORT);
  233. sleep(random(500, 600));
  234. openTab(Tab.INVENTORY);
  235. sleep(random(2200, 2200));
  236.  
  237. }
  238. }
  239.  
  240. if (!inven.contains(MAGIC_RUNE_ID)
  241. && (!inven.contains(FIRE_RUNE_ID))) {
  242.  
  243. if (FIREMAKE_AREA.contains(player)) {
  244.  
  245. if (!player.isAnimating() && !player.isMoving()) {
  246. inven.interactWithId(LOGS_ID, "Use", true);
  247. sleep(random(100));
  248. inven.interactWithId(TINDER_BOX_ID, "Use", true);
  249. sleep(random(100));
  250. inven.interactWithId(TINDER_BOX_ID, "Use", true);
  251. sleep(random(1000, 1100));
  252.  
  253. }
  254.  
  255. } else {
  256. if (!player.isMoving()) {
  257. walkToSq();
  258. sleep(random(700, 800));
  259. }
  260.  
  261. }
  262. }
  263.  
  264. } else {
  265. // bank
  266.  
  267. Entity bankbooth = closestObjectForName(BANK_NAME);
  268.  
  269. if (BANK_AREA.contains(player)) {
  270.  
  271. if (bank.isOpen()) {
  272. if (!bank.contains(LOGS_ID)) {
  273. log("Ran out of logs!");
  274. log("Logging out...");
  275. bank.close();
  276. bank.close();
  277. bank.close();
  278. stop();
  279.  
  280. }
  281. bank.depositAllExcept(TINDER_BOX_ID, MAGIC_RUNE_ID,
  282. FIRE_RUNE_ID, AIR_RUNE_ID);
  283. sleep(random(300, 400));
  284. bank.withdrawAll(LOGS_ID);
  285. sleep(random(300, 400));
  286. bank.close();
  287. sleep(random(300, 400));
  288. bank.close();
  289. sleep(random(300, 400));
  290. bank.close();
  291. sleep(random(300, 400));
  292.  
  293. } else {
  294. if (bankbooth != null) {
  295. if (bankbooth.isVisible()) {
  296. bankbooth.interact("Bank");
  297. sleep(random(1200, 1300));
  298.  
  299. } else {
  300. client.moveCameraToEntity(bankbooth);
  301. }
  302.  
  303. }
  304.  
  305. }
  306.  
  307. } else {
  308. if (!player.isMoving()) {
  309. walk(BANK_AREA);
  310. sleep(random(700, 800));
  311. }
  312.  
  313. }
  314.  
  315. }
  316.  
  317. AntiBan();
  318.  
  319. return 50;
  320.  
  321. }
  322.  
  323. public void onMessage(String message) throws InterruptedException {
  324. Player player = client.getMyPlayer();
  325. Inventory inven = client.getInventory();
  326. if (message.contains("The fire catches and the logs begin to burn.")) {
  327. flaxpicked++;
  328. }
  329. if (message.contains("You can't light a fire here.")) {
  330. if (!player.isMoving()) {
  331. walk(SQ_AREA);
  332. sleep(random(100, 200));
  333. if (SQ_AREA.contains(player)) {
  334. if (FIREMAKE_AREA.contains(player)) {
  335.  
  336. if (!player.isAnimating() && !player.isMoving()) {
  337. inven.interactWithId(LOGS_ID, "Use", true);
  338. sleep(random(100));
  339. inven.interactWithId(TINDER_BOX_ID, "Use", true);
  340. sleep(random(100));
  341. inven.interactWithId(TINDER_BOX_ID, "Use", true);
  342. sleep(random(1000, 1100));
  343.  
  344. }
  345.  
  346. }
  347. }
  348. }
  349. }
  350.  
  351. }
  352.  
  353. // paint
  354. public void onPaint(Graphics g) {
  355.  
  356. Graphics2D gr = (Graphics2D) g;
  357.  
  358. if (!hide) {
  359. // Paint
  360. g.drawImage(img, 2, 338, null);
  361. g.drawImage(img2, 2, 323, null);
  362.  
  363. gr.setColor(Color.BLACK);
  364. gr.setFont(new Font("Arial", Font.PLAIN, 12));
  365.  
  366. // fires made
  367.  
  368. gr.drawString("" + flaxpicked, 320, 357);
  369.  
  370. // fires per hour
  371. gr.drawString("" + getPerHour(flaxpicked), 338, 376);
  372.  
  373. // runtime
  374. gr.drawString("" + runTime(startTime), 306, 395);
  375.  
  376. // xp gained
  377.  
  378. gr.drawString(
  379. ""
  380. + (client.getSkills().getExperience(
  381. Skill.FIREMAKING) - startExp), 321, 434);
  382.  
  383. // xp per hour
  384. gr.drawString(
  385. ""
  386. + getPerHour(client.getSkills().getExperience(
  387. Skill.FIREMAKING)
  388. - startExp), 367, 453);
  389.  
  390. // firemaking lvl
  391.  
  392. gr.drawString(
  393. ""
  394. + (client.getSkills().getLevel(Skill.FIREMAKING)
  395. + " + ("
  396. + (client.getSkills().getLevel(
  397. Skill.FIREMAKING) - startLvl) + ")"),
  398. 347, 415);
  399. } else {
  400. // Show button
  401. g.drawImage(img3, 2, 318, null);
  402. }
  403.  
  404. gr.setColor(Color.RED);
  405. gr.setFont(new Font("Arial", Font.BOLD, 13));
  406.  
  407. gr.drawString("BETA 1.1", 455, 335);
  408.  
  409. }
  410.  
  411. public String runTime(long i) {
  412. DecimalFormat nf = new DecimalFormat("00");
  413. long millis = System.currentTimeMillis() - i;
  414. long hours = millis / (1000 * 60 * 60);
  415. millis -= hours * (1000 * 60 * 60);
  416. long minutes = millis / (1000 * 60);
  417. millis -= minutes * (1000 * 60);
  418. long seconds = millis / 1000;
  419. return nf.format(hours) + ":" + nf.format(minutes) + ":"
  420. + nf.format(seconds);
  421. }
  422.  
  423. public static int getPerHour(int value) {
  424. if (runTime != null && runTime.getElapsed() > 0) {
  425. return (int) (value * 3600000d / runTime.getElapsed());
  426. } else {
  427. return 0;
  428. }
  429. }
  430.  
  431. public static long getPerHour(long value) {
  432. if (runTime != null && runTime.getElapsed() > 0) {
  433. return (long) (value * 3600000d / runTime.getElapsed());
  434. } else {
  435. return 0;
  436. }
  437. }
  438.  
  439. @Override
  440. public void mouseClicked(MouseEvent e) {
  441. p = e.getPoint();
  442. if (close.contains(p) && !hide) {
  443. hide = true;
  444. } else if (open.contains(p) && hide) {
  445. hide = false;
  446. }
  447. }
  448.  
  449. }
Advertisement
Add Comment
Please, Sign In to add comment