Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 27th, 2012  |  syntax: None  |  size: 4.18 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import org.rsbot.script.Script;
  2. import org.rsbot.script.ScriptManifest;
  3. import org.rsbot.script.methods.Skills;
  4. import org.rsbot.script.util.Timer;
  5. import org.rsbot.script.wrappers.RSObject;
  6. import org.rsbot.script.wrappers.RSNPC;
  7. import org.rsbot.event.events.ServerMessageEvent;
  8. import org.rsbot.event.listeners.*;
  9. import java.awt.*;
  10.  
  11. @ScriptManifest(authors = "Alfansor", name = "Alfies FishnDrop", version = 0.6, description = "Just go to the trout/salmon spot near barbarian village and run the script.")
  12. public class AlfFishnDrop extends Script implements PaintListener,
  13.                 ServerMessageListener {
  14.  
  15.         int[] Inventory = { 309, 314 };
  16.         int[] spotID = { 328 };
  17.         int fishCount = 0;
  18.         Thread abThread;
  19.         // Paint stuff
  20.         long startTime = 0;
  21.         int startXp = 0;
  22.         int startLvl = 0;
  23.         int expGained = 0;
  24.         int lvlsGained = 0;
  25.  
  26.         private final RenderingHints antialiasing = new RenderingHints(
  27.                         RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  28.  
  29.         private final Color color1 = new Color(255, 255, 255, 134);
  30.         private final Color color2 = new Color(0, 0, 0);
  31.  
  32.         private final BasicStroke stroke1 = new BasicStroke(1);
  33.  
  34.         private final Font font1 = new Font("Arial", 1, 15);
  35.         private final Font font2 = new Font("Arial", 0, 10);
  36.  
  37.         public void onRepaint(Graphics g1) {
  38.                 if (game.isLoggedIn()) {
  39.                         Graphics2D g = (Graphics2D) g1;
  40.                         g.setRenderingHints(antialiasing);
  41.  
  42.                         if (startTime == 0) {
  43.                                 startTime = System.currentTimeMillis();
  44.                         }
  45.                         if (startXp == 0) {
  46.                                 startXp = skills.getCurrentExp(Skills.FISHING);
  47.                                 startLvl = skills.getRealLevel(Skills.FISHING);
  48.                         }
  49.  
  50.                         expGained = skills.getCurrentExp(Skills.FISHING) - startXp;
  51.                         lvlsGained = (skills.getRealLevel(Skills.FISHING) - startLvl);
  52.  
  53.                         g.setColor(color1);
  54.                         g.fillRect(2, 253, 202, 86);
  55.                         g.setColor(color2);
  56.                         g.setStroke(stroke1);
  57.                         g.drawRect(2, 253, 202, 86);
  58.                         g.setFont(font1);
  59.                         g.drawString("Alf Fish 'n' Drop", 15, 272);
  60.                         g.setFont(font2);
  61.                         g.drawString("Time Running: "
  62.                                         + Timer.format(System.currentTimeMillis() - startTime), 15,
  63.                                         287);
  64.                         g.drawString("Fish Caught: " + fishCount, 16, 300); // Writes the
  65.                         g.drawString("Levels Gained: " + lvlsGained, 16, 313); // the + is
  66.                         g.drawString("Exp Gained: " + expGained, 16, 327);
  67.                 }
  68.         }
  69.         @Override
  70.         public void serverMessageRecieved(ServerMessageEvent e) {
  71.                 String msg = e.getMessage();
  72.                 if (msg.contains("You catch")) {
  73.                         fishCount++;
  74.                 }
  75.         }
  76.         // paint stuff END
  77.         public boolean onStart() {
  78.                 log("Welcome to Alfies FishnDrop!");
  79.                 abThread = new Thread(new antiBan());
  80.                 abThread.start();
  81.                 return true;
  82.  
  83.         }
  84.  
  85.         private void Lure() {
  86.                 try {
  87.                         RSNPC lureSpot = npcs.getNearest(spotID);
  88.                         if (calc.tileOnScreen(lureSpot.getLocation())
  89.                                         && getMyPlayer().getAnimation() == -1) {
  90.                                 lureSpot.doAction("Lure");
  91.                         }
  92.                         if (!calc.tileOnScreen(lureSpot.getLocation())) {
  93.                                 if (calc.distanceTo(lureSpot) <= 7) {
  94.  
  95.                                         camera.turnToTile(lureSpot.getLocation());
  96.                                 } else {
  97.                                         if (!getMyPlayer().isMoving()) {
  98.                                                 walking.walkTileMM(lureSpot.getLocation());
  99.                                         }
  100.  
  101.                                 }
  102.                         }
  103.                 } catch (Exception e) {
  104.  
  105.                 }
  106.         }
  107.  
  108.         private void dropFish() {
  109.                 inventory.dropAllExcept(Inventory);
  110.         }
  111.  
  112.         public void onFinish() {
  113.                 abThread = null;
  114.                 log("Thanks for using Alfies FishnDrop.");
  115.         }
  116.  
  117.         public int loop() {
  118.  
  119.                 if (inventory.isFull()) {
  120.                         dropFish();
  121.                 } else if (!inventory.isFull()) {
  122.                         Lure();
  123.                 }
  124.                 return (random(600, 1250));
  125.  
  126.         }
  127.  
  128.         class antiBan extends Thread {
  129.                 public void run() {
  130.  
  131.                         while (abThread != null) {
  132.                                 try {
  133.                                         int state = random(0, 8);
  134.                                         switch (state) {
  135.                                         case 1:
  136.                                                 int currTab = game.getCurrentTab();
  137.                                                 game.openTab(random(0, 5));
  138.                                                 Thread.sleep(random(1000, 4000));
  139.                                                 game.openTab(currTab);
  140.                                                 break;
  141.                                         case 2:
  142.                                                 camera.setAngle(random(0, 360));
  143.                                                 break;
  144.                                         case 3:
  145.                                                 camera.setPitch(random(0, 100));
  146.                                                 break;
  147.                                         case 4:
  148.                                                 mouse.moveSlightly();
  149.                                                 Thread.sleep(random(850, 1150));
  150.                                                 mouse.moveSlightly();
  151.                                                 break;
  152.                                         }
  153.                                         Thread.sleep(5000);
  154.  
  155.                                 } catch (InterruptedException e) {
  156.                                         log.severe("Antiban has encountered an error. Error:" + e);
  157.                                 }
  158.                         }
  159.                 }
  160.         }
  161.  
  162. }