Advertisement
Guest User

Untitled

a guest
Aug 19th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.15 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. try {
  91.  
  92.  
  93. if (checkAttack() && !checkEat() && atSpiders() && canEat()) {
  94. attack();
  95. log("Debugging: Attacking");
  96. }
  97.  
  98. if (checkEat() && canEat()) {
  99. eat();
  100. log("Debugging:Eating");
  101. }
  102.  
  103. if (spiderFloor() && !canEat()) {
  104. doBankingWalk();
  105. }
  106. } catch (Exception ignore) {
  107. }
  108.  
  109. return random(50, 100);
  110.  
  111. }
  112.  
  113. public void doBankingWalk() {
  114. RSItem teleTab = inventory.getItem(teleID);
  115. if (inventory.contains(teleID)) {
  116. teleTab.doAction("Break");
  117. } else {
  118. walkToBank();
  119. }
  120. }
  121.  
  122. public void walkToBank() {
  123. RSObject door7 = objects.getTopAt(doors[7]);
  124. RSObject door6 = objects.getTopAt(doors[6]);
  125. RSObject door5 = objects.getTopAt(doors[5]);
  126. RSObject door4 = objects.getTopAt(doors[4]);
  127. RSObject door3 = objects.getTopAt(doors[3]);
  128. RSObject door2 = objects.getTopAt(doors[2]);
  129. RSObject door1 = objects.getTopAt(doors[1]);
  130. RSObject door0 = objects.getTopAt(doors[0]);
  131.  
  132. if(spiderArea1.contains(getMyPlayer().getLocation())){
  133. door7.doAction("Open");
  134. sleep(random(3000,3200));
  135. }
  136.  
  137. if(firstArea.contains(getMyPlayer().getLocation())){
  138. door6.doAction("Open");
  139. sleep(random(3000,3200));
  140. }
  141.  
  142. if(secondArea.contains(getMyPlayer().getLocation())){
  143. if(calc.distanceTo(door5) > 5){
  144. RSPath path = null;
  145. if (path == null) {
  146. path = walking.getPath(secondTile);
  147. }
  148. path.traverse();
  149. } else {
  150. door5.doAction("Open");
  151. sleep(random(3000,3200));
  152. }
  153. }
  154.  
  155. if(thirdArea.contains(getMyPlayer().getLocation())){
  156. door4.doAction("Open");
  157. sleep(random(3000,3200));
  158. }
  159.  
  160. if(fourthArea.contains(getMyPlayer().getLocation())){
  161. if(calc.distanceTo(door3) > 5){
  162. RSPath path = null;
  163. if (path == null) {
  164. path = walking.getPath(fourthTile);
  165. }
  166. path.traverse();
  167. } else {
  168. door3.doAction("Open");
  169. sleep(random(3000,3200));
  170. }
  171. }
  172.  
  173. if(fifthArea.contains(getMyPlayer().getLocation())){
  174. door2.doAction("Open");
  175. sleep(random(3000,3200));
  176. }
  177.  
  178. if(sixthArea.contains(getMyPlayer().getLocation())){
  179. if(calc.distanceTo(door1) > 5){
  180. RSPath path = null;
  181. if (path == null) {
  182. path = walking.getPath(sixthTile);
  183. }
  184. path.traverse();
  185. } else {
  186. door1.doAction("Open");
  187. sleep(random(3000,3200));
  188. }
  189. }
  190.  
  191. if(seventhArea.contains(getMyPlayer().getLocation())){
  192. door0.doAction("Open");
  193. sleep(random(3000,3200));
  194. }
  195.  
  196. if(eighthArea1.contains(getMyPlayer().getLocation()) || eighthArea2.contains(getMyPlayer().getLocation()) || getMyPlayer().getLocation() == new RSTile(2133, 5256)){
  197. RSObject ladder = objects.getTopAt(new RSTile(2123, 5251));
  198. if (calc.distanceTo(ladder) > 5){
  199. RSPath path = null;
  200. if (path == null) {
  201. path = walking.getPath(new RSTile(2125, 5253));
  202. }
  203. path.traverse();
  204. } else {
  205. ladder.doAction("Climb");
  206. sleep(random(2100,2300));
  207. }
  208. }
  209.  
  210.  
  211.  
  212. }
  213.  
  214. public void walkToSecondRoom() {
  215.  
  216. }
  217.  
  218.  
  219.  
  220. public boolean spiderFloor() {
  221. RSNPC spiders = getNpc();
  222. if (spiders != null) {
  223. return true;
  224. } else {
  225. return false;
  226. }
  227. }
  228.  
  229. public boolean atSpiders() {
  230. if (spiderArea1.contains(getMyPlayer().getLocation())
  231. || spiderArea2.contains(getMyPlayer().getLocation())) {
  232. return true;
  233. } else {
  234. return false;
  235. }
  236. }
  237.  
  238. public boolean canEat() {
  239. if (inventory.containsOneOf(foodID)) {
  240. return true;
  241. } else {
  242. return false;
  243. }
  244. }
  245.  
  246. public void eat() {
  247. RSItem food = inventory.getItem(foodID);
  248. food.doAction("Eat");
  249. sleep(random(100, 200));
  250. }
  251.  
  252. public int getLifePoints() {
  253. try {
  254. return ((int) ((Integer.parseInt(interfaces.get(748)
  255. .getComponent(8).getText().trim()) / (double) (skills
  256. .getRealLevel(Skills.CONSTITUTION) * 10)) * 100));
  257. } catch (Exception e) {
  258. return 100;
  259. }
  260. }
  261.  
  262. public boolean checkEat() {
  263. if (getLifePoints() <= 100) {
  264. return true;
  265. } else {
  266. return false;
  267. }
  268. }
  269.  
  270. public boolean checkAttack() {
  271. if (getMyPlayer().getAnimation() == -1
  272. && getMyPlayer().getInteracting() == null
  273. && !getMyPlayer().isInCombat()) {
  274. return true;
  275. } else {
  276. return false;
  277. }
  278. }
  279.  
  280. public void attack() {
  281. RSNPC spider = getNpc();
  282. spider.doAction("Attack");
  283. }
  284.  
  285. public RSNPC getNpc() {
  286. final Filter<RSNPC> filter = new Filter<RSNPC>() {
  287.  
  288. public boolean accept(RSNPC n) {
  289. return (validNpc(n) && (!n.isInCombat() && n.getInteracting() == null))
  290. && n.getHPPercent() != 0;
  291. }
  292. };
  293.  
  294. return npcs.getNearest(filter);
  295. }
  296.  
  297. public boolean validNpc(RSNPC n) {
  298. if (n != null) {
  299. for (int id : giantID) {
  300. if (id == n.getID())
  301. return true;
  302. }
  303.  
  304. if (n.getName().toLowerCase().contains("giant".toLowerCase()))
  305. return true;
  306.  
  307. }
  308. return false;
  309. }
  310.  
  311. @Override
  312. public void onFinish() {
  313.  
  314. }
  315.  
  316. // START: Code generated using Enfilade's Easel
  317.  
  318. public void mouseClicked(MouseEvent e) {// this is the mouse listener, it
  319. // listen's for the click.
  320.  
  321. }
  322.  
  323. // END: Code generated using Enfilade's Easel
  324.  
  325. @Override
  326. public void mouseEntered(MouseEvent arg0) {
  327. // TODO Auto-generated method stub
  328.  
  329. }
  330.  
  331. @Override
  332. public void mouseExited(MouseEvent arg0) {
  333. // TODO Auto-generated method stub
  334.  
  335. }
  336.  
  337. @Override
  338. public void mousePressed(MouseEvent arg0) {
  339. // TODO Auto-generated method stub
  340.  
  341. }
  342.  
  343. @Override
  344. public void mouseReleased(MouseEvent arg0) {
  345. // TODO Auto-generated method stub
  346.  
  347. }
  348.  
  349. @Override
  350. public void mouseDragged(MouseEvent arg0) {
  351. // TODO Auto-generated method stub
  352.  
  353. }
  354.  
  355. @Override
  356. public void mouseMoved(MouseEvent arg0) {
  357. // TODO Auto-generated method stub
  358.  
  359. }
  360.  
  361. @Override
  362. public void actionPerformed(ActionEvent arg0) {
  363. // TODO Auto-generated method stub
  364.  
  365. }
  366.  
  367. @Override
  368. public void messageReceived(MessageEvent arg0) {
  369.  
  370. }
  371.  
  372. @Override
  373. public void onRepaint(Graphics arg0) {
  374. // TODO Auto-generated method stub
  375.  
  376. }
  377.  
  378. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement