Guest User

Untitled

a guest
Jul 21st, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.51 KB | None | 0 0
  1. import com.kbotpro.scriptsystem.runnable.Script;
  2. import com.kbotpro.scriptsystem.interfaces.Looped;
  3. import com.kbotpro.scriptsystem.wrappers.NPC;
  4. import com.kbotpro.scriptsystem.input.jobs.MouseJob;
  5. import com.kbotpro.scriptsystem.input.jobs.MouseHoverJob;
  6. import com.kbotpro.scriptsystem.input.callbacks.MouseMoveListener;
  7.  
  8. import javax.swing.*;
  9.  
  10. /**
  11. * Created by IntelliJ IDEA.
  12. * User: Alowan
  13. * Date: 23-dec-2009
  14. * Time: 5:41:04
  15. * This code is for educational purposes only!
  16. */
  17. public class Anyfighter extends Script {
  18. private int[] NPC_IDS;
  19.  
  20. public void stop() {
  21.  
  22. }
  23.  
  24. public void registerWorkers() {
  25. String[] idsInString = JOptionPane.showInputDialog("NPC ID's seperated by a comma").split(",");
  26. NPC_IDS = new int[idsInString.length];
  27. int fail = 0;
  28. for(int i = 0; i < NPC_IDS.length; i++) {
  29. try {
  30. NPC_IDS[i] = Integer.parseInt(idsInString[i]);
  31. } catch (Exception e) {
  32. NPC_IDS[i] = -1;
  33. fail++;
  34. }
  35. }
  36. if(fail == NPC_IDS.length) return;
  37. createWorker(new Looped() {
  38. NPC currentNPC;
  39. NPC nextNPC;
  40. MouseJob mouseHover;
  41.  
  42. public int loop() {
  43. NPC[] bufs = npcs.getNPCs();
  44. NPC bufferNPC = null;
  45. int dist = 9999;
  46. outer: for(NPC n : bufs) {
  47. if(n.isInCombat() || n.isInteracting())
  48. continue;
  49. for(int i : NPC_IDS) {
  50. if(n.getID() == i) {
  51. if(getDistanceTo(n) < dist) {
  52. bufferNPC = n;
  53. dist = (int) getDistanceTo(n);
  54. }
  55. continue outer;
  56. }
  57. }
  58. }
  59. if(bufferNPC == null) return random(200, 400);
  60. if(nextNPC == null || !bufferNPC.equals(nextNPC)) {
  61. nextNPC = bufferNPC;
  62. if(mouseHover != null && mouseHover.isAlive())
  63. mouseHover.stop();
  64. }
  65. if(nextNPC == null) return random(200, 400);
  66. if(mouseHover == null || !mouseHover.isAlive()) {
  67. mouseHover = mouse.createMouseHoverJob(new MouseMoveListener() {
  68. int counter = 0;
  69. public void onMouseOverTarget(MouseJob mouseJob) {
  70. if(!getMyPlayer().isInteracting()) {
  71. counter++;
  72. if(counter > random(15, 31)) {
  73. if(menu.atMenu("attack")) {
  74. mouseJob.stop();
  75. currentNPC = nextNPC;
  76. nextNPC = null;
  77. }
  78. }
  79. }
  80. }
  81. public void onFinished(MouseJob mouseJob) {}
  82. }, nextNPC);
  83. mouseHover.start();
  84. }
  85. return random(200, 400);
  86. }
  87. });
  88. }
  89.  
  90. public boolean canStart() {
  91. return true;
  92. }
  93.  
  94. public void onStart() {
  95.  
  96. }
  97.  
  98. public String getName() {
  99. return null;
  100. }
  101. }
Add Comment
Please, Sign In to add comment