Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.Image;
- import java.awt.Point;
- import java.awt.Rectangle;
- import java.io.IOException;
- import java.net.URL;
- import java.util.LinkedList;
- import java.util.List;
- import javax.imageio.ImageIO;
- import org.nut.api.util.Timer;
- import org.cb.api.Script;
- import org.cb.api.ScriptDetails;
- @ScriptDetails(
- author = "Nissan Nut",
- description = "A basic seagull killer",
- name = "LazyGulls",
- version = 1.0
- )
- public class LazyGulls extends Script {
- private final Color c0 = new Color(0, 38, 0);
- private final Color c1 = new Color(160, 160, 153);
- private final Color c2 = new Color(224, 224, 214);
- private List <Point> C1;
- private List <Point> C2;
- private List <Point> COMBAT = new LinkedList<Point> ();
- private Point Gull = null;
- private Rectangle NPC = null;
- private final Rectangle VIEW = new Rectangle(4, 5, 511, 332);
- private final Rectangle HPBAR = new Rectangle(231, 134, 59, 17);
- private Timer Wait = new Timer(4000);
- private int clicks = 0;
- public long millis = 0, hours = 0, minutes = 0, seconds = 0, startTime = 0;
- private final Image img1 = getImage("http://www.upload.ee/image/2407603/Untitled.png");
- @Override
- public long loop() throws InterruptedException {
- //theMouse.setSpeed(random(4, 7));
- if (Gull != null && !inCombat() && Wait.getValue() < 0){
- theMouse.click(Gull, theMouse.LEFT_CLICK);
- clicks++;
- Wait.endIn(random(4000, 5000));
- }
- C1 = findColourArray(VIEW, c1, 1);
- C2 = findColourArray(VIEW, c2, 1);
- COMBAT = findColourArray(HPBAR, c0, 1);
- Gull = null;
- if (C1 != null && C2 != null){
- for (Point p1 : C1){
- NPC = new Rectangle(p1.x-5, p1.y-5, 10, 10);
- for (Point p2 : C2){
- if (NPC.contains(p2)){
- Gull = new Point(p2.x + random(-1, 1), p2.y + random(-1, 1));
- return 5;
- }
- }
- }
- }
- return 15;
- }
- private boolean inCombat() {
- if (COMBAT .isEmpty()){
- return false;
- }
- return true;
- }
- @Override
- public void onEnd() throws InterruptedException {
- // TODO Auto-generated method stub
- }
- @Override
- public void onStart() throws InterruptedException {
- startTime = System.currentTimeMillis();
- }
- @Override
- public void onRepaint(Graphics g1){
- Graphics2D g = (Graphics2D) g1;
- millis = System.currentTimeMillis() - startTime;
- hours = millis / (1000 * 60 * 60);
- millis -= hours * (1000 * 60 * 60);
- minutes = millis / (1000 * 60);
- millis -= minutes * (1000 * 60);
- seconds = millis / 1000;
- if (C1 != null){
- g.setColor(Color.BLUE);
- for (Point p : C1){
- g.drawLine(p.x, p.y - 2, p.x, p.y + 2);
- g.drawLine(p.x - 2, p.y, p.x + 2, p.y);
- }
- }
- if (C2 != null){
- g.setColor(Color.RED);
- for (Point p : C2){
- g.drawLine(p.x, p.y - 2, p.x, p.y + 2);
- g.drawLine(p.x - 2, p.y, p.x + 2, p.y);
- }
- }
- if (Gull != null){
- g.setColor(Color.GREEN);
- g.draw(new Rectangle(Gull.x-5, Gull.y-5, 10, 10));
- g.drawString("Target", Gull.x-15, Gull.y-8);
- }
- g.drawImage(img1, 307, 341, null);
- g.setFont(new Font("Calibri", 0, 12));
- g.setColor(Color.WHITE);
- g.drawString("Runtime: " + hours + ":" + minutes + ":" + seconds, 333, 400);
- g.drawString("Clicks: " + clicks, 333, 415);
- }
- private Image getImage(String url) {
- try {
- return ImageIO.read(new URL(url));
- } catch (IOException e) {
- return null;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment