Advertisement
Guest User

Untitled

a guest
Aug 19th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.17 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. RSObject door7 = objects.getTopAt(doors[7]);
  92. RSObject door6 = objects.getTopAt(doors[6]);
  93. RSObject door5 = objects.getTopAt(doors[5]);
  94. RSObject door4 = objects.getTopAt(doors[4]);
  95. RSObject door3 = objects.getTopAt(doors[3]);
  96. RSObject door2 = objects.getTopAt(doors[2]);
  97. RSObject door1 = objects.getTopAt(doors[1]);
  98. RSObject door0 = objects.getTopAt(doors[0]);
  99.  
  100. if(spiderArea1.contains(getMyPlayer().getLocation())){
  101. door7.doAction("Open2");
  102. sleep(random(2500,3000));
  103. }
  104. /*
  105. if (checkAttack() && !checkEat() && atSpiders() && canEat()) {
  106. attack();
  107. log("Debugging: Attacking");
  108. }
  109.  
  110. if (checkEat() && canEat()) {
  111. eat();
  112. log("Debugging:Eating");
  113. }
  114.  
  115. if (spiderFloor() && !canEat()) {
  116. doBankingWalk();
  117. }*/
  118. } catch (Exception ignore) {
  119. }
  120.  
  121. return random(50, 100);
  122.  
  123. }
  124.  
  125. public void doBankingWalk() {
  126. RSItem teleTab = inventory.getItem(teleID);
  127. if (inventory.contains(teleID)) {
  128. teleTab.doAction("Break");
  129. } else {
  130. walkToBank();
  131. }
  132. }
  133.  
  134. public void walkToBank() {
  135.  
  136. }
  137.  
  138. public void walkToSecondRoom() {
  139.  
  140. }
  141.  
  142.  
  143.  
  144. public boolean spiderFloor() {
  145. RSNPC spiders = getNpc();
  146. if (spiders != null) {
  147. return true;
  148. } else {
  149. return false;
  150. }
  151. }
  152.  
  153. public boolean atSpiders() {
  154. if (spiderArea1.contains(getMyPlayer().getLocation())
  155. || spiderArea2.contains(getMyPlayer().getLocation())) {
  156. return true;
  157. } else {
  158. return false;
  159. }
  160. }
  161.  
  162. public boolean canEat() {
  163. if (inventory.containsOneOf(foodID)) {
  164. return true;
  165. } else {
  166. return false;
  167. }
  168. }
  169.  
  170. public void eat() {
  171. RSItem food = inventory.getItem(foodID);
  172. food.doAction("Eat");
  173. sleep(random(100, 200));
  174. }
  175.  
  176. public int getLifePoints() {
  177. try {
  178. return ((int) ((Integer.parseInt(interfaces.get(748)
  179. .getComponent(8).getText().trim()) / (double) (skills
  180. .getRealLevel(Skills.CONSTITUTION) * 10)) * 100));
  181. } catch (Exception e) {
  182. return 100;
  183. }
  184. }
  185.  
  186. public boolean checkEat() {
  187. if (getLifePoints() <= 100) {
  188. return true;
  189. } else {
  190. return false;
  191. }
  192. }
  193.  
  194. public boolean checkAttack() {
  195. if (getMyPlayer().getAnimation() == -1
  196. && getMyPlayer().getInteracting() == null
  197. && !getMyPlayer().isInCombat()) {
  198. return true;
  199. } else {
  200. return false;
  201. }
  202. }
  203.  
  204. public void attack() {
  205. RSNPC spider = getNpc();
  206. spider.doAction("Attack");
  207. }
  208.  
  209. public RSNPC getNpc() {
  210. final Filter<RSNPC> filter = new Filter<RSNPC>() {
  211.  
  212. public boolean accept(RSNPC n) {
  213. return (validNpc(n) && (!n.isInCombat() && n.getInteracting() == null))
  214. && n.getHPPercent() != 0;
  215. }
  216. };
  217.  
  218. return npcs.getNearest(filter);
  219. }
  220.  
  221. public boolean validNpc(RSNPC n) {
  222. if (n != null) {
  223. for (int id : giantID) {
  224. if (id == n.getID())
  225. return true;
  226. }
  227.  
  228. if (n.getName().toLowerCase().contains("giant".toLowerCase()))
  229. return true;
  230.  
  231. }
  232. return false;
  233. }
  234.  
  235. @Override
  236. public void onFinish() {
  237.  
  238. }
  239.  
  240. // START: Code generated using Enfilade's Easel
  241.  
  242. public void mouseClicked(MouseEvent e) {// this is the mouse listener, it
  243. // listen's for the click.
  244.  
  245. }
  246.  
  247. // END: Code generated using Enfilade's Easel
  248.  
  249. @Override
  250. public void mouseEntered(MouseEvent arg0) {
  251. // TODO Auto-generated method stub
  252.  
  253. }
  254.  
  255. @Override
  256. public void mouseExited(MouseEvent arg0) {
  257. // TODO Auto-generated method stub
  258.  
  259. }
  260.  
  261. @Override
  262. public void mousePressed(MouseEvent arg0) {
  263. // TODO Auto-generated method stub
  264.  
  265. }
  266.  
  267. @Override
  268. public void mouseReleased(MouseEvent arg0) {
  269. // TODO Auto-generated method stub
  270.  
  271. }
  272.  
  273. @Override
  274. public void mouseDragged(MouseEvent arg0) {
  275. // TODO Auto-generated method stub
  276.  
  277. }
  278.  
  279. @Override
  280. public void mouseMoved(MouseEvent arg0) {
  281. // TODO Auto-generated method stub
  282.  
  283. }
  284.  
  285. @Override
  286. public void actionPerformed(ActionEvent arg0) {
  287. // TODO Auto-generated method stub
  288.  
  289. }
  290.  
  291. @Override
  292. public void messageReceived(MessageEvent arg0) {
  293.  
  294. }
  295.  
  296. @Override
  297. public void onRepaint(Graphics arg0) {
  298. // TODO Auto-generated method stub
  299.  
  300. }
  301.  
  302. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement