Guest User

Untitled

a guest
Aug 18th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.12 KB | None | 0 0
  1. package pxpc2.scripts.brchickens;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Graphics;
  5. import java.awt.Graphics2D;
  6. import org.powerbot.concurrent.Task;
  7. import org.powerbot.concurrent.strategy.Condition;
  8. import org.powerbot.concurrent.strategy.Strategy;
  9. import org.powerbot.game.api.ActiveScript;
  10. import org.powerbot.game.api.Manifest;
  11. import org.powerbot.game.api.methods.Tabs;
  12. import org.powerbot.game.api.methods.Walking;
  13. import org.powerbot.game.api.methods.input.Mouse;
  14. import org.powerbot.game.api.methods.interactive.NPCs;
  15. import org.powerbot.game.api.methods.interactive.Players;
  16. import org.powerbot.game.api.methods.widget.Camera;
  17. import org.powerbot.game.api.util.Random;
  18. import org.powerbot.game.api.util.Time;
  19. import org.powerbot.game.api.wrappers.interactive.NPC;
  20. import org.powerbot.game.bot.event.listener.PaintListener;
  21.  
  22. @Manifest(authors = { "PXPC2" },
  23.     name = "BRChickens BETA",
  24.     description = "Chicken Killer",
  25.     version = 0.1,
  26.     premium = false)
  27.  
  28. public class BRChickens extends ActiveScript implements PaintListener {
  29.    
  30.     boolean guiRunning = false;
  31.     String status;
  32.     boolean isAttacking;
  33.     final int COMBAT_STYLES_X = 536;
  34.     final int COMBAT_STYLES_Y = 183;
  35.     final int[] CHICKEN_ID = {41,1017};
  36.    
  37.     enum AntiBanQuantity {
  38.         LITTLE,
  39.         NORMAL,
  40.         MUCH;
  41.     }
  42.    
  43.     @Override
  44.     protected void setup() {
  45.         status = "Starting";
  46.         log.info("Welcome to BRChickens BETA version 0.1!");
  47.         try {
  48.             Tabs.ATTACK.open();
  49.             provide(new Strategy(new AntiBan(), new AntiBan()));
  50.             provide(new Strategy(new AttackChickens(), new AttackChickens()));
  51.         }
  52.         catch (Exception e) {
  53.             e.printStackTrace();
  54.             log.info("Exception at setup()");
  55.             stop();
  56.         }
  57.     }
  58.    
  59.     enum SkillToTrain {
  60.         STRENGTH,
  61.         ATTACK,
  62.         DEFENCE;
  63.     }
  64.    
  65.     protected class AttackChickens implements Task, Condition {
  66.  
  67.         @Override
  68.         public void run() {
  69.             try {
  70.                 NPC chicken = NPCs.getNearest(CHICKEN_ID);
  71.                 if (chicken != null && chicken.isOnScreen()) {
  72.                     if (!chicken.isInCombat() && chicken.getHpPercent() > 10) {
  73.                         if (Players.getLocal().getAnimation() == -1) {
  74.                             chicken.interact("Attack");
  75.                             Time.sleep(Random.nextInt(1200,1800));
  76.                         }
  77.                     }
  78.                     while (Players.getLocal().getAnimation() != -1) {
  79.                         isAttacking = true;
  80.                     }
  81.                 } else {
  82.                     Walking.walk(chicken.getLocation());
  83.                 }
  84.             }
  85.             catch (Exception e) {
  86.                 e.printStackTrace();
  87.                 log.info("exception at class AttackChickens method run()");
  88.                 stop();
  89.             }
  90.         }
  91.  
  92.         @Override
  93.         public boolean validate() {
  94.             return !guiRunning;
  95.         }
  96.        
  97.     }
  98.    
  99.     protected class AntiBan implements Task, Condition {
  100.  
  101.         @Override
  102.         public void run() {
  103.             try {
  104.                 switch(Random.nextInt(1, 15)) {
  105.                 case 1:
  106.                     log.info("Setting camera angle -  ANTIBAN");
  107.                     status = "Turning camera";
  108.                     Camera.setAngle(Random.nextInt(-180, 180));
  109.                     break;
  110.                 case 3:
  111.                     log.info("Setting camera pitch - ANTIBAN");
  112.                     status = "Turning camera";
  113.                     Camera.setPitch(Random.nextInt(42, 90));
  114.                     break;
  115.                 case 8:
  116.                     log.info("Checking strength level");
  117.                     status = "Checking levels";
  118.                     if (Tabs.getCurrent() != Tabs.STATS) {
  119.                         Tabs.STATS.open();
  120.                         Time.sleep(Random.nextInt(50, 150));
  121.                     } else {
  122.                         Mouse.move(590, 248);
  123.                         Time.sleep(Random.nextInt(342, 1432));
  124.                         Tabs.INVENTORY.open();
  125.                     }
  126.                     break;
  127.                 case 11:
  128.                     log.info("Moving mouse");
  129.                     status = "Moving mouse";
  130.                     Mouse.move(Random.nextInt(0, 750), Random.nextInt(0, 750));
  131.                     break;
  132.                 }
  133.             }
  134.             catch (Exception e) {
  135.                 e.printStackTrace();
  136.                 log.info("Exception at class antiBan, method run()");
  137.                 stop();
  138.             }
  139.         }
  140.  
  141.         @Override
  142.         public boolean validate() {
  143.             return !guiRunning;
  144.         }
  145.        
  146.     }
  147.     private static int mouseX = 0;
  148.     private static int mouseY = 0;
  149.     @Override
  150.     public void onRepaint(Graphics g1) {
  151.         NPC chicken = NPCs.getNearest(CHICKEN_ID);
  152.         Graphics2D g = (Graphics2D)g1;
  153.         g.setColor(Color.BLUE);
  154.         chicken.draw(g);
  155.         mouseX = Mouse.getX();
  156.         mouseY = Mouse.getY();
  157.         g.setColor(Color.GREEN);
  158.         g.drawLine(mouseX, mouseY - 10, mouseX, mouseY + 10);
  159.         g.drawLine(mouseX - 10, mouseY, mouseX + 10, mouseY);
  160.     }
  161.  
  162. }
Add Comment
Please, Sign In to add comment