Advertisement
Guest User

Untitled

a guest
May 27th, 2015
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.26 KB | None | 0 0
  1. import java.awt.Graphics2D;
  2. import java.awt.Polygon;
  3. import java.awt.Rectangle;
  4. import java.io.IOException;
  5. import java.util.ArrayList;
  6. import java.util.HashSet;
  7. import java.util.Random;
  8. import org.osbot.rs07.api.Bank;
  9. import org.osbot.rs07.api.Camera;
  10. import org.osbot.rs07.api.Configs;
  11. import org.osbot.rs07.api.Dialogues;
  12. import org.osbot.rs07.api.Inventory;
  13. import org.osbot.rs07.api.LocalWalker;
  14. import org.osbot.rs07.api.NPCS;
  15. import org.osbot.rs07.api.Objects;
  16. import org.osbot.rs07.api.Skills;
  17. import org.osbot.rs07.api.Widgets;
  18. import org.osbot.rs07.api.filter.Filter;
  19. import org.osbot.rs07.api.map.Position;
  20. import org.osbot.rs07.api.model.NPC;
  21. import org.osbot.rs07.api.model.Player;
  22. import org.osbot.rs07.api.model.RS2Object;
  23. import org.osbot.rs07.api.ui.RS2Widget;
  24. import org.osbot.rs07.api.ui.Skill;
  25. import org.osbot.rs07.api.util.ExperienceTracker;
  26. import org.osbot.rs07.script.Script;
  27. import org.osbot.rs07.script.ScriptManifest;
  28.  
  29. @ScriptManifest(name="Blast 4 dayz", author="Dubzieisme23", version=1.0, info="", logo="")
  30. public class Blast
  31. extends Script
  32. {
  33. private long startTime;
  34. private long timeElapsed;
  35. private long startTime1;
  36. private long timeElapsed1;
  37. private boolean paid;
  38. public int count;
  39. public long timerM;
  40. public long timerS;
  41. private long minute;
  42. private long second;
  43. private int coalBelt;
  44. private int ironBelt;
  45. private int barsMade;
  46. private int coalPrice;
  47. private int ironPrice;
  48. private int barPrice;
  49. private int profit;
  50. public Blast.Area bridgeArea;
  51.  
  52. public Blast()
  53. {
  54. this.paid = true;
  55. this.count = 0;
  56.  
  57. this.coalBelt = 0;
  58. this.ironBelt = 0;
  59. this.barsMade = 0;
  60.  
  61. this.bridgeArea = new Blast.Area(1940, 4967, 1942, 4967);
  62. }
  63.  
  64. class Constants
  65. {
  66. public static final int coal = 453;
  67. public static final int iron = 440;
  68. public static final int ironBar = 2351;
  69. public static final int steelBar = 2353;
  70.  
  71. Constants() {}
  72. }
  73.  
  74. static class Random
  75. {
  76. public static final Random random = new Random();
  77.  
  78. public static final int getPerHour(double a, long a1)
  79. {
  80. return (int)(a * 3600000.0D / a1);
  81. }
  82.  
  83. public static int nextInt(int a, int a1)
  84. {
  85. return a1 < a ? a1 + nextInt(a - a1) : a + (a1 == a ? 0 : nextInt(a1 - a));
  86. }
  87.  
  88. public static long nextLong(long a)
  89. {
  90. return (random.nextDouble() * a);
  91. }
  92.  
  93. public static long nextLong(long a, long a1)
  94. {
  95. return a1 < a ? a1 + nextLong(a - a1) : a + (a1 == a ? 0L : nextLong(a1 - a));
  96. }
  97.  
  98. public static int nextInt(int a)
  99. {
  100. return (int)(random.nextDouble() * a);
  101. }
  102. }
  103.  
  104. class Area
  105. {
  106. private final Polygon area;
  107. private int z;
  108.  
  109. public Area(Position... tiles)
  110. {
  111. this.area = new Polygon();
  112. for (Position tile : tiles)
  113. {
  114. this.area.addPoint(tile.getX(), tile.getY());
  115. this.z = tile.getZ();
  116. }
  117. }
  118.  
  119. public Area(Position ne, Position sw)
  120. {
  121. this(new Position[] { new Position(Math.max(ne.getX(), sw.getX()) + 1, Math.max(ne.getY() + 1, sw.getY()), ne.getZ()), new Position(
  122. Math.max(ne.getX(), sw.getX()) + 1, Math.min(ne.getY(), sw.getY()), ne.getZ()), new Position(
  123. Math.min(ne.getX(), sw.getX()), Math.min(ne.getY(), sw.getY()), ne.getZ()), new Position(
  124. Math.min(ne.getX(), sw.getX()), Math.max(ne.getY(), sw.getY() + 1), ne.getZ()) });
  125. this.z = ne.getZ();
  126. }
  127.  
  128. public Area(int x1, int y1, int x2, int y2)
  129. {
  130. this(x1, y1, x2, y2, 0);
  131. }
  132.  
  133. public Area(int x1, int y1, int x2, int y2, int z)
  134. {
  135. this(new Position(x1 > x2 ? x1 : x2, y1 > y2 ? y1 : y2, z), new Position(x1 > x2 ? x2 : x1, y1 > y2 ? y2 : y1, z));
  136.  
  137. this.z = z;
  138. }
  139.  
  140. public Position[] getTiles()
  141. {
  142. HashSet<Position> tiles = new HashSet();
  143. Rectangle areaBounds = this.area.getBounds();
  144. for (int x = areaBounds.x; x <= areaBounds.x + areaBounds.width; x++) {
  145. for (int y = areaBounds.y; y <= areaBounds.y + areaBounds.height; y++) {
  146. if (this.area.contains(x, y)) {
  147. tiles.add(new Position(x, y, this.z));
  148. }
  149. }
  150. }
  151. return (Position[])tiles.toArray(new Position[tiles.size()]);
  152. }
  153.  
  154. public Position getRandomTile()
  155. {
  156. Position[] tiles = getTiles();
  157. new Blast.Random();return tiles[Blast.Random.nextInt(0, tiles.length - 1)];
  158. }
  159.  
  160. public boolean contains(int x, int y)
  161. {
  162. return this.area.contains(x, y);
  163. }
  164.  
  165. public boolean contains(Position tile)
  166. {
  167. return (contains(tile.getX(), tile.getY())) && ((this.z < 0) || (tile.getZ() == this.z));
  168. }
  169. }
  170.  
  171. public void onStart()
  172. {
  173. log("What's gucci?");
  174. this.startTime = System.currentTimeMillis();
  175. this.startTime1 = System.currentTimeMillis();
  176. GrandExchange ge = new GrandExchange();
  177. try
  178. {
  179. this.coalPrice = ge.getBuyingPrice(453);
  180. this.ironPrice = ge.getBuyingPrice(440);
  181. this.barPrice = ge.getBuyingPrice(2353);
  182. }
  183. catch (IOException e)
  184. {
  185. log("cant grab");
  186. }
  187. }
  188.  
  189. public void onExit()
  190. {
  191. log("Bye nigga");
  192. }
  193.  
  194. public void checkTime()
  195. {
  196. if (getSkills().getStatic(Skill.SMITHING) < 60)
  197. {
  198. if ((this.timerM == 10L) && (this.timerS == 0L))
  199. {
  200. log("reset");
  201. this.paid = false;
  202. }
  203. }
  204. else {
  205. log("nothing");
  206. }
  207. }
  208.  
  209. public void checkFailure()
  210. {
  211. if (this.inventory.contains(new int[] { 440 })) {
  212. this.ironBelt -= 27;
  213. }
  214. if (this.inventory.contains(new int[] { 453 })) {
  215. this.coalBelt -= 27;
  216. }
  217. }
  218.  
  219. public void resetTime()
  220. {
  221. if (getSkills().getStatic(Skill.SMITHING) < 60)
  222. {
  223. this.startTime1 = System.currentTimeMillis();
  224. this.paid = true;
  225. }
  226. else
  227. {
  228. log("nothing");
  229. }
  230. }
  231.  
  232. public int getOptionCount()
  233. {
  234. RS2Widget var0;
  235. return this.dialogues.isPendingOption() ? 0 : ((var0 = this.widgets.get(219, 0)) != null) && (var0.isVisible()) ? var0.getChildWidgets().length - 3 : 0;
  236. }
  237.  
  238. public RS2Widget getNPCChatWidget()
  239. {
  240. RS2Widget var0;
  241. return ((var0 = this.widgets.get(219, 0)) != null) && (var0.isVisible()) ? var0 : null;
  242. }
  243.  
  244. public ArrayList<String> getOptions()
  245. {
  246. ArrayList var1 = new ArrayList();
  247. RS2Widget var0;
  248. if ((var0 = getNPCChatWidget()) != null)
  249. {
  250. RS2Widget[] var5;
  251. int var4 = (var5 = var0.getChildWidgets()).length;
  252. int var3;
  253. for (int var6 = var3 = 0; var6 < var4; var6 = var3)
  254. {
  255. RS2Widget var2;
  256. if ((!(var2 = var5[var3]).getMessage().equals("")) && (var2.getTextColor() == 0)) {
  257. var1.add(var2.getMessage());
  258. }
  259. var3++;
  260. }
  261. }
  262. return var1;
  263. }
  264.  
  265. public void pay()
  266. throws InterruptedException
  267. {
  268. log("pay");
  269.  
  270. NPC Man = (NPC)this.npcs.closest(new Filter[] { new Filter()
  271. {
  272. public boolean match(NPC npc)
  273. {
  274. return npc.getName().equals("Blast Furnace Foreman");
  275. }
  276. } });
  277. if (Man != null)
  278. {
  279. log("!=null");
  280. if (getDialogues().isPendingOption())
  281. {
  282. getDialogues().selectOption(1);
  283.  
  284. resetTime();
  285. }
  286. else
  287. {
  288. Man.interact(new String[] { "Pay" });
  289. sleep(1000L);
  290. }
  291. }
  292. }
  293.  
  294. public int onLoop()
  295. throws InterruptedException
  296. {
  297. if ((this.dialogues.inDialogue()) && (this.dialogues.isPendingContinuation())) {
  298. this.dialogues.clickContinue();
  299. }
  300. if (this.paid)
  301. {
  302. if ((this.coalBelt == 0) || ((this.coalBelt == 27) && (this.ironBelt == 0)))
  303. {
  304. if ((!this.inventory.contains(new int[] { 453 })) || (this.coalBelt != 0))
  305. {
  306. if ((!this.inventory.contains(new int[] { 440 })) || (this.coalBelt != 27)) {}
  307. }
  308. else
  309. {
  310. log("start");
  311. if (!this.dialogues.isPendingContinuation())
  312. {
  313. log("2nd");
  314. if (getWidgets().get(28, 0) != null) {
  315. getWidgets().get(28, 118).interact(new String[] { "Close" });
  316. }
  317. if (getBank().isOpen()) {
  318. getBank().close();
  319. }
  320. RS2Object conveyor = (RS2Object)getObjects().closest(new Filter[] { new Filter()
  321. {
  322. public boolean match(RS2Object object)
  323. {
  324. if ((object != null) && (object.getName() != null) && (object.getName().equals("Conveyor belt"))) {
  325. if (object.hasAction(new String[] { "Put-ore-on" })) {
  326. return true;
  327. }
  328. }
  329. return false;
  330. }
  331. } });
  332. if (!myPlayer().isMoving()) {
  333. if (this.dialogues.isPendingOption())
  334. {
  335. if (this.dialogues.selectOption(new String[] { "Yes" }))
  336. {
  337. if (this.inventory.contains(new int[] { 453 })) {
  338. this.coalBelt += 27;
  339. } else if (this.inventory.contains(new int[] { 440 })) {
  340. this.ironBelt += 27;
  341. }
  342. sleep(random(1000, 2000));
  343. }
  344. }
  345. else if ((conveyor != null) && ((conveyor.getPosition().distance(myPlayer()) < 8) || (this.bridgeArea.contains(myPlayer().getPosition()))))
  346. {
  347. conveyor.interact(new String[] { "Put-ore-on" });
  348. sleep(random(1000, 2000));
  349. }
  350. else
  351. {
  352. log("fuck me");
  353. log(this.bridgeArea.getRandomTile());
  354. this.localWalker.walk(this.bridgeArea.getRandomTile());
  355. sleep(random(2000, 3000));
  356. }
  357. }
  358. break label1546;
  359. }
  360. if (!getDialogues().isPendingContinuation()) {
  361. break label1546;
  362. }
  363. log("here");
  364. if (this.widgets.getWidgetContainingText(new String[] { "You must ask the foreman's permission" }) == null) {
  365. break label1546;
  366. }
  367. this.paid = false;
  368. break label1546;
  369. }
  370. if ((!this.inventory.contains(new int[] { 453 })) && (this.coalBelt == 0))
  371. {
  372. RS2Object gameObject = (RS2Object)this.objects.closest(new String[] { "Bank chest" });
  373. if (this.inventory.isEmptyExcept(new int[] { 995 })) {
  374. if (((RS2Object)this.objects.closest(new int[] { 26707 })).getPosition().distance(myPlayer()) >= 4)
  375. {
  376. this.localWalker.walk(this.objects.closest(new int[] { 26707 }));
  377. this.camera.toEntity(gameObject);
  378. }
  379. else if (!this.bank.isOpen())
  380. {
  381. gameObject.interact(new String[] { "Use" });
  382. sleep(1000L);
  383. if (this.widgets.get(402, 2) != null) {
  384. this.widgets.get(402, 2, 11).interact(new String[] { "Close" });
  385. }
  386. }
  387. else
  388. {
  389. this.bank.withdrawAll(453);
  390. }
  391. }
  392. }
  393. else if ((!this.inventory.contains(new int[] { 440 })) && (this.coalBelt == 27) && (this.ironBelt == 0))
  394. {
  395. RS2Object gameObject = (RS2Object)this.objects.closest(new String[] { "Bank chest" });
  396. if (this.inventory.isEmptyExcept(new int[] { 995 })) {
  397. if (((RS2Object)this.objects.closest(new int[] { 26707 })).getPosition().distance(myPlayer()) >= 4)
  398. {
  399. this.localWalker.walk(this.objects.closest(new int[] { 26707 }));
  400. this.camera.toEntity(gameObject);
  401. }
  402. else if (!this.bank.isOpen())
  403. {
  404. gameObject.interact(new String[] { "Use" });
  405. sleep(1000L);
  406. if (this.widgets.get(402, 2) != null) {
  407. this.widgets.get(402, 2, 11).interact(new String[] { "Close" });
  408. }
  409. }
  410. else
  411. {
  412. this.bank.withdrawAll(440);
  413. }
  414. }
  415. }
  416. }
  417. else
  418. {
  419. log("waiting on bars");
  420. if (!this.inventory.contains(new int[] { 2353 }))
  421. {
  422. RS2Object Disp = (RS2Object)this.objects.closest(new int[] { 9092 });
  423. checkFailure();
  424. checkTime();
  425. if (Disp.hasAction(new String[] { "Search" }))
  426. {
  427. log("Waiting");
  428. if (((RS2Object)this.objects.closest(new int[] { 9092 })).getPosition().distance(myPlayer()) >= 3) {
  429. this.localWalker.walk(this.objects.closest(new int[] { 9092 }));
  430. }
  431. Disp.hover();
  432. return random(500, 1000);
  433. }
  434. if (Disp.hasAction(new String[] { "Take" })) {
  435. if (getWidgets().get(28, 0) != null)
  436. {
  437. if (this.configs.get(545) > 0) {
  438. if (this.configs.get(545) < 65536) {
  439. getWidgets().get(28, 109).interact(new String[] { "Take" });
  440. } else {
  441. getWidgets().get(28, 110).interact(new String[] { "Take" });
  442. }
  443. }
  444. sleep(random(1000, 2000));
  445. getWidgets().get(28, 118).interact(new String[] { "Close" });
  446. }
  447. else if (Disp != null)
  448. {
  449. if (Disp.hasAction(new String[] { "Take" }))
  450. {
  451. Disp.interact(new String[] { "Take" });
  452. sleep(random(1000, 2500));
  453. }
  454. }
  455. }
  456. }
  457. else if (this.inventory.contains(new int[] { 2353 }))
  458. {
  459. RS2Object gameObject = (RS2Object)this.objects.closest(new String[] { "Bank chest" });
  460. if (((RS2Object)this.objects.closest(new int[] { 26707 })).getPosition().distance(myPlayer()) >= 4)
  461. {
  462. this.localWalker.walk(this.objects.closest(new int[] { 26707 }));
  463. this.camera.toEntity(gameObject);
  464. }
  465. else if (!this.bank.isOpen())
  466. {
  467. gameObject.interact(new String[] { "Use" });
  468. sleep(1000L);
  469. }
  470. else
  471. {
  472. this.bank.depositAllExcept(new int[] { 995 });
  473.  
  474. this.coalBelt = 0;
  475. this.ironBelt = 0;
  476. this.barsMade += 27;
  477. }
  478. }
  479. }
  480. }
  481. else if (!this.paid) {
  482. if (this.inventory.contains(new int[] { 995 }))
  483. {
  484. log("have to pay");
  485. pay();
  486. }
  487. else
  488. {
  489. log("get coins");
  490. stop();
  491. }
  492. }
  493. label1546:
  494. checkTime();
  495. return 100;
  496. }
  497.  
  498. public void onPaint(Graphics2D g)
  499. {
  500. int exp = this.experienceTracker.getGainedXP(Skill.MAGIC);
  501.  
  502. this.timeElapsed = (System.currentTimeMillis() - this.startTime);
  503. this.timeElapsed1 = (System.currentTimeMillis() - this.startTime1);
  504.  
  505. this.second = (this.timeElapsed / 1000L % 60L);
  506. this.minute = (this.timeElapsed / 60000L % 60L);
  507. long hour = this.timeElapsed / 3600000L % 24L;
  508. this.timerS = (this.timeElapsed1 / 1000L % 60L);
  509. this.timerM = (this.timeElapsed1 / 60000L % 60L);
  510. this.profit = (this.barPrice - (this.ironPrice + this.coalPrice));
  511.  
  512. g.drawString("Runtime: " + hour + ":" + this.minute + ":" + this.second, 17, 358);
  513. g.drawString("Paid: " + this.paid, 17, 370);
  514. g.drawString("Timer: 0:" + this.timerM + ":" + this.timerS, 17, 390);
  515. g.drawString("Coal: " + this.coalBelt, 400, 358);
  516. g.drawString("Iron: " + this.ironBelt, 400, 370);
  517. g.drawString("Bars: " + this.barsMade, 400, 382);
  518. g.drawString("Bars/H: " + (int)(this.barsMade * 3600000.0D / this.timeElapsed), 400, 394);
  519. g.drawString("Proft/H: " + (int)(this.barsMade * this.profit * 3600000.0D / this.timeElapsed), 400, 406);
  520. g.drawString("Coal Price: " + this.coalPrice, 400, 40);
  521. g.drawString("Iron Price: " + this.ironPrice, 400, 52);
  522. g.drawString("Bar Price: " + this.barPrice, 400, 64);
  523. g.drawString("Profit Per: " + this.profit, 400, 76);
  524. g.drawString("Profit: " + this.profit * this.barsMade, 400, 418);
  525. }
  526. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement