Guest User

Untitled

a guest
Dec 11th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.10 KB | None | 0 0
  1. import java.awt.Graphics;
  2. import java.awt.Point;
  3. import java.awt.event.ActionEvent;
  4. import java.awt.event.ActionListener;
  5.  
  6. import java.awt.event.MouseEvent;
  7. import java.awt.event.MouseListener;
  8. import java.awt.event.MouseMotionListener;
  9.  
  10. import java.awt.*;
  11. import javax.imageio.ImageIO;
  12. import java.io.IOException;
  13. import java.net.URL;
  14. import java.util.Random;
  15.  
  16. import org.rsbot.event.events.MessageEvent;
  17. import org.rsbot.event.listeners.MessageListener;
  18. import org.rsbot.event.listeners.PaintListener;
  19. import org.rsbot.script.Script;
  20. import org.rsbot.script.ScriptManifest;
  21. import org.rsbot.script.methods.Game;
  22. import org.rsbot.script.methods.Inventory;
  23. import org.rsbot.script.methods.Skills;
  24. import org.rsbot.script.util.Filter;
  25. import org.rsbot.script.util.Timer;
  26. import org.rsbot.script.wrappers.RSArea;
  27. import org.rsbot.script.wrappers.RSGroundItem;
  28. import org.rsbot.script.wrappers.RSItem;
  29. import org.rsbot.script.wrappers.RSNPC;
  30. import org.rsbot.script.wrappers.RSObject;
  31. import org.rsbot.script.wrappers.RSPath;
  32. import org.rsbot.script.wrappers.RSPlayer;
  33. import org.rsbot.script.wrappers.RSTile;
  34.  
  35. @ScriptManifest(authors = { "Wei Su" }, name = "Blue Dragon Resource Killer", version = 1.0, description = "Kills blue dragons for loot in the taverly resource dungeon", keywords = {
  36. "Dragon", "money", "admin" })
  37. public class WeiDK extends Script implements PaintListener, MessageListener,
  38. ActionListener, MouseMotionListener, MouseListener {
  39.  
  40.  
  41.  
  42. public int[] oD = { 4665, 4682, 4683, 4666 };
  43. public int count;
  44.  
  45. public int[] dragonsID = { 55, 4681, 4682, 4683, 4684 };
  46. public int foodID = 7946;
  47. public int foodAmount = 5;
  48. public int tab = 8009;
  49. public int[] supplies = {foodID, tab};
  50. public final static RSArea insideDungeon = new RSArea(2877, 9781, 2925,
  51. 9815);
  52. public final static RSArea falador = new RSArea(2936, 3344, 2983, 3392);
  53. public final static RSArea faladorBank = new RSArea(2944, 3367, 2948, 3374);
  54. public final static RSArea outsideFalador = new RSArea(2850, 3325, 2935,
  55. 3404);
  56. public final static RSArea dragonsLair = new RSArea(950, 4480, 1025, 4545);
  57.  
  58. public RSTile destination = null;
  59.  
  60. @Override
  61. public boolean onStart() {
  62. sleep(1000);
  63.  
  64. return true;
  65. }
  66.  
  67.  
  68.  
  69. @Override
  70. public int loop() {
  71.  
  72. try {
  73. RSObject crumblingWall = objects.getNearest(11844);
  74. RSObject bankBooth = objects.getNearest(11758);
  75. RSObject ladder = objects.getNearest(55404);
  76. RSObject shortcut = objects.getNearest(9293);
  77. RSObject resourceEntrance = objects.getNearest(52852);
  78. RSNPC outDragons = npcs.getNearest(oD);
  79.  
  80. switch (getCase()) {
  81.  
  82. case 1:
  83. doFaladorWalking();
  84. log("doFaladorWalking");
  85. return random(50, 100);
  86.  
  87. case 2:
  88. doFaladorBanking();
  89. log("doFaladorBanking");
  90. return random(50, 100);
  91.  
  92. case 3:
  93. doWithdrawing();
  94. log("doWithdrawing");
  95. return random(50, 100);
  96.  
  97. case 4:
  98. crumblingWallPath();
  99. log("crumblingWallPath");
  100. return random(50, 100);
  101.  
  102. case 5:
  103. climbCrumblingWall();
  104. log("climbCrumblingWall");
  105. return random(50, 100);
  106.  
  107. case 6:
  108. walkToDungeon();
  109. log("walkToDungeon");
  110. return random(50, 100);
  111.  
  112. case 7:
  113. climbDownLadder();
  114. log("climbDownLadder");
  115. return random(50, 100);
  116.  
  117. case 8:
  118. usePipe();
  119. log("usePipe");
  120. return random(50, 100);
  121.  
  122. case 9:
  123. walkToResource();
  124. log("walkToResource");
  125. return random(50, 100);
  126.  
  127. case 10:
  128. enterResource();
  129. log("enterResource");
  130. return random(50, 100);
  131.  
  132. case 11:
  133. attack();
  134. log("attack");
  135. return random(50, 100);
  136.  
  137. case 12:
  138. healing();
  139. log("healing");
  140. return random(50, 100);
  141.  
  142. case 13:
  143. teleSafe();
  144. log("teleSafe");
  145. return random(50, 100);
  146.  
  147. case 14:
  148. teleSafe();
  149. log("teleSafe");
  150. return random(50, 100);
  151.  
  152. }
  153. } catch (Exception ignore) {
  154. }
  155.  
  156. return (random(80, 90));
  157. }
  158.  
  159. public int getCase() {
  160. RSObject crumblingWall = objects.getNearest(11844);
  161. RSObject bankBooth = objects.getNearest(11758);
  162. RSObject ladder = objects.getNearest(55404);
  163. RSObject shortcut = objects.getNearest(9293);
  164. RSObject resourceEntrance = objects.getNearest(52852);
  165. RSNPC outDragons = npcs.getNearest(oD);
  166.  
  167. if (inFalador() && !inBank()
  168. && (inventory.isFull() || getLifePoints()<90)) {
  169. log("1");
  170. return 1;
  171. }
  172.  
  173. if (!needToHeal() && inLair() && killDragons()
  174. && !getMyPlayer().isInCombat()
  175. && getMyPlayer().getInteracting() == null) {
  176. log("11");
  177. return 11;
  178. }
  179.  
  180. if (needToHeal() && canHeal()) {
  181. log("12)");
  182. return 12;
  183. }
  184.  
  185. if (needTeleSafe() && inLair()) {
  186. log("13");
  187. return 13;
  188. }
  189.  
  190. if (inFalador() && inBank() && inventory.isFull()) {
  191. log("2");
  192. return 2;
  193. }
  194.  
  195. if (inFalador() && inBank() && needSupplies()) {
  196. log("3");
  197. return 3;
  198. }
  199.  
  200. if (inFalador() && readyForDungeon() && !crumblingWall.isOnScreen()) {
  201. log("4");
  202. return 4;
  203. }
  204.  
  205. if (inFalador() && readyForDungeon() && crumblingWall != null) {
  206. log("5");
  207. return 5;
  208. }
  209.  
  210. if (outsideFally() && readyForDungeon()
  211. && (ladder == null || calc.distanceTo(ladder) > 5)) {
  212. log("6");
  213. return 6;
  214. }
  215.  
  216. if (outsideFally() && readyForDungeon() && calc.distanceTo(ladder) < 5) {
  217. log("7");
  218. return 7;
  219. }
  220.  
  221. if (getMyPlayer().getLocation().getY() > 9000 && needToPipe()
  222. && readyForDungeon()) {
  223. log("8");
  224. return 8;
  225. }
  226.  
  227. if (!resourceEntrance.isOnScreen() && inDungeon() && readyForDungeon()
  228. && insideDungeon.contains(getMyPlayer().getLocation())) {
  229. log("9");
  230. return 9;
  231. }
  232.  
  233. if (inDungeon() && readyForDungeon() && resourceEntrance.isOnScreen()
  234. && insideDungeon.contains(getMyPlayer().getLocation())) {
  235. log("10");
  236. return 10;
  237. }
  238.  
  239. if (tripEnded()) {
  240. log("14");
  241. return 14;
  242. }
  243.  
  244. return -9001;
  245. }
  246.  
  247. public boolean inFalador() {
  248. if (falador.contains(getMyPlayer().getLocation())) {
  249. return true;
  250. } else {
  251. return false;
  252. }
  253.  
  254. }
  255.  
  256. public boolean inBank() {
  257. if (faladorBank.contains(getMyPlayer().getLocation())) {
  258. return true;
  259. } else {
  260. return false;
  261. }
  262.  
  263. }
  264.  
  265. public void walking() {
  266. RSPath path = null;
  267. if (path == null) {
  268. path = walking.getPath(destination);
  269. }
  270. path.traverse();
  271.  
  272. }
  273.  
  274. public void doFaladorWalking() {
  275.  
  276. destination = new RSTile(2946, 3369);
  277. walking();
  278.  
  279. }
  280.  
  281. public void doFaladorBanking() {
  282. RSObject bankBooth = objects.getNearest(11758);
  283. if (!bank.isOpen()) {
  284. if (bankBooth.isOnScreen()) {
  285. bankBooth.doAction("Use-q");
  286. } else {
  287. camera.turnTo(bankBooth);
  288. }
  289. } else {
  290. bank.depositAll();
  291. }
  292. }
  293.  
  294. public boolean needSupplies() {
  295. if (inventory.containsAll(supplies)) {
  296. return false;
  297. } else {
  298. return true;
  299. }
  300. }
  301.  
  302. public void doWithdrawing() {
  303. RSObject bankBooth = objects.getNearest(11758);
  304. if(bankBooth.isOnScreen()){
  305. if(bank.isOpen()){
  306.  
  307. if(inventory.getCount(foodID) != foodAmount ){
  308. bank.withdraw(foodID, foodAmount);
  309. sleep(random(1000,1200));
  310. }
  311.  
  312. if(inventory.contains(tab)){
  313. bank.withdraw(tab, 1);
  314. }
  315. }
  316. } else {
  317. camera.turnTo(bankBooth);
  318. }
  319. }
  320.  
  321. public boolean readyForDungeon() {
  322. if (getLifePoints()>90 && !needSupplies() && !inventory.isFull()) {
  323. return true;
  324. } else {
  325. return false;
  326. }
  327. }
  328.  
  329. public void crumblingWallPath() {
  330. destination = new RSTile(2936, 3355);
  331. walking();
  332. }
  333.  
  334. public void climbCrumblingWall() {
  335. RSObject crumblingWall = objects.getNearest(11844);
  336. if (crumblingWall.isOnScreen()) {
  337. crumblingWall.doAction("Climb");
  338. sleep(random(900, 1200));
  339. } else {
  340. camera.turnTo(crumblingWall);
  341. }
  342. }
  343.  
  344. public boolean outsideFally() {
  345. return outsideFalador.contains(getMyPlayer().getLocation());
  346. }
  347.  
  348. public void walkToDungeon() {
  349. destination = new RSTile(2885, 3395);
  350. walking();
  351. }
  352.  
  353. public void climbDownLadder() {
  354. RSObject ladder = objects.getNearest(55404);
  355. if (ladder.isOnScreen()) {
  356. ladder.doAction("Climb");
  357. sleep(random(900, 1200));
  358. } else {
  359. camera.turnTo(ladder);
  360. }
  361. }
  362.  
  363. public boolean inDungeon() {
  364. RSObject shortcut = objects.getNearest(9293);
  365. RSNPC outDragons = npcs.getNearest(oD);
  366.  
  367. if (shortcut.isOnScreen() || outDragons.isOnScreen()) {
  368. return true;
  369. } else {
  370. return false;
  371. }
  372.  
  373. }
  374.  
  375. public boolean needToPipe() {
  376. if (getMyPlayer().getLocation().getX() < 2889) {
  377. return true;
  378. } else {
  379. return false;
  380. }
  381.  
  382. }
  383.  
  384. public void usePipe() {
  385. RSObject shortcut = objects.getNearest(9293);
  386. shortcut.doAction("Squeeze");
  387. sleep(random(900, 1300));
  388. }
  389.  
  390. public void walkToResource() {
  391. destination = new RSTile(2912, 9810);
  392. walking();
  393. }
  394.  
  395. public void enterResource() {
  396. RSObject resourceEntrance = objects.getNearest(52852);
  397. if (resourceEntrance.isOnScreen()) {
  398. resourceEntrance.doAction("Enter");
  399. sleep(random(900, 1300));
  400. } else {
  401. camera.turnTo(resourceEntrance);
  402. }
  403. }
  404.  
  405. public void attack() {
  406. RSNPC npc = getNpc();
  407. if (npc != null) {
  408. camera.turnTo(npc);
  409. if (!npc.isOnScreen())
  410. destination = (npc.getLocation());
  411. walking();
  412. if (!getMyPlayer().isInCombat()
  413. && getMyPlayer().getInteracting() == null)
  414. npc.doAction("Attack");
  415. }
  416. }
  417.  
  418. public RSNPC getNpc() {
  419. final Filter<RSNPC> filter = new Filter<RSNPC>() {
  420.  
  421. public boolean accept(RSNPC n) {
  422. return (validNpc(n) && (!n.isInCombat() && n.getInteracting() == null))
  423. && n.getHPPercent() != 0;
  424. }
  425. };
  426.  
  427. return npcs.getNearest(filter);
  428. }
  429.  
  430. public boolean validNpc(RSNPC n) {
  431. if (n != null) {
  432. for (int id : dragonsID) {
  433. if (id == n.getID())
  434. return true;
  435. }
  436.  
  437. if (n.getName().toLowerCase().contains("dragon".toLowerCase()))
  438. return true;
  439.  
  440. }
  441. return false;
  442. }
  443.  
  444. public boolean inLair() {
  445. if (dragonsLair.contains(getMyPlayer().getLocation())) {
  446. return true;
  447. } else {
  448. return false;
  449. }
  450. }
  451.  
  452. public boolean killDragons() {
  453.  
  454. if (!inventory.isFull() && inventory.contains(tab)
  455. && getLifePoints() > 50) {
  456. return true;
  457. } else {
  458. return false;
  459. }
  460.  
  461. }
  462.  
  463. public int getLifePoints() {
  464. try {
  465. return ((int) ((Integer.parseInt(interfaces.get(748).getComponent(8).getText().trim()) / (double)(skills.getRealLevel(Skills.CONSTITUTION) * 10)) * 100));
  466. } catch (Exception e) {
  467. return 100;
  468. }
  469. }
  470.  
  471. public boolean needToHeal() {
  472. if (getLifePoints()<50) {
  473. return true;
  474. } else {
  475. return false;
  476. }
  477. }
  478.  
  479. public boolean canHeal() {
  480. if (inventory.containsOneOf(foodID)) {
  481. return true;
  482. } else {
  483. return false;
  484. }
  485. }
  486.  
  487. public boolean needTeleSafe() {
  488. if (needToHeal() && !canHeal()) {
  489. return true;
  490. } else {
  491. return false;
  492. }
  493.  
  494. }
  495.  
  496. public boolean tripEnded() {
  497. if (inventory.isFull()
  498. && dragonsLair.contains(getMyPlayer().getLocation())) {
  499. return true;
  500. } else {
  501. return false;
  502. }
  503.  
  504. }
  505.  
  506. public void teleSafe() {
  507. RSItem teleTab = inventory.getItem(8009);
  508.  
  509. teleTab.doAction("Break");
  510. }
  511.  
  512. public void healing() {
  513. // eat
  514. }
  515.  
  516. @Override
  517. public void onFinish() {
  518.  
  519. }
  520.  
  521. public void onRepaint(Graphics g1) {
  522. }
  523.  
  524. // END: Code generated using Enfilade's Easel
  525.  
  526. @Override
  527. public void mouseClicked(MouseEvent arg0) {
  528. // TODO Auto-generated method stub
  529.  
  530. }
  531.  
  532. @Override
  533. public void mouseEntered(MouseEvent arg0) {
  534. // TODO Auto-generated method stub
  535.  
  536. }
  537.  
  538. @Override
  539. public void mouseExited(MouseEvent arg0) {
  540. // TODO Auto-generated method stub
  541.  
  542. }
  543.  
  544. @Override
  545. public void mousePressed(MouseEvent arg0) {
  546. // TODO Auto-generated method stub
  547.  
  548. }
  549.  
  550. @Override
  551. public void mouseReleased(MouseEvent arg0) {
  552. // TODO Auto-generated method stub
  553.  
  554. }
  555.  
  556. @Override
  557. public void mouseDragged(MouseEvent arg0) {
  558. // TODO Auto-generated method stub
  559.  
  560. }
  561.  
  562. @Override
  563. public void mouseMoved(MouseEvent arg0) {
  564. // TODO Auto-generated method stub
  565.  
  566. }
  567.  
  568. @Override
  569. public void actionPerformed(ActionEvent arg0) {
  570. // TODO Auto-generated method stub
  571.  
  572. }
  573.  
  574. @Override
  575. public void messageReceived(MessageEvent arg0) {
  576. // TODO Auto-generated method stub
  577.  
  578. }
  579.  
  580. }
Add Comment
Please, Sign In to add comment