Advertisement
Guest User

Untitled

a guest
Aug 19th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.49 KB | None | 0 0
  1. import java.awt.Color;
  2. import java.awt.Container;
  3. import java.awt.Dimension;
  4. import java.awt.Font;
  5. import java.awt.Graphics;
  6. import java.awt.Graphics2D;
  7. import java.awt.Insets;
  8. import java.awt.Point;
  9. import java.awt.Rectangle;
  10. import java.awt.event.ActionEvent;
  11. import java.awt.event.ActionListener;
  12.  
  13. import org.rsbot.script.wrappers.RSObject;
  14. import org.rsbot.script.methods.Game;
  15. import org.rsbot.script.methods.Skills;
  16. import org.rsbot.script.util.Filter;
  17. import org.rsbot.script.Script;
  18. import java.util.Random;
  19. import org.rsbot.script.wrappers.RSPlayer;
  20.  
  21. import java.awt.*;
  22. import javax.imageio.ImageIO;
  23. import javax.swing.DefaultComboBoxModel;
  24. import javax.swing.JButton;
  25. import javax.swing.JCheckBox;
  26. import javax.swing.JComboBox;
  27. import javax.swing.JFrame;
  28. import javax.swing.JLabel;
  29. import javax.swing.JPanel;
  30. import javax.swing.JSlider;
  31.  
  32. import java.io.IOException;
  33. import java.net.URL;
  34.  
  35. import java.awt.event.MouseEvent;
  36. import java.awt.event.MouseListener;
  37. import java.awt.event.MouseMotionListener;
  38.  
  39. import org.rsbot.event.events.MessageEvent;
  40. import org.rsbot.event.listeners.MessageListener;
  41. import org.rsbot.event.listeners.PaintListener;
  42. import org.rsbot.script.ScriptManifest;
  43. import org.rsbot.script.wrappers.RSArea;
  44. import org.rsbot.script.wrappers.RSItem;
  45. import org.rsbot.script.wrappers.RSNPC;
  46. import org.rsbot.script.wrappers.RSPath;
  47. import org.rsbot.script.wrappers.RSTile;
  48.  
  49. @ScriptManifest(authors = { "Wei Su" }, name = "Ultimate Spider Killer", version = 0.1, description = "Kills giant spider", keywords = {
  50. "", "", "" })
  51. /* Save as script.java - who could get that wrong! :) */
  52. public class UltimateSpiderKiller extends Script implements PaintListener,
  53. MessageListener, ActionListener, MouseMotionListener, MouseListener {
  54.  
  55. public int[] giantID = { 4400 };
  56. public int[] foodID = { 7946 };
  57. public int[] doorID = { 16090 };
  58. public int teleID = 8007;
  59. RSArea spiderArea1 = new RSArea(2144, 5302, 2156, 5310);
  60. RSArea spiderArea2 = new RSArea(2115, 5260, 2135, 5278);
  61. RSArea firstArea = new RSArea(2148, 5299, 2149, 5301);
  62. RSArea secondArea = new RSArea(2141, 5294, 2158, 5298);
  63. RSTile secondTile = new RSTile(2141, 5294);
  64. RSArea thirdArea = new RSArea(2138, 5294, 2140, 5295);
  65. RSArea fourthArea = new RSArea(2127, 5282, 2137, 5295);
  66. RSTile fourthTile = new RSTile(2132, 5282);
  67. RSArea fifthArea = new RSArea(2132, 5279, 2133, 5281);
  68. RSArea sixthArea = new RSArea(2117, 5261, 2137, 5278);
  69. RSTile sixthTile = new RSTile(2132, 5262);
  70. RSArea seventhArea = new RSArea(2132, 5257, 2133, 5259);
  71. RSArea eighthArea1 = new RSArea(2117, 5251, 2130, 5258);
  72. RSArea eighthArea2 = new RSArea(2129, 5252, 2132, 5256);
  73. RSTile eighthTile = new RSTile(2123, 5252);
  74.  
  75. private final RSTile doors[] = { new RSTile(2132, 5257),
  76. new RSTile(2132, 5260), new RSTile(2132, 5278),
  77. new RSTile(2132, 5281), new RSTile(2138, 5294),
  78. new RSTile(2141, 5294), new RSTile(2148, 5299),
  79. new RSTile(2148, 5302) };
  80. //first is last, last is [7]
  81.  
  82.  
  83. @Override
  84. public boolean onStart() {
  85. mouse.setSpeed(3);
  86. return true;
  87. }
  88.  
  89. public int loop() {
  90. RSObject ladder2 = objects.getNearest(16080);
  91. RSObject ladder3 = objects.getTopAt(new RSTile(1859, 5244));
  92. try {
  93.  
  94. if (checkAttack() && !checkEat() && atSpiders() && canEat()) {
  95. attack();
  96. log("Debugging: Attacking");
  97. }
  98.  
  99. if (checkEat() && canEat()) {
  100. eat();
  101. log("Debugging:Eating");
  102. }
  103.  
  104. if (spiderFloor() && !canEat()) {
  105. doBankingWalk();
  106. }
  107.  
  108. if (!canEat() && ladder2.isOnScreen()){
  109. ladder2.doAction("Climb");
  110. sleep(random(2000,3000));
  111. }
  112.  
  113. if (!canEat() && ladder3.isOnScreen()){
  114. ladder3.doAction("Climb");
  115. sleep(random(2000,3000));
  116. }
  117.  
  118. } catch (Exception ignore) {
  119. }
  120.  
  121.  
  122. return random(50, 100);
  123.  
  124. }
  125.  
  126. public void doBankingWalk() {
  127. RSItem teleTab = inventory.getItem(teleID);
  128. if (inventory.contains(teleID)) {
  129. teleTab.doAction("Break");
  130. } else {
  131. walkToBank();
  132. }
  133. }
  134.  
  135. public void walkToBank() {
  136. RSObject door7 = objects.getTopAt(doors[7]);
  137. RSObject door6 = objects.getTopAt(doors[6]);
  138. RSObject door5 = objects.getTopAt(doors[5]);
  139. RSObject door4 = objects.getTopAt(doors[4]);
  140. RSObject door3 = objects.getTopAt(doors[3]);
  141. RSObject door2 = objects.getTopAt(doors[2]);
  142. RSObject door1 = objects.getTopAt(doors[1]);
  143. RSObject door0 = objects.getTopAt(doors[0]);
  144.  
  145. if(spiderArea1.contains(getMyPlayer().getLocation())){
  146. door7.doAction("Open");
  147. sleep(random(3000,3200));
  148. }
  149.  
  150. if(firstArea.contains(getMyPlayer().getLocation())){
  151. door6.doAction("Open");
  152. sleep(random(3000,3200));
  153. }
  154.  
  155. if(secondArea.contains(getMyPlayer().getLocation())){
  156. if(calc.distanceTo(door5) > 5){
  157. RSPath path = null;
  158. if (path == null) {
  159. path = walking.getPath(secondTile);
  160. }
  161. path.traverse();
  162. } else {
  163. door5.doAction("Open");
  164. sleep(random(3000,3200));
  165. }
  166. }
  167.  
  168. if(thirdArea.contains(getMyPlayer().getLocation())){
  169. door4.doAction("Open");
  170. sleep(random(3000,3200));
  171. }
  172.  
  173. if(fourthArea.contains(getMyPlayer().getLocation())){
  174. if(calc.distanceTo(door3) > 5){
  175. RSPath path = null;
  176. if (path == null) {
  177. path = walking.getPath(fourthTile);
  178. }
  179. path.traverse();
  180. } else {
  181. door3.doAction("Open");
  182. sleep(random(3000,3200));
  183. }
  184. }
  185.  
  186. if(fifthArea.contains(getMyPlayer().getLocation())){
  187. door2.doAction("Open");
  188. sleep(random(3000,3200));
  189. }
  190.  
  191. if(sixthArea.contains(getMyPlayer().getLocation())){
  192. if(calc.distanceTo(door1) > 5){
  193. RSPath path = null;
  194. if (path == null) {
  195. path = walking.getPath(sixthTile);
  196. }
  197. path.traverse();
  198. } else {
  199. door1.doAction("Open");
  200. sleep(random(3000,3200));
  201. }
  202. }
  203.  
  204. if(seventhArea.contains(getMyPlayer().getLocation())){
  205. door0.doAction("Open");
  206. sleep(random(3000,3200));
  207. }
  208.  
  209. if(eighthArea1.contains(getMyPlayer().getLocation()) || eighthArea2.contains(getMyPlayer().getLocation()) || getMyPlayer().getLocation() == new RSTile(2133, 5256)){
  210. RSObject ladder = objects.getTopAt(new RSTile(2123, 5251));
  211. if (calc.distanceTo(ladder) > 5){
  212. RSPath path = null;
  213. if (path == null) {
  214. path = walking.getPath(new RSTile(2125, 5253));
  215. }
  216. path.traverse();
  217. } else {
  218. ladder.doAction("Climb");
  219. sleep(random(2100,2300));
  220. }
  221. }
  222.  
  223.  
  224.  
  225. }
  226.  
  227. public void walkToSecondRoom() {
  228.  
  229. }
  230.  
  231.  
  232.  
  233. public boolean spiderFloor() {
  234. RSNPC spiders = getNpc();
  235. if (spiders != null) {
  236. return true;
  237. } else {
  238. return false;
  239. }
  240. }
  241.  
  242. public boolean atSpiders() {
  243. if (spiderArea1.contains(getMyPlayer().getLocation())
  244. || spiderArea2.contains(getMyPlayer().getLocation())) {
  245. return true;
  246. } else {
  247. return false;
  248. }
  249. }
  250.  
  251. public boolean canEat() {
  252. if (inventory.containsOneOf(foodID)) {
  253. return true;
  254. } else {
  255. return false;
  256. }
  257. }
  258.  
  259. public void eat() {
  260. RSItem food = inventory.getItem(foodID);
  261. food.doAction("Eat");
  262. sleep(random(100, 200));
  263. }
  264.  
  265. public int getLifePoints() {
  266. try {
  267. return ((int) ((Integer.parseInt(interfaces.get(748)
  268. .getComponent(8).getText().trim()) / (double) (skills
  269. .getRealLevel(Skills.CONSTITUTION) * 10)) * 100));
  270. } catch (Exception e) {
  271. return 100;
  272. }
  273. }
  274.  
  275. public boolean checkEat() {
  276. if (getLifePoints() <= 100) {
  277. return true;
  278. } else {
  279. return false;
  280. }
  281. }
  282.  
  283. public boolean checkAttack() {
  284. if (getMyPlayer().getAnimation() == -1
  285. && getMyPlayer().getInteracting() == null
  286. && !getMyPlayer().isInCombat()) {
  287. return true;
  288. } else {
  289. return false;
  290. }
  291. }
  292.  
  293. public void attack() {
  294. RSNPC spider = getNpc();
  295. spider.doAction("Attack");
  296. }
  297.  
  298. public RSNPC getNpc() {
  299. final Filter<RSNPC> filter = new Filter<RSNPC>() {
  300.  
  301. public boolean accept(RSNPC n) {
  302. return (validNpc(n) && (!n.isInCombat() && n.getInteracting() == null))
  303. && n.getHPPercent() != 0;
  304. }
  305. };
  306.  
  307. return npcs.getNearest(filter);
  308. }
  309.  
  310. public boolean validNpc(RSNPC n) {
  311. if (n != null) {
  312. for (int id : giantID) {
  313. if (id == n.getID())
  314. return true;
  315. }
  316.  
  317. if (n.getName().toLowerCase().contains("giant".toLowerCase()))
  318. return true;
  319.  
  320. }
  321. return false;
  322. }
  323.  
  324. @Override
  325. public void onFinish() {
  326.  
  327. }
  328.  
  329. // START: Code generated using Enfilade's Easel
  330.  
  331. public void mouseClicked(MouseEvent e) {// this is the mouse listener, it
  332. // listen's for the click.
  333.  
  334. }
  335.  
  336. // END: Code generated using Enfilade's Easel
  337.  
  338. @Override
  339. public void mouseEntered(MouseEvent arg0) {
  340. // TODO Auto-generated method stub
  341.  
  342. }
  343.  
  344. @Override
  345. public void mouseExited(MouseEvent arg0) {
  346. // TODO Auto-generated method stub
  347.  
  348. }
  349.  
  350. @Override
  351. public void mousePressed(MouseEvent arg0) {
  352. // TODO Auto-generated method stub
  353.  
  354. }
  355.  
  356. @Override
  357. public void mouseReleased(MouseEvent arg0) {
  358. // TODO Auto-generated method stub
  359.  
  360. }
  361.  
  362. @Override
  363. public void mouseDragged(MouseEvent arg0) {
  364. // TODO Auto-generated method stub
  365.  
  366. }
  367.  
  368. @Override
  369. public void mouseMoved(MouseEvent arg0) {
  370. // TODO Auto-generated method stub
  371.  
  372. }
  373.  
  374. @Override
  375. public void actionPerformed(ActionEvent arg0) {
  376. // TODO Auto-generated method stub
  377.  
  378. }
  379.  
  380. @Override
  381. public void messageReceived(MessageEvent arg0) {
  382.  
  383. }
  384.  
  385. @Override
  386. public void onRepaint(Graphics arg0) {
  387. // TODO Auto-generated method stub
  388.  
  389. }
  390.  
  391. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement