Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import com.kbotpro.scriptsystem.runnable.Script;
- import com.kbotpro.scriptsystem.interfaces.Looped;
- import com.kbotpro.scriptsystem.wrappers.NPC;
- import com.kbotpro.scriptsystem.input.jobs.MouseJob;
- import com.kbotpro.scriptsystem.input.jobs.MouseHoverJob;
- import com.kbotpro.scriptsystem.input.callbacks.MouseMoveListener;
- import javax.swing.*;
- /**
- * Created by IntelliJ IDEA.
- * User: Alowan
- * Date: 23-dec-2009
- * Time: 5:41:04
- * This code is for educational purposes only!
- */
- public class Anyfighter extends Script {
- private int[] NPC_IDS;
- public void stop() {
- }
- public void registerWorkers() {
- String[] idsInString = JOptionPane.showInputDialog("NPC ID's seperated by a comma").split(",");
- NPC_IDS = new int[idsInString.length];
- int fail = 0;
- for(int i = 0; i < NPC_IDS.length; i++) {
- try {
- NPC_IDS[i] = Integer.parseInt(idsInString[i]);
- } catch (Exception e) {
- NPC_IDS[i] = -1;
- fail++;
- }
- }
- if(fail == NPC_IDS.length) return;
- createWorker(new Looped() {
- NPC currentNPC;
- NPC nextNPC;
- MouseJob mouseHover;
- public int loop() {
- NPC[] bufs = npcs.getNPCs();
- NPC bufferNPC = null;
- int dist = 9999;
- outer: for(NPC n : bufs) {
- if(n.isInCombat() || n.isInteracting())
- continue;
- for(int i : NPC_IDS) {
- if(n.getID() == i) {
- if(getDistanceTo(n) < dist) {
- bufferNPC = n;
- dist = (int) getDistanceTo(n);
- }
- continue outer;
- }
- }
- }
- if(bufferNPC == null) return random(200, 400);
- if(nextNPC == null || !bufferNPC.equals(nextNPC)) {
- nextNPC = bufferNPC;
- if(mouseHover != null && mouseHover.isAlive())
- mouseHover.stop();
- }
- if(nextNPC == null) return random(200, 400);
- if(mouseHover == null || !mouseHover.isAlive()) {
- mouseHover = mouse.createMouseHoverJob(new MouseMoveListener() {
- int counter = 0;
- public void onMouseOverTarget(MouseJob mouseJob) {
- if(!getMyPlayer().isInteracting()) {
- counter++;
- if(counter > random(15, 31)) {
- if(menu.atMenu("attack")) {
- mouseJob.stop();
- currentNPC = nextNPC;
- nextNPC = null;
- }
- }
- }
- }
- public void onFinished(MouseJob mouseJob) {}
- }, nextNPC);
- mouseHover.start();
- }
- return random(200, 400);
- }
- });
- }
- public boolean canStart() {
- return true;
- }
- public void onStart() {
- }
- public String getName() {
- return null;
- }
- }
Add Comment
Please, Sign In to add comment